mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Prevent duplicate alerts & added owner field
This commit is contained in:
parent
d1fb11a0c0
commit
99054e1e77
@ -1,26 +0,0 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('Geo-ExecutionPlan-EventsFusionGenerateNotifications')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('ExecutionPlan')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Plan:trace('false')
|
||||
|
||||
@Import('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
|
||||
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
|
||||
|
||||
@Export('iot.per.device.stream.geo.AlertNotifications:1.0.0')
|
||||
define stream alertsOut ( id string, state string, information string, timeStamp long, latitude double, longitude double, type string);
|
||||
|
||||
@Export('iot.per.device.stream.geo.FusedSpatialEvent:1.0.0')
|
||||
define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string, notify bool );
|
||||
|
||||
from dataIn
|
||||
select id, latitude, longitude, timeStamp, type, speed, heading, state , information, (str:strcmp("ALERTED", state) == 0) as notify
|
||||
insert into dataOut;
|
||||
|
||||
from dataOut[notify == true]
|
||||
select id, state, information,timeStamp, latitude, longitude, type
|
||||
insert into alertsOut;
|
||||
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name="Geo-ExecutionPlan-EventsFusionGenerateNotifications" version="1.0.0" type="event/execution-plan" serverRole="GeoDashboard">
|
||||
<file>Geo-ExecutionPlan-EventsFusionGenerateNotifications-1.0.0.siddhiql</file>
|
||||
</artifact>
|
||||
@ -7,11 +7,11 @@
|
||||
/* 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);
|
||||
define stream dataIn (id string, owner 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);
|
||||
@Export('iot.per.device.stream.geo.FusedSpatialEvent:1.0.0')
|
||||
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
|
||||
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "Normal driving pattern" as information
|
||||
select id, owner, latitude, longitude,timeStamp, type ,speed, heading, "NORMAL" as state, "Normal driving pattern" as information, false as notify
|
||||
insert into dataOut;
|
||||
@ -9,6 +9,14 @@
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>owner</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>latitude</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
|
||||
@ -9,6 +9,14 @@
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>owner</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>state</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
|
||||
@ -9,13 +9,13 @@
|
||||
@Plan:trace('false')
|
||||
|
||||
@Import('org.wso2.iot.LocationStream:1.0.0')
|
||||
define stream dataIn (meta_deviceId string, meta_deviceType string, timeStamp long, latitude double, longitude double);
|
||||
define stream dataIn (meta_deviceId string, meta_owner string, meta_deviceType string, timeStamp long, latitude double, longitude double);
|
||||
|
||||
@Export('org.wso2.geo.StandardSpatialEvents:1.0.0')
|
||||
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
|
||||
define stream dataOut (id string, owner string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
|
||||
|
||||
from every fs1=dataIn -> fs2=dataIn[fs2.timeStamp > fs1.timeStamp and fs1.meta_deviceId == fs2.meta_deviceId]
|
||||
select fs1.meta_deviceId as id, fs2.latitude, fs2.longitude, fs2.timeStamp, fs1.meta_deviceType as type,
|
||||
select fs1.meta_deviceId as id, fs1.meta_owner as owner, fs2.latitude, fs2.longitude, fs2.timeStamp, fs1.meta_deviceType as type,
|
||||
convert(geo:distance(fs2.latitude, fs2.longitude, fs1.latitude, fs1.longitude) * 3600/(fs2.timeStamp - fs1.timeStamp), 'float') as speed,
|
||||
0.0f as heading, UUID() as eventId
|
||||
group by fs1.meta_deviceId
|
||||
|
||||
@ -22,7 +22,6 @@
|
||||
<!-- CEP Artifacts -->
|
||||
<dependency artifact="WSO2IoT-Geo-Event-Receiver" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="WSO2IoT-EventSink-FusedStream" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="Geo-ExecutionPlan-EventsFusionGenerateNotifications" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="Geo-ExecutionPlan-Pass_through" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="WSO2IoT-Geo-ExecutionPlan" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="WSO2IoT-Geo-AlertNotifications" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
@ -31,7 +30,6 @@
|
||||
<dependency artifact="iot.per.device.stream.geo.AlertNotifications" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="iot.per.device.stream.geo.FusedSpatialEvent" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="org.wso2.iot.LocationStream" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="org.wso2.geo.ProcessedSpatialEvents" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
<dependency artifact="org.wso2.geo.StandardSpatialEvents" version="1.0.0" include="true" serverRole="GeoDashboard"/>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
|
||||
@ -8,6 +8,10 @@
|
||||
"name": "id",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "state",
|
||||
"type": "STRING"
|
||||
|
||||
@ -8,6 +8,10 @@
|
||||
"name": "id",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "latitude",
|
||||
"type": "DOUBLE"
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<artifact name="org.wso2.geo.ProcessedSpatialEvents" version="1.0.0" type="event/stream" serverRole="GeoDashboard">
|
||||
<file>org.wso2.geo.ProcessedSpatialEvents-1.0.0.json</file>
|
||||
</artifact>
|
||||
@ -1,48 +0,0 @@
|
||||
{
|
||||
"name": "org.wso2.geo.ProcessedSpatialEvents",
|
||||
"version": "1.0.0",
|
||||
"nickName": "",
|
||||
"description": "",
|
||||
"payloadData": [
|
||||
{
|
||||
"name": "id",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "latitude",
|
||||
"type": "DOUBLE"
|
||||
},
|
||||
{
|
||||
"name": "longitude",
|
||||
"type": "DOUBLE"
|
||||
},
|
||||
{
|
||||
"name": "timeStamp",
|
||||
"type": "LONG"
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "speed",
|
||||
"type": "FLOAT"
|
||||
},
|
||||
{
|
||||
"name": "heading",
|
||||
"type": "FLOAT"
|
||||
},
|
||||
{
|
||||
"name": "eventId",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "state",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "information",
|
||||
"type": "STRING"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -8,6 +8,10 @@
|
||||
"name": "id",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "latitude",
|
||||
"type": "DOUBLE"
|
||||
|
||||
@ -8,6 +8,10 @@
|
||||
"name": "deviceId",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"name": "deviceType",
|
||||
"type": "STRING"
|
||||
|
||||
@ -69,13 +69,14 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device event logging.");
|
||||
}
|
||||
Device device;
|
||||
try {
|
||||
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Event is publishing has not enabled.").build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(),
|
||||
AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build();
|
||||
} else if (device == null){
|
||||
@ -92,7 +93,8 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
Message message = new Message();
|
||||
Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), AndroidConstants.DEVICE_TYPE_ANDROID};
|
||||
Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), device.getEnrolmentInfo().getOwner(),
|
||||
AndroidConstants.DEVICE_TYPE_ANDROID};
|
||||
String eventPayload = eventBeanWrapper.getPayload();
|
||||
JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class);
|
||||
Object[] payload = {
|
||||
|
||||
@ -70,13 +70,14 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invoking Android device event logging.");
|
||||
}
|
||||
Device device;
|
||||
try {
|
||||
if (!DeviceManagerUtil.isPublishLocationResponseEnabled()) {
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Event is publishing has not enabled.").build();
|
||||
}
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(eventBeanWrapper.getDeviceIdentifier(),
|
||||
AndroidConstants.DEVICE_TYPE_ANDROID);
|
||||
Device device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
device = AndroidAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
if (device != null && EnrolmentInfo.Status.ACTIVE != device.getEnrolmentInfo().getStatus()){
|
||||
return Response.status(Response.Status.ACCEPTED).entity("Device is not in Active state.").build();
|
||||
} else if (device == null){
|
||||
@ -93,7 +94,8 @@ public class EventReceiverServiceImpl implements EventReceiverService {
|
||||
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
|
||||
}
|
||||
Message message = new Message();
|
||||
Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), AndroidConstants.DEVICE_TYPE_ANDROID};
|
||||
Object[] metaData = {eventBeanWrapper.getDeviceIdentifier(), device.getEnrolmentInfo().getOwner(),
|
||||
AndroidConstants.DEVICE_TYPE_ANDROID};
|
||||
String eventPayload = eventBeanWrapper.getPayload();
|
||||
JsonObject jsonObject = gson.fromJson(eventPayload, JsonObject.class);
|
||||
Object[] payload = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user