Merge pull request #71 from menaka121/master

publishedToDAS method changed
application-manager-new
Ruwan 9 years ago
commit fe2ae62d56

@ -47,6 +47,7 @@ public class ConnectedCupServiceUtils {
//TODO; replace this tenant domain
private static final String SUPER_TENANT = "carbon.super";
private static final String TEMPERATURE_STREAM_DEFINITION = "org.wso2.iot.devices.temperature";
private static final String COFFEE_LEVEL_STREAM_DEFINITION = "org.wso2.iot.devices.coffeelevel";
public static String sendCommandViaHTTP(final String deviceHTTPEndpoint, String urlContext,
boolean fireAndForgot) throws DeviceManagementException {
@ -193,7 +194,7 @@ public class ConnectedCupServiceUtils {
return completeResponse.toString();
}
public static boolean publishToDAS(String owner, String deviceId, float temperature) {
public static boolean publishToDAS(String owner, String deviceId, String sensor, float values) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(SUPER_TENANT, true);
@ -201,11 +202,19 @@ public class ConnectedCupServiceUtils {
DeviceAnalyticsService.class, null);
Object metdaData[] = {owner, ConnectedCupConstants.DEVICE_TYPE, deviceId,
System.currentTimeMillis()};
Object payloadData[] = {temperature};
Object payloadData[] = {values};
try {
switch (sensor){
case "temperature":
deviceAnalyticsService.publishEvent(TEMPERATURE_STREAM_DEFINITION, "1.0.0", metdaData,
new Object[0], payloadData);
break;
case "coffeelevel":
deviceAnalyticsService.publishEvent(COFFEE_LEVEL_STREAM_DEFINITION, "1.0.0", metdaData,
new Object[0], payloadData);
}
} catch (DataPublisherConfigurationException e) {
return false;
} finally {

Loading…
Cancel
Save