Refactored SQL queries and added null checks

4.x.x
mharindu 9 years ago
parent 52b4902aa5
commit 9d8c52958d

@ -145,7 +145,7 @@ public class DeviceDAOImpl implements DeviceDAO {
List<Device> devices = null;
try {
conn = this.getConnection();
String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
String sql = "SELECT d1.DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION, " +
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT d.ID AS DEVICE_ID, d.DESCRIPTION, d.NAME," +
"d.DEVICE_IDENTIFICATION, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
"WHERE d.DEVICE_TYPE_ID = t.ID AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";
@ -175,7 +175,7 @@ public class DeviceDAOImpl implements DeviceDAO {
List<Device> devices = null;
try {
conn = this.getConnection();
String selectDBQueryForType = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, " +
String selectDBQueryForType = "SELECT d1.ID AS DEVICE_ID, d1.DESCRIPTION, d1.NAME AS DEVICE_NAME, d1.DEVICE_TYPE, d1.DEVICE_IDENTIFICATION," +
"e.OWNER, e.OWNERSHIP, e.STATUS, e.DATE_OF_LAST_UPDATE, e.DATE_OF_ENROLMENT FROM DM_ENROLMENT e, (SELECT d.ID, d.DESCRIPTION, d.NAME, " +
"d.DEVICE_IDENTIFICATION, d.OWNER, t.NAME AS DEVICE_TYPE FROM DM_DEVICE d, DM_DEVICE_TYPE t " +
"WHERE d.DM_DEVICE.DEVICE_TYPE_ID = t.ID AND t.NAME = ? AND d.TENANT_ID = ?) d1 WHERE d1.DEVICE_ID = e.DEVICE_ID AND TENANT_ID = ?";

@ -229,8 +229,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device dmsDevice =
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
if (dmsDevice != null) {
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
}
devices.add(device);
}
return devices;
@ -259,8 +261,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device dmsDevice =
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
if (dmsDevice != null) {
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
}
devices.add(device);
}
return devices;
@ -409,8 +413,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
if (device != null) {
DeviceManager dms = this.getPluginRepository().getDeviceManagementService(deviceId.getType());
Device pluginSpecificInfo = dms.getDevice(deviceId);
device.setProperties(pluginSpecificInfo.getProperties());
device.setFeatures(pluginSpecificInfo.getFeatures());
if (pluginSpecificInfo != null) {
device.setFeatures(pluginSpecificInfo.getFeatures());
device.setProperties(pluginSpecificInfo.getProperties());
}
}
return device;
}
@ -554,8 +560,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device dmsDevice =
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
if (dmsDevice != null) {
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
}
devices.add(device);
}
return devices;
@ -596,8 +604,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device dmsDevice =
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
if (dmsDevice != null) {
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
}
devices.add(device);
}
}
@ -643,8 +653,10 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
Device dmsDevice =
this.getPluginRepository().getDeviceManagementService(device.getType()).getDevice(
new DeviceIdentifier(device.getDeviceIdentifier(), device.getType()));
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
if (dmsDevice != null) {
device.setFeatures(dmsDevice.getFeatures());
device.setProperties(dmsDevice.getProperties());
}
devices.add(device);
}
return devices;

Loading…
Cancel
Save