define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string,speed float, heading float, eventId string, state string, information string);
define stream dataOut (id string, owner string, latitude double, longitude double, timeStamp long, type string,speed float, heading float, state string, information string, notify bool);
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==false and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id), " is outside $areaName area!!!") as information
define stream alertsOut (id string, owner string, state string, information string, timeStamp long, latitude double, longitude double, type string);
/* Check if the device is within the geo fence. */
from dataIn[id == "$deviceId" and owner == "$owner"]
select id, owner, "ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id), " is outside $areaName area!!!") as information, timeStamp, latitude, longitude, type
define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
define stream dataOut (id string, owner string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string,notify bool);
from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
select id,str:concat(",",proximityWith) as proximityWith , eventId
select id, owner, str:concat(",",proximityWith) as proximityWith , eventId
insert into AlertsTable;
insert into AlertsTable;
from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
select proximityWith as id,str:concat(",",id) as proximityWith , eventId
select proximityWith as id, owner, str:concat(",",id) as proximityWith , eventId
insert into AlertsTable;
insert into AlertsTable;
from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
select innerStreamOne.id as id, innerStreamOne.owner as owner, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
select innerStreamSeven.proximityWith as id, innerStreamSeven.owner as owner, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
insert into updateStream;
from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
select innerStreamOne.id as id, innerStreamOne.owner as owner, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
select innerStreamSeven.proximityWith as id, innerStreamSeven.owner as owner, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
insert into updateStream;
from updateStream
from updateStream
@ -88,23 +88,23 @@ delete AlertsTable
on id== AlertsTable.id;
on id== AlertsTable.id;
from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
on publishStream.id== AlertsTable.id
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
select publishStream.id as id, publishStream.owner as owner, 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;
insert into innerStreamTwo;
from publishStream[inAlertTable == false]
from publishStream[inAlertTable == false]
delete ProximityTable on ProximityTable.id==id;
delete ProximityTable on ProximityTable.id==id;
from publishStream[inAlertTable == false]
from publishStream[inAlertTable == false]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
select id,owner, latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
insert into dataOutStream;
from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
@ -112,29 +112,29 @@ insert into innerStreamThree;
from innerStreamThree#window.length(0) join ProximityTable
from innerStreamThree#window.length(0) join ProximityTable
on innerStreamThree.id == ProximityTable.id
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
select innerStreamThree.id,innerStreamThree.owner, 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;
insert into innerStreamFour;
from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,proximityInfo,"true" as isProximity
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
select id,owner, latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
insert into dataOutStream;
from dataOutStream[isProximity == 'true']
from dataOutStream[isProximity == 'true']
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,"WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information
select id, owner, latitude, longitude, timeStamp, type, speed, heading, "WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information, true as notify
insert into dataOut;
insert into dataOut;
from dataOutStream[isProximity == 'false']
from dataOutStream[isProximity == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading,eventId,"NORMAL" as state,"" as information
select id,owner, latitude, longitude,timeStamp, type, speed, heading, "NORMAL" as state,"" as information, false as notify
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string);
define stream dataOut (id string, owner string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string, notify bool );
from dataIn[speed >= $speedAlertValue and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "ALERTED" as state, str:concat(str:concat(str:concat(str:concat("Movement of ",type), " device "), id), " is not normal!!") as information
define stream alertsOut (id string, owner string, state string, information string, timeStamp long, latitude double, longitude double, type string);
from dataIn[speed >= $speedAlertValue and id == "$deviceId" and owner == "$owner"]
select id, owner, latitude, longitude, timeStamp, type, speed, heading, "ALERTED" as state, str:concat(str:concat(str:concat(str:concat("Speed of ",type), " device "), id), " is not normal!!") as information, true as notify
insert into dataOut;
insert into dataOut;
from dataIn[speed < $speedAlertValue and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, str:concat(str:concat(str:concat(str:concat("Movement of ",type), " device "), id), " is normal") as information
from dataIn[speed < $speedAlertValue and id == "$deviceId" and owner == "$owner"]
select id, owner, latitude, longitude, timeStamp, type, speed, heading, "NORMAL" as state, str:concat(str:concat(str:concat(str:concat("Speed of ",type), " device "), id), " is normal") as information, false as notify
insert into dataOut;
insert into dataOut;
from dataOut[notify == true]
select id, owner, state, information, timeStamp, latitude, longitude, type
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
define stream alertsOut (id string, owner string, state string, information string, timeStamp long, latitude double, longitude double, type string);
select id ,latitude, longitude,timeStamp, type, speed, heading,eventId,"ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id),"is in $stationeryName area!!!") as information
select id,owner,latitude, longitude,timeStamp, type, speed, heading, "ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id),"is in $stationeryName area!!!") as information, true as notify
insert into dataOut;
insert into dataOut;
from dataOutStream[isStationary == 'false']
from dataOutStream[isStationary == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading,eventId,"NORMAL" as state,"" as information
select id,owner, latitude, longitude,timeStamp, type, speed, heading, "NORMAL" as state,"" as information, false as notify
insert into dataOut;
insert into dataOut;
from dataOut[notify == true]
select id, owner, state, information, timeStamp, latitude, longitude, type
/* define streams/tables and write queries here ... */
/* define streams/tables and write queries here ... */
@Import('rawGeoStream:1.0.0')
@Import('rawGeoStream:1.0.0')
define stream dataIn (id string, timeStamp long, geometry string, state string, information string);
define stream dataIn (id string, owner string, timeStamp long, geometry string, state string, information string);
@Export('AlertsNotifications:1.0.0')
@Export('AlertsNotifications:1.0.0')
define stream dataOut (id string, state string, information string, timeStamp long, latitude double, longitude double);
define stream dataOut (id string, owner 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]
from dataIn[geo:intersects(geometry, "$geoFenceGeoJSON")==true and geodashboard:needToNotify(id, str:concat(information, state), "sendFirst") == true and id == "$deviceId" and owner == "$owner"]
select id, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
select id, owner, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string,speed float, heading float, eventId string, state string, information string);
define stream dataOut (id string, owner string, latitude double, longitude double, timeStamp long, type string,speed float, heading float, state string, information string, notify bool );
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, str:concat(str:concat(str:concat(type," device "), id), " is in $areaName restricted area!!!") as information
define stream alertsOut (id string, owner string, state string, information string, timeStamp long, latitude double, longitude double, type string);
/* Check if the device is within the geo fence. */
from dataIn[id == "$deviceId" and owner == "$owner"]
select id, owner, latitude, longitude,timeStamp, type, speed, heading, "ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id), " is in $areaName restricted area!!!") as information, true as notify
insert into dataOut;
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
from withinStream[isWithin == false]
select id, owner, latitude, longitude,timeStamp, type, speed, heading, "NORMAL" as state, "" as information, false as notify
insert into dataOut;
insert into dataOut;
from every fs1=withinStream, fs2=withinStream[fs1.isWithin != isWithin]
select id, owner, "ALERTED" as state, str:concat(str:concat(str:concat(type," device "),id), " is outside $areaName area!!!") as information, timeStamp, latitude, longitude, type
return'Geo-ExecutionPlan-Within'+(queryName?'_'+queryName:'')+"---"+(deviceId?'_'+deviceId:'')+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Exit"){
return'Geo-ExecutionPlan-Exit'+(queryName?'_'+queryName:'')+"---"+(deviceId?'_'+deviceId:'')+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Stationery"){
return'Geo-ExecutionPlan-Stationery'+(queryName?'_'+queryName:'')+"---"+(deviceId?'_'+deviceId:'')+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Traffic"){
return'Geo-ExecutionPlan-Traffic'+(queryName?'_'+queryName:'')+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}
}
// TODO:this is not a remote call , move this to application.js
// TODO:this is not a remote call , move this to application.js
'parseData':JSON.stringify({'speedAlertValue':speedAlertValue,'deviceId':deviceId}),// parseKey : parseValue pair , this key pair is replace with the key in the template file
'parseData':JSON.stringify({
'speedAlertValue':speedAlertValue,
'deviceId':deviceId}),// parseKey : parseValue pair , this key pair is replace with the key in the template file
'executionPlan':'Speed',
'executionPlan':'Speed',
'customName':null,
'customName':null,
'cepAction':'edit',
'cepAction':'edit',
@ -221,7 +223,6 @@ function setWithinAlert(leafletId) {
@ -569,21 +567,6 @@ function setProximityAlert() {
}
}
}
}
// TODO:this is not a remote call , move this to application.js
functioncreateExecutionPlanName(queryName,id){
if(id=="WithIn"){
return'Geo-ExecutionPlan-Within'+(queryName?'_'+queryName:'')+"---"+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Exit"){
return'Geo-ExecutionPlan-Exit'+(queryName?'_'+queryName:'')+"---"+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Stationery"){
return'Geo-ExecutionPlan-Stationery'+(queryName?'_'+queryName:'')+"---"+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}elseif(id=="Traffic"){
return'Geo-ExecutionPlan-Traffic'+(queryName?'_'+queryName:'')+'_alert';// TODO: value of the `queryName` can't be empty, because it will cause name conflicts in CEP, have to do validation(check not empty String)
}
}
// TODO:this is not a remote call , move this to application.js
// TODO:this is not a remote call , move this to application.js