Merge branch 'android-sense-agent-fixes' into release-3.0.x

revert-dabc3590
sinthuja 8 years ago
commit f23fd9c85f

@ -12,9 +12,9 @@ define stream dataIn (id string, latitude double, longitude double, timeStamp lo
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0') @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); 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() 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 select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
insert into dataOut; insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == $deviceId] 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 select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut; insert into dataOut;

@ -281,7 +281,8 @@ function setWithinAlert(leafletId) {
'parseData': JSON.stringify({ 'parseData': JSON.stringify({
'geoFenceGeoJSON': selectedAreaGeoJson, 'geoFenceGeoJSON': selectedAreaGeoJson,
'executionPlanName': createExecutionPlanName(queryName, "WithIn", deviceId), 'executionPlanName': createExecutionPlanName(queryName, "WithIn", deviceId),
'areaName': areaName 'areaName': areaName,
'deviceId' : deviceId
}), }),
'executionPlan': 'Within', 'executionPlan': 'Within',
'customName': areaName, // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM 'customName': areaName, // TODO: fix , When template copies there can be two queryName and areaName id elements in the DOM

@ -116,6 +116,10 @@ SpatialObject.prototype.update = function (geoJSON) {
// Update the spatial object leaflet marker // Update the spatial object leaflet marker
this.marker.setLatLng([this.latitude, this.longitude]); this.marker.setLatLng([this.latitude, this.longitude]);
if (this.latitude, this.longitude) {
map.setView([this.latitude, this.longitude]);
}
this.marker.setIconAngle(this.heading); this.marker.setIconAngle(this.heading);
this.marker.setIcon(this.stateIcon()); this.marker.setIcon(this.stateIcon());
@ -677,13 +681,14 @@ function intializeWebsocketUrls() {
.constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain +
ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
.CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION
+ "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + "?deviceId=" + deviceId + "&deviceType=" + deviceType;
alertWebSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance alertWebSocketURL = 'wss://' + data.ip + ':' + data.httpsPort + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
.CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions .CEP_WEB_SOCKET_OUTPUT_ADAPTOR_WEBAPP_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions
.constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain + .constance.TENANT_INDEX + ApplicationOptions.constance.PATH_SEPARATOR + data.user.domain +
ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance
.CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION .CEP_ON_ALERT_WEB_SOCKET_OUTPUT_ADAPTOR_NAME + ApplicationOptions.constance.PATH_SEPARATOR + ApplicationOptions.constance.VERSION
+ "?token=ee9971c8-bf09-3c83-b097-ce87a0c88806&deviceId=" + deviceId + "&deviceType=" + deviceType; + "?deviceId=" + deviceId + "&deviceType=" + deviceType;
document.cookie = "websocket-token=f98d6142-e988-3c7f-a8c9-7e6d74da7113; path=/";
initializeWebSocket(); initializeWebSocket();
initializeOnAlertWebSocket(); initializeOnAlertWebSocket();
}); });
@ -705,7 +710,8 @@ intializeWebsocketUrls();
SpatialObject.prototype.stateIcon = function () { SpatialObject.prototype.stateIcon = function () {
var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/" + this.type.toLowerCase(); //TODO : Need to add separate icons for each device type
var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/default";
if (0 < this.speed && (-360 <= this.heading && 360 >= this.heading)) { if (0 < this.speed && (-360 <= this.heading && 360 >= this.heading)) {
iconUrl = iconUrl + "/moving/" + this.state.toLowerCase(); iconUrl = iconUrl + "/moving/" + this.state.toLowerCase();
} else { } else {

@ -12,7 +12,7 @@
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string ); define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
@Export('org.wso2.geo.AlertsNotifications:1.0.0') @Export('org.wso2.geo.AlertsNotifications:1.0.0')
define stream alertsOut ( id string, state string, information string, timeStamp long, latitude double, longitude double ); define stream alertsOut ( id string, state string, information string, timeStamp long, latitude double, longitude double, type string);
@Export('org.wso2.geo.FusedSpatialEvent:1.0.0') @Export('org.wso2.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 ); define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, state string, information string, notify bool );
@ -25,5 +25,5 @@ select id, latitude, longitude, timeStamp, type, speed, heading, state , informa
insert into dataOut; insert into dataOut;
from dataOut[notify == true] from dataOut[notify == true]
select id,state,information,timeStamp, latitude, longitude select id, state, information,timeStamp, latitude, longitude, type
insert into alertsOut; insert into alertsOut;

@ -7,8 +7,8 @@
"messageType" : "Point", "messageType" : "Point",
"type": "Feature", "type": "Feature",
"id": {{id}}, "id": {{id}},
"deviceId": "rkxb293yw2t2", "deviceId": {{id}},
"deviceType": "virtual_firealarm", "deviceType": {{type}},
"properties": { "properties": {
"speed": {{speed}}, "speed": {{speed}},
"heading": {{heading}}, "heading": {{heading}},

@ -8,8 +8,8 @@
"messageType" : "Alert", "messageType" : "Alert",
"type": "Feature", "type": "Feature",
"id": {{id}}, "id": {{id}},
"deviceId": "rkxb293yw2t2", "deviceId": {{id}},
"deviceType" : "virtual_firealarm", "deviceType" : "{{type}}",
"state": {{state}}, "state": {{state}},
"information": {{information}}, "information": {{information}},
"longitude" : {{longitude}}, "longitude" : {{longitude}},

@ -27,6 +27,10 @@
{ {
"name": "longitude", "name": "longitude",
"type": "DOUBLE" "type": "DOUBLE"
},
{
"name": "type",
"type": "STRING"
} }
] ]
} }

@ -29,14 +29,15 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData; import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData; import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData;
import org.wso2.carbon.iot.android.sense.event.streams.Speed.SpeedData; import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData;
import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData; import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData;
import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData;
import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData;
import org.wso2.carbon.iot.android.sense.event.streams.call.CallData; import org.wso2.carbon.iot.android.sense.event.streams.call.CallData;
import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData;
import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData;
import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData;
import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords; import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords;
@ -277,6 +278,19 @@ public class DataPublisherService extends Service {
} }
SenseDataHolder.resetApplicationDataHolder(); SenseDataHolder.resetApplicationDataHolder();
//Retrieve network data
List<NetworkData> networkDataList = SenseDataHolder.getNetworkDataHolder();
if (!networkDataList.isEmpty()) {
for (NetworkData networkData : networkDataList) {
Event event = new Event();
event.setTimestamp(networkData.getTimeStamp());
event.setDataType(networkData.getDataType());
event.setDataReceived(networkData.getDataReceived());
event.setDataSent(networkData.getDataSent());
events.add(event);
}
}
SenseDataHolder.resetNetworkDataHolder();
//publish the data //publish the data
if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { if (events.size() > 0 && LocalRegistry.isEnrolled(context)) {

@ -61,6 +61,17 @@ public class Event {
private String packageName; private String packageName;
private String action; private String action;
/**
* Network data
* Time stamp
* Data type
* Data sent
* Data received.
* */
private String dataType;
private long dataSent;
private long dataReceived;
private int getBattery() { private int getBattery() {
return battery; return battery;
} }
@ -411,6 +422,36 @@ public class Event {
this.confidence = confidence; this.confidence = confidence;
} }
public String getDataType() {
this.type = "data";
return dataType;
}
public void setDataType(String dataType) {
this.type = "data";
this.dataType = dataType;
}
public long getDataSent() {
this.type = "data";
return dataSent;
}
public void setDataSent(long dataSent) {
this.type = "data";
this.dataSent = dataSent;
}
public long getDataReceived() {
this.type = "data";
return dataReceived;
}
public void setDataReceived(long dataReceived) {
this.type = "data";
this.dataReceived = dataReceived;
}
public JSONObject getEvent() throws JSONException { public JSONObject getEvent() throws JSONException {
JSONObject jsonEvent = new JSONObject(); JSONObject jsonEvent = new JSONObject();
JSONObject jsonMetaData = new JSONObject(); JSONObject jsonMetaData = new JSONObject();
@ -502,6 +543,10 @@ public class Event {
jsonPayloadData.put("application_name", getPackageName()); jsonPayloadData.put("application_name", getPackageName());
jsonPayloadData.put("action", getAction()); jsonPayloadData.put("action", getAction());
//Network data
jsonPayloadData.put("data_type", getDataType());
jsonPayloadData.put("data_received", getDataReceived());
jsonPayloadData.put("data_sent", getDataSent());
jsonEvent.put("payloadData", jsonPayloadData); jsonEvent.put("payloadData", jsonPayloadData);

@ -56,6 +56,7 @@ public class SenseService extends Service {
SenseDataReceiverManager.registerActivityDataReceiver(this); SenseDataReceiverManager.registerActivityDataReceiver(this);
SenseDataReceiverManager.registerSmsDataReceiver(this); SenseDataReceiverManager.registerSmsDataReceiver(this);
SenseDataReceiverManager.registerAppDataReceiver(this); SenseDataReceiverManager.registerAppDataReceiver(this);
SenseDataReceiverManager.registerNetworkDataReceiver(this);
//service will not be stopped until we manually stop the service //service will not be stopped until we manually stop the service
return Service.START_NOT_STICKY; return Service.START_NOT_STICKY;
@ -69,6 +70,7 @@ public class SenseService extends Service {
SenseDataReceiverManager.unregisterActivityDataReceiver(this); SenseDataReceiverManager.unregisterActivityDataReceiver(this);
SenseDataReceiverManager.unregisterSmsDataReceiver(this); SenseDataReceiverManager.unregisterSmsDataReceiver(this);
SenseDataReceiverManager.unregisterAppDataReceiver(this); SenseDataReceiverManager.unregisterAppDataReceiver(this);
SenseDataReceiverManager.unregisterNetworkDataReceiver(this);
SenseWakeLock.releaseCPUWakeLock(); SenseWakeLock.releaseCPUWakeLock();
super.onDestroy(); super.onDestroy();

@ -15,10 +15,9 @@
package org.wso2.carbon.iot.android.sense.event.streams; package org.wso2.carbon.iot.android.sense.event.streams;
import android.content.Context; import android.content.Context;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationDataReader; import org.wso2.carbon.iot.android.sense.event.streams.location.LocationDataReader;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorDataReader; import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorDataReader;
import org.wso2.carbon.iot.android.sense.event.streams.Speed.SpeedDataReader; import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedDataReader;
import org.wso2.carbon.iot.android.sense.beacon.MonitoringActivity;
import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioDataReader; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioDataReader;
/** /**

@ -0,0 +1,60 @@
/*
* 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.
*/
package org.wso2.carbon.iot.android.sense.event.streams.data;
import java.util.Date;
public class NetworkData {
//Mobile or Wifi
private String DATA_TYPE;
private long dataReceived;
private long dataSent;
private long timeStamp;
public NetworkData(long received, long sent) {
this.dataReceived = received;
this.dataSent = sent;
this.timeStamp = new Date().getTime();
}
public String getDataType() {
return DATA_TYPE;
}
public long getDataReceived() {
return dataReceived;
}
public void setDataReceived(long dataReceived) {
this.dataReceived = dataReceived;
}
public long getDataSent() {
return dataSent;
}
public void setDataSent(long dataSent) {
this.dataSent = dataSent;
}
public long getTimeStamp() {
return timeStamp;
}
}

@ -0,0 +1,42 @@
/*
* 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.
*/
package org.wso2.carbon.iot.android.sense.event.streams.data;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
public class NetworkDataReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
long sent = android.net.TrafficStats.getTotalTxBytes();
long received = android.net.TrafficStats.getTotalRxBytes();
Log.d("NetworkData :", "Received: " + sent + " Received : " + received);
NetworkData networkData = new NetworkData(received, sent);
SenseDataHolder.getNetworkDataHolder().add(networkData);
}
}

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
* *
*/ */
package org.wso2.carbon.iot.android.sense.event.streams.Location; package org.wso2.carbon.iot.android.sense.event.streams.location;
import java.util.Date; import java.util.Date;

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
* *
*/ */
package org.wso2.carbon.iot.android.sense.event.streams.Location; package org.wso2.carbon.iot.android.sense.event.streams.location;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;

@ -11,7 +11,7 @@
* See the License for the specific language governing permissions and limitations under the License. * See the License for the specific language governing permissions and limitations under the License.
* *
*/ */
package org.wso2.carbon.iot.android.sense.event.streams.Sensor; package org.wso2.carbon.iot.android.sense.event.streams.sensor;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -26,6 +26,7 @@ import org.wso2.carbon.iot.android.sense.realtimeviewer.sensorlisting.SupportedS
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -65,7 +66,7 @@ public class SensorDataReader extends DataReader implements SensorEventListener
SensorData sensorInfo = senseDataStruct.get(sensor.getName()); SensorData sensorInfo = senseDataStruct.get(sensor.getName());
sensorVector.add(sensorInfo); sensorVector.add(sensorInfo);
Log.d(TAG, "Sensor Name " + sensor.getName() + ", Type " + sensor.getType() + " " + Log.d(TAG, "Sensor Name " + sensor.getName() + ", Type " + sensor.getType() + " " +
", sensorValue :" + sensorInfo.getSensorValues()); ", sensorValue :" + Arrays.toString(sensorInfo.getSensorValues()));
} }
} catch (Throwable e) { } catch (Throwable e) {
Log.d(TAG, "error on sensors"); Log.d(TAG, "error on sensors");

@ -12,10 +12,10 @@
* *
*/ */
package org.wso2.carbon.iot.android.sense.event.streams.Speed; package org.wso2.carbon.iot.android.sense.event.streams.speed;
import org.wso2.carbon.iot.android.sense.event.streams.DataReader; import org.wso2.carbon.iot.android.sense.event.streams.DataReader;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData; import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData;
import org.wso2.carbon.iot.android.sense.realtimeviewer.sensorlisting.SupportedSensors; import org.wso2.carbon.iot.android.sense.realtimeviewer.sensorlisting.SupportedSensors;
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
import android.content.Context; import android.content.Context;
@ -37,9 +37,6 @@ import java.util.concurrent.TimeUnit;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Intent; import android.content.Intent;
import android.app.Activity;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationDataReader;
public class SpeedDataReader extends DataReader implements SensorEventListener { public class SpeedDataReader extends DataReader implements SensorEventListener {

@ -42,9 +42,9 @@ public class RealTimeSensorReader implements SensorEventListener {
RealTimeSensor realTimeSensor = new RealTimeSensor(); RealTimeSensor realTimeSensor = new RealTimeSensor();
realTimeSensor.setName(supportedSensors.getType(event.sensor.getType()).toUpperCase()); realTimeSensor.setName(supportedSensors.getType(event.sensor.getType()).toUpperCase());
realTimeSensor.setValueX(event.values[0] + ""); realTimeSensor.setValueX(event.values == null ? "" : event.values[0] + "");
realTimeSensor.setValueY(event.values[1] + ""); realTimeSensor.setValueY(event.values == null || event.values.length <= 1 ? "" : event.values[1] + "");
realTimeSensor.setValueZ(event.values[2] + ""); realTimeSensor.setValueZ(event.values == null || event.values.length <= 1 ? "" : event.values[2] + "");
TempStore.sensorDataMap.put(supportedSensors.getType(event.sensor.getType()), realTimeSensor); TempStore.sensorDataMap.put(supportedSensors.getType(event.sensor.getType()), realTimeSensor);

@ -18,9 +18,8 @@ import android.os.AsyncTask;
import android.widget.EditText; import android.widget.EditText;
import org.apache.commons.codec.language.Soundex; import org.apache.commons.codec.language.Soundex;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData;
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;

@ -23,6 +23,7 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants;
import org.wso2.carbon.iot.android.sense.util.dto.AccessTokenInfo; import org.wso2.carbon.iot.android.sense.util.dto.AccessTokenInfo;
import org.wso2.carbon.iot.android.sense.util.dto.AndroidConfiguration; import org.wso2.carbon.iot.android.sense.util.dto.AndroidConfiguration;
import org.wso2.carbon.iot.android.sense.util.dto.AndroidSenseManagerService; import org.wso2.carbon.iot.android.sense.util.dto.AndroidSenseManagerService;
import org.wso2.carbon.iot.android.sense.util.dto.ApiApplicationKey;
import org.wso2.carbon.iot.android.sense.util.dto.ApiApplicationRegistrationService; import org.wso2.carbon.iot.android.sense.util.dto.ApiApplicationRegistrationService;
import org.wso2.carbon.iot.android.sense.util.dto.ApiRegistrationProfile; import org.wso2.carbon.iot.android.sense.util.dto.ApiRegistrationProfile;
import org.wso2.carbon.iot.android.sense.util.dto.DynamicClientRegistrationService; import org.wso2.carbon.iot.android.sense.util.dto.DynamicClientRegistrationService;
@ -98,41 +99,24 @@ public class SenseClientAsyncExecutor extends AsyncTask<String, Void, Map<String
responseMap.put(STATUS, "200"); responseMap.put(STATUS, "200");
AccessTokenInfo accessTokenInfo = null; AccessTokenInfo accessTokenInfo = null;
try { try {
//DynamicClientRegistraiton.
DynamicClientRegistrationService dynamicClientRegistrationService = Feign.builder()
.client(disableHostnameVerification).contract(new
JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(DynamicClientRegistrationService.class, endpoint + SenseConstants.DCR_CONTEXT);
RegistrationProfile registrationProfile = new RegistrationProfile();
String applicationName = "android-sense:" + deviceId;
registrationProfile.setOwner(username);
registrationProfile.setClientName(applicationName);
registrationProfile.setCallbackUrl("");
registrationProfile.setGrantType("password refresh_token client_credentials");
registrationProfile.setApplicationType("device");
registrationProfile.setTokenScope("production");
OAuthApplicationInfo oAuthApplicationInfo = dynamicClientRegistrationService.register(registrationProfile);
//PasswordGrantType
TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification).requestInterceptor(
new BasicAuthRequestInterceptor(oAuthApplicationInfo.getClient_id(), oAuthApplicationInfo.getClient_secret()))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(TokenIssuerService.class, endpoint + SenseConstants.TOKEN_ISSUER_CONTEXT);
accessTokenInfo = tokenIssuerService.getToken("password", username, password);
//ApiApplicationRegistration //ApiApplicationRegistration
ApiApplicationRegistrationService apiApplicationRegistrationService = Feign.builder().client(disableHostnameVerification) ApiApplicationRegistrationService apiApplicationRegistrationService = Feign.builder().client(disableHostnameVerification)
.requestInterceptor(new OAuthRequestInterceptor(accessTokenInfo.getAccess_token())) .requestInterceptor(new BasicAuthRequestInterceptor(username, password))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()) .contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(ApiApplicationRegistrationService.class, endpoint + SenseConstants.API_APPLICATION_REGISTRATION_CONTEXT); .target(ApiApplicationRegistrationService.class, endpoint + SenseConstants.API_APPLICATION_REGISTRATION_CONTEXT);
ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile(); ApiRegistrationProfile apiRegistrationProfile = new ApiRegistrationProfile();
apiRegistrationProfile.setApplicationName(applicationName); apiRegistrationProfile.setApplicationName("android_sense_" + deviceId);
apiRegistrationProfile.setConsumerKey(oAuthApplicationInfo.getClient_id());
apiRegistrationProfile.setConsumerSecret(oAuthApplicationInfo.getClient_secret());
apiRegistrationProfile.setIsAllowedToAllDomains(false); apiRegistrationProfile.setIsAllowedToAllDomains(false);
apiRegistrationProfile.setIsMappingAnExistingOAuthApp(true); apiRegistrationProfile.setIsMappingAnExistingOAuthApp(false);
apiRegistrationProfile.setTags(new String[]{SenseConstants.DEVICE_TYPE}); apiRegistrationProfile.setTags(new String[]{SenseConstants.DEVICE_TYPE});
String replyMsg = apiApplicationRegistrationService.register(apiRegistrationProfile); ApiApplicationKey apiApplicationKey = apiApplicationRegistrationService.register(apiRegistrationProfile);
//PasswordGrantType
TokenIssuerService tokenIssuerService = Feign.builder().client(disableHostnameVerification).requestInterceptor(
new BasicAuthRequestInterceptor(apiApplicationKey.getConsumerKey(), apiApplicationKey.getConsumerSecret()))
.contract(new JAXRSContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder())
.target(TokenIssuerService.class, endpoint + SenseConstants.TOKEN_ISSUER_CONTEXT);
accessTokenInfo = tokenIssuerService.getToken("password", username, password, "device_" + deviceId);
//DeviceRegister //DeviceRegister
AndroidSenseManagerService androidSenseManagerService = Feign.builder().client(disableHostnameVerification) AndroidSenseManagerService androidSenseManagerService = Feign.builder().client(disableHostnameVerification)

@ -14,14 +14,15 @@
package org.wso2.carbon.iot.android.sense.util; package org.wso2.carbon.iot.android.sense.util;
import org.wso2.carbon.iot.android.sense.beacon.BeaconScanedData; import org.wso2.carbon.iot.android.sense.beacon.BeaconScanedData;
import org.wso2.carbon.iot.android.sense.event.streams.Location.LocationData; import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData;
import org.wso2.carbon.iot.android.sense.event.streams.Sensor.SensorData; import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData;
import org.wso2.carbon.iot.android.sense.event.streams.Speed.SpeedData; import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData;
import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData; import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData;
import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData;
import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData;
import org.wso2.carbon.iot.android.sense.event.streams.call.CallData; import org.wso2.carbon.iot.android.sense.event.streams.call.CallData;
import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData;
import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData;
import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData;
import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData; import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData;
@ -47,6 +48,7 @@ public class SenseDataHolder {
private static List<ActivityData> activityDataHolder; private static List<ActivityData> activityDataHolder;
private static List<SmsData> smsDataHolder; private static List<SmsData> smsDataHolder;
private static List<ApplicationData> applicationDataHolder; private static List<ApplicationData> applicationDataHolder;
private static List<NetworkData> networkDataHolder;
//LocationData gps; //LocationData gps;
@ -141,6 +143,13 @@ public class SenseDataHolder {
return applicationDataHolder; return applicationDataHolder;
} }
public static List<NetworkData> getNetworkDataHolder() {
if (networkDataHolder == null) {
networkDataHolder = new CopyOnWriteArrayList<>();
}
return networkDataHolder;
}
public static void resetSensorDataHolder() { public static void resetSensorDataHolder() {
sensorDataHolder = null; sensorDataHolder = null;
} }
@ -188,4 +197,8 @@ public class SenseDataHolder {
public static void resetApplicationDataHolder() { public static void resetApplicationDataHolder() {
applicationDataHolder = null; applicationDataHolder = null;
} }
public static void resetNetworkDataHolder() {
networkDataHolder = null;
}
} }

@ -35,6 +35,7 @@ import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityReceiver
import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationDataReceiver;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryDataReceiver;
import org.wso2.carbon.iot.android.sense.event.streams.call.CallDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.call.CallDataReceiver;
import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkDataReceiver;
import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenDataReceiver;
import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsDataReceiver; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsDataReceiver;
@ -51,6 +52,8 @@ public class SenseDataReceiverManager {
private static ApplicationDataReceiver appDataReceiver; private static ApplicationDataReceiver appDataReceiver;
private static NetworkDataReceiver networkDataReceiver;
private SenseDataReceiverManager() { private SenseDataReceiverManager() {
} }
@ -171,5 +174,21 @@ public class SenseDataReceiverManager {
context.unregisterReceiver(appDataReceiver); context.unregisterReceiver(appDataReceiver);
appDataReceiver = null; appDataReceiver = null;
} }
} public static void registerNetworkDataReceiver(Context context) {
if (networkDataReceiver == null) {
networkDataReceiver = new NetworkDataReceiver();
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_MANAGE_NETWORK_USAGE);
context.registerReceiver(networkDataReceiver, intentFilter);
}
}
public static void unregisterNetworkDataReceiver(Context context) {
if (networkDataReceiver != null) {
context.unregisterReceiver(networkDataReceiver);
}
networkDataReceiver = null;
} }
} }

@ -0,0 +1,43 @@
/*
* 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.
*/
package org.wso2.carbon.iot.android.sense.util.dto;
/**
* This holds api application consumer key and secret.
*/
public class ApiApplicationKey {
private String client_id;
private String client_secret;
public String getConsumerKey() {
return this.client_id;
}
public void setClient_id(String consumerKey) {
this.client_id = consumerKey;
}
public String getConsumerSecret() {
return this.client_secret;
}
public void setClient_secret(String consumerSecret) {
this.client_secret = consumerSecret;
}
}

@ -21,5 +21,5 @@ public interface ApiApplicationRegistrationService {
@POST @POST
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
String register(ApiRegistrationProfile registrationProfile); ApiApplicationKey register(ApiRegistrationProfile registrationProfile);
} }

@ -29,5 +29,5 @@ public interface TokenIssuerService {
@POST @POST
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username, AccessTokenInfo getToken(@QueryParam("grant_type") String grant, @QueryParam("username") String username,
@QueryParam("password") String password); @QueryParam("password") String password, @QueryParam("deviceId") String deviceId);
} }

