Merged with upstream and resolved conflicts.

revert-70aa11f8
charithag 9 years ago
commit 0a8e00fd1e

@ -36,6 +36,8 @@ public class Application implements Serializable {
private Properties appProperties; private Properties appProperties;
private String applicationIdentifier; private String applicationIdentifier;
private int memoryUsage;
public String getType() { public String getType() {
return type; return type;
} }
@ -111,6 +113,14 @@ public class Application implements Serializable {
this.applicationIdentifier = applicationIdentifier; this.applicationIdentifier = applicationIdentifier;
} }
public int getMemoryUsage() {
return memoryUsage;
}
public void setMemoryUsage(int memoryUsage) {
this.memoryUsage = memoryUsage;
}
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
return true; return true;

@ -24,8 +24,8 @@ import java.util.List;
public class SearchContext { public class SearchContext {
private List<Condition> conditions; private List<Condition> conditions;
private int start; // private int start;
private int end; // private int end;
public List<Condition> getConditions() { public List<Condition> getConditions() {
return conditions; return conditions;
@ -35,20 +35,20 @@ public class SearchContext {
this.conditions = conditions; this.conditions = conditions;
} }
public int getStart() { // public int getStart() {
return start; // return start;
} // }
//
public void setStart(int start) { // public void setStart(int start) {
this.start = start; // this.start = start;
} // }
//
public int getEnd() { // public int getEnd() {
return end; // return end;
} // }
//
public void setEnd(int end) { // public void setEnd(int end) {
this.end = end; // this.end = end;
} // }
} }

@ -237,6 +237,13 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--<dependency>-->
<!--<groupId>com.google.code.gson</groupId>-->
<!--<artifactId>gson</artifactId>-->
<!--<version>1.7.1</version>-->
<!--</dependency>-->
</dependencies> </dependencies>
</project> </project>

@ -47,8 +47,8 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " + stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID,APP_PROPERTIES,APP_IDENTIFIER) " + "VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID, APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?)"); "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
stmt.setString(1, application.getName()); stmt.setString(1, application.getName());
stmt.setString(2, application.getPlatform()); stmt.setString(2, application.getPlatform());
@ -65,6 +65,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
stmt.setBytes(9, bao.toByteArray()); stmt.setBytes(9, bao.toByteArray());
stmt.setString(10, application.getApplicationIdentifier()); stmt.setString(10, application.getApplicationIdentifier());
stmt.setInt(11, application.getMemoryUsage());
stmt.execute(); stmt.execute();
rs = stmt.getGeneratedKeys(); rs = stmt.getGeneratedKeys();
@ -108,8 +109,8 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " + stmt = conn.prepareStatement("INSERT INTO DM_APPLICATION (NAME, PLATFORM, CATEGORY, " +
"VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID,APP_PROPERTIES,APP_IDENTIFIER) " + "VERSION, TYPE, LOCATION_URL, IMAGE_URL, TENANT_ID,APP_PROPERTIES, APP_IDENTIFIER, MEMORY_USAGE) " +
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?,?)", new String[] {"id"}); "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", new String[]{"id"});
for (Application application : applications) { for (Application application : applications) {
@ -129,6 +130,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
stmt.setBytes(9, bao.toByteArray()); stmt.setBytes(9, bao.toByteArray());
stmt.setString(10, application.getApplicationIdentifier()); stmt.setString(10, application.getApplicationIdentifier());
stmt.setInt(11, application.getMemoryUsage());
stmt.executeUpdate(); stmt.executeUpdate();
rs = stmt.getGeneratedKeys(); rs = stmt.getGeneratedKeys();
@ -206,7 +208,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + stmt = conn.prepareStatement("SELECT ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " + "LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, TENANT_ID FROM DM_APPLICATION WHERE APP_IDENTIFIER = ? " +
"AND TENANT_ID = ?"); "AND TENANT_ID = ?");
stmt.setString(1, identifier); stmt.setString(1, identifier);
stmt.setInt(2, tenantId); stmt.setInt(2, tenantId);
@ -238,7 +240,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
try { try {
conn = this.getConnection(); conn = this.getConnection();
stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " + stmt = conn.prepareStatement("Select ID, NAME, APP_IDENTIFIER, PLATFORM, CATEGORY, VERSION, TYPE, " +
"LOCATION_URL, IMAGE_URL, APP_PROPERTIES, TENANT_ID From DM_APPLICATION app " + "LOCATION_URL, IMAGE_URL, APP_PROPERTIES, MEMORY_USAGE, TENANT_ID From DM_APPLICATION app " +
"INNER JOIN " + "INNER JOIN " +
"(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " + "(Select APPLICATION_ID From DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID=?) APPMAP " +
"ON " + "ON " +
@ -284,6 +286,7 @@ public class ApplicationDAOImpl implements ApplicationDAO {
application.setLocationUrl(rs.getString("LOCATION_URL")); application.setLocationUrl(rs.getString("LOCATION_URL"));
application.setPlatform(rs.getString("PLATFORM")); application.setPlatform(rs.getString("PLATFORM"));
application.setVersion(rs.getString("VERSION")); application.setVersion(rs.getString("VERSION"));
application.setMemoryUsage(rs.getInt("MEMORY_USAGE"));
application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER")); application.setApplicationIdentifier(rs.getString("APP_IDENTIFIER"));
} catch (IOException e) { } catch (IOException e) {

@ -136,14 +136,5 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
} }
} }
// @Override
// public void addDeviceApplications(DeviceApplication deviceApplication) throws DeviceDetailsMgtException {
//
// }
//
// @Override
// public DeviceApplication getDeviceApplication(DeviceIdentifier deviceIdentifier) throws DeviceDetailsMgtException {
// return null;
// }
} }

