From 54cdab5085eb4a12053394fee8dae9a0586bfdc6 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Thu, 12 Oct 2023 11:54:23 +0530 Subject: [PATCH] Improvements to the device sub type impl --- .../cache/GetDeviceSubTypeCacheLoader.java | 2 +- .../subtype/mgt/dao/DeviceSubTypeDAO.java | 12 +++---- .../mgt/dao/DeviceSubTypeDAOFactory.java | 15 +++++++++ .../mgt/dao/impl/DeviceSubTypeDAOImpl.java | 24 +++++++------- .../core/subtype/mgt/dao/util/DAOUtil.java | 9 ++++-- .../core/subtype/mgt/dto/DeviceSubType.java | 24 +++++++++----- .../mgt/dto/DeviceSubTypeCacheKey.java | 6 ++-- .../mgt/impl/DeviceSubTypeServiceImpl.java | 32 ++++--------------- .../subtype/mgt/spi/DeviceSubTypeService.java | 12 +++---- .../mgt/util/DeviceSubTypeMgtUtil.java | 4 +-- .../mgt/core/subtype/mgt/DAONegativeTest.java | 17 +++++----- .../device/mgt/core/subtype/mgt/DAOTest.java | 17 +++++----- .../core/subtype/mgt/ServiceNegativeTest.java | 13 ++++---- .../mgt/core/subtype/mgt/ServiceTest.java | 17 +++++----- .../mgt/core/subtype/mgt/TestUtils.java | 8 ++--- .../src/main/resources/dbscripts/cdm/h2.sql | 4 +-- .../main/resources/dbscripts/cdm/mssql.sql | 4 +-- .../main/resources/dbscripts/cdm/mysql.sql | 4 +-- .../main/resources/dbscripts/cdm/oracle.sql | 4 +-- .../resources/dbscripts/cdm/postgresql.sql | 4 +-- 20 files changed, 122 insertions(+), 110 deletions(-) diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java index 7819a2ed99..c6d8c0e69d 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/cache/GetDeviceSubTypeCacheLoader.java @@ -47,7 +47,7 @@ public class GetDeviceSubTypeCacheLoader extends CacheLoader getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + List getAllDeviceSubTypes(int tenantId, String deviceType) throws SubTypeMgtDAOException; - int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; + int getDeviceSubTypeCount(String deviceType) throws SubTypeMgtDAOException; - boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtDAOException; - DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) + DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, String deviceType) throws SubTypeMgtDAOException; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java index 0a6c962cd4..d83558cd59 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/DeviceSubTypeDAOFactory.java @@ -26,10 +26,14 @@ import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; import io.entgra.device.mgt.core.device.mgt.core.config.datasource.DataSourceConfig; +import javax.sql.DataSource; +import java.sql.SQLException; + public class DeviceSubTypeDAOFactory { private static final Log log = LogFactory.getLog(DeviceSubTypeDAOFactory.class); private static String databaseEngine; + private static DataSource dataSource; public static void init(DataSourceConfig dataSourceConfiguration) { if (log.isDebugEnabled()) { log.debug("Initializing Device SubType Mgt Data Source"); @@ -38,6 +42,17 @@ public class DeviceSubTypeDAOFactory { databaseEngine = ConnectionManagerUtil.getDatabaseType(); } + public static void init(DataSource dtSource) { + dataSource = dtSource; + + try { + databaseEngine = dataSource.getConnection().getMetaData().getDatabaseProductName(); + } catch (SQLException var2) { + log.error("Error occurred while retrieving config.datasource connection", var2); + } + + } + public static DeviceSubTypeDAO getDeviceSubTypeDAO() { if (databaseEngine != null) { //noinspection SwitchStatementWithTooFewBranches diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java index a6224a2ed2..ecfc1fbcc4 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/impl/DeviceSubTypeDAOImpl.java @@ -67,7 +67,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + public boolean updateDeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition) throws SubTypeMgtDAOException { try { @@ -80,7 +80,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { stmt.setString(2, subTypeName); stmt.setString(3, subTypeId); stmt.setInt(4, tenantId); - stmt.setString(5, deviceType.toString()); + stmt.setString(5, deviceType); return stmt.executeUpdate() > 0; } @@ -98,7 +98,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE = ?"; @@ -107,7 +107,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, subTypeId); stmt.setInt(2, tenantId); - stmt.setString(3, deviceType.toString()); + stmt.setString(3, deviceType); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { return DAOUtil.loadDeviceSubType(rs); @@ -130,7 +130,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + public List getAllDeviceSubTypes(int tenantId, String deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE TENANT_ID = ? AND DEVICE_TYPE = ? ORDER BY " + @@ -139,7 +139,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setInt(1, tenantId); - stmt.setString(2, deviceType.toString()); + stmt.setString(2, deviceType); try (ResultSet rs = stmt.executeQuery()) { return DAOUtil.loadDeviceSubTypes(rs); } @@ -159,13 +159,13 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { + public int getDeviceSubTypeCount(String deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT COUNT(*) as DEVICE_COUNT FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; Connection conn = ConnectionManagerUtil.getDBConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { - stmt.setString(1, deviceType.toString()); + stmt.setString(1, deviceType); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { return rs.getInt("DEVICE_COUNT"); @@ -188,7 +188,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { } @Override - public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE " + @@ -198,7 +198,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, subTypeId); stmt.setInt(2, tenantId); - stmt.setString(3, deviceType.toString()); + stmt.setString(3, deviceType); try (ResultSet rs = stmt.executeQuery()) { return rs.next(); } @@ -219,7 +219,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { @Override public DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, - DeviceSubType.DeviceType deviceType) + String deviceType) throws SubTypeMgtDAOException { try { String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_NAME = ? AND TENANT_ID = ? AND DEVICE_TYPE " + @@ -229,7 +229,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO { try (PreparedStatement stmt = conn.prepareStatement(sql)) { stmt.setString(1, subTypeName); stmt.setInt(2, tenantId); - stmt.setString(3, deviceType.toString()); + stmt.setString(3, deviceType); try (ResultSet rs = stmt.executeQuery()) { if (rs.next()) { return DAOUtil.loadDeviceSubType(rs); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java index 9473a88c6b..34e108a4a6 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dao/util/DAOUtil.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.subtype.mgt.dao.util; +import com.fasterxml.jackson.core.JsonProcessingException; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; import java.sql.ResultSet; @@ -30,17 +31,19 @@ public class DAOUtil { public static DeviceSubType loadDeviceSubType(ResultSet rs) throws SQLException { DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { return null; } + public String parseSubTypeToJson() throws JsonProcessingException { + return null; + } }; deviceSubType.setTenantId(rs.getInt("TENANT_ID")); deviceSubType.setSubTypeId(rs.getString("SUB_TYPE_ID")); deviceSubType.setSubTypeName(rs.getString("SUB_TYPE_NAME")); - deviceSubType.setDeviceType(DeviceSubType.DeviceType.valueOf(rs.getString("DEVICE_TYPE"))); + deviceSubType.setDeviceType(rs.getString("DEVICE_TYPE")); deviceSubType.setTypeDefinition(rs.getString("TYPE_DEFINITION")); return deviceSubType; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java index f914bf9930..84eaa124c6 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubType.java @@ -26,10 +26,21 @@ public abstract class DeviceSubType { private String subTypeId; private int tenantId; - private DeviceType deviceType; + private String deviceType; private String subTypeName; private String typeDefinition; + public DeviceSubType() { + } + + public DeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition) { + this.subTypeId = subTypeId; + this.tenantId = tenantId; + this.deviceType = deviceType; + this.subTypeName = subTypeName; + this.typeDefinition = typeDefinition; + } + public String getSubTypeId() { return subTypeId; } @@ -46,11 +57,11 @@ public abstract class DeviceSubType { this.tenantId = tenantId; } - public DeviceType getDeviceType() { + public String getDeviceType() { return deviceType; } - public void setDeviceType(DeviceType deviceType) { + public void setDeviceType(String deviceType) { this.deviceType = deviceType; } @@ -70,11 +81,8 @@ public abstract class DeviceSubType { this.typeDefinition = typeDefinition; } - public abstract DeviceSubType setDeviceSubType(T objType, String typeDef); + public abstract DeviceSubType convertToDeviceSubType(); - public abstract String parseSubTypeToJson(Object objType) throws JsonProcessingException; + public abstract String parseSubTypeToJson() throws JsonProcessingException; - public enum DeviceType { - COM, METER, SIM - } } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubTypeCacheKey.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubTypeCacheKey.java index eb66f92a46..2834300d5f 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubTypeCacheKey.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/dto/DeviceSubTypeCacheKey.java @@ -21,7 +21,7 @@ package io.entgra.device.mgt.core.subtype.mgt.dto; public class DeviceSubTypeCacheKey { int tenantId; String subTypeId; - DeviceSubType.DeviceType deviceType; + String deviceType; public int getTenantId() { return tenantId; @@ -39,11 +39,11 @@ public class DeviceSubTypeCacheKey { this.subTypeId = subTypeId; } - public DeviceSubType.DeviceType getDeviceType() { + public String getDeviceType() { return deviceType; } - public void setDeviceType(DeviceSubType.DeviceType deviceType) { + public void setDeviceType(String deviceType) { this.deviceType = deviceType; } } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java index 5af54eabf9..24d8ced648 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/impl/DeviceSubTypeServiceImpl.java @@ -93,7 +93,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, + public boolean updateDeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition) throws SubTypeMgtPluginException { String msg = ""; @@ -139,13 +139,13 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtPluginException { try { String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); return deviceSubTypeCache.get(key); } catch (CacheLoader.InvalidCacheLoadException e) { - String msg = "Not having any sim subtype for subtype id: " + subTypeId; + String msg = "Not having any" + deviceType + " subtype for subtype id: " + subTypeId; log.error(msg, e); return null; } catch (ExecutionException e) { @@ -156,7 +156,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + public List getAllDeviceSubTypes(int tenantId, String deviceType) throws SubTypeMgtPluginException { try { ConnectionManagerUtil.openDBConnection(); @@ -177,20 +177,14 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException { + public int getDeviceSubTypeCount(String deviceType) throws SubTypeMgtPluginException { try { - ConnectionManagerUtil.openDBConnection(); int result = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); if (result <= 0) { String msg = "There are no any subtypes for device type: " + deviceType; log.error(msg); } return result; - } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the database connection to retrieve device subtypes count " + - "for " + deviceType + " subtypes"; - log.error(msg); - throw new SubTypeMgtPluginException(msg, e); } catch (SubTypeMgtDAOException e) { String msg = "Error occurred in the database level while retrieving device subtypes count for " + deviceType + " subtypes"; @@ -203,16 +197,10 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { @Override public DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, - DeviceSubType.DeviceType deviceType) + String deviceType) throws SubTypeMgtPluginException { try { - ConnectionManagerUtil.openDBConnection(); return deviceSubTypeDAO.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType); - } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the database connection to retrieve device subtype for " + - deviceType + " subtype & subtype name: " + subTypeName; - log.error(msg); - throw new SubTypeMgtPluginException(msg, e); } catch (SubTypeMgtDAOException e) { String msg = "Error occurred in the database level while retrieving device subtype for " + deviceType + " subtype & subtype name: " + subTypeName; @@ -224,16 +212,10 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService { } @Override - public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtPluginException { try { - ConnectionManagerUtil.openDBConnection(); return deviceSubTypeDAO.checkDeviceSubTypeExist(subTypeId, tenantId, deviceType); - } catch (DBConnectionException e) { - String msg = "Error occurred while obtaining the database connection to check device subtype exist for " + - deviceType + " subtype & subtype id: " + subTypeId; - log.error(msg); - throw new SubTypeMgtPluginException(msg, e); } catch (SubTypeMgtDAOException e) { String msg = "Error occurred in the database level while checking device subtype exist for " + deviceType + " subtype & subtype id: " + subTypeId; diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java index 6ccf98d748..c77987f255 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/spi/DeviceSubTypeService.java @@ -27,20 +27,20 @@ public interface DeviceSubTypeService { boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException; - boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, + boolean updateDeviceSubType(String subTypeId, int tenantId, String deviceType, String subTypeName, String typeDefinition) throws SubTypeMgtPluginException; - DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + DeviceSubType getDeviceSubType(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtPluginException; - List getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) + List getAllDeviceSubTypes(int tenantId, String deviceType) throws SubTypeMgtPluginException; - int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtPluginException; + int getDeviceSubTypeCount(String deviceType) throws SubTypeMgtPluginException; - DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) + DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, String deviceType) throws SubTypeMgtPluginException; - boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) + boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, String deviceType) throws SubTypeMgtPluginException; } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java index 76222e21f7..1d84bbf0f9 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/main/java/io/entgra/device/mgt/core/subtype/mgt/util/DeviceSubTypeMgtUtil.java @@ -22,7 +22,7 @@ import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; public class DeviceSubTypeMgtUtil { - public static String setDeviceSubTypeCacheKey(int tenantId, String subTypeId, DeviceSubType.DeviceType deviceType) { + public static String setDeviceSubTypeCacheKey(int tenantId, String subTypeId, String deviceType) { return tenantId + "|" + subTypeId + "|" + deviceType.toString(); } @@ -30,7 +30,7 @@ public class DeviceSubTypeMgtUtil { String[] keys = key.split("\\|"); int tenantId = Integer.parseInt(keys[0]); String subTypeId = keys[1]; - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.valueOf(keys[2]); + String deviceType = keys[2]; DeviceSubTypeCacheKey deviceSubTypesCacheKey = new DeviceSubTypeCacheKey(); deviceSubTypesCacheKey.setTenantId(tenantId); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAONegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAONegativeTest.java index 421fb804ae..e0492ace14 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAONegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAONegativeTest.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.subtype.mgt; +import com.fasterxml.jackson.core.JsonProcessingException; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; @@ -48,12 +49,12 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest { public void testAddDeviceSubType() throws SubTypeMgtDAOException { DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; @@ -85,18 +86,18 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest { String subTypeName = "TestSubType"; DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; deviceSubType.setSubTypeId(subTypeId); deviceSubType.setSubTypeName(subTypeName); - deviceSubType.setDeviceType(DeviceSubType.DeviceType.COM); + deviceSubType.setDeviceType("COM"); try { ConnectionManagerUtil.beginDBTransaction(); deviceSubTypeDAO.addDeviceSubType(deviceSubType); @@ -127,17 +128,17 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest { String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; deviceSubType.setSubTypeName(subTypeName); - deviceSubType.setDeviceType(DeviceSubType.DeviceType.COM); + deviceSubType.setDeviceType("COM"); deviceSubType.setTenantId(tenantId); deviceSubType.setTypeDefinition(typeDefinition); try { diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAOTest.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAOTest.java index f4c51ab6d1..89d5797491 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAOTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/DAOTest.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.subtype.mgt; +import com.fasterxml.jackson.core.JsonProcessingException; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAO; import io.entgra.device.mgt.core.subtype.mgt.dao.DeviceSubTypeDAOFactory; import io.entgra.device.mgt.core.subtype.mgt.dao.util.ConnectionManagerUtil; @@ -50,14 +51,14 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConnectionManagerUtil.openDBConnection(); DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType("1", tenantId, - DeviceSubType.DeviceType.COM); + "COM"); ConnectionManagerUtil.closeDBConnection(); Assert.assertNotNull(subTypeActual, "Should not be null"); } @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetAllDeviceSubTypes() throws DBConnectionException, SubTypeMgtDAOException { - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String deviceType = "COM"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); ConnectionManagerUtil.openDBConnection(); List subTypesActual = deviceSubTypeDAO.getAllDeviceSubTypes(tenantId, deviceType); @@ -71,17 +72,17 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String subTypeName = "TestSubType"; - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String deviceType = "COM"; String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; @@ -104,7 +105,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { public void testUpdateDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String deviceType = "COM"; String subTypeName = "TestSubType"; String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); @@ -121,7 +122,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeByProvider() throws DBConnectionException, SubTypeMgtDAOException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String deviceType = "COM"; String subTypeName = "TestSubType"; ConnectionManagerUtil.openDBConnection(); DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType); @@ -131,7 +132,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeCount() throws DBConnectionException, SubTypeMgtDAOException { - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; + String deviceType = "COM"; ConnectionManagerUtil.openDBConnection(); int subTypeCount = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); ConnectionManagerUtil.closeDBConnection(); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceNegativeTest.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceNegativeTest.java index 0c1d15e382..0624cd0afd 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceNegativeTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceNegativeTest.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.subtype.mgt; +import com.fasterxml.jackson.core.JsonProcessingException; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; import io.entgra.device.mgt.core.subtype.mgt.impl.DeviceSubTypeServiceImpl; @@ -45,12 +46,12 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { public void testAddDeviceSubType() throws SubTypeMgtPluginException { DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; @@ -65,16 +66,16 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { public void testAddDeviceSubTypes() throws SubTypeMgtPluginException { String subTypeId = "1"; String subTypeName = "TestSubType"; - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; + String deviceType = "SIM"; DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; @@ -91,7 +92,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest { public void testUpdateDeviceSubTypes() throws SubTypeMgtPluginException { String subTypeId = "15"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; + String deviceType = "SIM"; String subTypeName = "TestSubType"; String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceTest.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceTest.java index d5e3b96556..8d800a2c69 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceTest.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/ServiceTest.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.subtype.mgt; +import com.fasterxml.jackson.core.JsonProcessingException; import io.entgra.device.mgt.core.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.core.subtype.mgt.exception.SubTypeMgtPluginException; import io.entgra.device.mgt.core.subtype.mgt.impl.DeviceSubTypeServiceImpl; @@ -48,13 +49,13 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { public void testGetDeviceType() throws SubTypeMgtPluginException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType("1", tenantId, - DeviceSubType.DeviceType.METER); + "METER"); TestUtils.verifyDeviceSubType(subTypeActual); } @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetAllDeviceTypes() throws SubTypeMgtPluginException { - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String deviceType = "METER"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); List subTypesActual = deviceSubTypeService.getAllDeviceSubTypes(tenantId, deviceType); log.info(deviceType + " sub types count should be " + subTypesActual.size()); @@ -66,17 +67,17 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); String subTypeName = "TestSubType"; - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String deviceType = "METER"; String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); DeviceSubType deviceSubType = new DeviceSubType() { @Override - public DeviceSubType setDeviceSubType(T objType, String typeDef) { + public DeviceSubType convertToDeviceSubType() { return null; } @Override - public String parseSubTypeToJson(Object objType) { + public String parseSubTypeToJson() throws JsonProcessingException { return null; } }; @@ -96,7 +97,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { public void testUpdateDeviceSubType() throws SubTypeMgtPluginException { String subTypeId = "1"; int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String deviceType = "METER"; String subTypeName = "TestSubType"; String subTypeExpected = TestUtils.createUpdateDeviceSubType(subTypeId); @@ -111,7 +112,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeByProvider() throws SubTypeMgtPluginException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String deviceType = "METER"; String subTypeName = "TestSubType"; DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType); @@ -120,7 +121,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest { @Test(dependsOnMethods = "testAddDeviceSubType") public void testGetDeviceTypeCount() throws SubTypeMgtPluginException { - DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; + String deviceType = "METER"; int subTypeCount = deviceSubTypeService.getDeviceSubTypeCount(deviceType); log.info(deviceType + " Device subtypes count: " + subTypeCount); } diff --git a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/TestUtils.java b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/TestUtils.java index b5b8011e76..24f70a7afd 100644 --- a/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/TestUtils.java +++ b/components/subtype-mgt/io.entgra.device.mgt.core.subtype.mgt/src/test/java/io/entgra/device/mgt/core/subtype/mgt/TestUtils.java @@ -47,7 +47,7 @@ public class TestUtils { public static void verifyDeviceSubType(DeviceSubType deviceSubType) { String typeDefExpected = TestUtils.createNewDeviceSubType("1"); Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); - Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); + Assert.assertEquals(deviceSubType.getDeviceType(), "METER"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } @@ -55,7 +55,7 @@ public class TestUtils { public static void verifyDeviceSubTypeDAO(DeviceSubType deviceSubType) { String typeDefExpected = TestUtils.createNewDeviceSubType("1"); Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); - Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); + Assert.assertEquals(deviceSubType.getDeviceType(), "COM"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } @@ -63,7 +63,7 @@ public class TestUtils { public static void verifyUpdatedDeviceSubType(DeviceSubType deviceSubType) { String typeDefExpected = TestUtils.createUpdateDeviceSubType("1"); Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); - Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); + Assert.assertEquals(deviceSubType.getDeviceType(), "METER"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } @@ -71,7 +71,7 @@ public class TestUtils { public static void verifyUpdatedDeviceSubTypeDAO(DeviceSubType deviceSubType) { String typeDefExpected = TestUtils.createUpdateDeviceSubType("1"); Assert.assertEquals(deviceSubType.getSubTypeId(), "1"); - Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); + Assert.assertEquals(deviceSubType.getDeviceType(), "COM"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql index 4d87dbdcca..f0d43f0fd6 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/h2.sql @@ -804,8 +804,8 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, SUB_TYPE_ID VARCHAR(45) NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - SUB_TYPE_NAME VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(45) NOT NULL, + SUB_TYPE_NAME VARCHAR(100) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql index 4c8c753448..969fc008b4 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mssql.sql @@ -876,8 +876,8 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D CREATE TABLE DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, SUB_TYPE_ID VARCHAR(45) NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - SUB_TYPE_NAME VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(45) NOT NULL, + SUB_TYPE_NAME VARCHAR(100) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ); diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index 1ea355fb81..a6cbeffc47 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -873,8 +873,8 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, SUB_TYPE_ID VARCHAR(45) NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - SUB_TYPE_NAME VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(45) NOT NULL, + SUB_TYPE_NAME VARCHAR(100) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql index f19645cdb7..4678844a53 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1148,8 +1148,8 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, SUB_TYPE_ID VARCHAR(45) NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - SUB_TYPE_NAME VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(45) NOT NULL, + SUB_TYPE_NAME VARCHAR(100) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB; diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql index 51361a90d3..3e69291e14 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/postgresql.sql @@ -795,8 +795,8 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( TENANT_ID INT DEFAULT 0, SUB_TYPE_ID VARCHAR(45) NOT NULL, - DEVICE_TYPE VARCHAR(25) NOT NULL, - SUB_TYPE_NAME VARCHAR(45) NOT NULL, + DEVICE_TYPE VARCHAR(45) NOT NULL, + SUB_TYPE_NAME VARCHAR(100) NOT NULL, TYPE_DEFINITION TEXT NOT NULL, PRIMARY KEY (SUB_TYPE_ID,DEVICE_TYPE) ) ENGINE=InnoDB;