diff --git a/modules/analytics/Samples/GadgetLocationData/artifact.xml b/modules/analytics/Samples/GadgetLocationData/artifact.xml
new file mode 100644
index 00000000..ab4deb36
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/artifact.xml
@@ -0,0 +1,4 @@
+
+
+ geo-dashboard
+
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/assets/html_templates/view_fence_popup.html b/modules/analytics/Samples/GadgetLocationData/locationData/assets/html_templates/view_fence_popup.html
new file mode 100644
index 00000000..4284bb5e
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/assets/html_templates/view_fence_popup.html
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Proximity_alert.siddhiql b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Proximity_alert.siddhiql
new file mode 100644
index 00000000..fb647203
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Proximity_alert.siddhiql
@@ -0,0 +1,140 @@
+/* Enter a unique ExecutionPlan */
+@Plan:name('Geo-ExecutionPlan-Proximity_alert')
+
+/* Enter a unique description for ExecutionPlan */
+-- @Plan:description('ExecutionPlan')
+
+/* define streams/tables and write queries here ... */
+
+@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
+define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string );
+
+@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
+define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
+
+@IndexBy('id')
+define table ProximityTable(id string, timeStamp long);
+
+@IndexBy('id')
+define table AlertsTable(id string , proximityWith string, eventId string);
+
+from dataIn#geodashboard:subscribe()
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId
+insert into initialStream;
+
+from initialStream[type == 'STOP']
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
+insert into dataOutStream;
+
+from initialStream[type != 'STOP']
+select *
+insert into objectInitialStream;
+
+from objectInitialStream#geo:proximity(id,longitude,latitude, $proximityDistance)
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith
+insert into proxymityStream;
+
+from proxymityStream[AlertsTable.id == proxymityStream.id in AlertsTable]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
+insert into innerStreamOne;
+
+from proxymityStream[not(AlertsTable.id == proxymityStream.id in AlertsTable)]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
+insert into innerStreamOne;
+
+from proxymityStream[AlertsTable.id == proxymityStream.proximityWith in AlertsTable]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
+insert into innerStreamSeven;
+
+from proxymityStream[not(AlertsTable.id == proxymityStream.proximityWith in AlertsTable)]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
+insert into innerStreamSeven;
+
+from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
+select id,str:concat(",",proximityWith) as proximityWith , eventId
+insert into AlertsTable;
+
+from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
+select proximityWith as id,str:concat(",",id) as proximityWith , eventId
+insert into AlertsTable;
+
+from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
+on innerStreamOne.id == AlertsTable.id
+select innerStreamOne.id as id, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
+insert into updateStream;
+
+from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
+on innerStreamSeven.proximityWith == AlertsTable.id
+select innerStreamSeven.proximityWith as id, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
+insert into updateStream;
+
+from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
+on innerStreamOne.id == AlertsTable.id
+select innerStreamOne.id as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
+insert into updateStream;
+
+from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
+on innerStreamSeven.proximityWith == AlertsTable.id
+select innerStreamSeven.proximityWith as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
+insert into updateStream;
+
+from updateStream
+select *
+update AlertsTable
+ on id== AlertsTable.id;
+
+from updateStream[proximityWith == ""]
+delete AlertsTable
+ on id== AlertsTable.id;
+
+from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId, true as inAlertTable
+insert into publishStream;
+
+from objectInitialStream[not(AlertsTable.id == objectInitialStream.id in AlertsTable)]
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId, false as inAlertTable
+insert into publishStream;
+
+from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
+on publishStream.id== AlertsTable.id
+select publishStream.id as id, publishStream.latitude as latitude, publishStream.longitude as longitude, publishStream.timeStamp as timeStamp, publishStream.type as type, publishStream.speed as speed, publishStream.heading as heading, publishStream.eventId as eventId, AlertsTable.proximityWith as proximityInfo
+insert into innerStreamTwo;
+
+from publishStream[inAlertTable == false]
+delete ProximityTable on ProximityTable.id==id;
+
+from publishStream[inAlertTable == false]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
+insert into dataOutStream;
+
+from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
+insert into innerStreamThree;
+
+from innerStreamThree#window.length(0) join ProximityTable
+on innerStreamThree.id == ProximityTable.id
+select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId, ProximityTable.timeStamp as storedTime, innerStreamThree.proximityInfo as proximityInfo
+insert into innerStreamFour;
+
+from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,proximityInfo,"true" as isProximity
+insert into dataOutStream;
+
+from innerStreamFour[(timeStamp - storedTime) < $proximityTime]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , proximityInfo ,"false" as isProximity
+insert into dataOutStream;
+
+from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
+select innerStreamTwo.id, innerStreamTwo.timeStamp
+insert into ProximityTable;
+
+from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
+insert into dataOutStream;
+
+from dataOutStream[isProximity == 'true']
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,"WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information
+insert into dataOut;
+
+from dataOutStream[isProximity == 'false']
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
+insert into dataOut;
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql
new file mode 100644
index 00000000..65dad468
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Speed_alert.siddhiql
@@ -0,0 +1,20 @@
+/* Enter a unique ExecutionPlan */
+@Plan:name('Geo-ExecutionPlan-Speed---$deviceId_alert')
+
+/* Enter a unique description for ExecutionPlan */
+-- @Plan:description('ExecutionPlan')
+
+/* define streams/tables and write queries here ... */
+
+@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
+define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
+
+@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
+define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string);
+
+from dataIn[speed >= $speedAlertValue and id == "$deviceId"]#geodashboard:subscribe()
+select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "ALERTED" as state, "This device movement is not normal!!" as information
+insert into dataOut;
+from dataIn[speed < $speedAlertValue and id == "$deviceId"]
+select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information
+insert into dataOut;
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Stationery_alert.siddhiql b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Stationery_alert.siddhiql
new file mode 100644
index 00000000..46bfbfe2
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Stationery_alert.siddhiql
@@ -0,0 +1,89 @@
+/* Enter a unique ExecutionPlan */
+@Plan:name('$executionPlanName')
+
+/* Enter a unique description for ExecutionPlan */
+-- @Plan:description('ExecutionPlan')
+
+/* define streams/tables and write queries here ... */
+
+@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
+define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
+
+
+@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
+define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
+
+@IndexBy('id')
+define table StationeryTable(id string, timeStamp long);
+
+@IndexBy('id')
+define table AlertsTable(id string, stationary bool);
+
+from dataIn#geodashboard:subscribe()
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,geo:within(longitude,latitude,"$geoFenceGeoJSON") as isWithin
+insert into innerStreamOne;
+
+from innerStreamOne[isWithin == false]
+delete StationeryTable on StationeryTable.id==id;
+
+from innerStreamOne[isWithin == false]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
+insert into dataOutStream;
+
+from innerStreamOne[isWithin == true]#geo:stationary(id,longitude,latitude, $fluctuationRadius)
+select id, latitude, longitude, timeStamp, type, speed, heading, eventId,stationary
+insert into innerStreamTwo;
+
+from innerStreamTwo[innerStreamTwo.stationary == true]
+select innerStreamTwo.id, innerStreamTwo.stationary
+insert into AlertsTable;
+
+from innerStreamTwo[innerStreamTwo.stationary == false]
+delete AlertsTable on AlertsTable.id==id;
+
+from innerStreamTwo[innerStreamTwo.stationary == false]
+delete StationeryTable on StationeryTable.id==id;
+
+from innerStreamOne[isWithin == true AND not(AlertsTable.id == innerStreamOne.id in AlertsTable)]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
+insert into dataOutStream;
+
+from innerStreamOne[isWithin == true AND AlertsTable.id == innerStreamOne.id in AlertsTable]
+insert into innerStreamThree;
+
+from innerStreamThree#window.length(0) join AlertsTable
+on innerStreamThree.id == AlertsTable.id
+select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId
+insert into innerStreamFour;
+
+from innerStreamFour[not(StationeryTable.id == innerStreamFour.id in StationeryTable)]
+select innerStreamFour.id, innerStreamFour.timeStamp
+insert into StationeryTable;
+
+from innerStreamOne[isWithin == true AND not(StationeryTable.id == innerStreamOne.id in StationeryTable)]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
+insert into dataOutStream;
+
+from innerStreamOne[isWithin == true AND StationeryTable.id == innerStreamOne.id in StationeryTable]
+insert into innerStreamFive;
+
+from innerStreamFive#window.length(0) join StationeryTable
+on innerStreamFive.id == StationeryTable.id
+select innerStreamFive.id , innerStreamFive.latitude, innerStreamFive.longitude,innerStreamFive.timeStamp, innerStreamFive.type, innerStreamFive.speed, innerStreamFive.heading ,innerStreamFive.eventId, StationeryTable.timeStamp as storedTime
+insert into innerStreamSix;
+
+from innerStreamSix[(timeStamp - storedTime) >= $stationeryTime]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"true" as isStationary
+insert into dataOutStream;
+
+from innerStreamSix[(timeStamp - storedTime) < $stationeryTime]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"false" as isStationary
+insert into dataOutStream;
+
+from dataOutStream[isStationary == 'true']
+select id ,latitude, longitude,timeStamp, type, speed, heading ,eventId ,"ALERTED" as state, "This device is in $stationeryName area!!!" as information
+insert into dataOut;
+
+from dataOutStream[isStationary == 'false']
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
+insert into dataOut;
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Traffic_alert.siddhiql b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Traffic_alert.siddhiql
new file mode 100644
index 00000000..5e6bb5b1
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Traffic_alert.siddhiql
@@ -0,0 +1,17 @@
+/* Enter a unique ExecutionPlan */
+@Plan:name('$executionPlanName')
+
+/* Enter a unique description for ExecutionPlan */
+-- @Plan:description('ExecutionPlan')
+
+/* define streams/tables and write queries here ... */
+
+@Import('rawGeoStream:1.0.0')
+define stream dataIn (id string, timeStamp long, geometry string, state string, information string);
+
+@Export('AlertsNotifications:1.0.0')
+define stream dataOut (id string, state string, information string, timeStamp long, latitude double, longitude double);
+
+from dataIn[geo:intersects(geometry, "$geoFenceGeoJSON")==true and geodashboard:needToNotify(id, str:concat(information, state), "sendFirst") == true and id == $deviceId]
+select id, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
+insert into dataOut
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql
new file mode 100644
index 00000000..b58fd59e
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/conf/alerts/Geo-ExecutionPlan-Within_alert.siddhiql
@@ -0,0 +1,20 @@
+/* Enter a unique ExecutionPlan */
+@Plan:name('$executionPlanName')
+
+/* Enter a unique description for ExecutionPlan */
+-- @Plan:description('ExecutionPlan')
+
+/* define streams/tables and write queries here ... */
+
+@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
+define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
+
+@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
+define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
+
+from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe()
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
+insert into dataOut;
+from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"]
+select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
+insert into dataOut;
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/css/style.css b/modules/analytics/Samples/GadgetLocationData/locationData/css/style.css
new file mode 100644
index 00000000..0db6cfae
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/css/style.css
@@ -0,0 +1,97 @@
+body {
+ font: 10px sans-serif;
+}
+.axis path,
+.axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+.point {
+ stroke: #000;
+}
+
+form {
+ margin-top: 25px;
+ text-align: center;
+}
+.slider {
+ width: 80%;
+ display: block;
+ margin: 0 auto;
+}
+output {
+ display: block;
+ margin: 25px auto;
+ font-size:2em;
+}
+div.tooltip {
+ position: absolute;
+ text-align: center;
+ width: 60px;
+ height: 28px;
+ padding: 2px;
+ font: 12px sans-serif;
+ background: lightsteelblue;
+ border: 0px;
+ border-radius: 8px;
+ pointer-events: none;
+}
+.axis path,
+.axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.bar {
+ fill: orange;
+}
+
+.bar:hover {
+ fill: orangered ;
+}
+
+.x.axis path {
+ display: none;
+}
+
+.d3-tip {
+ line-height: 1;
+ font-weight: bold;
+ padding: 12px;
+ background: rgba(0, 0, 0, 0.8);
+ color: #fff;
+ border-radius: 2px;
+ z-index: 1000;
+}
+
+/* Creates a small triangle extender for the tooltip */
+.d3-tip:after {
+ box-sizing: border-box;
+ display: inline;
+ font-size: 10px;
+ width: 100%;
+ line-height: 1;
+ color: rgba(0, 0, 0, 0.8);
+ content: "\25BC";
+ position: absolute;
+ text-align: center;
+}
+
+/* Style northward tooltips differently */
+.d3-tip.n:after {
+ margin: -1px 0 0 0;
+ top: 100%;
+ left: 0;
+}
+.btn-space {
+ margin-right: 30px;
+ margin-bottom: 10px;
+ margin-top: 10px;
+}
+.element-space{
+ margin-right: 30px;
+ margin-bottom: 10px;
+ margin-top: 10px;
+}
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/gadget.json b/modules/analytics/Samples/GadgetLocationData/locationData/gadget.json
new file mode 100644
index 00000000..52169849
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/gadget.json
@@ -0,0 +1,26 @@
+{
+ "id": "geo-dashboard",
+ "title": "Geo Dashboard",
+ "type": "widget",
+ "thumbnail": "gadget/geo-dashboard/img/thumbnail.png",
+ "settings": {
+ "personalize": true
+ },
+ "data": {
+ "url": "gadget/geo-dashboard/index.xml"
+ },
+ "styles": {
+ "borders": false,
+ "title": false
+ },
+ "notify": {
+ "select": {
+ "type": "address",
+ "description": "This notifies selected state"
+ },
+ "cancel": {
+ "type": "boolean",
+ "description": "This notifies cancellation of state selection"
+ }
+ }
+}
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/img/floor.jpg b/modules/analytics/Samples/GadgetLocationData/locationData/img/floor.jpg
new file mode 100644
index 00000000..ea795445
Binary files /dev/null and b/modules/analytics/Samples/GadgetLocationData/locationData/img/floor.jpg differ
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/include/commons.jag b/modules/analytics/Samples/GadgetLocationData/locationData/include/commons.jag
new file mode 100644
index 00000000..6c64ed85
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/include/commons.jag
@@ -0,0 +1,31 @@
+<%
+/*
+ ~ 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 escapeSiddhiql = function (s) {
+ XML_CHAR_MAP = {
+ '<': '<',
+ '>': '>',
+ '&': '&',
+ '"': '"',
+ "'": '''
+ };
+ return s.replace(/[<>&"']/g, function (ch) {
+ return XML_CHAR_MAP[ch];
+ });
+};
+%>
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/include/store_alerts.jag b/modules/analytics/Samples/GadgetLocationData/locationData/include/store_alerts.jag
new file mode 100644
index 00000000..a42d43e5
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/include/store_alerts.jag
@@ -0,0 +1,165 @@
+<%
+/*
+ ~ 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.
+ */
+
+// TODO: change the name of this jaggery file even thoe it says 'store_alerts' it is actually removing the alerts from the data store as well o.O wired
+var log = new Log();
+var constants = require("../controllers/constants.jag");
+
+var getRegistry = function() {
+ var carbon = require("carbon");
+ var server = new carbon.server.Server();
+ return new carbon.registry.Registry(server, {
+ system: true
+ });
+};
+
+/**
+ * Get the registry path to save the alert
+ * @param {String} alert_type Type of the alert
+ * @param {String} id Id of the device
+ * @param {String} optional /optional identity
+ * @return {String} Registry Path to save teh alert
+ * */
+var registryPath = function (alert_type, id, optional) {
+ if (alert_type && id ) {
+ if (alert_type === constants.EXECUTION_PLAN_TYPE_SPEED || alert_type === constants
+ .EXECUTION_PLAN_TYPE_PROXIMITY) {
+ return constants.REGISTRY_PATH_FOR_ALERTS + alert_type + "/" + id;
+ } else {
+ return constants.REGISTRY_PATH_FOR_ALERTS + alert_type + "/" + id + "/" + optional;
+ }
+ } else {
+ throw "Alert type and ID are mandatory field to generate the relevant registry path";
+ }
+};
+
+
+/**
+ * To store the alerts for visualizing purposes
+ * @param resourceContents Value that need to saved
+ * @param executionPlan Type of the execution plan
+ * @param optional Optional parameters that are only specific to particular device types
+ * @param deviceId Id of the device
+ */
+function store(resourceContents, executionPlan, optional, deviceId) {
+ var registry = getRegistry();
+ var pathToAddAlert = "";
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:*** resourceContents:" + resourceContents);
+ }
+ if (executionPlan === constants.EXECUTION_PLAN_TYPE_SPEED) {
+ pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_SPEED, deviceId);
+ registry.put(pathToAddAlert, {
+ content: '{"speedLimit": ' + resourceContents + '}',
+ mediaType: 'application/json'
+ });
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:*** Current speed limit set to:" + currentLimit.content);
+ }
+ }
+ else if (executionPlan === constants.EXECUTION_PLAN_TYPE_WITHIN) {
+ pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_WITHIN, deviceId, optional.queryName);
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:****** resourceContents = " + String('{"geoJson": ' + resourceContents + '}'));
+ }
+ registry.put(pathToAddAlert, {
+ content: JSON.stringify(resourceContents),
+ mediaType: 'application/json',
+ properties : {
+ "queryName" : optional.queryName,
+ "areaName" : optional.customName
+ }
+ });
+ } else if (executionPlan === constants.EXECUTION_PLAN_TYPE_PROXIMITY) {
+ pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_PROXIMITY, deviceId);
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:****** resourceContents = " + resourceContents);
+ }
+ registry.put(pathToAddAlert, {
+ content: "",
+ mediaType: 'application/json'
+ });
+ registry.addProperty(pathToAddAlert, "proximityDistance", resourceContents.proximityDistance);
+ registry.addProperty(pathToAddAlert, "proximityTime", resourceContents.proximityTime);
+ } else if (executionPlan === constants.EXECUTION_PLAN_TYPE_STATIONARY) {
+ pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_STATIONARY, deviceId, optional.queryName);
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:****** resourceContents = " + resourceContents);
+ }
+ var registryResource = {
+ content: JSON.stringify(resourceContents.geoFenceGeoJSON),
+ mediaType: 'application/json',
+ properties: {
+ "queryName" : optional.queryName,
+ "stationeryName" : optional.customName,
+ "stationeryTime" : resourceContents.stationeryTime,
+ "fluctuationRadius" : resourceContents.fluctuationRadius
+ }
+ };
+ registry.put(pathToAddAlert, registryResource);
+ } else if (executionPlan === constants.EXECUTION_PLAN_TYPE_TRAFFIC) {
+ pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_TRAFFIC, deviceId, optional.queryName);
+ if (log.isDebugEnabled()) {
+ log.debug("DEBUG:****** resourceContents = " + resourceContents.geoFenceGeoJSON);
+ }
+ var registryResource = {
+ content: JSON.stringify(resourceContents),
+ mediaType: 'application/json',
+ properties: {
+ "queryName" : optional.queryName,
+ "stationeryName" : optional.customName,
+ "stationeryTime" : resourceContents.stationeryTime,
+ "fluctuationRadius" : resourceContents.fluctuationRadius
+ }
+ };
+ registry.put(pathToAddAlert, {
+ content: JSON.stringify(resourceContents),
+ mediaType: 'application/json',
+ properties: {
+ "queryName" : optional.queryName,
+ "areaName" : optional.customName
+ }
+ });
+ }
+}
+
+/**
+ * To remove the registry resource
+ * @param queryName Name of the query that need to be removed
+ * @param executionPlanType type of the execution plan that need to be removed
+ * @param deviceId Id of the device
+ */
+function remove(queryName, executionPlanType, deviceId) {
+ var path = "";
+ try {
+ if (executionPlanType === constants.EXECUTION_PLAN_TYPE_SPEED || executionPlanType === constants.EXECUTION_PLAN_TYPE_PROXIMITY) {
+ path = registryPath(executionPlanType, deviceId);
+ } else {
+ path = registryPath(executionPlanType, deviceId, queryName);
+ }
+ getRegistry().remove(path);
+ if (log.isDebugEnabled()) {
+ log.debug("Resource is removed from the path" + path);
+ }
+ }
+ catch (e) {
+ log.error("The requested resource " + path + " was not found on this server.");
+ }
+}
+%>
\ No newline at end of file
diff --git a/modules/analytics/Samples/GadgetLocationData/locationData/index.xml b/modules/analytics/Samples/GadgetLocationData/locationData/index.xml
new file mode 100644
index 00000000..069371da
--- /dev/null
+++ b/modules/analytics/Samples/GadgetLocationData/locationData/index.xml
@@ -0,0 +1,196 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Select Time
+
+
+
+
+
+
+
+
+
+
+
Select Duration
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Typical Scenario
+
+
+
+
+
+
+
Upload Data file
+
+
+
+
+
Change Image
+
+
+
+
+
+
+
+
+
+
+
+