@ -24,4 +24,5 @@ public class Constants {
public static String GENERAL = "GENERAL"; public static String GENERAL = "GENERAL";
public static String PROP_AND = "PROP_AND"; public static String PROP_AND = "PROP_AND";
public static String PROP_OR = "PROP_OR"; public static String PROP_OR = "PROP_OR";
public static String LOCATION = "LOCATION";
} }

@ -32,6 +32,8 @@ public interface QueryBuilder {
String processOR(List<Condition> conditions) throws InvalidOperatorException; String processOR(List<Condition> conditions) throws InvalidOperatorException;
List<String> processLocation(Condition condition) throws InvalidOperatorException;
List<String> processANDProperties(List<Condition> conditions) throws InvalidOperatorException; List<String> processANDProperties(List<Condition> conditions) throws InvalidOperatorException;
List<String> processORProperties(List<Condition> conditions) throws InvalidOperatorException; List<String> processORProperties(List<Condition> conditions) throws InvalidOperatorException;

@ -47,6 +47,7 @@ public class ProcessorImpl implements Processor {
List<DeviceWrapper> generalDevices = new ArrayList<>(); List<DeviceWrapper> generalDevices = new ArrayList<>();
List<List<DeviceWrapper>> allANDDevices = new ArrayList<>(); List<List<DeviceWrapper>> allANDDevices = new ArrayList<>();
List<List<DeviceWrapper>> allORDevices = new ArrayList<>(); List<List<DeviceWrapper>> allORDevices = new ArrayList<>();
List<DeviceWrapper> locationDevices = new ArrayList<>();
try { try {
Map<String, List<String>> queries = queryBuilder.buildQueries(searchContext.getConditions()); Map<String, List<String>> queries = queryBuilder.buildQueries(searchContext.getConditions());
DeviceManagementDAOFactory.openConnection(); DeviceManagementDAOFactory.openConnection();
@ -66,6 +67,10 @@ public class ProcessorImpl implements Processor {
allORDevices.add(orDevices); allORDevices.add(orDevices);
} }
} }
if (queries.containsKey(Constants.LOCATION)) {
locationDevices = searchDAO.searchDevicePropertyTable(
queries.get(Constants.LOCATION).get(0));
}
} catch (InvalidOperatorException e) { } catch (InvalidOperatorException e) {
throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e); throw new SearchMgtException("Invalid operator was provided, so cannot execute the search.", e);
} catch (SQLException e) { } catch (SQLException e) {
@ -84,6 +89,7 @@ public class ProcessorImpl implements Processor {
deviceWrappers.put(Constants.GENERAL, generalDevices); deviceWrappers.put(Constants.GENERAL, generalDevices);
deviceWrappers.put(Constants.PROP_AND, this.processANDSearch(allANDDevices)); deviceWrappers.put(Constants.PROP_AND, this.processANDSearch(allANDDevices));
deviceWrappers.put(Constants.PROP_OR, this.processORSearch(allORDevices)); deviceWrappers.put(Constants.PROP_OR, this.processORSearch(allORDevices));
deviceWrappers.put(Constants.LOCATION, locationDevices);
return aggregator.aggregate(deviceWrappers); return aggregator.aggregate(deviceWrappers);
} }
@ -157,5 +163,6 @@ public class ProcessorImpl implements Processor {
} }
return maps; return maps;
} }
} }

