Add fix for search operation (#251)

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

Co-authored-by: osh <osh.silva@gmail.com>
Reviewed-on: community/device-mgt-core#251
Co-authored-by: Oshani Silva <oshani@entgra.io>
Co-committed-by: Oshani Silva <oshani@entgra.io>
revert
Oshani Silva 1 year ago committed by Pahansith Gunathilake
parent 8696ec9343
commit c3cc4fe6d4

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

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

Loading…
Cancel
Save