Fix for the Windows app installed devices not loading

device-task-configuration
Lasantha Dharmakeerthi 7 months ago
commit d050736aaf

@ -1268,33 +1268,36 @@ 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, " + "DM_DEVICE.DEVICE_TYPE_ID, "
+ "DM_DEVICE.DEVICE_TYPE_ID, " + "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, "
+ "DM_DEVICE.DEVICE_IDENTIFICATION AS DEVICE_IDENTIFICATION, " + "e.ID AS ENROLMENT_ID, "
+ "e.ID AS ENROLMENT_ID, " + "e.OWNER, "
+ "e.OWNER, " + "e.OWNERSHIP, "
+ "e.OWNERSHIP, " + "e.DATE_OF_ENROLMENT, "
+ "e.DATE_OF_ENROLMENT, " + "e.DATE_OF_LAST_UPDATE, "
+ "e.DATE_OF_LAST_UPDATE, " + "e.STATUS, "
+ "e.STATUS, " + "e.IS_TRANSFERRED, "
+ "e.IS_TRANSFERRED, " + "device_types.NAME AS DEVICE_TYPE "
+ "device_types.NAME AS DEVICE_TYPE " + "FROM DM_DEVICE "
+ "FROM DM_DEVICE " + "INNER JOIN DM_ENROLMENT e ON "
+ "INNER JOIN DM_ENROLMENT e ON " + "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
+ "DM_DEVICE.ID = i.DEVICE_ID " query = query.concat("INNER JOIN DM_DEVICE_INFO i ON "
+ "AND i.KEY_FIELD = 'serial' " + "DM_DEVICE.ID = i.DEVICE_ID "
+ "WHERE DM_DEVICE.ID IN (", + "AND i.KEY_FIELD = 'serial' ");
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