@ -44,9 +44,13 @@ public class QueryBuilderImpl implements QueryBuilder {
List<Condition> orColumns = new ArrayList<>(); List<Condition> orColumns = new ArrayList<>();
List<Condition> otherANDColumns = new ArrayList<>(); List<Condition> otherANDColumns = new ArrayList<>();
List<Condition> otherORColumns = new ArrayList<>(); List<Condition> otherORColumns = new ArrayList<>();
Condition locConditon = new Condition();
if (conditions.size() == 1) { if (conditions.size() == 1) {
if (Utils.getDeviceDetailsColumnNames().containsKey(conditions.get(0)) ||
if (conditions.get(0).getKey().equalsIgnoreCase(Constants.LOCATION)) {
locConditon = conditions.get(0);
} else if (Utils.getDeviceDetailsColumnNames().containsKey(conditions.get(0)) ||
Utils.getDeviceLocationColumnNames().containsKey(conditions.get(0))) { Utils.getDeviceLocationColumnNames().containsKey(conditions.get(0))) {
andColumns.add(conditions.get(0)); andColumns.add(conditions.get(0));
} else { } else {
@ -54,7 +58,9 @@ public class QueryBuilderImpl implements QueryBuilder {
} }
} else { } else {
for (Condition con : conditions) { for (Condition con : conditions) {
if (Utils.getDeviceDetailsColumnNames().containsKey(con.getKey()) || if (con.getKey().equalsIgnoreCase(Constants.LOCATION)) {
locConditon = con;
} else if (Utils.getDeviceDetailsColumnNames().containsKey(con.getKey()) ||
Utils.getDeviceLocationColumnNames().containsKey(con.getKey())) { Utils.getDeviceLocationColumnNames().containsKey(con.getKey())) {
if (con.getState().equals(Condition.State.AND)) { if (con.getState().equals(Condition.State.AND)) {
andColumns.add(con); andColumns.add(con);
@ -80,11 +86,13 @@ public class QueryBuilderImpl implements QueryBuilder {
this.processOR(orColumns))); this.processOR(orColumns)));
queries.put(Constants.PROP_AND, this.processANDProperties(otherANDColumns)); queries.put(Constants.PROP_AND, this.processANDProperties(otherANDColumns));
queries.put(Constants.PROP_OR, this.processORProperties(otherORColumns)); queries.put(Constants.PROP_OR, this.processORProperties(otherORColumns));
queries.put(Constants.LOCATION, this.processLocation(locConditon));
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("General Query : " + queries.get(Constants.GENERAL)); log.debug("General Query : " + queries.get(Constants.GENERAL));
log.debug("Property with AND Query : " + queries.get(Constants.PROP_AND)); log.debug("Property with AND Query : " + queries.get(Constants.PROP_AND));
log.debug("Property with OR Query : " + queries.get(Constants.PROP_OR)); log.debug("Property with OR Query : " + queries.get(Constants.PROP_OR));
log.debug("Location related Query : " + queries.get(Constants.LOCATION));
} }
return queries; return queries;
@ -125,6 +133,13 @@ public class QueryBuilderImpl implements QueryBuilder {
return querySuffix; return querySuffix;
} }
@Override
public List<String> processLocation(Condition condition) throws InvalidOperatorException {
List<String> queryList = new ArrayList<>();
queryList.add(this.buildLocationQuery(condition.getValue()));
return queryList;
}
@Override @Override
public List<String> processANDProperties(List<Condition> conditions) throws InvalidOperatorException { public List<String> processANDProperties(List<Condition> conditions) throws InvalidOperatorException {
return this.getQueryList(conditions); return this.getQueryList(conditions);
@ -146,6 +161,18 @@ public class QueryBuilderImpl implements QueryBuilder {
return queryList; return queryList;
} }
private String buildLocationQuery(String location) {
String query = this.getGenericQueryPart();
query = query + " OR STREET1 LIKE \'%" + location + "%\'";
query = query + " OR STREET2 LIKE \'%" + location + "%\'";
query = query + " OR CITY LIKE \'%" + location + "%\'";
query = query + " OR STATE LIKE \'%" + location + "%\'";
query = query + " OR COUNTRY LIKE \'%" + location + "%\'";
query = query + " OR ZIP LIKE \'%" + location + "%\'";
return query;
}
private String getGenericQueryPart() { private String getGenericQueryPart() {
return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" + return "SELECT D.ID, D.DESCRIPTION, D.NAME, \n" +
@ -159,18 +186,6 @@ public class QueryBuilderImpl implements QueryBuilder {
"DM_DEVICE_TYPE AS DT WHERE D.TENANT_ID = " + "DM_DEVICE_TYPE AS DT WHERE D.TENANT_ID = " +
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
// CREATE TABLE IF NOT EXISTS DM_DEVICE (
// ID INTEGER auto_increment NOT NULL,
// DESCRIPTION TEXT DEFAULT NULL,
// NAME VARCHAR(100) DEFAULT NULL,
// DEVICE_TYPE_ID INT(11) DEFAULT NULL,
// DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL,
// TENANT_ID INTEGER DEFAULT 0,
// PRIMARY KEY (ID),
// CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
// REFERENCES DM_DEVICE_TYPE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION
// );
} }
@ -190,4 +205,3 @@ public class QueryBuilderImpl implements QueryBuilder {
} }
} }

@ -36,15 +36,28 @@ public class ResultSetAggregatorImpl implements ResultSetAggregator {
Map<Integer, DeviceWrapper> generalQueryMap = this.convertToMap(deviceWrappers.get(Constants.GENERAL)); Map<Integer, DeviceWrapper> generalQueryMap = this.convertToMap(deviceWrappers.get(Constants.GENERAL));
Map<Integer, DeviceWrapper> andMap = this.convertToMap(deviceWrappers.get(Constants.PROP_AND)); Map<Integer, DeviceWrapper> andMap = this.convertToMap(deviceWrappers.get(Constants.PROP_AND));
Map<Integer, DeviceWrapper> orMap = this.convertToMap(deviceWrappers.get(Constants.PROP_OR)); Map<Integer, DeviceWrapper> orMap = this.convertToMap(deviceWrappers.get(Constants.PROP_OR));
Map<Integer, DeviceWrapper> locationMap = this.convertToMap(deviceWrappers.get(Constants.LOCATION));
List<DeviceWrapper> finalResult = new ArrayList<>(); List<DeviceWrapper> finalResult = new ArrayList<>();
for (Integer a : andMap.keySet()) { for (Integer a : andMap.keySet()) {
if (generalQueryMap.containsKey(a)) { if (generalQueryMap.containsKey(a)) {
if (!finalResult.contains(a)) {
finalResult.add(andMap.get(a)); finalResult.add(andMap.get(a));
} }
} }
}
for (Integer a : orMap.keySet()) { for (Integer a : orMap.keySet()) {
if (!finalResult.contains(a)) {
finalResult.add(orMap.get(a)); finalResult.add(orMap.get(a));
} }
}
for (Integer a : locationMap.keySet()) {
if (!finalResult.contains(a)) {
finalResult.add(locationMap.get(a));
}
}
return finalResult; return finalResult;
} }

@ -48,15 +48,37 @@ public class SearchDevice extends BaseDeviceManagementTest {
SearchContext context = new SearchContext(); SearchContext context = new SearchContext();
List<Condition> conditions = new ArrayList<>(); List<Condition> conditions = new ArrayList<>();
Condition cond = new Condition();
Condition cond = new Condition();
cond.setKey("BATTERY_VOLTAGE"); cond.setKey("BATTERY_VOLTAGE");
cond.setOperator("="); cond.setOperator("=");
cond.setValue("40"); cond.setValue("40");
cond.setState(Condition.State.AND); cond.setState(Condition.State.AND);
conditions.add(cond); conditions.add(cond);
Condition cond2 = new Condition();
cond2.setKey("CPU_USAGE");
cond2.setOperator(">");
cond2.setValue("40");
cond2.setState(Condition.State.OR);
conditions.add(cond2);
Condition cond3 = new Condition();
cond3.setKey("LOCATION");
cond3.setOperator("=");
cond3.setValue("Colombo");
cond3.setState(Condition.State.AND);
conditions.add(cond3);
context.setConditions(conditions); context.setConditions(conditions);
// Gson gson = new Gson();
//
// String aaa = gson.toJson(context);
//
// log.info(aaa);
SearchManagerService service = new SearchManagerServiceImpl(); SearchManagerService service = new SearchManagerServiceImpl();
List<DeviceWrapper> deviceWrappers = service.search(context); List<DeviceWrapper> deviceWrappers = service.search(context);

@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
ID INT AUTO_INCREMENT NOT NULL, ID INT auto_increment NOT NULL,
NAME VARCHAR(300) DEFAULT NULL, NAME VARCHAR(300) DEFAULT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
@ -16,15 +16,14 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
ID INTEGER AUTO_INCREMENT NOT NULL, ID INTEGER auto_increment NOT NULL,
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
CERTIFICATE BLOB DEFAULT NULL, CERTIFICATE BLOB DEFAULT NULL,
TENANT_ID INTEGER DEFAULT 0,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE TABLE IF NOT EXISTS DM_DEVICE (
ID INTEGER AUTO_INCREMENT NOT NULL, ID INTEGER auto_increment NOT NULL,
DESCRIPTION TEXT DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL,
NAME VARCHAR(100) DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL,
DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_TYPE_ID INT(11) DEFAULT NULL,
@ -145,6 +144,10 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_POLICY ( CREATE TABLE IF NOT EXISTS DM_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
NAME VARCHAR(45) DEFAULT NULL , NAME VARCHAR(45) DEFAULT NULL ,
@ -164,6 +167,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT(11) NOT NULL , DEVICE_ID INT(11) NOT NULL ,
@ -183,6 +189,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ID INT(11) NOT NULL , ID INT(11) NOT NULL ,
DEVICE_TYPE_ID INT(11) NOT NULL , DEVICE_TYPE_ID INT(11) NOT NULL ,
@ -200,6 +209,10 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ID INT(11) NOT NULL AUTO_INCREMENT, ID INT(11) NOT NULL AUTO_INCREMENT,
PROFILE_ID INT(11) NOT NULL, PROFILE_ID INT(11) NOT NULL,
@ -215,6 +228,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
ROLE_NAME VARCHAR(45) NOT NULL , ROLE_NAME VARCHAR(45) NOT NULL ,
@ -227,6 +243,9 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ID INT NOT NULL AUTO_INCREMENT , ID INT NOT NULL AUTO_INCREMENT ,
POLICY_ID INT NOT NULL , POLICY_ID INT NOT NULL ,
@ -239,6 +258,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
ID INT NOT NULL AUTO_INCREMENT , ID INT NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT NOT NULL , DEVICE_ID INT NOT NULL ,
@ -246,18 +266,20 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
POLICY_ID INT NOT NULL , POLICY_ID INT NOT NULL ,
POLICY_CONTENT BLOB NULL , POLICY_CONTENT BLOB NULL ,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
APPLIED BOOLEAN NULL, APPLIED TINYINT(1) NULL ,
CREATED_TIME TIMESTAMP NULL , CREATED_TIME TIMESTAMP NULL ,
UPDATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL ,
APPLIED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_POLICY_DEVICE_APPLIED CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED
FOREIGN KEY (DEVICE_ID ) FOREIGN KEY (DEVICE_ID )
REFERENCES DM_DEVICE (ID ) REFERENCES DM_DEVICE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
@ -265,6 +287,8 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA (
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
CRITERIA_ID INT NOT NULL, CRITERIA_ID INT NOT NULL,
@ -287,8 +311,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
POLICY_CRITERION_ID INT NOT NULL, POLICY_CRITERION_ID INT NOT NULL,
PROP_KEY VARCHAR(45) NULL, PROP_KEY VARCHAR(45) NULL,
PROP_VALUE VARCHAR(100) NULL, PROP_VALUE VARCHAR(100) NULL,
CONTENT BLOB NULL CONTENT BLOB NULL COMMENT 'This is used to ',
COMMENT 'This is used to ',
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
FOREIGN KEY (POLICY_CRITERION_ID) FOREIGN KEY (POLICY_CRITERION_ID)
@ -360,6 +383,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
LOCATION_URL VARCHAR(100) DEFAULT NULL, LOCATION_URL VARCHAR(100) DEFAULT NULL,
IMAGE_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL,
APP_PROPERTIES BLOB NULL, APP_PROPERTIES BLOB NULL,
MEMORY_USAGE DECIMAL(5) NULL,
TENANT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
@ -409,6 +433,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
DROP TABLE IF EXISTS DM_DEVICE_LOCATION; DROP TABLE IF EXISTS DM_DEVICE_LOCATION;
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
@ -430,6 +456,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL, DEVICE_ID INT NOT NULL,

@ -51,7 +51,7 @@
<RecurrentTimes>5</RecurrentTimes> <RecurrentTimes>5</RecurrentTimes>
</Operation> </Operation>
<Operation> <Operation>
<Name>LOCATION</Name> <Name>DEVICE_LOCATION</Name>
<RecurrentTimes>1</RecurrentTimes> <RecurrentTimes>1</RecurrentTimes>
</Operation> </Operation>
</Operations> </Operations>

@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE (
ID INT AUTO_INCREMENT NOT NULL, ID INT auto_increment NOT NULL,
NAME VARCHAR(300) DEFAULT NULL, NAME VARCHAR(300) DEFAULT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE ( CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
ID INTEGER AUTO_INCREMENT NOT NULL, ID INTEGER auto_increment NOT NULL,
SERIAL_NUMBER VARCHAR(500) DEFAULT NULL, SERIAL_NUMBER VARCHAR(500) DEFAULT NULL,
CERTIFICATE BLOB DEFAULT NULL, CERTIFICATE BLOB DEFAULT NULL,
TENANT_ID INTEGER DEFAULT 0, TENANT_ID INTEGER DEFAULT 0,
@ -24,7 +24,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_CERTIFICATE (
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE ( CREATE TABLE IF NOT EXISTS DM_DEVICE (
ID INTEGER AUTO_INCREMENT NOT NULL, ID INTEGER auto_increment NOT NULL,
DESCRIPTION TEXT DEFAULT NULL, DESCRIPTION TEXT DEFAULT NULL,
NAME VARCHAR(100) DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL,
DEVICE_TYPE_ID INT(11) DEFAULT NULL, DEVICE_TYPE_ID INT(11) DEFAULT NULL,
@ -145,6 +145,10 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_POLICY ( CREATE TABLE IF NOT EXISTS DM_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
NAME VARCHAR(45) DEFAULT NULL , NAME VARCHAR(45) DEFAULT NULL ,
@ -164,6 +168,9 @@ CREATE TABLE IF NOT EXISTS DM_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT(11) NOT NULL , DEVICE_ID INT(11) NOT NULL ,
@ -183,6 +190,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ID INT(11) NOT NULL , ID INT(11) NOT NULL ,
DEVICE_TYPE_ID INT(11) NOT NULL , DEVICE_TYPE_ID INT(11) NOT NULL ,
@ -200,6 +210,10 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ID INT(11) NOT NULL AUTO_INCREMENT, ID INT(11) NOT NULL AUTO_INCREMENT,
PROFILE_ID INT(11) NOT NULL, PROFILE_ID INT(11) NOT NULL,
@ -215,6 +229,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ID INT(11) NOT NULL AUTO_INCREMENT , ID INT(11) NOT NULL AUTO_INCREMENT ,
ROLE_NAME VARCHAR(45) NOT NULL , ROLE_NAME VARCHAR(45) NOT NULL ,
@ -227,6 +244,9 @@ CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ID INT NOT NULL AUTO_INCREMENT , ID INT NOT NULL AUTO_INCREMENT ,
POLICY_ID INT NOT NULL , POLICY_ID INT NOT NULL ,
@ -239,6 +259,7 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
ID INT NOT NULL AUTO_INCREMENT , ID INT NOT NULL AUTO_INCREMENT ,
DEVICE_ID INT NOT NULL , DEVICE_ID INT NOT NULL ,
@ -246,18 +267,20 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED (
POLICY_ID INT NOT NULL , POLICY_ID INT NOT NULL ,
POLICY_CONTENT BLOB NULL , POLICY_CONTENT BLOB NULL ,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
APPLIED BOOLEAN NULL, APPLIED TINYINT(1) NULL ,
CREATED_TIME TIMESTAMP NULL , CREATED_TIME TIMESTAMP NULL ,
UPDATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL ,
APPLIED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL ,
PRIMARY KEY (ID) , PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_POLICY_DEVICE_APPLIED CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED
FOREIGN KEY (DEVICE_ID ) FOREIGN KEY (DEVICE_ID )
REFERENCES DM_DEVICE (ID ) REFERENCES DM_DEVICE (ID )
ON DELETE NO ACTION ON DELETE NO ACTION
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
TENANT_ID INT NOT NULL, TENANT_ID INT NOT NULL,
@ -265,6 +288,8 @@ CREATE TABLE IF NOT EXISTS DM_CRITERIA (
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA ( CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
CRITERIA_ID INT NOT NULL, CRITERIA_ID INT NOT NULL,
@ -287,8 +312,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES (
POLICY_CRITERION_ID INT NOT NULL, POLICY_CRITERION_ID INT NOT NULL,
PROP_KEY VARCHAR(45) NULL, PROP_KEY VARCHAR(45) NULL,
PROP_VALUE VARCHAR(100) NULL, PROP_VALUE VARCHAR(100) NULL,
CONTENT BLOB NULL CONTENT BLOB NULL COMMENT 'This is used to ',
COMMENT 'This is used to ',
PRIMARY KEY (ID), PRIMARY KEY (ID),
CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES
FOREIGN KEY (POLICY_CRITERION_ID) FOREIGN KEY (POLICY_CRITERION_ID)
@ -360,6 +384,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
LOCATION_URL VARCHAR(100) DEFAULT NULL, LOCATION_URL VARCHAR(100) DEFAULT NULL,
IMAGE_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL,
APP_PROPERTIES BLOB NULL, APP_PROPERTIES BLOB NULL,
MEMORY_USAGE INTEGER(10) NULL,
TENANT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );
@ -409,6 +434,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
DROP TABLE IF EXISTS DM_DEVICE_LOCATION; DROP TABLE IF EXISTS DM_DEVICE_LOCATION;
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
@ -430,6 +457,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ON UPDATE NO ACTION ON UPDATE NO ACTION
); );
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL AUTO_INCREMENT, ID INT NOT NULL AUTO_INCREMENT,
DEVICE_ID INT NOT NULL, DEVICE_ID INT NOT NULL,

@ -349,6 +349,7 @@ CREATE TABLE DM_APPLICATION (
LOCATION_URL VARCHAR(100) DEFAULT NULL, LOCATION_URL VARCHAR(100) DEFAULT NULL,
IMAGE_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL,
APP_PROPERTIES VARBINARY(max) NULL, APP_PROPERTIES VARBINARY(max) NULL,
MEMORY_USAGE INTEGER(10) NULL,
TENANT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
); );

@ -356,6 +356,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
LOCATION_URL VARCHAR(100) DEFAULT NULL, LOCATION_URL VARCHAR(100) DEFAULT NULL,
IMAGE_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL,
APP_PROPERTIES BLOB NULL, APP_PROPERTIES BLOB NULL,
MEMORY_USAGE INTEGER(10) NULL,
TENANT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL,
PRIMARY KEY (ID) PRIMARY KEY (ID)
)ENGINE = InnoDB; )ENGINE = InnoDB;

@ -576,6 +576,7 @@ CREATE TABLE DM_APPLICATION (
LOCATION_URL VARCHAR2(100) DEFAULT NULL, LOCATION_URL VARCHAR2(100) DEFAULT NULL,
IMAGE_URL VARCHAR2(100) DEFAULT NULL, IMAGE_URL VARCHAR2(100) DEFAULT NULL,
APP_PROPERTIES BLOB NULL, APP_PROPERTIES BLOB NULL,
MEMORY_USAGE NUMBER(10) NULL,
TENANT_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL,
CONSTRAINT PK_DM_APPLICATION PRIMARY KEY (ID) CONSTRAINT PK_DM_APPLICATION PRIMARY KEY (ID)
) )
@ -654,3 +655,132 @@ WHEN (NEW.NOTIFICATION_ID IS NULL)
/ /
-- NOTIFICATION TABLE END -- -- NOTIFICATION TABLE END --
-- Device Info and Search Table --
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_INFO';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_INFO (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NULL,
KEY_FIELD VARCHAR2(45) NULL,
VALUE_FIELD VARCHAR2(100) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT DM_DEVICE_INFO_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_INFO_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_INFO_seq_tr
BEFORE INSERT ON DM_DEVICE_INFO FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_INFO_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX DM_DEVICE_INFO_DEVICE_idx ON DM_DEVICE_INFO (DEVICE_ID ASC);
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_LOCATION';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_LOCATION (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NULL,
LATITUDE BINARY_DOUBLE NULL,
LONGITUDE BINARY_DOUBLE NULL,
STREET1 VARCHAR2(45) NULL,
STREET2 VARCHAR2(45) NULL,
CITY VARCHAR2(45) NULL,
ZIP VARCHAR2(10) NULL,
STATE VARCHAR2(45) NULL,
COUNTRY VARCHAR2(45) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_LOCATION_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_LOCATION_seq_tr
BEFORE INSERT ON DM_DEVICE_LOCATION FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_LOCATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX DM_DEVICE_LOCATION_DEVICE_idx ON DM_DEVICE_LOCATION (DEVICE_ID ASC);
BEGIN
EXECUTE IMMEDIATE 'DROP TABLE DM_DEVICE_DETAIL';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE TABLE DM_DEVICE_DETAIL (
ID NUMBER(10) NOT NULL,
DEVICE_ID NUMBER(10) NOT NULL,
IMEI VARCHAR2(100) NULL,
IMSI VARCHAR2(100) NULL,
DEVICE_MODEL VARCHAR2(45) NULL,
VENDOR VARCHAR2(45) NULL,
OS_VERSION VARCHAR2(45) NULL,
BATTERY_LEVEL NUMBER(4) NULL,
INTERNAL_TOTAL_MEMORY NUMBER(5) NULL,
INTERNAL_AVAILABLE_MEMORY NUMBER(5) NULL,
EXTERNAL_TOTAL_MEMORY NUMBER(5) NULL,
EXTERNAL_AVAILABLE_MEMORY NUMBER(5) NULL,
OPERATOR VARCHAR2(45) NULL,
CONNECTION_TYPE VARCHAR2(10) NULL,
MOBILE_SIGNAL_STRENGTH NUMBER(5) NULL,
SSID VARCHAR2(45) NULL,
CPU_USAGE NUMBER(5) NULL,
TOTAL_RAM_MEMORY NUMBER(5) NULL,
AVAILABLE_RAM_MEMORY NUMBER(5) NULL,
PLUGGED_IN NUMBER(10) NULL,
PRIMARY KEY (ID)
,
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
)
;
-- Generate ID using sequence and trigger
CREATE SEQUENCE DM_DEVICE_DETAIL_seq START WITH 1 INCREMENT BY 1;
CREATE OR REPLACE TRIGGER DM_DEVICE_DETAIL_seq_tr
BEFORE INSERT ON DM_DEVICE_DETAIL FOR EACH ROW
WHEN (NEW.ID IS NULL)
BEGIN
SELECT DM_DEVICE_DETAIL_seq.NEXTVAL INTO :NEW.ID FROM DUAL;
END;
/
CREATE INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx ON DM_DEVICE_DETAIL (DEVICE_ID ASC);

@ -313,6 +313,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION (
LOCATION_URL VARCHAR(100) DEFAULT NULL, LOCATION_URL VARCHAR(100) DEFAULT NULL,
IMAGE_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL,
APP_PROPERTIES BYTEA NULL, APP_PROPERTIES BYTEA NULL,
MEMORY_USAGE INTEGER NULL,
TENANT_ID INTEGER NOT NULL TENANT_ID INTEGER NOT NULL
); );
@ -345,3 +346,75 @@ CREATE TABLE IF NOT EXISTS DM_NOTIFICATION (
-- NOTIFICATION TABLE END -- -- NOTIFICATION TABLE END --
-- Device Info and Search Table --
CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_INFO_seq') NOT NULL,
DEVICE_ID INT NULL,
KEY_FIELD VARCHAR(45) NULL,
VALUE_FIELD VARCHAR(100) NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_INFO_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX DM_DEVICE_INFO_DEVICE_idx ON DM_DEVICE_INFO (DEVICE_ID ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION (
ID INTEGER DEFAULT NEXTVAL ('DM_DEVICE_LOCATION_seq') NOT NULL,
DEVICE_ID INT NULL,
LATITUDE DOUBLE PRECISION NULL,
LONGITUDE DOUBLE PRECISION NULL,
STREET1 VARCHAR(45) NULL,
STREET2 VARCHAR(45) NULL,
CITY VARCHAR(45) NULL,
ZIP VARCHAR(10) NULL,
STATE VARCHAR(45) NULL,
COUNTRY VARCHAR(45) NULL,
PRIMARY KEY (ID) ,
CONSTRAINT DM_DEVICE_LOCATION_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX DM_DEVICE_LOCATION_DEVICE_idx ON DM_DEVICE_LOCATION (DEVICE_ID ASC);
CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL (
ID INT NOT NULL DEFAULT NEXTVAL ('DM_DEVICE_DETAIL_seq'),
DEVICE_ID INT NOT NULL,
IMEI VARCHAR(100) NULL,
IMSI VARCHAR(100) NULL,
DEVICE_MODEL VARCHAR(45) NULL,
VENDOR VARCHAR(45) NULL,
OS_VERSION VARCHAR(45) NULL,
BATTERY_LEVEL DECIMAL(4) NULL,
INTERNAL_TOTAL_MEMORY DECIMAL(5) NULL,
INTERNAL_AVAILABLE_MEMORY DECIMAL(5) NULL,
EXTERNAL_TOTAL_MEMORY DECIMAL(5) NULL,
EXTERNAL_AVAILABLE_MEMORY DECIMAL(5) NULL,
OPERATOR VARCHAR(45) NULL,
CONNECTION_TYPE VARCHAR(10) NULL,
MOBILE_SIGNAL_STRENGTH DECIMAL(5) NULL,
SSID VARCHAR(45) NULL,
CPU_USAGE DECIMAL(5) NULL,
TOTAL_RAM_MEMORY DECIMAL(5) NULL,
AVAILABLE_RAM_MEMORY DECIMAL(5) NULL,
PLUGGED_IN INT NULL,
PRIMARY KEY (ID) ,
CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE
FOREIGN KEY (DEVICE_ID)
REFERENCES DM_DEVICE (ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
);
CREATE INDEX FK_DM_DEVICE_DETAILS_DEVICE_idx ON DM_DEVICE_DETAIL (DEVICE_ID ASC);

Loading…
Cancel
Save