Refactoring

merge-requests/1/head
charithag 9 years ago
parent f630876d7a
commit e5c11b9fa5

@ -34,14 +34,14 @@ public class ServiceUtils {
*
* @param owner name of device owner
* @param deviceId unique identifier of the device
* @param sensorValue current value of sensor which is set at agent side
* @param sensorValue value of sensor which is set at agent side
* @return status
*/
public static boolean publishTemperatureToDAS(String owner, String deviceId,
String sensorValue) {
float temperature = Float.parseFloat(sensorValue);
Object payloadCurrent[] = {temperature};
return publishToDAS(owner, deviceId, payloadCurrent, ORG_WSO2_IOT_DEVICES_TEMPERATURE);
Object payload[] = {temperature};
return publishToDAS(owner, deviceId, payload, ORG_WSO2_IOT_DEVICES_TEMPERATURE);
}
/**
@ -49,17 +49,17 @@ public class ServiceUtils {
*
* @param owner name of device owner
* @param deviceId unique identifier of the device
* @param sensorValue current value of sensor which is set at agent side
* @param sensorValue value of sensor which is set at agent side
* @return status
*/
public static boolean publishHumidityToDAS(String owner, String deviceId,
String sensorValue) {
float humidity = Float.parseFloat(sensorValue);
Object payloadCurrent[] = {humidity};
return publishToDAS(owner, deviceId, payloadCurrent, ORG_WSO2_IOT_DEVICES_HUMIDITY);
Object payload[] = {humidity};
return publishToDAS(owner, deviceId, payload, ORG_WSO2_IOT_DEVICES_HUMIDITY);
}
private static boolean publishToDAS(String owner, String deviceId, Object[] payloadCurrent,
private static boolean publishToDAS(String owner, String deviceId, Object[] payload,
String definition) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@ -72,7 +72,7 @@ public class ServiceUtils {
Object metaData[] = {owner, DeviceTypeConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()};
try {
deviceAnalyticsService.publishEvent(definition, SENSOR_STREAM_VERSION, metaData,
new Object[0], payloadCurrent);
new Object[0], payload);
} catch (DataPublisherConfigurationException e) {
return false;
} finally {

@ -49,7 +49,7 @@ public class ServiceComponent {
log.debug("firealarm Management Service Component has been successfully activated");
}
} catch (Throwable e) {
log.error("Error occurred while activating Current Sensor Management Service Component", e);
log.error("Error occurred while activating Fire Alarm Management Service Component", e);
}
}
@ -62,7 +62,7 @@ public class ServiceComponent {
serviceRegistration.unregister();
}
if (log.isDebugEnabled()) {
log.debug("Current Sensor Management Service Component has been successfully de-activated");
log.debug("Fire Alarm Management Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error("Error occurred while de-activating Iot Device Management bundle", e);

@ -25,7 +25,7 @@
{{/zone}}
{{#zone "device-thumbnail"}}
<img src="{{@unit.publicUri}}/images/current-sensor.png"/>
<img src="{{@unit.publicUri}}/images/deviceType.png"/>
{{/zone}}
{{#zone "operation-status"}}

@ -67,7 +67,7 @@
<div class="control-group">
<div class="controls">
<input class="new-device-name" style="color:#3f3f3f;padding:5px"
type="text" placeholder="Ex. Lobby_CurrentSensor"
type="text" placeholder="Ex. Lobby_Fire_Alarm"
name="deviceName" size="60" required>
<br/>
<br/>

Loading…
Cancel
Save