Temo changes

pull/201/head
Pramila Niroshan 1 year ago
parent 2dcb65bc35
commit 2154dcbbff

@ -41,6 +41,8 @@ public class PaginationRequest {
private Date since; private Date since;
private String filter; private String filter;
private String serialNumber; private String serialNumber;
private String firmawareVersion;
private Map<String, Object> property = new HashMap<>(); private Map<String, Object> property = new HashMap<>();
private List<String> statusList = new ArrayList<>(); private List<String> statusList = new ArrayList<>();
private OperationLogFilters operationLogFilters = new OperationLogFilters(); private OperationLogFilters operationLogFilters = new OperationLogFilters();
@ -159,6 +161,10 @@ public class PaginationRequest {
public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; }
public String getFirmawareVersion() { return firmawareVersion; }
public void setFirmawareVersion(String firmawareVersion) { this.firmawareVersion = firmawareVersion; }
public Map<String, Object> getProperties() { public Map<String, Object> getProperties() {
Map<String, Object> temp = new HashMap<>(); Map<String, Object> temp = new HashMap<>();
temp.putAll(property); temp.putAll(property);

@ -1185,6 +1185,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
String user = request.getOwner(); String user = request.getOwner();
String ownership = request.getOwnership(); String ownership = request.getOwnership();
String serial = request.getSerialNumber(); String serial = request.getSerialNumber();
String firmawareVersion = request.getFirmawareVersion();
String query = null; String query = null;
try { try {
List<Device> devices = new ArrayList<>(); List<Device> devices = new ArrayList<>();
@ -1199,6 +1200,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
boolean isOwnerProvided = false; boolean isOwnerProvided = false;
boolean isOwnershipProvided = false; boolean isOwnershipProvided = false;
boolean isSerialProvided = false; boolean isSerialProvided = false;
boolean isFirmawareVersionProvided = false;
StringJoiner joiner = new StringJoiner(",", StringJoiner joiner = new StringJoiner(",",
"SELECT " "SELECT "
@ -1224,6 +1226,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
+ "INNER JOIN DM_DEVICE_INFO i ON " + "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' "
+ "OR i.KEY_FIELD = 'FIRMWARE_VERSION' "
+ "WHERE DM_DEVICE.ID IN (", + "WHERE DM_DEVICE.ID IN (",
") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?"); ") AND DM_DEVICE.TENANT_ID = ? AND e.STATUS != ?");
@ -1242,6 +1245,10 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
query += " AND i.VALUE_FIELD LIKE ?" ; query += " AND i.VALUE_FIELD LIKE ?" ;
isSerialProvided = true; isSerialProvided = true;
} }
if (firmawareVersion != null && !firmawareVersion.isEmpty()) {
query += " OR i.VALUE_FIELD LIKE ?" ;
isFirmawareVersionProvided = true;
}
if (user != null && !user.isEmpty()) { if (user != null && !user.isEmpty()) {
query += " AND e.OWNER = ?"; query += " AND e.OWNER = ?";
isOwnerProvided = true; isOwnerProvided = true;
@ -1269,6 +1276,9 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
if (isSerialProvided) { if (isSerialProvided) {
ps.setString(index++, "%" + serial + "%"); ps.setString(index++, "%" + serial + "%");
} }
if (isFirmawareVersionProvided) {
ps.setString(index++, "%" + firmawareVersion + "%");
}
if (isOwnerProvided) { if (isOwnerProvided) {
ps.setString(index++, user); ps.setString(index++, user);
} }
@ -1291,6 +1301,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
String msg = "Error occurred while retrieving information of all registered devices " + String msg = "Error occurred while retrieving information of all registered devices " +
"according to device ids and the limit area. Executed query " + query; "according to device ids and the limit area. Executed query " + query;
log.error(msg, e); log.error(msg, e);
System.out.println(msg);
throw new DeviceManagementDAOException(msg, e); throw new DeviceManagementDAOException(msg, e);
} }
} }

Loading…
Cancel
Save