@ -0,0 +1,72 @@
|
||||
<?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>iot-analytics</artifactId>
|
||||
<version>3.0.3-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.wso2.carbon.iot.das.rest.api</artifactId>
|
||||
<name>WSO2 Carbon - IoT Server REST API</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-descriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
</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>
|
||||
<Private-Package>
|
||||
</Private-Package>
|
||||
<Export-Package>
|
||||
</Export-Package>
|
||||
<Import-Package>
|
||||
</Import-Package>
|
||||
<DynamicImport-Package>*</DynamicImport-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -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.
|
||||
*
|
||||
*/
|
||||
(function () {
|
||||
|
||||
response.contentType = 'application/json';
|
||||
var action = request.getParameter("action");
|
||||
var id = request.getParameter("id");
|
||||
var type = request.getParameter("type");
|
||||
var timeFrom = request.getParameter("timeFrom");
|
||||
var timeTo = request.getParameter("timeTo");
|
||||
var log = new Log();
|
||||
|
||||
var providerAPI = require('js/batch-provider-api.js');
|
||||
if (action === 'getSchema') {
|
||||
print(providerAPI.getSchema());
|
||||
return;
|
||||
} else if(action === 'getData'){
|
||||
log.info('FromTime : '+timeFrom+', toTime: '+ timeTo);
|
||||
print(providerAPI.getData(id, type, timeFrom, timeTo));
|
||||
return;
|
||||
}
|
||||
}());
|
||||
|
||||
|
||||
%>
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
var getConfig, validate, getMode, getSchema, getData, registerCallBackforPush;
|
||||
|
||||
(function () {
|
||||
|
||||
var PROVIDERS_LOCATION = '/extensions/providers/';
|
||||
|
||||
var PROVIDER_NAME = 'batch';
|
||||
var TYPE = "type";
|
||||
var TABLE_NAME = "tableName";
|
||||
var HTTPS_TRANSPORT = "https";
|
||||
var CONTENT_TYPE_JSON = "application/json";
|
||||
var AUTHORIZATION_HEADER = "Authorization";
|
||||
var USER_TOKEN = "user";
|
||||
var TENANT_DOMAIN = "domain";
|
||||
var CONST_AT = "@";
|
||||
var USERNAME = "username";
|
||||
var HTTP_USER_NOT_AUTHENTICATED = 403;
|
||||
var JS_MAX_VALUE = "9007199254740992";
|
||||
var JS_MIN_VALUE = "-9007199254740992";
|
||||
|
||||
var tableName = "ORG_WSO2_GEO_FUSEDSPATIALEVENT";
|
||||
|
||||
var typeMap = {
|
||||
"bool": "string",
|
||||
"boolean": "string",
|
||||
"string": "string",
|
||||
"int": "number",
|
||||
"integer": "number",
|
||||
"long": "number",
|
||||
"double": "number",
|
||||
"float": "number",
|
||||
"time": "time"
|
||||
};
|
||||
|
||||
var log = new Log();
|
||||
var carbon = require('carbon');
|
||||
var configs = require('/configs/designer.json');
|
||||
var utils = require('/modules/utils.js');
|
||||
var JSUtils = Packages.org.wso2.carbon.analytics.jsservice.Utils;
|
||||
var AnalyticsCachedJSServiceConnector = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector;
|
||||
var AnalyticsCache = Packages.org.wso2.carbon.analytics.jsservice.AnalyticsCachedJSServiceConnector.AnalyticsCache;
|
||||
var cacheTimeoutSeconds = 5;
|
||||
var loggedInUser = null;
|
||||
|
||||
if (configs.cacheTimeoutSeconds) {
|
||||
cacheTimeoutSeconds = parseInt(configs.cacheTimeoutSeconds);
|
||||
}
|
||||
var cacheSizeBytes = 1024 * 1024 * 1024; // 1GB
|
||||
if (configs.cacheSizeBytes) {
|
||||
cacheSizeBytes = parseInt(configs.cacheSizeBytes);
|
||||
}
|
||||
response.contentType = CONTENT_TYPE_JSON;
|
||||
|
||||
var authParam = request.getHeader(AUTHORIZATION_HEADER);
|
||||
if (authParam != null) {
|
||||
credentials = JSUtils.authenticate(authParam);
|
||||
loggedInUser = credentials[0];
|
||||
} else {
|
||||
var token = session.get(USER_TOKEN);
|
||||
if (token != null) {
|
||||
loggedInUser = token[USERNAME] + CONST_AT + token[TENANT_DOMAIN];
|
||||
} else {
|
||||
log.error("user is not authenticated!");
|
||||
response.status = HTTP_USER_NOT_AUTHENTICATED;
|
||||
print('{ "status": "Failed", "message": "User is not authenticated." }');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var cache = application.get("AnalyticsWebServiceCache");
|
||||
if (cache == null) {
|
||||
cache = new AnalyticsCache(cacheTimeoutSeconds, cacheSizeBytes);
|
||||
application.put("AnalyticsWebServiceCache", cache);
|
||||
}
|
||||
var connector = new AnalyticsCachedJSServiceConnector(cache);
|
||||
|
||||
|
||||
/**
|
||||
* returns an array of column names & types
|
||||
* @param providerConfig
|
||||
*/
|
||||
getSchema = function () {
|
||||
var schema = [];
|
||||
var result = connector.getTableSchema(loggedInUser, tableName).getMessage();
|
||||
result = JSON.parse(result);
|
||||
|
||||
var columns = result.columns;
|
||||
Object.getOwnPropertyNames(columns).forEach(function (name, idx, array) {
|
||||
var type = "ordinal";
|
||||
if (columns[name]['type']) {
|
||||
type = columns[name]['type'];
|
||||
}
|
||||
schema.push({
|
||||
fieldName: name,
|
||||
fieldType: typeMap[type.toLowerCase()]
|
||||
});
|
||||
});
|
||||
// log.info(schema);
|
||||
return schema;
|
||||
};
|
||||
|
||||
/**
|
||||
* returns the actual data
|
||||
* @param providerConfig
|
||||
* @param limit
|
||||
*/
|
||||
getData = function (deviceId, deviceType, fromTime, toTime) {
|
||||
var luceneQuery = "timeStamp:[" + fromTime + " TO " + toTime + "]";
|
||||
var limit = 100;
|
||||
var result;
|
||||
//if there's a filter present, we should perform a Lucene search instead of reading the table
|
||||
if (luceneQuery) {
|
||||
luceneQuery = 'id:"' + deviceId + '" AND type:"' + deviceType + '" AND ' + luceneQuery;
|
||||
var filter = {
|
||||
"query": luceneQuery,
|
||||
"start": 0,
|
||||
"count": limit
|
||||
};
|
||||
result = connector.search(loggedInUser, tableName, stringify(filter)).getMessage();
|
||||
} else {
|
||||
var from = JS_MIN_VALUE;
|
||||
var to = JS_MAX_VALUE;
|
||||
result = connector.getRecordsByRange(loggedInUser, tableName, from, to, 0, limit, null).getMessage();
|
||||
|
||||
}
|
||||
result = JSON.parse(result);
|
||||
var data = [];
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
var values = result[i].values;
|
||||
data.push(values);
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
}());
|
After Width: | Height: | Size: 86 B |
After Width: | Height: | Size: 5.7 KiB |
After Width: | Height: | Size: 90 B |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 3.2 KiB |
@ -0,0 +1,27 @@
|
||||
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
|
||||
.ui-timepicker-div dl { text-align: left; }
|
||||
.ui-timepicker-div dl dt { float: left; clear:left; padding: 0 0 0 5px; }
|
||||
.ui-timepicker-div dl dd { margin: 0 10px 10px 40%; }
|
||||
.ui-timepicker-div td { font-size: 90%; }
|
||||
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
|
||||
.ui-timepicker-div .ui_tpicker_unit_hide{ display: none; }
|
||||
|
||||
.ui-timepicker-rtl{ direction: rtl; }
|
||||
.ui-timepicker-rtl dl { text-align: right; padding: 0 5px 0 0; }
|
||||
.ui-timepicker-rtl dl dt{ float: right; clear: right; }
|
||||
.ui-timepicker-rtl dl dd { margin: 0 40% 10px 10px; }
|
||||
|
||||
/* Shortened version style */
|
||||
.ui-timepicker-div.ui-timepicker-oneLine { padding-right: 2px; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dt { display: none; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label { display: block; padding-top: 2px; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl { text-align: right; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd,
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd > div { display:inline-block; margin:0; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before { content:':'; display:inline-block; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,
|
||||
.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before { content:'.'; display:inline-block; }
|
||||
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,
|
||||
.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{ display: none; }
|
@ -0,0 +1,5 @@
|
||||
/*! jQuery Timepicker Addon - v1.5.3 - 2015-04-19
|
||||
* http://trentrichardson.com/examples/timepicker
|
||||
* Copyright (c) 2015 Trent Richardson; Licensed MIT */
|
||||
|
||||
.ui-timepicker-div .ui-widget-header{margin-bottom:8px}.ui-timepicker-div dl{text-align:left}.ui-timepicker-div dl dt{float:left;clear:left;padding:0 0 0 5px}.ui-timepicker-div dl dd{margin:0 10px 10px 40%}.ui-timepicker-div td{font-size:90%}.ui-tpicker-grid-label{background:0 0;border:0;margin:0;padding:0}.ui-timepicker-div .ui_tpicker_unit_hide{display:none}.ui-timepicker-rtl{direction:rtl}.ui-timepicker-rtl dl{text-align:right;padding:0 5px 0 0}.ui-timepicker-rtl dl dt{float:right;clear:right}.ui-timepicker-rtl dl dd{margin:0 40% 10px 10px}.ui-timepicker-div.ui-timepicker-oneLine{padding-right:2px}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time,.ui-timepicker-div.ui-timepicker-oneLine dt{display:none}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_time_label{display:block;padding-top:2px}.ui-timepicker-div.ui-timepicker-oneLine dl{text-align:right}.ui-timepicker-div.ui-timepicker-oneLine dl dd,.ui-timepicker-div.ui-timepicker-oneLine dl dd>div{display:inline-block;margin:0}.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_minute:before,.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_second:before{content:':';display:inline-block}.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_millisec:before,.ui-timepicker-div.ui-timepicker-oneLine dl dd.ui_tpicker_microsec:before{content:'.';display:inline-block}.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide,.ui-timepicker-div.ui-timepicker-oneLine .ui_tpicker_unit_hide:before{display:none}
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<artifact name="Geo-EventSink-FusedStream" version="1.0.0" type="analytics/eventstore" serverRole="GeoDashboard">
|
||||
<file>org_wso2_geo_FusedSpatialEvent.xml</file>
|
||||
</artifact>
|
@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<EventStoreConfiguration>
|
||||
<TableSchema>
|
||||
<ColumnDefinition>
|
||||
<Name>id</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>latitude</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>DOUBLE</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>longitude</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>DOUBLE</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>timeStamp</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>type</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>speed</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>FLOAT</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>heading</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>FLOAT</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>state</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>information</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>notify</Name>
|
||||
<IsFacet>false</IsFacet>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>BOOLEAN</Type>
|
||||
</ColumnDefinition>
|
||||
</TableSchema>
|
||||
<Source>
|
||||
<StreamId>org.wso2.geo.FusedSpatialEvent:1.0.0</StreamId>
|
||||
</Source>
|
||||
<MergeSchema>false</MergeSchema>
|
||||
<RecordStoreName>EVENT_STORE</RecordStoreName>
|
||||
</EventStoreConfiguration>
|