Add fix for search operation (#251)

fixes https://roadmap.entgra.net/issues/10279

Co-authored-by: osh <osh.silva@gmail.com>
Reviewed-on: #251
Co-authored-by: Oshani Silva <oshani@entgra.io>
Co-committed-by: Oshani Silva <oshani@entgra.io>
pull/248/head^2
Oshani Silva 12 months ago committed by Pahansith Gunathilake
parent 8696ec9343
commit c3cc4fe6d4

@ -94,7 +94,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
"t.NAME AS DEVICE_TYPE "; "t.NAME AS DEVICE_TYPE ";
//Filter by serial number or any Custom Property in DM_DEVICE_INFO //Filter by serial number or any Custom Property in DM_DEVICE_INFO
if (serial != null || !request.getCustomProperty().isEmpty()) { if ((serial != null) || (request.getCustomProperty() != null && !request.getCustomProperty().isEmpty())) {
sql = sql + sql = sql +
"FROM DM_DEVICE d " + "FROM DM_DEVICE d " +
"INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " + "INNER JOIN DM_DEVICE_TYPE t ON d.DEVICE_TYPE_ID = t.ID " +
@ -170,7 +170,7 @@ public class GenericDeviceDAOImpl extends AbstractDeviceDAOImpl {
if (isSerialProvided) { if (isSerialProvided) {
stmt.setString(paramIdx++, "%" + serial + "%"); stmt.setString(paramIdx++, "%" + serial + "%");
} }
if (!request.getCustomProperty().isEmpty()) { if (request.getCustomProperty() != null && !request.getCustomProperty().isEmpty()) {
for (Map.Entry<String, String> entry : request.getCustomProperty().entrySet()) { for (Map.Entry<String, String> entry : request.getCustomProperty().entrySet()) {
stmt.setString(paramIdx++, "%" + entry.getValue() + "%"); stmt.setString(paramIdx++, "%" + entry.getValue() + "%");
} }

@ -652,7 +652,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Map<String, DeviceManager> deviceManagerMap = new HashMap<>(); Map<String, DeviceManager> deviceManagerMap = new HashMap<>();
List<DeviceCacheKey> deviceCacheKeyList = new ArrayList<>(); List<DeviceCacheKey> deviceCacheKeyList = new ArrayList<>();
List<Device> existingDevices; List<Device> existingDevices;
List<Device> validDevices = new ArrayList<>();; List<Device> validDevices = new ArrayList<>();
int tenantId = this.getTenantId(); int tenantId = this.getTenantId();
try { try {

Loading…
Cancel
Save