From 00913e64d260133e008b9992e09ca44d8cd40e84 Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 7 Dec 2016 17:17:56 +0530 Subject: [PATCH] Added android sense battery execution plan. --- .../Android-Battery-ExecutionPlan.siddhiql | 19 +++++++++++++++ .../artifact.xml | 23 +++++++++++++++++++ .../service/impl/AndroidSenseServiceImpl.java | 6 +---- 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100755 components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/Android-Battery-ExecutionPlan.siddhiql create mode 100644 components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/artifact.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/Android-Battery-ExecutionPlan.siddhiql b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/Android-Battery-ExecutionPlan.siddhiql new file mode 100755 index 0000000000..68ed7fd490 --- /dev/null +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/Android-Battery-ExecutionPlan.siddhiql @@ -0,0 +1,19 @@ +@Plan:name('Android-Battery-ExecutionPlan') + +@Plan:description('Find the battery status of the android device.') + + +@Import('org.wso2.iot.android.battery:1.0.0') +define stream BatteryStream (meta_owner string, meta_deviceId string, meta_timestamp long, level int, state string, status string, temperature int); + + +@Export('org.wso2.iot.android.battery.stats:1.0.0') +define stream BatteryStatsStream (meta_owner string, meta_deviceId string, meta_timestamp long, level int, state +string, status string, temperature int, year int, month int, day int, hour int, minute int); + +partition with (meta_deviceId of BatteryStream) +begin + from BatteryStream + select meta_owner, meta_deviceId, meta_timestamp, level, state, status, temperature, time:extract(preState.meta_timestamp, 'year') as year, time:extract(preState.meta_timestamp, 'month') as month, time:extract(preState.meta_timestamp, 'day') as day, time:extract(preState.meta_timestamp, 'hour') as hour, time:extract(preState.meta_timestamp, 'minute') as minute + insert into BatteryStatsStream; +end; \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/artifact.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/artifact.xml new file mode 100644 index 0000000000..522f0bb2fd --- /dev/null +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_android_battery_execution_plan/artifact.xml @@ -0,0 +1,23 @@ + + + + + Android-Battery-ExecutionPlan.siddhiql + + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java index 72ccc6fe8f..5a4b65ddb8 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/AndroidSenseServiceImpl.java @@ -280,11 +280,7 @@ public class AndroidSenseServiceImpl implements AndroidSenseService { if (added) { AndroidConfiguration androidConfiguration = new AndroidConfiguration(); androidConfiguration.setTenantDomain(APIUtil.getAuthenticatedUserTenantDomain()); - String mqttEndpoint = DEFAULT_MQTT_ENDPOINT; - if (mqttEndpoint.contains(AndroidSenseConstants.LOCALHOST)) { - mqttEndpoint = mqttEndpoint.replace(AndroidSenseConstants.LOCALHOST, APIUtil.getServerUrl()); - } - androidConfiguration.setMqttEndpoint(mqttEndpoint); + androidConfiguration.setMqttEndpoint(APIUtil.getMqttEndpoint()); return Response.ok(androidConfiguration.toString()).build(); } else { return Response.status(Response.Status.NOT_ACCEPTABLE.getStatusCode()).entity(false).build();