Temo changes

temp-changes
Pramila Niroshan 1 year ago
parent 2dcb65bc35
commit 2154dcbbff

@ -41,6 +41,8 @@ public class PaginationRequest {
private Date since;
private String filter;
private String serialNumber;
private String firmawareVersion;
private Map<String, Object> property = new HashMap<>();
private List<String> statusList = new ArrayList<>();
private OperationLogFilters operationLogFilters = new OperationLogFilters();
@ -159,6 +161,10 @@ public class PaginationRequest {
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() {
Map<String, Object> temp = new HashMap<>();
temp.putAll(property);

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

Loading…
Cancel
Save