|
|
|
@ -97,10 +97,17 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
|
|
|
|
|
|
//Filter by serial number or any Custom Property in DM_DEVICE_INFO
|
|
|
|
|
if (serial != null || !request.getCustomProperty().isEmpty()) {
|
|
|
|
|
sql = sql + "FROM DM_DEVICE d INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID WHERE ";
|
|
|
|
|
sql = sql +
|
|
|
|
|
"FROM DM_DEVICE d " +
|
|
|
|
|
"INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " +
|
|
|
|
|
"WHERE ";
|
|
|
|
|
if (serial != null) {
|
|
|
|
|
sql += "EXISTS ( SELECT VALUE_FIELD FROM DM_DEVICE_INFO di WHERE di.DEVICE_ID = d.ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = 'serial' AND di.VALUE_FIELD LIKE ? ) ";
|
|
|
|
|
sql += "EXISTS (" +
|
|
|
|
|
"SELECT VALUE_FIELD " +
|
|
|
|
|
"FROM DM_DEVICE_INFO di " +
|
|
|
|
|
"WHERE di.DEVICE_ID = d.ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = 'serial' " +
|
|
|
|
|
"AND di.VALUE_FIELD LIKE ? ) ";
|
|
|
|
|
isSerialProvided = true;
|
|
|
|
|
}
|
|
|
|
|
if (!request.getCustomProperty().isEmpty()) {
|
|
|
|
@ -112,14 +119,17 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
|
if (conditionCount > 0) {
|
|
|
|
|
sql += "AND ";
|
|
|
|
|
}
|
|
|
|
|
sql += "EXISTS ( SELECT VALUE_FIELD FROM DM_DEVICE_INFO di WHERE di.DEVICE_ID = d.ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = '"+entry.getKey()+"' AND di.VALUE_FIELD LIKE ? ) ";
|
|
|
|
|
sql += "EXISTS (" +
|
|
|
|
|
"SELECT VALUE_FIELD " +
|
|
|
|
|
"FROM DM_DEVICE_INFO di " +
|
|
|
|
|
"WHERE di.DEVICE_ID = d.ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = '" + entry.getKey() + "' " +
|
|
|
|
|
"AND di.VALUE_FIELD LIKE ? ) ";
|
|
|
|
|
conditionCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sql += "AND d.TENANT_ID = ? ";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
sql = sql + "FROM DM_DEVICE d, DM_DEVICE_TYPE t WHERE DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ? ";
|
|
|
|
|
}
|
|
|
|
|
//Add query for last updated timestamp
|
|
|
|
@ -549,8 +559,12 @@ public class SQLServerDeviceDAOImpl extends AbstractDeviceDAOImpl {
|
|
|
|
|
//Filter Group with serial number or any Custom Property in DM_DEVICE_INFO
|
|
|
|
|
if (serial != null || !request.getCustomProperty().isEmpty()) {
|
|
|
|
|
if (serial != null) {
|
|
|
|
|
sql += "AND EXISTS (SELECT VALUE_FIELD FROM DM_DEVICE_INFO di WHERE di.DEVICE_ID = d1.DEVICE_ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = 'serial' AND di.VALUE_FIELD LIKE ?)";
|
|
|
|
|
sql += "AND EXISTS (" +
|
|
|
|
|
"SELECT VALUE_FIELD " +
|
|
|
|
|
"FROM DM_DEVICE_INFO di " +
|
|
|
|
|
"WHERE di.DEVICE_ID = d1.DEVICE_ID ";
|
|
|
|
|
sql += "AND di.KEY_FIELD = 'serial' " +
|
|
|
|
|
"AND di.VALUE_FIELD LIKE ?)";
|
|
|
|
|
isSerialProvided = true;
|
|
|
|
|
}
|
|
|
|
|
if (!request.getCustomProperty().isEmpty()) {
|
|
|
|
|