@ -29,6 +29,8 @@ define stream BatteryStream (meta_owner string, meta_deviceId string, meta_times
@Export('org.wso2.iot.android.sms:1.0.0') @Export('org.wso2.iot.android.sms:1.0.0')
define stream SmsStream (meta_owner string, meta_deviceId string, meta_timestamp long, number string, type string, body string); define stream SmsStream (meta_owner string, meta_deviceId string, meta_timestamp long, number string, type string, body string);
@Export('org.wso2.geo.LocationStream:1.0.0')
define stream geoLocationStream (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float);
from AndroidSense[meta_type == 'sms'] from AndroidSense[meta_type == 'sms']
select meta_owner, meta_deviceId, meta_timestamp, sms_number as number, action as type, "" as body select meta_owner, meta_deviceId, meta_timestamp, sms_number as number, action as type, "" as body
@ -42,7 +44,7 @@ from AndroidSense[meta_type == 'audio']
select meta_owner, meta_deviceId, meta_timestamp, audio_playing, headset_on, music_volume select meta_owner, meta_deviceId, meta_timestamp, audio_playing, headset_on, music_volume
insert into AudioStream; insert into AudioStream;
from AndroidSense[meta_type == 'location'] from AndroidSense[meta_type == 'gps']
select meta_owner, meta_deviceId, meta_timestamp, gps_lat as latitude, gps_long as longitude select meta_owner, meta_deviceId, meta_timestamp, gps_lat as latitude, gps_long as longitude
insert into LocationStream; insert into LocationStream;
@ -60,4 +62,8 @@ insert into ActivityStream;
from AndroidSense[meta_type == 'data'] from AndroidSense[meta_type == 'data']
select meta_owner, meta_deviceId, meta_timestamp, data_type as type, data_received as received, data_sent as sent select meta_owner, meta_deviceId, meta_timestamp, data_type as type, data_received as received, data_sent as sent
insert into DataStream; insert into DataStream;
from AndroidSense[meta_type == 'gps']
select meta_deviceId as id, meta_timestamp as timeStamp, gps_lat as latitude, gps_long as longitude, "android_sense" as type, speed_limit as speed, 0.0f as heading
insert into geoLocationStream;

@ -64,12 +64,10 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager"; private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager";
private static final String CACHE_NAME = "mqttAuthorizationCache"; private static final String CACHE_NAME = "mqttAuthorizationCache";
private static DeviceAccessAuthorizationAdminService deviceAccessAuthorizationAdminService; private static DeviceAccessAuthorizationAdminService deviceAccessAuthorizationAdminService;
private static Cache<AuthorizationCacheKey, Boolean> cache;
public DeviceAccessBasedMQTTAuthorizer() { public DeviceAccessBasedMQTTAuthorizer() {
this.MQTTAuthorizationConfiguration = AuthorizationConfigurationManager.getInstance(); this.MQTTAuthorizationConfiguration = AuthorizationConfigurationManager.getInstance();
createCache();
deviceAccessAuthorizationAdminService = Feign.builder() deviceAccessAuthorizationAdminService = Feign.builder()
.requestInterceptor(new OAuthRequestInterceptor()) .requestInterceptor(new OAuthRequestInterceptor())
.contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder()) .contract(new JAXRSContract()).encoder(new GsonEncoder()).decoder(new GsonDecoder())
@ -92,6 +90,7 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
if (!tenantDomainFromTopic.equals(authorizationSubject.getTenantDomain())) { if (!tenantDomainFromTopic.equals(authorizationSubject.getTenantDomain())) {
return false; return false;
} }
Cache<AuthorizationCacheKey, Boolean> cache = getCache();
if (topics.length < 3) { if (topics.length < 3) {
AuthorizationCacheKey authorizationCacheKey = new AuthorizationCacheKey(tenantDomainFromTopic AuthorizationCacheKey authorizationCacheKey = new AuthorizationCacheKey(tenantDomainFromTopic
, authorizationSubject.getUsername(), "", ""); , authorizationSubject.getUsername(), "", "");
@ -207,16 +206,15 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
* This method is used to create the Caches. * This method is used to create the Caches.
* @return Cachemanager * @return Cachemanager
*/ */
private void createCache() { private synchronized Cache<AuthorizationCacheKey, Boolean> getCache() {
PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
try { try {
CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME);
if (MQTTAuthorizationConfiguration.getCacheDuration() == 0) { if (MQTTAuthorizationConfiguration.getCacheDuration() == 0) {
cache = cacheManager.getCache(CACHE_NAME); return Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME).getCache(CACHE_NAME);
} else { } else {
cache = cacheManager.<AuthorizationCacheKey, Boolean>createCacheBuilder(CACHE_NAME). return Caching.getCacheManagerFactory().getCacheManager(CACHE_MANAGER_NAME).<AuthorizationCacheKey, Boolean>createCacheBuilder(CACHE_NAME).
setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration( setExpiry(CacheConfiguration.ExpiryType.MODIFIED, new CacheConfiguration.Duration(
TimeUnit.SECONDS, MQTTAuthorizationConfiguration.getCacheDuration())). TimeUnit.SECONDS, MQTTAuthorizationConfiguration.getCacheDuration())).
setStoreByValue(false).build(); setStoreByValue(false).build();

@ -36,6 +36,7 @@
<module>appm-connector</module> <module>appm-connector</module>
<module>cdmf-transport-adapters</module> <module>cdmf-transport-adapters</module>
<module>mb-extensions</module> <module>mb-extensions</module>
<module>siddhi-extensions</module>
</modules> </modules>
<build> <build>
@ -44,7 +45,7 @@
<plugin> <plugin>
<groupId>org.apache.felix</groupId> <groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId> <artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version> <version>${maven.scr.version}</version>
<executions> <executions>
<execution> <execution>
<id>generate-scr-scrdescriptor</id> <id>generate-scr-scrdescriptor</id>

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>siddhi-extensions</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Siddhi Execution Extension - Json</name>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-api</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${wso2.maven.compiler.source}</source>
<target>${wso2.maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
org.wso2.extension.siddhi.execution.json,
org.wso2.extension.siddhi.execution.json.*
</Export-Package>
<Import-Package>
org.json,
org.wso2.siddhi.core.*,
org.wso2.siddhi.query.api.*,
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,108 @@
/*
* 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.
*/
package org.wso2.extension.siddhi.execution.json;
import org.json.JSONObject;
import org.wso2.siddhi.core.config.ExecutionPlanContext;
import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException;
import org.wso2.siddhi.core.executor.ExpressionExecutor;
import org.wso2.siddhi.core.executor.function.FunctionExecutor;
import org.wso2.siddhi.query.api.definition.Attribute;
import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException;
/**
* getProperty(json , propertyName)
* Returns the vale of the property from the given json json
* Accept Type(s): (STRING, STRING)
* Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT)
*/
public class getPropertyFunctionExtension extends FunctionExecutor {
Attribute.Type returnType = Attribute.Type.STRING;
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors,
ExecutionPlanContext executionPlanContext) {
if (attributeExpressionExecutors.length != 2) {
throw new ExecutionPlanValidationException(
"Invalid no of arguments passed to json:getProperty() function," + " required 2, but found "
+ attributeExpressionExecutors.length);
}
if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException(
"Invalid parameter type found for the first argument of json:getProperty() function, " + "required "
+ Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType()
.toString());
}
if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException(
"Invalid parameter type found for the second argument of json:getProperty() function, " + "required "
+ Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType()
.toString());
}
}
@Override
protected Object execute(Object[] data) {
if (data[0] == null) {
throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. First argument cannot be null");
}
if (data[1] == null) {
throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. Second argument cannot be null");
}
String jsonString = (String) data[0];
String property = (String) data[1];
JSONObject jsonObject = new JSONObject(jsonString);
Object value = jsonObject.get(property).toString();
return value;
}
@Override
protected Object execute(Object data) {
return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented.
}
@Override
public void start() {
//Nothing to start
}
@Override
public void stop() {
//Nothing to stop
}
@Override
public Attribute.Type getReturnType() {
return returnType;
}
@Override
public Object[] currentState() {
return null; //No need to maintain a state.
}
@Override
public void restoreState(Object[] state) {
//Since there's no need to maintain a state, nothing needs to be done here.
}
}

@ -0,0 +1,19 @@
#
# 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.
#
getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension

@ -0,0 +1,88 @@
/*
* 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.
*/
package org.wso2.extension.siddhi.execution.json;
import junit.framework.Assert;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.wso2.siddhi.core.ExecutionPlanRuntime;
import org.wso2.siddhi.core.SiddhiManager;
import org.wso2.siddhi.core.event.Event;
import org.wso2.siddhi.core.query.output.callback.QueryCallback;
import org.wso2.siddhi.core.stream.input.InputHandler;
import org.wso2.siddhi.core.util.EventPrinter;
import org.wso2.extension.siddhi.execution.json.test.util.SiddhiTestHelper;
import java.util.concurrent.atomic.AtomicInteger;
public class getPropertyFunctionTestCase {
static final Logger log = Logger.getLogger(getPropertyFunctionTestCase.class);
private AtomicInteger count = new AtomicInteger(0);
private volatile boolean eventArrived;
@Before
public void init() {
count.set(0);
eventArrived = false;
}
@Test
public void testGetPropertyFunctionExtension() throws InterruptedException {
log.info("getPropertyFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);";
String query = ("@info(name = 'query1') from inputStream select id, json:getProperty(payload, 'latitude') "
+ "as latitude insert into outputStream;");
ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
executionPlanRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
for (Event event : inEvents) {
count.incrementAndGet();
if (count.get() == 1) {
Assert.assertEquals("1.5", event.getData(1));
eventArrived = true;
}
if (count.get() == 2) {
Assert.assertEquals("67.5", event.getData(1));
eventArrived = true;
}
if (count.get() == 3) {
Assert.assertEquals("7.5", event.getData(1));
eventArrived = true;
}
}
}
});
InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
executionPlanRuntime.start();
inputHandler.send(new Object[]{"{'latitude' : 1.5, 'longitude' : 78.5}","IBM",100l});
inputHandler.send(new Object[]{"{'latitude' : 67.5, 'longitude' : 34.9}","WSO2", 200l});
inputHandler.send(new Object[]{"{'latitude' : 7.5, 'longitude' : 44.9}", "XYZ", 200l});
SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
Assert.assertEquals(3, count.get());
Assert.assertTrue(eventArrived);
executionPlanRuntime.shutdown();
}
}

@ -0,0 +1,32 @@
/*
* 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.
*/
package org.wso2.extension.siddhi.execution.json.test.util;
import java.util.concurrent.atomic.AtomicInteger;
public class SiddhiTestHelper {
public static void waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout) throws InterruptedException {
long currentWaitTime = 0;
long startTime = System.currentTimeMillis();
while ((actualCount.get() < expectedCount) && (currentWaitTime <= timeout)) {
Thread.sleep(sleepTime);
currentWaitTime = System.currentTimeMillis() - startTime;
}
}
}

@ -0,0 +1,36 @@
#
# Copyright (c) 2015, 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.
#
# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.
# The root category uses the appender called A1. Since no priority is
# specified, the root category assumes the default priority for root
# which is DEBUG in log4j. The root category is the only category that
# has a default priority. All other categories need not be assigned a
# priority in which case they inherit their priority from the
# hierarchy.
#log4j.rootLogger=DEBUG, stdout
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n
#log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %x - %m%n

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2014, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>siddhi-extensions</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - Siddhi Extension</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.extension.siddhi.execution.json</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>${maven.scr.version}</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

@ -0,0 +1,37 @@
<?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.
-->
<project name="create-geo-fence-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="androidAgent" value="android_agent_analytics-1.0.0"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<zip destfile="${target-dir}/${androidAgent}.car">
<zipfileset dir="${src-dir}"/>
</zip>
</target>
</project>

@ -0,0 +1,76 @@
<?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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>android-plugin</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.analytics</artifactId>
<name>WSO2 Carbon - IoT Android Stream C-APP</name>
<url>http://wso2.org</url>
<description>This feature contains the android streams</description>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<ant antfile="build.xml" target="zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>${project.artifactId}-${carbon.devicemgt.plugins.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/src.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,36 @@
<!--
~ 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.
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>src</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<baseDirectory>${basedir}/src</baseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/target/carbonapps</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>

@ -0,0 +1,26 @@
<?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.
-->
<eventReceiver name="Android-Agent-Event-Receiver" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.android.agent.Stream" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,22 @@
<?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="Android-Agent-Event-Receiver" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>android_agent_event_receiver.xml</file>
</artifact>

@ -0,0 +1,20 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Android-Agent-ExecutionPlan')
/* Enter a unique description for ExecutionPlan */
@Plan:description('To convert the android agent incoming stream to relvant streams')
/* define streams/tables and write queries here ... */
@Plan:trace('false')
@Import('org.wso2.android.agent.Stream:1.0.0')
define stream dataIn (deviceId string, payload string, type string);
@Export('org.wso2.geo.LocationStream:1.0.0')
define stream dataOut (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float );
from dataIn[type == 'location']
select deviceId as id, convert(json:getProperty(payload, 'timeStamp'), 'long') as timeStamp, convert(json:getProperty(payload,
'latitude'), 'double') as latitude, convert(json:getProperty(payload, 'longitude'), 'double') as longitude,
'android' as type, 0.0f as speed, 0.0f as heading insert into dataOut

@ -0,0 +1,23 @@
<?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= "Android-Agent-ExecutionPlan" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
<file>Android-Agent-ExecutionPlan.siddhiql</file>
</artifact>

@ -0,0 +1,29 @@
<?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.
-->
<artifacts>
<artifact name="android_agent_analytics" version="1.0.0" type="carbon/application">
<dependency artifact="org.wso2.android.agent.Stream" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
<dependency artifact="Android-Agent-Event-Receiver" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
<dependency artifact="Android-Agent-ExecutionPlan" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,23 @@
<?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.android.agent.Stream" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.android.agent.Stream_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.android.agent.Stream",
"version": "1.0.0",
"nickName": "",
"description": "Stream that receives various types of events from android agent",
"payloadData": [
{
"name": "deviceId",
"type": "STRING"
},
{
"name": "payload",
"type": "STRING"
},
{
"name": "type",
"type": "STRING"
}
]
}

@ -40,8 +40,7 @@ import java.util.List;
@Path("/events") @Path("/events")
public class EventReceiverServiceImpl implements EventReceiverService { public class EventReceiverServiceImpl implements EventReceiverService {
private static final String EVENT_STREAM_DEFINITION = "org.wso2.android.agent.Stream";
private static final String EVENT_STREAM_DEFINITION = "android_agent";
private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class); private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class);
@POST @POST

@ -36,6 +36,7 @@
<module>org.wso2.carbon.device.mgt.mobile.android</module> <module>org.wso2.carbon.device.mgt.mobile.android</module>
<module>org.wso2.carbon.device.mgt.mobile.android.api</module> <module>org.wso2.carbon.device.mgt.mobile.android.api</module>
<module>org.wso2.carbon.device.mgt.mobile.android.ui</module> <module>org.wso2.carbon.device.mgt.mobile.android.ui</module>
<module>org.wso2.carbon.device.mgt.mobile.android.analytics</module>
</modules> </modules>
<build> <build>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions-feature</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.extension.siddhi.execution.json.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.3-SNAPSHOT</version>
<name>WSO2 Siddhi Execution Extension - Json Feature</name>
<url>http://wso2.org</url>
<description>This feature contains Siddhi extension feature for changing a json string to individual properties.</description>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>${carbon.p2.plugin.version}</version>
<executions>
<execution>
<id>p2-feature-generation</id>
<phase>package</phase>
<goals>
<goal>p2-feature-gen</goal>
</goals>
<configuration>
<id>org.wso2.extension.siddhi.execution.json</id>
<propertiesFile>../../etc/feature.properties</propertiesFile>
<adviceFile>
<properties>
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.extension.siddhi.execution.json:${carbon.devicemgt.plugins.version}
</bundleDef>
<bundleDef>org.json.wso2:json:${commons-json.version}</bundleDef>
</bundles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -37,6 +37,7 @@
<module>org.wso2.carbon.appmgt.mdm.osgiconnector.feature</module> <module>org.wso2.carbon.appmgt.mdm.osgiconnector.feature</module>
<module>org.wso2.carbon.device.mgt.adapter.feature</module> <module>org.wso2.carbon.device.mgt.adapter.feature</module>
<module>org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature</module> <module>org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature</module>
<module>org.wso2.extension.siddhi.execution.json.feature</module>
</modules> </modules>
</project> </project>

@ -117,6 +117,18 @@
</outputDirectory> </outputDirectory>
<includes>**/*</includes> <includes>**/*</includes>
</artifactItem> </artifactItem>
<artifactItem>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.analytics
</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>
${project.build.directory}/maven-shared-archive-resources/carbonapps
</outputDirectory>
<includes>**/*</includes>
</artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>

@ -1,5 +1,7 @@
instructions.configure = \ instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/devicemgt,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/devicemgt,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/android-web-agent,target:${installFolder}/../../deployment/server/jaggeryapps/android-web-agent,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/android-web-agent,target:${installFolder}/../../deployment/server/jaggeryapps/android-web-agent,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\ org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
@ -28,4 +30,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_agent_analytics-1.0.0.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android.xml);\ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android.xml);\

@ -382,6 +382,11 @@
<!--<artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>--> <!--<artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>-->
<!--<version>${carbon.devicemgt.plugins.version}</version>--> <!--<version>${carbon.devicemgt.plugins.version}</version>-->
<!--</dependency>--> <!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
<version>${carbon.devicemgt.plugins.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId> <groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.output.adapter.mqtt</artifactId> <artifactId>org.wso2.carbon.device.mgt.output.adapter.mqtt</artifactId>
@ -1185,6 +1190,24 @@
<artifactId>feign-gson</artifactId> <artifactId>feign-gson</artifactId>
<version>${io.github.openfeign.version}</version> <version>${io.github.openfeign.version}</version>
</dependency> </dependency>
<!-- dependencies for siddhi extension -->
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-api</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -1352,6 +1375,8 @@
<io.github.openfeign.version>9.3.1</io.github.openfeign.version> <io.github.openfeign.version>9.3.1</io.github.openfeign.version>
<javax.ws.rs.jsr311-api.version>[1.1.0, 2.0.0)</javax.ws.rs.jsr311-api.version> <javax.ws.rs.jsr311-api.version>[1.1.0, 2.0.0)</javax.ws.rs.jsr311-api.version>
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version> <maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
<siddhi.version>3.1.2</siddhi.version>
<maven.scr.version>1.7.2</maven.scr.version>
</properties> </properties>
<scm> <scm>

Loading…
Cancel
Save