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/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/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;
-%>
+