Update device property table in dm db when updating properties

merge-requests/804/head
Saad Sahibjan 3 years ago
parent 68405ed229
commit 5f64b0b1ad

@ -489,13 +489,14 @@ public class DeviceTypeManager implements DeviceManager {
throws DeviceManagementException { throws DeviceManagementException {
boolean status = false; boolean status = false;
if (propertiesExist) { if (propertiesExist) {
try {
if (log.isDebugEnabled()) {
log.debug("Getting the details of " + deviceType + " device : '" + deviceId.getId() + "'");
}
Device updatedDevice = new Device(); Device updatedDevice = new Device();
updatedDevice.setDeviceIdentifier(deviceId.getId()); updatedDevice.setDeviceIdentifier(deviceId.getId());
updatedDevice.setProperties(propertyList); updatedDevice.setProperties(propertyList);
try {
if (log.isDebugEnabled()) {
log.debug("Updating device properties of " + deviceType + " device : '"
+ deviceId.getId() + "'");
}
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction(); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction();
status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(updatedDevice); status = deviceTypePluginDAOManager.getDeviceDAO().updateDevice(updatedDevice);
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction(); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction();
@ -506,6 +507,24 @@ public class DeviceTypeManager implements DeviceManager {
} finally { } finally {
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().closeConnection(); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().closeConnection();
} }
if (propertyBasedDeviceTypePluginDAOManager != null && status) {
try {
if (log.isDebugEnabled()) {
log.debug("Updating device properties of " + deviceType + " device : '"
+ deviceId.getId() + "'");
}
propertyBasedDeviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction();
status = propertyBasedDeviceTypePluginDAOManager.getDeviceDAO().updateDevice(updatedDevice);
propertyBasedDeviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction();
} catch (DeviceTypeMgtPluginException e) {
propertyBasedDeviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction();
String msg = "Error while updating properties for " + deviceType + " device : " +
deviceId.getId();
throw new DeviceManagementException(msg, e);
} finally {
propertyBasedDeviceTypePluginDAOManager.getDeviceTypeDAOHandler().closeConnection();
}
}
} }
return status; return status;
} }

Loading…
Cancel
Save