From b652d025c8c7c1db5b5112b33254dfeb75d2d59a Mon Sep 17 00:00:00 2001 From: geethkokila Date: Mon, 15 Jan 2018 13:56:05 +0530 Subject: [PATCH] This commits fixes the issues of having the Application memory info and is-active flag with the DM_APPLICATION table, because those values should go to to DM_APPLICATION_MAPPING table. Change of the tables has happened. --- ...ApplicationManagerProviderServiceImpl.java | 23 ++++-- .../device/mgt/core/dao/ApplicationDAO.java | 2 + .../mgt/core/dao/ApplicationMappingDAO.java | 3 + .../mgt/core/dao/impl/ApplicationDAOImpl.java | 70 ++++++++++++------- .../dao/impl/ApplicationMappingDAOImpl.java | 68 ++++++++++++++++-- .../src/test/resources/sql/h2.sql | 3 + .../src/test/resources/sql-files/h2.sql | 3 + .../src/test/resources/sql/CreateH2TestDB.sql | 3 + .../src/main/resources/dbscripts/cdm/h2.sql | 5 +- .../main/resources/dbscripts/cdm/mssql.sql | 3 + .../main/resources/dbscripts/cdm/mysql.sql | 3 + .../main/resources/dbscripts/cdm/oracle.sql | 3 + .../resources/dbscripts/cdm/postgresql.sql | 3 + 13 files changed, 152 insertions(+), 40 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java index 548710691a..a5e454af9f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/app/mgt/ApplicationManagerProviderServiceImpl.java @@ -225,6 +225,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem applicationMappingDAO.removeApplicationMapping(device.getId(), appIdsToRemove, tenantId); Application installedApp; List applicationIds = new ArrayList<>(); + List applicationsToMap = new ArrayList<>(); for (Application application : applications) { // Adding N/A if application doesn't have a version. Also truncating the application version, @@ -232,17 +233,18 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem if (application.getVersion() == null) { application.setVersion("N/A"); } else if (application.getVersion().length() > - DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) { + DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH) { application.setVersion(StringUtils.abbreviate(application.getVersion(), DeviceManagementConstants.OperationAttributes.APPLIST_VERSION_MAX_LENGTH)); } if (!installedAppList.contains(application)) { installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), - application.getVersion(), tenantId); + application.getVersion(), device.getId(), tenantId); if (installedApp == null) { appsToAdd.add(application); } else { - applicationIds.add(installedApp.getId()); + application.setId(installedApp.getId()); + applicationsToMap.add(application); } } } @@ -250,11 +252,18 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem log.debug("num of apps add:" + appsToAdd.size()); } applicationIds.addAll(applicationDAO.addApplications(appsToAdd, tenantId)); + // Getting the applications ids for the second time + for (Application application : appsToAdd) { + installedApp = applicationDAO.getApplication(application.getApplicationIdentifier(), + application.getVersion(), device.getId(), tenantId); + application.setId(installedApp.getId()); + applicationsToMap.add(application); + } if (log.isDebugEnabled()) { log.debug("num of app Ids:" + applicationIds.size()); } - applicationMappingDAO.addApplicationMappings(device.getId(), applicationIds, tenantId); + applicationMappingDAO.addApplicationMappingsWithApps(device.getId(), applicationsToMap, tenantId); if (log.isDebugEnabled()) { log.debug("num of remove app Ids:" + appIdsToRemove.size()); @@ -267,7 +276,7 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem throw new ApplicationManagementException(msg, e); } catch (TransactionManagementException e) { String msg = "Error occurred while initializing transaction for saving application list to the device " - + deviceIdentifier.toString(); + + deviceIdentifier.toString(); log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (DeviceManagementException e) { @@ -310,14 +319,14 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem throw new ApplicationManagementException(msg, e); } catch (SQLException e) { String msg = "Error occurred while opening a connection to the data source to get application " + - "list of the device " + deviceId.toString(); + "list of the device " + deviceId.toString(); log.error(msg, e); throw new ApplicationManagementException(msg, e); } catch (Exception e) { String msg = "Exception occurred getting application list of the device " + deviceId.toString(); log.error(msg, e); throw new ApplicationManagementException(msg, e); - } finally { + } finally { DeviceManagementDAOFactory.closeConnection(); } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationDAO.java index e5e91f28bc..3f7265396e 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationDAO.java @@ -34,5 +34,7 @@ public interface ApplicationDAO { Application getApplication(String identifier, String version,int tenantId) throws DeviceManagementDAOException; + Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException; + List getInstalledApplications(int deviceId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java index e246c1c92b..10d60537b4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/ApplicationMappingDAO.java @@ -29,6 +29,9 @@ public interface ApplicationMappingDAO { void addApplicationMappings(int deviceId, List applicationIds, int tenantId) throws DeviceManagementDAOException; + void addApplicationMappingsWithApps(int deviceId, List applications, int tenantId) + throws DeviceManagementDAOException; + void removeApplicationMapping(int deviceId, List appIdList, int tenantId) throws DeviceManagementDAOException; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java index 0de0e3aefb..805775d0e4 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -112,8 +112,6 @@ public class ApplicationDAOImpl implements ApplicationDAO { Connection conn; PreparedStatement stmt = null; ResultSet rs; - ByteArrayOutputStream bao = null; - ObjectOutputStream oos = null; List applicationIds = new ArrayList<>(); try { conn = this.getConnection(); @@ -133,14 +131,15 @@ public class ApplicationDAOImpl implements ApplicationDAO { stmt.setString(7, application.getImageUrl()); stmt.setInt(8, tenantId); - bao = new ByteArrayOutputStream(); - oos = new ObjectOutputStream(bao); - oos.writeObject(application.getAppProperties()); - stmt.setBytes(9, bao.toByteArray()); + // Removing the application properties saving from the application table. + stmt.setBigDecimal(9, null); stmt.setString(10, application.getApplicationIdentifier()); - stmt.setInt(11, application.getMemoryUsage()); - stmt.setBoolean(12, application.isActive()); + + // Removing the application memory + stmt.setInt(11, 0); + stmt.setBoolean(12, true); + stmt.executeUpdate(); rs = stmt.getGeneratedKeys(); @@ -151,23 +150,7 @@ public class ApplicationDAOImpl implements ApplicationDAO { return applicationIds; } catch (SQLException e) { throw new DeviceManagementDAOException("Error occurred while adding bulk application list", e); - } catch (IOException e) { - throw new DeviceManagementDAOException("Error occurred while serializing application properties object", e); } finally { - if (bao != null) { - try { - bao.close(); - } catch (IOException e) { - log.error("Error occurred while closing ByteArrayOutputStream", e); - } - } - if (oos != null) { - try { - oos.close(); - } catch (IOException e) { - log.error("Error occurred while closing ObjectOutputStream", e); - } - } DeviceManagementDAOUtil.cleanupResources(stmt, null); } } @@ -264,6 +247,38 @@ public class ApplicationDAOImpl implements ApplicationDAO { } } + @Override + public Application getApplication(String identifier, String version, int deviceId, int tenantId) throws DeviceManagementDAOException { + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + Application application = null; + try { + conn = this.getConnection(); + stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + + "LOCATION_URL, IMAGE_URL, appmap.APP_PROPERTIES, appmap.MEMORY_USAGE, appmap.IS_ACTIVE, TENANT_ID " + + "FROM DM_APPLICATION app INNER JOIN " + + "(SELECT APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE FROM DM_DEVICE_APPLICATION_MAPPING W" + + "HERE DEVICE_ID = ?) appmap WHERE app.APP_IDENTIFIER = ? AND app.VERSION = ? AND " + + "appmap.APPLICATION_ID = app.id AND TENANT_ID = ?"); + stmt.setInt(1, deviceId); + stmt.setString(2, identifier); + stmt.setString(3, version); + stmt.setInt(4, tenantId); + rs = stmt.executeQuery(); + + if (rs.next()) { + application = this.loadApplication(rs); + } + return application; + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while retrieving application application '" + + identifier + "' and version '" + version + "'.", e); + } finally { + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + } + private Connection getConnection() throws SQLException { return DeviceManagementDAOFactory.getConnection(); } @@ -278,9 +293,10 @@ public class ApplicationDAOImpl implements ApplicationDAO { try { conn = this.getConnection(); stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + - "LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE, TENANT_ID From DM_APPLICATION app " + - "INNER JOIN " + - "(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " + + "LOCATION_URL, IMAGE_URL, APPMAP.APP_PROPERTIES, APPMAP.MEMORY_USAGE, APPMAP.IS_ACTIVE, " + + "TENANT_ID From DM_APPLICATION app INNER JOIN " + + "(Select APPLICATION_ID, APP_PROPERTIES, MEMORY_USAGE, IS_ACTIVE" + + " From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " + "ON " + "app.ID = APPMAP.APPLICATION_ID "); diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java index 45a4b881c4..b3ae5f3d06 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/dao/impl/ApplicationMappingDAOImpl.java @@ -28,9 +28,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil; import org.wso2.carbon.device.mgt.core.dto.operation.mgt.ProfileOperation; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; +import java.io.*; import java.sql.*; import java.util.ArrayList; import java.util.List; @@ -38,6 +36,8 @@ import java.util.Properties; public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { + private static final Log log = LogFactory.getLog(ApplicationMappingDAOImpl.class); + @Override public int addApplicationMapping(int deviceId, int applicationId, int tenantId) throws DeviceManagementDAOException { @@ -49,7 +49,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { conn = this.getConnection(); String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, " + "TENANT_ID) VALUES (?, ?, ?)"; - stmt = conn.prepareStatement(sql, new String[] {"id"}); + stmt = conn.prepareStatement(sql, new String[]{"id"}); stmt.setInt(1, deviceId); stmt.setInt(2, applicationId); stmt.setInt(3, tenantId); @@ -69,7 +69,7 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { @Override public void addApplicationMappings(int deviceId, List applicationIds, - int tenantId) throws DeviceManagementDAOException { + int tenantId) throws DeviceManagementDAOException { Connection conn; PreparedStatement stmt = null; ResultSet rs = null; @@ -96,6 +96,64 @@ public class ApplicationMappingDAOImpl implements ApplicationMappingDAO { } } + @Override + public void addApplicationMappingsWithApps(int deviceId, List applications, int tenantId) + throws DeviceManagementDAOException { + + Connection conn; + PreparedStatement stmt = null; + ResultSet rs = null; + ByteArrayOutputStream bao = null; + ObjectOutputStream oos = null; + + try { + conn = this.getConnection(); + String sql = "INSERT INTO DM_DEVICE_APPLICATION_MAPPING (DEVICE_ID, APPLICATION_ID, APP_PROPERTIES, " + + "MEMORY_USAGE, IS_ACTIVE, TENANT_ID) VALUES (?, ?, ?, ?, ?, ?)"; + + conn.setAutoCommit(false); + stmt = conn.prepareStatement(sql); + + for (Application application : applications) { + stmt.setInt(1, deviceId); + stmt.setInt(2, application.getId()); + + bao = new ByteArrayOutputStream(); + oos = new ObjectOutputStream(bao); + oos.writeObject(application.getAppProperties()); + stmt.setBytes(3, bao.toByteArray()); + + stmt.setInt(4, application.getMemoryUsage()); + stmt.setBoolean(5, application.isActive()); + + stmt.setInt(6, tenantId); + stmt.addBatch(); + } + stmt.executeBatch(); + } catch (SQLException e) { + throw new DeviceManagementDAOException("Error occurred while adding device application mappings", e); + } catch (IOException e) { + throw new DeviceManagementDAOException("Error occurred while serializing application properties object", e); + } finally { + if (bao != null) { + try { + bao.close(); + } catch (IOException e) { + log.error("Error occurred while closing ByteArrayOutputStream", e); + } + } + if (oos != null) { + try { + oos.close(); + } catch (IOException e) { + log.error("Error occurred while closing ObjectOutputStream", e); + } + } + DeviceManagementDAOUtil.cleanupResources(stmt, rs); + } + + } + @Override public void removeApplicationMapping(int deviceId, List appIdList, int tenantId) throws DeviceManagementDAOException { diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql index e40dc8d52f..e7893e242b 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/test/resources/sql/h2.sql @@ -367,6 +367,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sql-files/h2.sql index 7bdbec7df2..e2d3356c69 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sql-files/h2.sql +++ b/components/device-mgt/org.wso2.carbon.device.mgt.extensions/src/test/resources/sql-files/h2.sql @@ -367,6 +367,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql index 0f52104c3b..9d4af5087d 100644 --- a/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql +++ b/components/policy-mgt/org.wso2.carbon.policy.mgt.core/src/test/resources/sql/CreateH2TestDB.sql @@ -418,6 +418,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 5dbf1636be..37998699b8 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -301,7 +301,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( POLICY_CRITERION_ID INT NOT NULL, PROP_KEY VARCHAR(45) NULL, PROP_VALUE VARCHAR(100) NULL, - CONTENT BLOB NULL COMMENT 'This is used to ', + CONTENT BLOB NULL, PRIMARY KEY (ID), CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES FOREIGN KEY (POLICY_CRITERION_ID) @@ -367,6 +367,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index eca2355027..f96948323f 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -396,6 +396,9 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER IDENTITY(1,1) NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES VARBINARY(MAX) NULL, + MEMORY_USAGE INTEGER NULL, + IS_ACTIVE BIT NOT NULL DEFAULT 0, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 2a85f46944..ad24ba247c 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -411,6 +411,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID INTEGER AUTO_INCREMENT NOT NULL, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE INTEGER(10) NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index 8f5c88d871..082ee73a50 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -715,6 +715,9 @@ CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( ID NUMBER(10) NOT NULL, DEVICE_ID NUMBER(10) NOT NULL, APPLICATION_ID NUMBER(10) NOT NULL, + APP_PROPERTIES BLOB NULL, + MEMORY_USAGE NUMBER(10) NULL, + IS_ACTIVE NUMBER(10) DEFAULT 0 NOT NULL, TENANT_ID NUMBER(10) NOT NULL, CONSTRAINT PK_DM_DEVICE_APP_MAPPING PRIMARY KEY (ID), CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index f00821ecaa..457fee723d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -357,6 +357,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( ID BIGSERIAL NOT NULL PRIMARY KEY, DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, + APP_PROPERTIES BYTEA NULL, + MEMORY_USAGE INTEGER NULL, + IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION,