Fix for the Windows app installed devices not loading

remotes/1720607818248768243/tmp_refs/heads/master
Pahansith Gunathilake 8 months ago
parent dd03a073b2
commit 862cc72499

@ -1268,8 +1268,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
boolean isSerialProvided = false; boolean isSerialProvided = false;
StringJoiner joiner = new StringJoiner(",", query = "SELECT "
"SELECT "
+ "DM_DEVICE.ID AS DEVICE_ID, " + "DM_DEVICE.ID AS DEVICE_ID, "
+ "DM_DEVICE.NAME AS DEVICE_NAME, " + "DM_DEVICE.NAME AS DEVICE_NAME, "
+ "DM_DEVICE.DESCRIPTION AS DESCRIPTION, " + "DM_DEVICE.DESCRIPTION AS DESCRIPTION, "
@ -1288,13 +1287,17 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "DM_DEVICE.ID = e.DEVICE_ID AND " + "DM_DEVICE.ID = e.DEVICE_ID AND "
+ "DM_DEVICE.TENANT_ID = e.TENANT_ID " + "DM_DEVICE.TENANT_ID = e.TENANT_ID "
+ "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON " + "INNER JOIN (SELECT ID, NAME FROM DM_DEVICE_TYPE) AS device_types ON "
+ "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID " + "device_types.ID = DM_DEVICE.DEVICE_TYPE_ID ";
+ "INNER JOIN DM_DEVICE_INFO i ON "
if (null != serial && !serial.isEmpty()) { // Only if serial is provided, join with device info table
query = query.concat("INNER JOIN DM_DEVICE_INFO i ON "
+ "DM_DEVICE.ID = i.DEVICE_ID " + "DM_DEVICE.ID = i.DEVICE_ID "
+ "AND i.KEY_FIELD = 'serial' " + "AND i.KEY_FIELD = 'serial' ");
+ "WHERE DM_DEVICE.ID IN (", isSerialProvided = true;
}
query = query.concat("WHERE DM_DEVICE.ID IN (");
StringJoiner joiner = new StringJoiner(",", query ,
") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?"); ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?");
deviceIds.stream().map(ignored -> "?").forEach(joiner::add); deviceIds.stream().map(ignored -> "?").forEach(joiner::add);
query = joiner.toString(); query = joiner.toString();
@ -1306,9 +1309,8 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
query += " AND e.OWNERSHIP = ?"; query += " AND e.OWNERSHIP = ?";
isOwnershipProvided = true; isOwnershipProvided = true;
} }
if (serial != null && !serial.isEmpty()) { if (isSerialProvided) {
query += " AND i.VALUE_FIELD LIKE ?" ; query += " AND i.VALUE_FIELD LIKE ?" ;
isSerialProvided = true;
} }
if (user != null && !user.isEmpty()) { if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?"; query += " AND e.OWNER = ?";

Loading…
Cancel
Save