|
|
@ -135,36 +135,19 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
|
|
|
|
"UPDATE DM_DEVICE_PROPERTIES SET PROPERTY_VALUE = ? WHERE DEVICE_TYPE_NAME = ? AND " +
|
|
|
|
"UPDATE DM_DEVICE_PROPERTIES SET PROPERTY_VALUE = ? WHERE DEVICE_TYPE_NAME = ? AND " +
|
|
|
|
"DEVICE_IDENTIFICATION = ? AND PROPERTY_NAME = ? AND TENANT_ID= ?");
|
|
|
|
"DEVICE_IDENTIFICATION = ? AND PROPERTY_NAME = ? AND TENANT_ID= ?");
|
|
|
|
|
|
|
|
|
|
|
|
Device.Property[] properties = new Device.Property[device.getProperties().size()];
|
|
|
|
|
|
|
|
int i =0;
|
|
|
|
|
|
|
|
for (Device.Property property : device.getProperties()) {
|
|
|
|
for (Device.Property property : device.getProperties()) {
|
|
|
|
properties[i] = property;
|
|
|
|
if (!deviceProps.contains(property.getName())) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
stmt.setString(1, getPropertyValue(device.getProperties(), property.getValue()));
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.setString(1, property.getValue());
|
|
|
|
stmt.setString(1, deviceType);
|
|
|
|
stmt.setString(1, deviceType);
|
|
|
|
stmt.setString(2, device.getDeviceIdentifier());
|
|
|
|
stmt.setString(2, device.getDeviceIdentifier());
|
|
|
|
stmt.setString(3, property.getName());
|
|
|
|
stmt.setString(3, property.getName());
|
|
|
|
stmt.setInt(4, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
|
|
|
stmt.setInt(4, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
|
|
|
stmt.addBatch();
|
|
|
|
stmt.addBatch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int[] updates = stmt.executeBatch();
|
|
|
|
|
|
|
|
if (updates.length > 0) {
|
|
|
|
|
|
|
|
for (int j = 0; j < updates.length; j++) {
|
|
|
|
|
|
|
|
if (updates[j] < 0) {
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(
|
|
|
|
|
|
|
|
"INSERT INTO DM_DEVICE_PROPERTIES(DEVICE_TYPE_NAME, DEVICE_IDENTIFICATION, PROPERTY_NAME, " +
|
|
|
|
|
|
|
|
"PROPERTY_VALUE, TENANT_ID) VALUES (?, ?, ?, ?, ?)");
|
|
|
|
|
|
|
|
stmt.setString(1, deviceType);
|
|
|
|
|
|
|
|
stmt.setString(2, device.getDeviceIdentifier());
|
|
|
|
|
|
|
|
stmt.setString(3, properties[j].getName());
|
|
|
|
|
|
|
|
stmt.setString(4, getPropertyValue(device.getProperties(), properties[j].getValue()));
|
|
|
|
|
|
|
|
stmt.setInt(5, PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
|
|
|
|
|
|
|
stmt.addBatch();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stmt.executeBatch();
|
|
|
|
stmt.executeBatch();
|
|
|
|
status = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
String msg = "Error occurred while modifying the device '" +
|
|
|
|
String msg = "Error occurred while modifying the device '" +
|
|
|
|
device.getDeviceIdentifier() + "' data on" + deviceType;
|
|
|
|
device.getDeviceIdentifier() + "' data on" + deviceType;
|
|
|
@ -173,7 +156,6 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
DeviceTypeUtils.cleanupResources(stmt, null);
|
|
|
|
DeviceTypeUtils.cleanupResources(stmt, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return status;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean deleteDevice(String deviceId) throws DeviceTypeMgtPluginException {
|
|
|
|
public boolean deleteDevice(String deviceId) throws DeviceTypeMgtPluginException {
|
|
|
|