diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
index adb13b61b..bbb867dac 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.4-SNAPSHOT
+ 3.0.5-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml
new file mode 100644
index 000000000..5deaf0ae2
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.das.rest.api/pom.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+ org.wso2.carbon.devicemgt-plugins
+ iot-analytics
+ 3.0.3-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ org.wso2.carbon.iot.das.rest.api
+ WSO2 Carbon - IoT Server REST API
+ pom
+
+
+
+
+ org.apache.felix
+ maven-scr-plugin
+
+
+ generate-scr-descriptor
+
+ scr
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ org.apache.felix
+ maven-bundle-plugin
+ true
+
+
+ ${project.artifactId}
+ ${project.artifactId}
+
+
+
+
+
+
+ *
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
index 1dd5181a7..ed31c04ba 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.4-SNAPSHOT
+ 3.0.5-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
index 4c09bb788..6869eeae7 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml
@@ -21,7 +21,7 @@
org.wso2.carbon.devicemgt-plugins
iot-analytics
- 3.0.4-SNAPSHOT
+ 3.0.5-SNAPSHOT
../pom.xml
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/assets/html_templates/view_fence_popup.html b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/assets/html_templates/view_fence_popup.html
new file mode 100644
index 000000000..4284bb5e6
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/assets/html_templates/view_fence_popup.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/cep_info.json b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/cep_info.json
deleted file mode 100644
index 534bc8fb2..000000000
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/cep_info.json
+++ /dev/null
@@ -1 +0,0 @@
-{"username" : "admin", "password" : "admin"}
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/database.json b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/database.json
deleted file mode 100644
index b017a2a54..000000000
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/conf/database.json
+++ /dev/null
@@ -1 +0,0 @@
-{"username" : "wso2carbon", "password" : "wso2carbon"}
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/constants.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/constants.jag
new file mode 100644
index 000000000..15b67063d
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/constants.jag
@@ -0,0 +1,37 @@
+<%
+/*
+ ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ ~
+ ~ WSO2 Inc. licenses this file to you under the Apache License,
+ ~ Version 2.0 (the "License"); you may not use this file except
+ ~ in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ */
+
+var DATA_SOURCE_NAME = "WSO2_GEO_DB";
+var EXECUTION_PLAN_TYPE_SPEED = "Speed";
+var EXECUTION_PLAN_TYPE_WITHIN = "Within";
+var EXECUTION_PLAN_TYPE_PROXIMITY = "Proximity";
+var EXECUTION_PLAN_TYPE_STATIONARY = "Stationery";
+var EXECUTION_PLAN_TYPE_TRAFFIC = "Traffic";
+var REGISTRY_PATH_FOR_ALERTS = "/_system/governance/geo/alerts/";
+var GET_METHOD = "get";
+var QUERY_NAME = "queryName";
+var AREA_NAME = "areaName";
+var CREATED_TIME = "createdTime";
+var GEO_JSON = "geoJson";
+var PROXIMITY_DISTANCE = "proximityDistance";
+var PROXIMITY_TIME = "proximityTime";
+var STATIONARY_NAME = "stationeryName";
+var STATIONARY_TIME = "stationeryTime";
+var FLUCTUATION_RADIUS = "fluctuationRadius";
+%>
\ No newline at end of file
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag
new file mode 100644
index 000000000..25d50b9c0
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/gadget-controller.jag
@@ -0,0 +1,40 @@
+<%
+/**
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * WSO2 Inc. licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+(function () {
+
+ response.contentType = 'application/json';
+ var action = request.getParameter("action");
+ var id = request.getParameter("id");
+ var type = request.getParameter("type");
+ var timeFrom = request.getParameter("timeFrom");
+ var timeTo = request.getParameter("timeTo");
+
+ var providerAPI = require('js/batch-provider-api.js');
+ if (action === 'getSchema') {
+ print(providerAPI.getSchema());
+ return;
+ } else if(action === 'getData'){
+ print(providerAPI.getData(id, type, timeFrom, timeTo));
+ return;
+ }
+}());
+
+
+%>
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts.jag
index 1df5d7949..1434b0b23 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts.jag
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts.jag
@@ -17,104 +17,138 @@
~ under the License.
*/
var log = new Log();
-var dataStore = require('../include/commons.jag').dataStore;
-var verb = request.getMethod();
+var method = request.getMethod();
var resourceName = request.getParameter('name');
var webService = request.getParameter('service');
-
if(webService) {
response.contentType = 'application/json';
response.characterEncoding = 'UTF-8';
response.content = { resource : get(resourceName) };
}
-function get(name){
- if(name == 'within'){
- try{
- var res = dataStore.get("geo/alerts/within/");
- }
- catch(e){
- log.info(e.message);
+function getRegistry () {
+ var carbon = require("carbon");
+ var server = new carbon.server.Server();
+ return new carbon.registry.Registry(server, {
+ system: true
+ });
+}
+
+if (method === "GET") {
+ var constants = require("constants.jag");
+ var executionPlanType = request.getParameter("executionPlanType");
+ var deviceId = request.getParameter("deviceId");
+ response.content = get(executionPlanType, deviceId);
+ response.contentType = "application/json";
+}
+
+function get(executionPlanType, deviceId){
+ var resource = null;
+ var fence = {};
+ var registry = getRegistry();
+ if(executionPlanType == constants.EXECUTION_PLAN_TYPE_WITHIN){
+ try {
+ resource = registry.get(constants.REGISTRY_PATH_FOR_ALERTS + constants.EXECUTION_PLAN_TYPE_WITHIN +
+ "/" + deviceId + "/");
+ } catch(e){
+ log.error(e.message);
return false;
}
var allFences = [];
- for each (var resource in res.getChildren()) {
- var fence = {};
- try{
- fence['geoJson'] = JSON.parse(dataStore.get(resource).content.replace(/'/g, '"'));
- fence['queryName'] = dataStore.get(resource).getProperty('queryName');
- fence['areaName'] = dataStore.get(resource).getProperty('areaName');
- fence['createdTime'] = dataStore.get(resource).createdTime.toString();
- allFences.push(fence);
- }
- catch(e){
- log.info("Error: "+e+'\n');
+ if (resource) {
+ for each(var res in resource.content) {
+ var childResource = registry.get(res);
+ var properties = registry.properties(res);
+ fence = {};
+ try {
+ fence[constants.GEO_JSON] = JSON.parse(childResource.content);
+ fence[constants.QUERY_NAME] = properties[constants.QUERY_NAME][0];
+ fence[constants.AREA_NAME] = properties[constants.AREA_NAME][0];
+ fence[constants.CREATED_TIME] = childResource.created.time.toString();
+ allFences.push(fence);
+ }
+ catch (e) {
+ log.error("Error: " + e + '\n');
+ }
}
}
return allFences;
- } else if(name == 'speed'){
- var resource;
+ } else if(executionPlanType == constants.EXECUTION_PLAN_TYPE_SPEED){
try{
- resource = dataStore.get(name+'.json');
- }catch(e){
+ resource = registry.get(constants.REGISTRY_PATH_FOR_ALERTS + constants
+ .EXECUTION_PLAN_TYPE_SPEED + "/" + deviceId );
+ } catch(e){
resource = {'content': false};
}
- log.info("DEBUG:***** name = "+name);
- log.info("DEBUG:***** resource.content = "+resource.content);
+ if (log.isDebugEnabled()) {
+ log.info("DEBUG:***** name = " + executionPlanType);
+ log.info("DEBUG:***** resource.content = " + resource.content);
+ }
return JSON.parse(resource.content);
- } else if(name == 'proximity'){
+ } else if(executionPlanType == constants.EXECUTION_PLAN_TYPE_PROXIMITY){
var result;
try{
- var resource = dataStore.get("/geo/alerts/proximity/proximity.json");
- result={proximityDistance: resource.getProperty("proximityDistance"), proximityTime: resource.getProperty("proximityTime")};
+ resource = registry.properties(constants.REGISTRY_PATH_FOR_ALERTS + constants.EXECUTION_PLAN_TYPE_PROXIMITY +
+ "/" + deviceId);
+ result = {
+ proximityDistance: resource[constants.PROXIMITY_DISTANCE],
+ proximityTime: resource[constants.PROXIMITY_TIME]
+ };
}catch(e){
result = {'content': false};
}
return result;
- } else if(name == 'stationery'){
- var res;
+ } else if(executionPlanType == constants.EXECUTION_PLAN_TYPE_STATIONARY){
try{
- res = dataStore.get("geo/alerts/stationery/");
+ resource = registry.get(constants.REGISTRY_PATH_FOR_ALERTS + constants.EXECUTION_PLAN_TYPE_STATIONARY +
+ "/" + deviceId);
}
catch(e){
log.info(e.message);
return false;
}
var allFences = [];
- for each (var resource in res.getChildren()) {
- var fence = {};
- try{
- fence['geoJson'] = JSON.parse(dataStore.get(resource).content.replace(/'/g, '"'));
- fence['queryName'] = dataStore.get(resource).getProperty('queryName');
- fence['areaName'] = dataStore.get(resource).getProperty('stationeryName');
- fence['stationeryTime'] = dataStore.get(resource).getProperty('stationeryTime');
- fence['fluctuationRadius'] = dataStore.get(resource).getProperty('fluctuationRadius');
- fence['createdTime'] = dataStore.get(resource).createdTime.toString();
- allFences.push(fence);
- }
- catch(e){
- log.info("Error: "+e+'\n');
+
+ if (resource) {
+ for each(var res in resource.content) {
+ var fence = {};
+ var childResource = registry.get(res);
+ var properties = registry.properties(res);
+ try {
+ fence[constants.GEO_JSON] = JSON.parse(childResource.content);
+ fence[constants.QUERY_NAME] = properties[constants.QUERY_NAME][0];
+ fence[constants.AREA_NAME] = properties[constants.STATIONARY_NAME][0];
+ fence[constants.STATIONARY_TIME] = properties[constants.STATIONARY_TIME][0];
+ fence[constants.FLUCTUATION_RADIUS] = properties[constants.FLUCTUATION_RADIUS][0];
+ fence[constants.CREATED_TIME] = childResource.created.time.toString();
+ allFences.push(fence);
+ } catch (e) {
+ log.error("Error: " + e + '\n');
+ }
}
}
return allFences;
- } else if( name == 'traffic'){
+ } else if( executionPlanType == constants.EXECUTION_PLAN_TYPE_TRAFFIC){
try{
- var res = dataStore.get("geo/alerts/traffic/");
+ resource = registry.get(constants.REGISTRY_PATH_FOR_ALERTS + constants.EXECUTION_PLAN_TYPE_TRAFFIC +
+ "/" + deviceId + "/");
}
catch(e){
log.info(e.message);
return false;
}
var allFences = [];
- for each (var resource in res.getChildren()) {
+ for each (var res in resource.content) {
var fence = {};
+ var childResource = registry.get(res);
+ var properties = registry.properties(res);
try{
- fence['geoJson'] = JSON.parse(dataStore.get(resource).content.replace(/'/g, '"'));
- fence['queryName'] = dataStore.get(resource).getProperty('queryName');
- fence['areaName'] = dataStore.get(resource).getProperty('areaName');
- fence['createdTime'] = dataStore.get(resource).createdTime.toString();
+ fence[constants.GEO_JSON] = JSON.parse(childResource.content);
+ fence[constants.QUERY_NAME] = properties[constants.QUERY_NAME][0];
+ fence[constants.AREA_NAME] = properties[constants.AREA_NAME][0];
+ fence[constants.CREATED.TIME] = childResource.created.time.toString();
allFences.push(fence);
}
catch(e){
@@ -123,7 +157,6 @@ function get(name){
}
return allFences;
}
-
}
%>
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts_history.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts_history.jag
index c62800f7f..a6fa01526 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts_history.jag
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/get_alerts_history.jag
@@ -17,14 +17,11 @@
~ under the License.
*/
-var db = require("../include/database.jag");
-var configuration = require('../conf/database.json');
+var constants = require("constants.jag");
+var db = new Database(constants.DATA_SOURCE_NAME);
var log = new Log();
-
-var db = new Database("jdbc:h2:repository/database/WSO2_GEO",configuration.username,configuration.password);
var objectId = request.getParameter("objectId");
-
-var getHistory = "SELECT * FROM alerts_history WHERE id = \'"+objectId+"\' ORDER BY timeStamp DESC LIMIT 50";
+var getHistory = "SELECT * FROM alerts_history WHERE id = \'" + objectId + "\' ORDER BY timeStamp DESC LIMIT 50";
try{
var history = db.query(getHistory);
@@ -38,5 +35,4 @@ catch(e){
finally{
db.close();
}
-
%>
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js
new file mode 100644
index 000000000..ba0a14521
--- /dev/null
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/js/batch-provider-api.js
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush;
+
+(function () {
+
+ var PROVIDERS_LOCATION = '/extensions/providers/';
+
+ var PROVIDER_NAME = 'batch';
+ var TYPE = "type";
+ var TABLE_NAME = "tableName";
+ var HTTPS_TRANSPORT = "https";
+ var CONTENT_TYPE_JSON = "application/json";
+ var AUTHORIZATION_HEADER = "Authorization";
+ var USER_TOKEN = "user";
+ var TENANT_DOMAIN = "domain";
+ var CONST_AT = "@";
+ var USERNAME = "username";
+ var HTTP_USER_NOT_AUTHENTICATED = 403;
+ var JS_MAX_VALUE = "9007199254740992";
+ var JS_MIN_VALUE = "-9007199254740992";
+
+ var tableName = "ORG_WSO2_GEO_FUSEDSPATIALEVENT";
+
+ var typeMap = {
+ "bool": "string",
+ "boolean": "string",
+ "string": "string",
+ "int": "number",
+ "integer": "number",
+ "long": "number",
+ "double": "number",
+ "float": "number",
+ "time": "time"
+ };
+
+ var log = new Log();
+ var carbon = require('carbon');
+ var configs = require('/configs/designer.json');
+ var utils = require('/modules/utils.js');
+ var JSUtils = Packages.org.wso2.carbon.analytics.jsservice.Utils;
+ var AnalyticsCachedJSServiceConnector = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector;
+ var AnalyticsCache = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector.AnalyticsCache;
+ var cacheTimeoutSeconds = 5;
+ var loggedInUser = null;
+
+ if (configs.cacheTimeoutSeconds) {
+ cacheTimeoutSeconds = parseInt(configs.cacheTimeoutSeconds);
+ }
+ var cacheSizeBytes = 1024 * 1024 * 1024; // 1GB
+ if (configs.cacheSizeBytes) {
+ cacheSizeBytes = parseInt(configs.cacheSizeBytes);
+ }
+ response.contentType = CONTENT_TYPE_JSON;
+
+ var authParam = request.getHeader(AUTHORIZATION_HEADER);
+ if (authParam != null) {
+ credentials = JSUtils.authenticate(authParam);
+ loggedInUser = credentials[0];
+ } else {
+ var token = session.get(USER_TOKEN);
+ if (token != null) {
+ loggedInUser = token[USERNAME] + CONST_AT + token[TENANT_DOMAIN];
+ } else {
+ log.error("user is not authenticated!");
+ response.status = HTTP_USER_NOT_AUTHENTICATED;
+ print('{ "status": "Failed", "message": "User is not authenticated." }');
+ return;
+ }
+ }
+
+ var cache = application.get("AnalyticsWebServiceCache");
+ if (cache == null) {
+ cache = new AnalyticsCache(cacheTimeoutSeconds, cacheSizeBytes);
+ application.put("AnalyticsWebServiceCache", cache);
+ }
+ var connector = new AnalyticsCachedJSServiceConnector(cache);
+
+
+ /**
+ * returns an array of column names & types
+ * @param providerConfig
+ */
+ getSchema = function () {
+ var schema = [];
+ var result = connector.getTableSchema(loggedInUser, tableName).getMessage();
+ result = JSON.parse(result);
+
+ var columns = result.columns;
+ Object.getOwnPropertyNames(columns).forEach(function (name, idx, array) {
+ var type = "ordinal";
+ if (columns[name]['type']) {
+ type = columns[name]['type'];
+ }
+ schema.push({
+ fieldName: name,
+ fieldType: typeMap[type.toLowerCase()]
+ });
+ });
+ // log.info(schema);
+ return schema;
+ };
+
+ /**
+ * returns the actual data
+ * @param providerConfig
+ * @param limit
+ */
+ getData = function (deviceId, deviceType, fromTime, toTime) {
+ var luceneQuery = "timeStamp:[" + fromTime + " TO " + toTime + "]";
+ var limit = 100;
+ var result;
+ //if there's a filter present, we should perform a Lucene search instead of reading the table
+ if (luceneQuery) {
+ luceneQuery = 'id:"' + deviceId + '" AND type:"' + deviceType + '" AND ' + luceneQuery;
+ var filter = {
+ "query": luceneQuery,
+ "start": 0,
+ "count": limit
+ };
+ result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage();
+ } else {
+ var from = JS_MIN_VALUE;
+ var to = JS_MAX_VALUE;
+ result = connector.getRecordsByRange(loggedInUser, tableName, from, to, 0, limit, null).getMessage();
+
+ }
+ result = JSON.parse(result);
+ var data = [];
+ for (var i = 0; i < result.length; i++) {
+ var values = result[i].values;
+ data.push(values);
+ }
+ return data;
+ };
+
+}());
diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/modals/proximity_alert.jag b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/modals/proximity_alert.jag
index 119140456..1270b8d71 100644
--- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/modals/proximity_alert.jag
+++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/src/main/resources/carbonapps/GadgetGeoDashboard_1.0.0/geo-dashboard/controllers/modals/proximity_alert.jag
@@ -48,9 +48,6 @@
}
-<%
-var get = require('../get_alerts.jag').get;
-%>
+