change subtype id as String field & add review changes

app-icon-change
kavindya_devindi 2 years ago
parent 0c0300e2fc
commit 93ad9a3fd0

@ -46,7 +46,7 @@ public class GetDeviceSubTypeCacheLoader extends CacheLoader<String, DeviceSubTy
public DeviceSubType load(String key) throws SubTypeMgtPluginException { public DeviceSubType load(String key) throws SubTypeMgtPluginException {
DeviceSubTypeCacheKey deviceSubTypeCacheKey = DeviceSubTypeMgtUtil.getDeviceSubTypeCacheKey(key); DeviceSubTypeCacheKey deviceSubTypeCacheKey = DeviceSubTypeMgtUtil.getDeviceSubTypeCacheKey(key);
int tenantId = deviceSubTypeCacheKey.getTenantId(); int tenantId = deviceSubTypeCacheKey.getTenantId();
int subTypeId = deviceSubTypeCacheKey.getSubTypeId(); String subTypeId = deviceSubTypeCacheKey.getSubTypeId();
DeviceSubType.DeviceType deviceType = deviceSubTypeCacheKey.getDeviceType(); DeviceSubType.DeviceType deviceType = deviceSubTypeCacheKey.getDeviceType();
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {

@ -26,10 +26,10 @@ import java.util.List;
public interface DeviceSubTypeDAO { public interface DeviceSubTypeDAO {
boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtDAOException; boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtDAOException;
boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName,
String typeDefinition) throws SubTypeMgtDAOException; String typeDefinition) throws SubTypeMgtDAOException;
DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtDAOException; throws SubTypeMgtDAOException;
List<DeviceSubType> getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) List<DeviceSubType> getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType)
@ -37,7 +37,8 @@ public interface DeviceSubTypeDAO {
int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; int getDeviceSubTypeCount(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException;
int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException; boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtDAOException;
DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtDAOException; throws SubTypeMgtDAOException;

@ -38,15 +38,14 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO {
private static final Log log = LogFactory.getLog(DeviceSubTypeDAOImpl.class); private static final Log log = LogFactory.getLog(DeviceSubTypeDAOImpl.class);
@Override @Override
public boolean addDeviceSubType(DeviceSubType deviceSubType) public boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtDAOException {
throws SubTypeMgtDAOException {
try { try {
String sql = "INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, " + String sql = "INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, " +
"TYPE_DEFINITION) VALUES (?, ?, ?, ?, ?)"; "TYPE_DEFINITION) VALUES (?, ?, ?, ?, ?)";
Connection conn = ConnectionManagerUtil.getDBConnection(); Connection conn = ConnectionManagerUtil.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, deviceSubType.getSubTypeId()); stmt.setString(1, deviceSubType.getSubTypeId());
stmt.setInt(2, deviceSubType.getTenantId()); stmt.setInt(2, deviceSubType.getTenantId());
stmt.setString(3, deviceSubType.getDeviceType().toString()); stmt.setString(3, deviceSubType.getDeviceType().toString());
stmt.setString(4, deviceSubType.getSubTypeName()); stmt.setString(4, deviceSubType.getSubTypeName());
@ -68,7 +67,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO {
} }
@Override @Override
public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType,
String subTypeName, String typeDefinition) String subTypeName, String typeDefinition)
throws SubTypeMgtDAOException { throws SubTypeMgtDAOException {
try { try {
@ -79,7 +78,7 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO {
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, typeDefinition); stmt.setString(1, typeDefinition);
stmt.setString(2, subTypeName); stmt.setString(2, subTypeName);
stmt.setInt(3, subTypeId); stmt.setString(3, subTypeId);
stmt.setInt(4, tenantId); stmt.setInt(4, tenantId);
stmt.setString(5, deviceType.toString()); stmt.setString(5, deviceType.toString());
return stmt.executeUpdate() > 0; return stmt.executeUpdate() > 0;
@ -99,14 +98,14 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO {
} }
@Override @Override
public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtDAOException { throws SubTypeMgtDAOException {
try { try {
String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE = ?"; String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE = ?";
Connection conn = ConnectionManagerUtil.getDBConnection(); Connection conn = ConnectionManagerUtil.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setInt(1, subTypeId); stmt.setString(1, subTypeId);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
stmt.setString(3, deviceType.toString()); stmt.setString(3, deviceType.toString());
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
@ -189,29 +188,30 @@ public class DeviceSubTypeDAOImpl implements DeviceSubTypeDAO {
} }
@Override @Override
public int getMaxSubTypeId(DeviceSubType.DeviceType deviceType) throws SubTypeMgtDAOException { public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtDAOException {
try { try {
String sql = "SELECT COALESCE(MAX(SUB_TYPE_ID),0) as MAX_ID FROM DM_DEVICE_SUB_TYPE WHERE DEVICE_TYPE = ? "; String sql = "SELECT * FROM DM_DEVICE_SUB_TYPE WHERE SUB_TYPE_ID = ? AND TENANT_ID = ? AND DEVICE_TYPE " +
"= ? ";
Connection conn = ConnectionManagerUtil.getDBConnection(); Connection conn = ConnectionManagerUtil.getDBConnection();
try (PreparedStatement stmt = conn.prepareStatement(sql)) { try (PreparedStatement stmt = conn.prepareStatement(sql)) {
stmt.setString(1, deviceType.toString()); stmt.setString(1, subTypeId);
stmt.setInt(2, tenantId);
stmt.setString(3, deviceType.toString());
try (ResultSet rs = stmt.executeQuery()) { try (ResultSet rs = stmt.executeQuery()) {
if (rs.next()) { return rs.next();
return rs.getInt("MAX_ID");
}
return 0;
} }
} }
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
String msg = "Error occurred while obtaining DB connection to retrieve max device subtype id for " + String msg = "Error occurred while obtaining DB connection to check device subtype exist for " + deviceType
deviceType + " subtype"; + " subtype & subtype id: " + subTypeId;
log.error(msg); log.error(msg);
throw new SubTypeMgtDAOException(msg, e); throw new SubTypeMgtDAOException(msg, e);
} catch (SQLException e) { } catch (SQLException e) {
String msg = "Error occurred while processing SQL to retrieve max device subtype id for " + deviceType String msg = "Error occurred while processing SQL to check device subtype exist for " + deviceType + " " +
+ " subtype"; "subtype & subtype id: " + subTypeId;
log.error(msg); log.error(msg);
throw new SubTypeMgtDAOException(msg, e); throw new SubTypeMgtDAOException(msg, e);
} }

@ -38,7 +38,7 @@ public class DAOUtil {
public String parseSubTypeToJson(Object objType) { return null; } public String parseSubTypeToJson(Object objType) { return null; }
}; };
deviceSubType.setTenantId(rs.getInt("TENANT_ID")); deviceSubType.setTenantId(rs.getInt("TENANT_ID"));
deviceSubType.setSubTypeId(rs.getInt("SUB_TYPE_ID")); deviceSubType.setSubTypeId(rs.getString("SUB_TYPE_ID"));
deviceSubType.setSubTypeName(rs.getString("SUB_TYPE_NAME")); deviceSubType.setSubTypeName(rs.getString("SUB_TYPE_NAME"));
deviceSubType.setDeviceType(DeviceSubType.DeviceType.valueOf(rs.getString("DEVICE_TYPE"))); deviceSubType.setDeviceType(DeviceSubType.DeviceType.valueOf(rs.getString("DEVICE_TYPE")));
deviceSubType.setTypeDefinition(rs.getString("TYPE_DEFINITION")); deviceSubType.setTypeDefinition(rs.getString("TYPE_DEFINITION"));

@ -24,17 +24,17 @@ import com.fasterxml.jackson.core.JsonProcessingException;
public abstract class DeviceSubType { public abstract class DeviceSubType {
private int subTypeId; private String subTypeId;
private int tenantId; private int tenantId;
private DeviceType deviceType; private DeviceType deviceType;
private String subTypeName; private String subTypeName;
private String typeDefinition; private String typeDefinition;
public int getSubTypeId() { public String getSubTypeId() {
return subTypeId; return subTypeId;
} }
public void setSubTypeId(int subTypeId) { public void setSubTypeId(String subTypeId) {
this.subTypeId = subTypeId; this.subTypeId = subTypeId;
} }

@ -20,7 +20,7 @@ package io.entgra.device.mgt.subtype.mgt.dto;
public class DeviceSubTypeCacheKey { public class DeviceSubTypeCacheKey {
int tenantId; int tenantId;
int subTypeId; String subTypeId;
DeviceSubType.DeviceType deviceType; DeviceSubType.DeviceType deviceType;
public int getTenantId() { public int getTenantId() {
@ -31,11 +31,11 @@ public class DeviceSubTypeCacheKey {
this.tenantId = tenantId; this.tenantId = tenantId;
} }
public int getSubTypeId() { public String getSubTypeId() {
return subTypeId; return subTypeId;
} }
public void setSubTypeId(int subTypeId) { public void setSubTypeId(String subTypeId) {
this.subTypeId = subTypeId; this.subTypeId = subTypeId;
} }

@ -51,27 +51,22 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
} }
@Override @Override
public boolean addDeviceSubType(DeviceSubType deviceSubType) public boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException {
throws SubTypeMgtPluginException {
String msg = ""; String msg = "";
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
deviceSubType.setTenantId(tenantId); deviceSubType.setTenantId(tenantId);
try { try {
ConnectionManagerUtil.beginDBTransaction(); ConnectionManagerUtil.beginDBTransaction();
//TODO This is done as a temporary... we need to implement addDeviceSubType method either with uuid
// or auto incrementing subtype id. In order to that we have to fix hardcoded subtype id in code level..
// ex: transport code level
int maxSubTypeId = deviceSubTypeDAO.getMaxSubTypeId(deviceSubType.getDeviceType());
deviceSubType.setSubTypeId(maxSubTypeId + 1);
boolean result = deviceSubTypeDAO.addDeviceSubType(deviceSubType); boolean result = deviceSubTypeDAO.addDeviceSubType(deviceSubType);
if (result) { if (result) {
msg = "Device subtype added successfully,for " + deviceSubType.getDeviceType() + " subtype & subtype " + msg = "Device subtype added successfully,for " + deviceSubType.getDeviceType() + " subtype & subtype " +
"Id: " "Id: " + deviceSubType.getSubTypeId();
+ deviceSubType.getSubTypeId(); if (log.isDebugEnabled()) {
log.debug(msg);
}
} else { } else {
ConnectionManagerUtil.rollbackDBTransaction();
msg = "Device subtype failed to add,for " + deviceSubType.getDeviceType() + " subtype & subtype Id: " + msg = "Device subtype failed to add,for " + deviceSubType.getDeviceType() + " subtype & subtype Id: " +
deviceSubType.getSubTypeId(); deviceSubType.getSubTypeId();
throw new SubTypeMgtPluginException(msg); throw new SubTypeMgtPluginException(msg);
@ -80,9 +75,6 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, deviceSubType.getSubTypeId(), String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, deviceSubType.getSubTypeId(),
deviceSubType.getDeviceType()); deviceSubType.getDeviceType());
deviceSubTypeCache.put(key, deviceSubType); deviceSubTypeCache.put(key, deviceSubType);
if (log.isDebugEnabled()) {
log.debug(msg);
}
return true; return true;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
msg = "Error occurred while obtaining the database connection to add device subtype for " + msg = "Error occurred while obtaining the database connection to add device subtype for " +
@ -90,6 +82,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
log.error(msg); log.error(msg);
throw new SubTypeMgtPluginException(msg, e); throw new SubTypeMgtPluginException(msg, e);
} catch (SubTypeMgtDAOException e) { } catch (SubTypeMgtDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
msg = "Error occurred in the database level while adding device subtype for " + msg = "Error occurred in the database level while adding device subtype for " +
deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId(); deviceSubType.getDeviceType() + " subtype & subtype Id: " + deviceSubType.getSubTypeId();
log.error(msg); log.error(msg);
@ -100,9 +93,9 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
} }
@Override @Override
public boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, public boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType,
String subTypeName, String subTypeName, String typeDefinition)
String typeDefinition) throws SubTypeMgtPluginException { throws SubTypeMgtPluginException {
String msg = ""; String msg = "";
DeviceSubType deviceSubTypeOld = getDeviceSubType(subTypeId, tenantId, deviceType); DeviceSubType deviceSubTypeOld = getDeviceSubType(subTypeId, tenantId, deviceType);
@ -117,14 +110,15 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
typeDefinition); typeDefinition);
if (result) { if (result) {
msg = "Device subtype updated successfully,for " + deviceType + " subtype & subtype Id: " + subTypeId; msg = "Device subtype updated successfully,for " + deviceType + " subtype & subtype Id: " + subTypeId;
if (log.isDebugEnabled()) {
log.debug(msg);
}
} else { } else {
ConnectionManagerUtil.rollbackDBTransaction();
msg = "Device subtype failed to update,for " + deviceType + " subtype & subtype Id: " + subTypeId; msg = "Device subtype failed to update,for " + deviceType + " subtype & subtype Id: " + subTypeId;
throw new SubTypeMgtPluginException(msg); throw new SubTypeMgtPluginException(msg);
} }
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
if (log.isDebugEnabled()) {
log.debug(msg);
}
return true; return true;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
msg = "Error occurred while obtaining the database connection to update device subtype for " + deviceType msg = "Error occurred while obtaining the database connection to update device subtype for " + deviceType
@ -132,6 +126,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
log.error(msg); log.error(msg);
throw new SubTypeMgtPluginException(msg, e); throw new SubTypeMgtPluginException(msg, e);
} catch (SubTypeMgtDAOException e) { } catch (SubTypeMgtDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction();
msg = "Error occurred in the database level while updating device subtype for " + deviceType + msg = "Error occurred in the database level while updating device subtype for " + deviceType +
" subtype & subtype Id: " + subTypeId; " subtype & subtype Id: " + subTypeId;
log.error(msg); log.error(msg);
@ -144,7 +139,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
} }
@Override @Override
public DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) public DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtPluginException { throws SubTypeMgtPluginException {
try { try {
String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType); String key = DeviceSubTypeMgtUtil.setDeviceSubTypeCacheKey(tenantId, subTypeId, deviceType);
@ -188,7 +183,7 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
int result = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType); int result = deviceSubTypeDAO.getDeviceSubTypeCount(deviceType);
if (result <= 0) { if (result <= 0) {
String msg = "There are no any subtypes for device type: " + deviceType; String msg = "There are no any subtypes for device type: " + deviceType;
log.info(msg); log.error(msg);
} }
return result; return result;
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
@ -228,5 +223,24 @@ public class DeviceSubTypeServiceImpl implements DeviceSubTypeService {
} }
} }
@Override
public boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType 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;
log.error(msg);
throw new SubTypeMgtPluginException(msg, e);
} finally {
ConnectionManagerUtil.closeDBConnection();
}
}
} }

@ -27,10 +27,10 @@ public interface DeviceSubTypeService {
boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException; boolean addDeviceSubType(DeviceSubType deviceSubType) throws SubTypeMgtPluginException;
boolean updateDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName, boolean updateDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType, String subTypeName,
String typeDefinition) throws SubTypeMgtPluginException; String typeDefinition) throws SubTypeMgtPluginException;
DeviceSubType getDeviceSubType(int subTypeId, int tenantId, DeviceSubType.DeviceType deviceType) DeviceSubType getDeviceSubType(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtPluginException; throws SubTypeMgtPluginException;
List<DeviceSubType> getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType) List<DeviceSubType> getAllDeviceSubTypes(int tenantId, DeviceSubType.DeviceType deviceType)
@ -40,4 +40,7 @@ public interface DeviceSubTypeService {
DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType) DeviceSubType getDeviceSubTypeByProvider(String subTypeName, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtPluginException; throws SubTypeMgtPluginException;
boolean checkDeviceSubTypeExist(String subTypeId, int tenantId, DeviceSubType.DeviceType deviceType)
throws SubTypeMgtPluginException;
} }

@ -22,14 +22,14 @@ import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType;
import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubTypeCacheKey; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubTypeCacheKey;
public class DeviceSubTypeMgtUtil { public class DeviceSubTypeMgtUtil {
public static String setDeviceSubTypeCacheKey(int tenantId, int subTypeId, DeviceSubType.DeviceType deviceType) { public static String setDeviceSubTypeCacheKey(int tenantId, String subTypeId, DeviceSubType.DeviceType deviceType) {
return tenantId + "|" + subTypeId + "|" + deviceType.toString(); return tenantId + "|" + subTypeId + "|" + deviceType.toString();
} }
public static DeviceSubTypeCacheKey getDeviceSubTypeCacheKey(String key) { public static DeviceSubTypeCacheKey getDeviceSubTypeCacheKey(String key) {
String[] keys = key.split("\\|"); String[] keys = key.split("\\|");
int tenantId = Integer.parseInt(keys[0]); int tenantId = Integer.parseInt(keys[0]);
int subTypeId = Integer.parseInt(keys[1]); String subTypeId = keys[1];
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.valueOf(keys[2]); DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.valueOf(keys[2]);
DeviceSubTypeCacheKey deviceSubTypesCacheKey = new DeviceSubTypeCacheKey(); DeviceSubTypeCacheKey deviceSubTypesCacheKey = new DeviceSubTypeCacheKey();

@ -81,7 +81,7 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest {
expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype"
) )
public void testAddDeviceSubTypes() throws SubTypeMgtDAOException { public void testAddDeviceSubTypes() throws SubTypeMgtDAOException {
int subTypeId = 1; String subTypeId = "1";
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
DeviceSubType deviceSubType = new DeviceSubType() { DeviceSubType deviceSubType = new DeviceSubType() {
@Override @Override
@ -121,7 +121,7 @@ public class DAONegativeTest extends BaseDeviceSubTypePluginTest {
expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype" expectedExceptionsMessageRegExp = "Error occurred while processing SQL to insert device subtype"
) )
public void testAddDeviceSubtypes() throws SubTypeMgtDAOException { public void testAddDeviceSubtypes() throws SubTypeMgtDAOException {
int subTypeId = 1; String subTypeId = "1";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId); String typeDefinition = TestUtils.createNewDeviceSubType(subTypeId);

@ -49,7 +49,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest {
public void testGetDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { public void testGetDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType(1, tenantId, DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubType("1", tenantId,
DeviceSubType.DeviceType.COM); DeviceSubType.DeviceType.COM);
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
Assert.assertNotNull(subTypeActual, "Should not be null"); Assert.assertNotNull(subTypeActual, "Should not be null");
@ -68,7 +68,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest {
@Test @Test
public void testAddDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { public void testAddDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException {
int subTypeId = 1; String subTypeId = "1";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM;
@ -102,7 +102,7 @@ public class DAOTest extends BaseDeviceSubTypePluginTest {
@Test(dependsOnMethods = "testAddDeviceSubType") @Test(dependsOnMethods = "testAddDeviceSubType")
public void testUpdateDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException { public void testUpdateDeviceSubType() throws DBConnectionException, SubTypeMgtDAOException {
int subTypeId = 1; String subTypeId = "1";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM;
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
@ -118,6 +118,17 @@ public class DAOTest extends BaseDeviceSubTypePluginTest {
TestUtils.verifyUpdatedDeviceSubTypeDAO(subTypeActual); TestUtils.verifyUpdatedDeviceSubTypeDAO(subTypeActual);
} }
@Test(dependsOnMethods = "testAddDeviceSubType")
public void testGetDeviceTypeByProvider() throws DBConnectionException, SubTypeMgtDAOException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM;
String subTypeName = "TestSubType";
ConnectionManagerUtil.openDBConnection();
DeviceSubType subTypeActual = deviceSubTypeDAO.getDeviceSubTypeByProvider(subTypeName, tenantId, deviceType);
ConnectionManagerUtil.closeDBConnection();
Assert.assertNotNull(subTypeActual, "Should not be null");
}
@Test(dependsOnMethods = "testAddDeviceSubType") @Test(dependsOnMethods = "testAddDeviceSubType")
public void testGetDeviceTypeCount() throws DBConnectionException, SubTypeMgtDAOException { public void testGetDeviceTypeCount() throws DBConnectionException, SubTypeMgtDAOException {
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.COM;

@ -15,6 +15,7 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package io.entgra.device.mgt.subtype.mgt; package io.entgra.device.mgt.subtype.mgt;
import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType; import io.entgra.device.mgt.subtype.mgt.dto.DeviceSubType;
@ -62,6 +63,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest {
expectedExceptionsMessageRegExp = "Error occurred in the database level while adding device subtype for " + expectedExceptionsMessageRegExp = "Error occurred in the database level while adding device subtype for " +
"SIM subtype & subtype Id: 1") "SIM subtype & subtype Id: 1")
public void testAddDeviceSubTypes() throws SubTypeMgtPluginException { public void testAddDeviceSubTypes() throws SubTypeMgtPluginException {
String subTypeId = "1";
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM;
@ -76,6 +78,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest {
return null; return null;
} }
}; };
deviceSubType.setSubTypeId(subTypeId);
deviceSubType.setSubTypeName(subTypeName); deviceSubType.setSubTypeName(subTypeName);
deviceSubType.setDeviceType(deviceType); deviceSubType.setDeviceType(deviceType);
deviceSubTypeService.addDeviceSubType(deviceSubType); deviceSubTypeService.addDeviceSubType(deviceSubType);
@ -86,7 +89,7 @@ public class ServiceNegativeTest extends BaseDeviceSubTypePluginTest {
expectedExceptions = {SubTypeMgtPluginException.class}, expectedExceptions = {SubTypeMgtPluginException.class},
expectedExceptionsMessageRegExp = "Cannot find device subtype for SIM subtype & subtype Id: 15") expectedExceptionsMessageRegExp = "Cannot find device subtype for SIM subtype & subtype Id: 15")
public void testUpdateDeviceSubTypes() throws SubTypeMgtPluginException { public void testUpdateDeviceSubTypes() throws SubTypeMgtPluginException {
int subTypeId = 15; String subTypeId = "15";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.SIM;
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";

@ -47,7 +47,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest {
@Test(dependsOnMethods = "testAddDeviceSubType") @Test(dependsOnMethods = "testAddDeviceSubType")
public void testGetDeviceType() throws SubTypeMgtPluginException { public void testGetDeviceType() throws SubTypeMgtPluginException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType(1, tenantId, DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubType("1", tenantId,
DeviceSubType.DeviceType.METER); DeviceSubType.DeviceType.METER);
TestUtils.verifyDeviceSubType(subTypeActual); TestUtils.verifyDeviceSubType(subTypeActual);
} }
@ -63,7 +63,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest {
@Test @Test
public void testAddDeviceSubType() throws SubTypeMgtPluginException { public void testAddDeviceSubType() throws SubTypeMgtPluginException {
int subTypeId = 1; String subTypeId = "1";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER;
@ -80,6 +80,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest {
return null; return null;
} }
}; };
deviceSubType.setSubTypeId(subTypeId);
deviceSubType.setSubTypeName(subTypeName); deviceSubType.setSubTypeName(subTypeName);
deviceSubType.setDeviceType(deviceType); deviceSubType.setDeviceType(deviceType);
deviceSubType.setTenantId(tenantId); deviceSubType.setTenantId(tenantId);
@ -93,7 +94,7 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest {
@Test(dependsOnMethods = "testAddDeviceSubType") @Test(dependsOnMethods = "testAddDeviceSubType")
public void testUpdateDeviceSubType() throws SubTypeMgtPluginException { public void testUpdateDeviceSubType() throws SubTypeMgtPluginException {
int subTypeId = 1; String subTypeId = "1";
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER;
String subTypeName = "TestSubType"; String subTypeName = "TestSubType";
@ -107,6 +108,16 @@ public class ServiceTest extends BaseDeviceSubTypePluginTest {
TestUtils.verifyUpdatedDeviceSubType(subTypeActual); TestUtils.verifyUpdatedDeviceSubType(subTypeActual);
} }
@Test(dependsOnMethods = "testAddDeviceSubType")
public void testGetDeviceTypeByProvider() throws SubTypeMgtPluginException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER;
String subTypeName = "TestSubType";
DeviceSubType subTypeActual = deviceSubTypeService.getDeviceSubTypeByProvider(subTypeName, tenantId,
deviceType);
TestUtils.verifyDeviceSubType(subTypeActual);
}
@Test(dependsOnMethods = "testAddDeviceSubType") @Test(dependsOnMethods = "testAddDeviceSubType")
public void testGetDeviceTypeCount() throws SubTypeMgtPluginException { public void testGetDeviceTypeCount() throws SubTypeMgtPluginException {
DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER; DeviceSubType.DeviceType deviceType = DeviceSubType.DeviceType.METER;

@ -32,45 +32,45 @@ import java.sql.Statement;
public class TestUtils { public class TestUtils {
private static final Log log = LogFactory.getLog(TestUtils.class); private static final Log log = LogFactory.getLog(TestUtils.class);
public static String createNewDeviceSubType(int subtypeId) { public static String createNewDeviceSubType(String subtypeId) {
return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM800\", " + return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM800\", " +
"\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": true, \"hasICMPSupport\": true, " + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": true, \"hasICMPSupport\": true, " +
"\"socketServerPort\": 8071}"; "\"socketServerPort\": 8071}";
} }
public static String createUpdateDeviceSubType(int subtypeId) { public static String createUpdateDeviceSubType(String subtypeId) {
return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM900\", " + return "{\"make\": \"TestSubType\", \"model\": \"ATx-Mega SIM900\", " +
"\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": false, \"hasICMPSupport\": true, " + "\"subTypeId\": " + subtypeId + ", \"hasSMSSupport\": false, \"hasICMPSupport\": true, " +
"\"socketServerPort\": 8071}"; "\"socketServerPort\": 8071}";
} }
public static void verifyDeviceSubType(DeviceSubType deviceSubType) { public static void verifyDeviceSubType(DeviceSubType deviceSubType) {
String typeDefExpected = TestUtils.createNewDeviceSubType(1); String typeDefExpected = TestUtils.createNewDeviceSubType("1");
Assert.assertEquals(deviceSubType.getSubTypeId(), 1); Assert.assertEquals(deviceSubType.getSubTypeId(), "1");
Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER"));
Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType");
Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected);
} }
public static void verifyDeviceSubTypeDAO(DeviceSubType deviceSubType) { public static void verifyDeviceSubTypeDAO(DeviceSubType deviceSubType) {
String typeDefExpected = TestUtils.createNewDeviceSubType(1); String typeDefExpected = TestUtils.createNewDeviceSubType("1");
Assert.assertEquals(deviceSubType.getSubTypeId(), 1); Assert.assertEquals(deviceSubType.getSubTypeId(), "1");
Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM"));
Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType");
Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected);
} }
public static void verifyUpdatedDeviceSubType(DeviceSubType deviceSubType) { public static void verifyUpdatedDeviceSubType(DeviceSubType deviceSubType) {
String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); String typeDefExpected = TestUtils.createUpdateDeviceSubType("1");
Assert.assertEquals(deviceSubType.getSubTypeId(), 1); Assert.assertEquals(deviceSubType.getSubTypeId(), "1");
Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER")); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("METER"));
Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType");
Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected);
} }
public static void verifyUpdatedDeviceSubTypeDAO(DeviceSubType deviceSubType) { public static void verifyUpdatedDeviceSubTypeDAO(DeviceSubType deviceSubType) {
String typeDefExpected = TestUtils.createUpdateDeviceSubType(1); String typeDefExpected = TestUtils.createUpdateDeviceSubType("1");
Assert.assertEquals(deviceSubType.getSubTypeId(), 1); Assert.assertEquals(deviceSubType.getSubTypeId(), "1");
Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM")); Assert.assertEquals(deviceSubType.getDeviceType(), DeviceSubType.DeviceType.valueOf("COM"));
Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType"); Assert.assertEquals(deviceSubType.getSubTypeName(), "TestSubType");
Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected); Assert.assertEquals(deviceSubType.getTypeDefinition(), typeDefExpected);

@ -779,7 +779,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
-- DM_DEVICE_SUB_TYPE TABLE-- -- DM_DEVICE_SUB_TYPE TABLE--
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

@ -4,7 +4,7 @@
CREATE TABLE IF NOT EXISTS `DM_DEVICE_SUB_TYPE` ( CREATE TABLE IF NOT EXISTS `DM_DEVICE_SUB_TYPE` (
`TENANT_ID` INT DEFAULT 0, `TENANT_ID` INT DEFAULT 0,
`SUB_TYPE_ID` INT NOT NULL, `SUB_TYPE_ID` VARCHAR(45) NOT NULL,
`DEVICE_TYPE` VARCHAR(25) NOT NULL, `DEVICE_TYPE` VARCHAR(25) NOT NULL,
`SUB_TYPE_NAME` VARCHAR(45) NOT NULL, `SUB_TYPE_NAME` VARCHAR(45) NOT NULL,
`TYPE_DEFINITION` TEXT NOT NULL, `TYPE_DEFINITION` TEXT NOT NULL,
@ -12,20 +12,8 @@
); );
-- ----------------------------------------------------- -- -----------------------------------------------------
-- Sample data for DAO test cases -- Sample data for test cases
-- ----------------------------------------------------- -- -----------------------------------------------------
INSERT INTO DM_DEVICE_TYPE(NAME, DEVICE_TYPE_META, LAST_UPDATED_TIMESTAMP, PROVIDER_TENANT_ID, SHARED_WITH_ALL_TENANTS) VALUES
('android','NULL','2020-10-14 16:05:15',-1234,1),('power-meter','NULL','2020-10-14 16:05:15',-1234,1),
('communication-module','NULL','2020-10-14 16:05:15',-1234,1),('sim','NULL','2020-10-14 16:05:15',-1234,1);
INSERT INTO DM_DEVICE(DESCRIPTION, NAME, DEVICE_TYPE_ID, DEVICE_IDENTIFICATION, LAST_UPDATED_TIMESTAMP, TENANT_ID) VALUES
('+94713192111', '192.168.118.111', 4, '413012689159555', '2022-04-04 16:55:52', '-1234'),
('NULL', '864495036647555', 3, '864495036647555', '2022-04-04 16:56:52', '-1234'),
('NULL', '000019729555', 2, '000019729555', '2022-04-04 16:56:52', '-1234');
INSERT INTO DM_ENROLMENT(DEVICE_ID,OWNER,OWNERSHIP,STATUS,IS_TRANSFERRED,DATE_OF_ENROLMENT,DATE_OF_LAST_UPDATE,TENANT_ID) VALUES
(1,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234),
(2,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234),
(3,'admin','COPE','ACTIVE',0,'2022-04-11 15:41:30','2022-04-11 15:41:30',-1234);
INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES INSERT INTO DM_DEVICE_SUB_TYPE (SUB_TYPE_ID, TENANT_ID, DEVICE_TYPE, SUB_TYPE_NAME, TYPE_DEFINITION) VALUES
(3,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'), (3,-1234,'Meter','TestSubType','{"make": "TestSubType", "model": "ATx-Mega SIM800", "subTypeId": 3, "hasSMSSupport": true, "hasICMPSupport": true, "socketServerPort": 8071}'),

@ -791,7 +791,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
-- DM_DEVICE_SUB_TYPE TABLE-- -- DM_DEVICE_SUB_TYPE TABLE--
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

@ -759,7 +759,7 @@ CREATE TABLE DYNAMIC_TASK_PROPERTIES (
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_SUB_TYPE]') AND TYPE IN (N'U')) IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[DM_DEVICE_SUB_TYPE]') AND TYPE IN (N'U'))
CREATE TABLE DM_DEVICE_SUB_TYPE ( CREATE TABLE DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

@ -855,7 +855,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
-- DM_DEVICE_SUB_TYPE TABLE-- -- DM_DEVICE_SUB_TYPE TABLE--
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

@ -1123,7 +1123,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
-- DM_DEVICE_SUB_TYPE TABLE-- -- DM_DEVICE_SUB_TYPE TABLE--
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

@ -777,7 +777,7 @@ CREATE TABLE IF NOT EXISTS DYNAMIC_TASK_PROPERTIES (
-- DM_DEVICE_SUB_TYPE TABLE-- -- DM_DEVICE_SUB_TYPE TABLE--
CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_SUB_TYPE (
TENANT_ID INT DEFAULT 0, TENANT_ID INT DEFAULT 0,
SUB_TYPE_ID INT NOT NULL, SUB_TYPE_ID VARCHAR(45) NOT NULL,
DEVICE_TYPE VARCHAR(25) NOT NULL, DEVICE_TYPE VARCHAR(25) NOT NULL,
SUB_TYPE_NAME VARCHAR(45) NOT NULL, SUB_TYPE_NAME VARCHAR(45) NOT NULL,
TYPE_DEFINITION TEXT NOT NULL, TYPE_DEFINITION TEXT NOT NULL,

Loading…
Cancel
Save