Merge pull request #107 from charithag/master

Refactoring
merge-requests/1/head
Charitha Goonetilleke 9 years ago
commit 9afcfc6ee6

@ -34,14 +34,14 @@ public class ServiceUtils {
* *
* @param owner name of device owner * @param owner name of device owner
* @param deviceId unique identifier of the device * @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 * @return status
*/ */
public static boolean publishTemperatureToDAS(String owner, String deviceId, public static boolean publishTemperatureToDAS(String owner, String deviceId,
String sensorValue) { String sensorValue) {
float temperature = Float.parseFloat(sensorValue); float temperature = Float.parseFloat(sensorValue);
Object payloadCurrent[] = {temperature}; Object payload[] = {temperature};
return publishToDAS(owner, deviceId, payloadCurrent, ORG_WSO2_IOT_DEVICES_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 owner name of device owner
* @param deviceId unique identifier of the device * @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 * @return status
*/ */
public static boolean publishHumidityToDAS(String owner, String deviceId, public static boolean publishHumidityToDAS(String owner, String deviceId,
String sensorValue) { String sensorValue) {
float humidity = Float.parseFloat(sensorValue); float humidity = Float.parseFloat(sensorValue);
Object payloadCurrent[] = {humidity}; Object payload[] = {humidity};
return publishToDAS(owner, deviceId, payloadCurrent, ORG_WSO2_IOT_DEVICES_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) { String definition) {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
@ -72,7 +72,7 @@ public class ServiceUtils {
Object metaData[] = {owner, DeviceTypeConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()}; Object metaData[] = {owner, DeviceTypeConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()};
try { try {
deviceAnalyticsService.publishEvent(definition, SENSOR_STREAM_VERSION, metaData, deviceAnalyticsService.publishEvent(definition, SENSOR_STREAM_VERSION, metaData,
new Object[0], payloadCurrent); new Object[0], payload);
} catch (DataPublisherConfigurationException e) { } catch (DataPublisherConfigurationException e) {
return false; return false;
} finally { } finally {

@ -49,7 +49,7 @@ public class ServiceComponent {
log.debug("firealarm Management Service Component has been successfully activated"); log.debug("firealarm Management Service Component has been successfully activated");
} }
} catch (Throwable e) { } 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(); serviceRegistration.unregister();
} }
if (log.isDebugEnabled()) { 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) { } catch (Throwable e) {
log.error("Error occurred while de-activating Iot Device Management bundle", e); log.error("Error occurred while de-activating Iot Device Management bundle", e);

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

@ -67,7 +67,7 @@
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<input class="new-device-name" style="color:#3f3f3f;padding:5px" <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> name="deviceName" size="60" required>
<br/> <br/>
<br/> <br/>

Loading…
Cancel
Save