application-manager-new
Hasunie 8 years ago
commit 2a1db1ba69

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="GadgetLocationData" version="1.0.0" type="dashboards/gadget" serverRole="GeoDashboard">
<file>geo-dashboard</file>
</artifact>

@ -0,0 +1,69 @@
<!--~ 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.-->
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="viewWithinAlert" >
<form role="form" style="width: auto">
<div class="form-group">
<label class="text-info">Query name</label>
<div id="viewQueryName" class="well well-sm"></div>
<label class="text-info">Area name</label>
<div id="viewAreaName" class="well well-sm"></div>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</a>
</div>
<div class="btn-group">
<a id="hideViewFence" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</a>
</div>
</div>
</div>
</form>
</div>
<div id="viewStationeryAlert" >
<form role="form" style="width: auto">
<div class="form-group">
<label class="text-info">Query name</label>
<div id="viewQueryName" class="well well-sm"></div>
<label class="text-info">Stationery name</label>
<div id="viewAreaName" class="well well-sm"></div>
<label class="text-info">Stationery time(Seconds)</label>
<div id="viewAreaTime" class="well well-sm"></div>
</div>
<div>
<div class="btn-group btn-group-sm btn-group-justified">
<div class="btn-group">
<a id="exportGeoJson" download="geoJson.json" href="#" onclick="exportToGeoJSON(this,JSON.stringify(map._layers[$(this).attr('leaflet_id')].toGeoJSON(),null, '\t'))" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="Export selected area as a geoJson file">Export</a>
</div>
<div class="btn-group">
<a id="hideViewFence" class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="left" title="Hide this fence" onclick="map.removeLayer(map._layers[$(this).attr('leaflet_id')])" >Hide</a>
</div>
</div>
</div>
</form>
</div>
</body>
</html>

@ -0,0 +1,140 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Geo-ExecutionPlan-Proximity_alert')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string );
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut ( id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string );
@IndexBy('id')
define table ProximityTable(id string, timeStamp long);
@IndexBy('id')
define table AlertsTable(id string , proximityWith string, eventId string);
from dataIn#geodashboard:subscribe()
select id, latitude, longitude, timeStamp, type, speed, heading, eventId
insert into initialStream;
from initialStream[type == 'STOP']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from initialStream[type != 'STOP']
select *
insert into objectInitialStream;
from objectInitialStream#geo:proximity(id,longitude,latitude, $proximityDistance)
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith
insert into proxymityStream;
from proxymityStream[AlertsTable.id == proxymityStream.id in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
insert into innerStreamOne;
from proxymityStream[not(AlertsTable.id == proxymityStream.id in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
insert into innerStreamOne;
from proxymityStream[AlertsTable.id == proxymityStream.proximityWith in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,true as inAlertTable
insert into innerStreamSeven;
from proxymityStream[not(AlertsTable.id == proxymityStream.proximityWith in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,inCloseProximity,proximityWith,false as inAlertTable
insert into innerStreamSeven;
from innerStreamOne[inCloseProximity == true AND not(inAlertTable)]
select id,str:concat(",",proximityWith) as proximityWith , eventId
insert into AlertsTable;
from innerStreamSeven[inCloseProximity == true AND not(inAlertTable)]
select proximityWith as id,str:concat(",",id) as proximityWith , eventId
insert into AlertsTable;
from innerStreamOne[innerStreamOne.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:concat(",", innerStreamOne.proximityWith, AlertsTable.proximityWith) as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == true AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:concat(",", innerStreamSeven.id, AlertsTable.proximityWith) as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
from innerStreamOne[innerStreamOne.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamOne.id == AlertsTable.id
select innerStreamOne.id as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamOne.proximityWith), "") as proximityWith, innerStreamOne.eventId as eventId
insert into updateStream;
from innerStreamSeven[innerStreamSeven.inCloseProximity == false AND inAlertTable]#window.length(0) join AlertsTable
on innerStreamSeven.proximityWith == AlertsTable.id
select innerStreamSeven.proximityWith as id, str:replaceAll(AlertsTable.proximityWith, str:concat(",", innerStreamSeven.id), "") as proximityWith, innerStreamSeven.eventId as eventId
insert into updateStream;
from updateStream
select *
update AlertsTable
on id== AlertsTable.id;
from updateStream[proximityWith == ""]
delete AlertsTable
on id== AlertsTable.id;
from objectInitialStream[AlertsTable.id == objectInitialStream.id in AlertsTable]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, true as inAlertTable
insert into publishStream;
from objectInitialStream[not(AlertsTable.id == objectInitialStream.id in AlertsTable)]
select id, latitude, longitude, timeStamp, type, speed, heading, eventId, false as inAlertTable
insert into publishStream;
from publishStream[inAlertTable == true]#window.length(0) join AlertsTable
on publishStream.id== AlertsTable.id
select publishStream.id as id, publishStream.latitude as latitude, publishStream.longitude as longitude, publishStream.timeStamp as timeStamp, publishStream.type as type, publishStream.speed as speed, publishStream.heading as heading, publishStream.eventId as eventId, AlertsTable.proximityWith as proximityInfo
insert into innerStreamTwo;
from publishStream[inAlertTable == false]
delete ProximityTable on ProximityTable.id==id;
from publishStream[inAlertTable == false]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from innerStreamTwo[ProximityTable.id == innerStreamTwo.id in ProximityTable]
insert into innerStreamThree;
from innerStreamThree#window.length(0) join ProximityTable
on innerStreamThree.id == ProximityTable.id
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId, ProximityTable.timeStamp as storedTime, innerStreamThree.proximityInfo as proximityInfo
insert into innerStreamFour;
from innerStreamFour[(timeStamp - storedTime) >= $proximityTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,proximityInfo,"true" as isProximity
insert into dataOutStream;
from innerStreamFour[(timeStamp - storedTime) < $proximityTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , proximityInfo ,"false" as isProximity
insert into dataOutStream;
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
select innerStreamTwo.id, innerStreamTwo.timeStamp
insert into ProximityTable;
from innerStreamTwo[not(ProximityTable.id == innerStreamTwo.id in ProximityTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "" as proximityInfo ,"false" as isProximity
insert into dataOutStream;
from dataOutStream[isProximity == 'true']
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,"WARNING" as state,str:concat("Proximity with "," ",proximityInfo) as information
insert into dataOut;
from dataOutStream[isProximity == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
insert into dataOut;

@ -0,0 +1,20 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Geo-ExecutionPlan-Speed---$deviceId_alert')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string, speed float, heading float, eventId string, state string, information string);
from dataIn[speed >= $speedAlertValue and id == "$deviceId"]#geodashboard:subscribe()
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "ALERTED" as state, "This device movement is not normal!!" as information
insert into dataOut;
from dataIn[speed < $speedAlertValue and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type ,speed, heading ,eventId , "NORMAL" as state, "This device movement is normal" as information
insert into dataOut;

@ -0,0 +1,89 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
@IndexBy('id')
define table StationeryTable(id string, timeStamp long);
@IndexBy('id')
define table AlertsTable(id string, stationary bool);
from dataIn#geodashboard:subscribe()
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,geo:within(longitude,latitude,"$geoFenceGeoJSON") as isWithin
insert into innerStreamOne;
from innerStreamOne[isWithin == false]
delete StationeryTable on StationeryTable.id==id;
from innerStreamOne[isWithin == false]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true]#geo:stationary(id,longitude,latitude, $fluctuationRadius)
select id, latitude, longitude, timeStamp, type, speed, heading, eventId,stationary
insert into innerStreamTwo;
from innerStreamTwo[innerStreamTwo.stationary == true]
select innerStreamTwo.id, innerStreamTwo.stationary
insert into AlertsTable;
from innerStreamTwo[innerStreamTwo.stationary == false]
delete AlertsTable on AlertsTable.id==id;
from innerStreamTwo[innerStreamTwo.stationary == false]
delete StationeryTable on StationeryTable.id==id;
from innerStreamOne[isWithin == true AND not(AlertsTable.id == innerStreamOne.id in AlertsTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true AND AlertsTable.id == innerStreamOne.id in AlertsTable]
insert into innerStreamThree;
from innerStreamThree#window.length(0) join AlertsTable
on innerStreamThree.id == AlertsTable.id
select innerStreamThree.id , innerStreamThree.latitude, innerStreamThree.longitude,innerStreamThree.timeStamp, innerStreamThree.type, innerStreamThree.speed, innerStreamThree.heading ,innerStreamThree.eventId
insert into innerStreamFour;
from innerStreamFour[not(StationeryTable.id == innerStreamFour.id in StationeryTable)]
select innerStreamFour.id, innerStreamFour.timeStamp
insert into StationeryTable;
from innerStreamOne[isWithin == true AND not(StationeryTable.id == innerStreamOne.id in StationeryTable)]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "false" as isStationary
insert into dataOutStream;
from innerStreamOne[isWithin == true AND StationeryTable.id == innerStreamOne.id in StationeryTable]
insert into innerStreamFive;
from innerStreamFive#window.length(0) join StationeryTable
on innerStreamFive.id == StationeryTable.id
select innerStreamFive.id , innerStreamFive.latitude, innerStreamFive.longitude,innerStreamFive.timeStamp, innerStreamFive.type, innerStreamFive.speed, innerStreamFive.heading ,innerStreamFive.eventId, StationeryTable.timeStamp as storedTime
insert into innerStreamSix;
from innerStreamSix[(timeStamp - storedTime) >= $stationeryTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"true" as isStationary
insert into dataOutStream;
from innerStreamSix[(timeStamp - storedTime) < $stationeryTime]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"false" as isStationary
insert into dataOutStream;
from dataOutStream[isStationary == 'true']
select id ,latitude, longitude,timeStamp, type, speed, heading ,eventId ,"ALERTED" as state, "This device is in $stationeryName area!!!" as information
insert into dataOut;
from dataOutStream[isStationary == 'false']
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId ,"NORMAL" as state,"" as information
insert into dataOut;

@ -0,0 +1,17 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('rawGeoStream:1.0.0')
define stream dataIn (id string, timeStamp long, geometry string, state string, information string);
@Export('AlertsNotifications:1.0.0')
define stream dataOut (id string, state string, information string, timeStamp long, latitude double, longitude double);
from dataIn[geo:intersects(geometry, "$geoFenceGeoJSON")==true and geodashboard:needToNotify(id, str:concat(information, state), "sendFirst") == true and id == $deviceId]
select id, state, str:concat("Traffic alert in $areaName. State: ", state, " ", information) as information, timeStamp, 0.0 as latitude, 0.0 as longitude
insert into dataOut

@ -0,0 +1,20 @@
/* Enter a unique ExecutionPlan */
@Plan:name('$executionPlanName')
/* Enter a unique description for ExecutionPlan */
-- @Plan:description('ExecutionPlan')
/* define streams/tables and write queries here ... */
@Import('org.wso2.geo.StandardSpatialEvents:1.0.0')
define stream dataIn (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string);
@Export('org.wso2.geo.ProcessedSpatialEvents:1.0.0')
define stream dataOut (id string, latitude double, longitude double, timeStamp long, type string ,speed float, heading float, eventId string, state string, information string);
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")==true and id == "$deviceId"]#geodashboard:subscribe()
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "ALERTED" as state, "This device is in $areaName restricted area!!!" as information
insert into dataOut;
from dataIn[geo:within(longitude,latitude,"$geoFenceGeoJSON")!=true and id == "$deviceId"]
select id , latitude, longitude,timeStamp, type, speed, heading ,eventId , "NORMAL" as state, "" as information
insert into dataOut;

@ -0,0 +1,97 @@
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.point {
stroke: #000;
}
form {
margin-top: 25px;
text-align: center;
}
.slider {
width: 80%;
display: block;
margin: 0 auto;
}
output {
display: block;
margin: 25px auto;
font-size:2em;
}
div.tooltip {
position: absolute;
text-align: center;
width: 60px;
height: 28px;
padding: 2px;
font: 12px sans-serif;
background: lightsteelblue;
border: 0px;
border-radius: 8px;
pointer-events: none;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.bar {
fill: orange;
}
.bar:hover {
fill: orangered ;
}
.x.axis path {
display: none;
}
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 12px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
z-index: 1000;
}
/* Creates a small triangle extender for the tooltip */
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
/* Style northward tooltips differently */
.d3-tip.n:after {
margin: -1px 0 0 0;
top: 100%;
left: 0;
}
.btn-space {
margin-right: 30px;
margin-bottom: 10px;
margin-top: 10px;
}
.element-space{
margin-right: 30px;
margin-bottom: 10px;
margin-top: 10px;
}

@ -0,0 +1,26 @@
{
"id": "geo-dashboard",
"title": "Geo Dashboard",
"type": "widget",
"thumbnail": "gadget/geo-dashboard/img/thumbnail.png",
"settings": {
"personalize": true
},
"data": {
"url": "gadget/geo-dashboard/index.xml"
},
"styles": {
"borders": false,
"title": false
},
"notify": {
"select": {
"type": "address",
"description": "This notifies selected state"
},
"cancel": {
"type": "boolean",
"description": "This notifies cancellation of state selection"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

@ -0,0 +1,31 @@
<%
/*
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
*/
var escapeSiddhiql = function (s) {
XML_CHAR_MAP = {
'<': '&lt;',
'>': '&gt;',
'&': '&amp;',
'"': '&quot;',
"'": '&apos;'
};
return s.replace(/[<>&"']/g, function (ch) {
return XML_CHAR_MAP[ch];
});
};
%>

@ -0,0 +1,165 @@
<%
/*
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
*/
// TODO: change the name of this jaggery file even thoe it says 'store_alerts' it is actually removing the alerts from the data store as well o.O wired
var log = new Log();
var constants = require("../controllers/constants.jag");
var getRegistry = function() {
var carbon = require("carbon");
var server = new carbon.server.Server();
return new carbon.registry.Registry(server, {
system: true
});
};
/**
* Get the registry path to save the alert
* @param {String} alert_type Type of the alert
* @param {String} id Id of the device
* @param {String} optional /optional identity
* @return {String} Registry Path to save teh alert
* */
var registryPath = function (alert_type, id, optional) {
if (alert_type && id ) {
if (alert_type === constants.EXECUTION_PLAN_TYPE_SPEED || alert_type === constants
.EXECUTION_PLAN_TYPE_PROXIMITY) {
return constants.REGISTRY_PATH_FOR_ALERTS + alert_type + "/" + id;
} else {
return constants.REGISTRY_PATH_FOR_ALERTS + alert_type + "/" + id + "/" + optional;
}
} else {
throw "Alert type and ID are mandatory field to generate the relevant registry path";
}
};
/**
* To store the alerts for visualizing purposes
* @param resourceContents Value that need to saved
* @param executionPlan Type of the execution plan
* @param optional Optional parameters that are only specific to particular device types
* @param deviceId Id of the device
*/
function store(resourceContents, executionPlan, optional, deviceId) {
var registry = getRegistry();
var pathToAddAlert = "";
if (log.isDebugEnabled()) {
log.debug("DEBUG:*** resourceContents:" + resourceContents);
}
if (executionPlan === constants.EXECUTION_PLAN_TYPE_SPEED) {
pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_SPEED, deviceId);
registry.put(pathToAddAlert, {
content: '{"speedLimit": ' + resourceContents + '}',
mediaType: 'application/json'
});
if (log.isDebugEnabled()) {
log.debug("DEBUG:*** Current speed limit set to:" + currentLimit.content);
}
}
else if (executionPlan === constants.EXECUTION_PLAN_TYPE_WITHIN) {
pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_WITHIN, deviceId, optional.queryName);
if (log.isDebugEnabled()) {
log.debug("DEBUG:****** resourceContents = " + String('{"geoJson": ' + resourceContents + '}'));
}
registry.put(pathToAddAlert, {
content: JSON.stringify(resourceContents),
mediaType: 'application/json',
properties : {
"queryName" : optional.queryName,
"areaName" : optional.customName
}
});
} else if (executionPlan === constants.EXECUTION_PLAN_TYPE_PROXIMITY) {
pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_PROXIMITY, deviceId);
if (log.isDebugEnabled()) {
log.debug("DEBUG:****** resourceContents = " + resourceContents);
}
registry.put(pathToAddAlert, {
content: "",
mediaType: 'application/json'
});
registry.addProperty(pathToAddAlert, "proximityDistance", resourceContents.proximityDistance);
registry.addProperty(pathToAddAlert, "proximityTime", resourceContents.proximityTime);
} else if (executionPlan === constants.EXECUTION_PLAN_TYPE_STATIONARY) {
pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_STATIONARY, deviceId, optional.queryName);
if (log.isDebugEnabled()) {
log.debug("DEBUG:****** resourceContents = " + resourceContents);
}
var registryResource = {
content: JSON.stringify(resourceContents.geoFenceGeoJSON),
mediaType: 'application/json',
properties: {
"queryName" : optional.queryName,
"stationeryName" : optional.customName,
"stationeryTime" : resourceContents.stationeryTime,
"fluctuationRadius" : resourceContents.fluctuationRadius
}
};
registry.put(pathToAddAlert, registryResource);
} else if (executionPlan === constants.EXECUTION_PLAN_TYPE_TRAFFIC) {
pathToAddAlert = registryPath(constants.EXECUTION_PLAN_TYPE_TRAFFIC, deviceId, optional.queryName);
if (log.isDebugEnabled()) {
log.debug("DEBUG:****** resourceContents = " + resourceContents.geoFenceGeoJSON);
}
var registryResource = {
content: JSON.stringify(resourceContents),
mediaType: 'application/json',
properties: {
"queryName" : optional.queryName,
"stationeryName" : optional.customName,
"stationeryTime" : resourceContents.stationeryTime,
"fluctuationRadius" : resourceContents.fluctuationRadius
}
};
registry.put(pathToAddAlert, {
content: JSON.stringify(resourceContents),
mediaType: 'application/json',
properties: {
"queryName" : optional.queryName,
"areaName" : optional.customName
}
});
}
}
/**
* To remove the registry resource
* @param queryName Name of the query that need to be removed
* @param executionPlanType type of the execution plan that need to be removed
* @param deviceId Id of the device
*/
function remove(queryName, executionPlanType, deviceId) {
var path = "";
try {
if (executionPlanType === constants.EXECUTION_PLAN_TYPE_SPEED || executionPlanType === constants.EXECUTION_PLAN_TYPE_PROXIMITY) {
path = registryPath(executionPlanType, deviceId);
} else {
path = registryPath(executionPlanType, deviceId, queryName);
}
getRegistry().remove(path);
if (log.isDebugEnabled()) {
log.debug("Resource is removed from the path" + path);
}
}
catch (e) {
log.error("The requested resource " + path + " was not found on this server.");
}
}
%>

@ -0,0 +1,196 @@
<?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.
-->
<Module>
<ModulePrefs title="Location Data" description="Location Data">
<Require feature="dynamic-height" />
<Require feature="dynamic-width" />
<Require feature="wso2-gadgets-identity" />
<Require feature="wso2-gadgets-state" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<html>
<meta charset="utf-8">
<head>
<link rel="stylesheet" href="css/style.css">
</head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="lib/js/jquery.js"></script>
<body>
<link rel="stylesheet" href="lib/css/bootstrap.css">
<script src="lib/js/bootstrap.js"></script>
<script src="lib/js/d3.js"></script>
<script src="js/RestCaller.js"></script>
<script src="js/graph.js"></script>
<script src="js/traffic.js"></script>
<script src="lib/js/d3tip.js"></script>
<script>
var imageX=-30;
var imageY=-5
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 1400 - margin.left - margin.right,
height = 744 - margin.top - margin.bottom;
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.linear()
.range([0,height]);
loadImage(imageX,imageY);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
loadImage(imageX,imageY);
getDimension();
GetInitStartTime();
GetEndTime();
</script>
<div class="well">
<div class="container">
<div class="col-sm-4">
<h3 class="text-primary">Select Time</h3>
<input class="slider form-control input-sm" type="range" id="valueSlider" value="" step="1000" min="01170000853070" max="01172715042247" oninput="outputUpdate(value)">
<output for=value id="output" hidden="true"></output>
<output id="calenderDate"></output>
<div hidden="true">
<label for="stt">Starting Time</label>
<input id="stt" name="stt" onchange="show()">
</div>
</div>
<div class="col-sm-5">
<h3 class="text-primary">Select Duration</h3>
<select class="form-control input-sm-4" id="gap" name="gap" onclick="changeStep()">
<option value=1000>1s</option>
<option value=5000>5s</option>
<option value=15000>15s</option>
<option value=30000>30s</option>
<option value=60000>1min</option>
<option value=300000>5min</option>
<option value=600000>10min</option>
<option value=3600000>1hour</option>
<option value=7200000>2hour</option>
<option value=86400000>1day</option>
</select>
</br>
<button class="btn btn-default btn-space" onclick="show() "style="align-content: center;width: 110px;height: 40px" >Show</button>
<button class="btn btn-default btn-space" onclick="showPrevious()"style="align-content: center;width: 110px;height: 40px">Previous</button>
<button class="btn btn-default btn-space" onclick="showNext()"style="align-content: center;width: 110px;height: 40px">Next</button>
<button class="btn btn-primary btn-space" onclick="play()"style="align-content: center;width: 110px;height: 40px">Play</button>
<button class="btn btn-default btn-space" onclick="showDensity()"style="align-content: center;width: 110px;height: 40px">Show Density</button>
<button class="btn btn-default btn-space" onclick="display()"style="align-content: center;width: 110px;height: 40px">Reset</button>
</div>
</div>
</div>
<div class="well">
<div class="container">
<div class="col-sm-4">
<div class="container">
<h3 class="text-primary">Typical Scenario</h3>
<select class="form-control input-sm-4 element-space" id="time" name="time" style="width: 200px" >
<option value=00>0AM</option>
<option value=01>1AM</option>
<option value=02>2AM</option>
<option value=03>3AM</option>
<option value=04>4AM</option>
<option value=05>5AM</option>
<option value=06>6AM</option>
<option value=07>7AM</option>
<option value=08>8AM</option>
<option value=09>9AM</option>
<option value=10>10AM</option>
<option value=11>11AM</option>
<option value=12>12AM</option>
<option value=13>1PM</option>
<option value=14>2PM</option>
<option value=15>3PM</option>
<option value=16>4PM</option>
<option value=17>5PM</option>
<option value=18>6PM</option>
<option value=19>7PM</option>
<option value=20>8PM</option>
<option value=21>9PM</option>
<option value=22>10PM</option>
<option value=23>11PM</option>
</select>
<select class="form-control input-sm-4 element-space" id="day" name="day" style="width: 200px" >
<option value=mon>Monday</option>
<option value=tue>Tuesday</option>
<option value=wed>Wednesday</option>
<option value=thu>Thursday</option>
<option value=fri>Friday</option>
<option value=sat>Saturday</option>
<option value=sun>Sunday</option>
</select>
<button class="btn btn-primary element-space" onclick="showScene()"style="align-content: center;width: 110px;height: 40px" >View Scenario</button>
</div>
</div>
<div class="col-sm-4 " >
<h3 class="text-primary">Upload Data file</h3>
<input class="form-control input-sm-4 element-space" id="fileupload" type="file" />
<Button class="btn btn-primary element-space" onclick="sendFile()" id="submit" style="align-content: center;width: 110px;height: 40px">Submit</Button>
</div>
<div class="col-sm-4 " >
<h3 class="text-primary">Change Image</h3>
<button class="btn btn-default btn-space" onclick="changeImage(0,1)"style="align-content: center;width: 110px;height: 40px" >Up</button>
<button class="btn btn-default btn-space" onclick="changeImage(0,-1)"style="align-content: center;width: 110px;height: 40px">Down</button>
<button class="btn btn-default btn-space" onclick="changeImage(1,0)"style="align-content: center;width: 110px;height: 40px">Left</button>
<button class="btn btn-default btn-space" onclick="changeImage(-1,0)"style="align-content: center;width: 110px;height: 40px">Right</button>
<button class="btn btn-default btn-space" onclick="showDensity()"style="align-content: center;width: 110px;height: 40px">Show Density</button>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade row-fluid" id="frequency_view" role="dialog" >
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="width: 1000px">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Sensor Triggered Frequencies</h4>
</div>
<div id="modal_body" name="modal_body" class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>
]]>
</Content>
</Module>

@ -0,0 +1,478 @@
require("lib/js/d3.js");
require("js/graph.js");
require("js/traffic.js");
require("lib/js/d3tip.js");
var GetInitStartTime = function () {
$.ajax({
url: 'http://localhost:8080/service/time/start',
type: 'GET',
dataType:'json',
success: function(data) {
var start =JSON.parse(JSON.stringify(data.stt));
document.getElementById("stt").value=start;
var valueSlider =document.getElementById("valueSlider");
valueSlider.innerHTML=start;
valueSlider.value=start;
valueSlider.min=parseInt(start);
setCalendarDate(start);
//alert(JSON.stringify(data));
},
error:function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
var GetEndTime = function () {
$.ajax({
url: 'http://localhost:8080/service/time/end',
type: 'GET',
dataType:'json',
success: function(data) {
var end =JSON.parse(JSON.stringify(data.stt));
document.getElementById("valueSlider").max =end;
show();
//alert(JSON.stringify(data));
},
error:function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
var show = function () {
var start = parseInt(document.getElementById('stt').value);
document.getElementById('valueSlider').value = start;
var end = start + parseInt(document.getElementById('gap').value);
var data2 = [];
$.ajax({
url: 'http://localhost:8080/service/data',
type: 'GET',
data: 'start=' + start + '&end=' + end, // or $('#myform').serializeArray()
dataType: 'json',
success: function (data) {
var X = JSON.parse(JSON.stringify(data.map.X.myArrayList));
var Y = JSON.parse(JSON.stringify(data.map.Y.myArrayList));
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i]});
}
draw(data2);
//alert(JSON.stringify(data));
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
function sendFile() {
var file = document.getElementById('fileupload').files[0];
var fd = new FormData();
fd.append( 'file', file);
$.ajax({
url: 'http://localhost:8080/service/file/upload',
data: fd,
processData: false,
contentType: false,
type: 'POST',
success: function(data) {
alert("file upload sucessfull");
GetInitStartTime();
GetEndTime();
show();
//alert(JSON.stringify(data));
},
error:function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
function getDimension() {
var url;
var value;
$.ajax({
url: 'http://localhost:8080/service/get/dimension',
type: 'GET',
dataType: 'json',
success: function (data) {
Xmax = JSON.parse(JSON.stringify(data.maxX));
Ymax = JSON.parse(JSON.stringify(data.maxY));
Xmin = JSON.parse(JSON.stringify(data.minX));
Ymin = JSON.parse(JSON.stringify(data.minY));
x.domain(d3.extent([Xmin,Xmax])).nice();
y.domain(d3.extent([Ymin,Ymax])).nice();
return value;
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
})
x.domain(d3.extent([-50,50])).nice();
y.domain(d3.extent([-100,100])).nice();
}
function play(start,chunk) {
var start=parseInt(document.getElementById('stt').value);
var chunk =parseInt(document.getElementById('gap').value)
var end = parseInt(start) + (500*parseInt(chunk));
// var data2 =[];
var xList,yList,tList,cList;
$.ajax({
url: 'http://localhost:8080/service/data/chunk',
type: 'GET',
data: 'start='+start+'&end='+end, // or $('#myform').serializeArray()
dataType:'json',
success: function(data) {
alert("data loaded");
xList=JSON.parse(JSON.stringify(data.X));
yList=JSON.parse(JSON.stringify(data.Y));
tList=JSON.parse(JSON.stringify(data.T));
cList=JSON.parse(JSON.stringify(data.C));
var i=0;
while(i<500){
var s=parseInt(start)+(i*1000);
doScaledTimeout(i,s,tList,chunk,xList,yList,cList);
i+=1;
}
},
error:function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
var draw=function (data) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+parseFloat(d.c)};
});
});
// Compute the scales domains.
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"))
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(isNaN(d.c)){
return colorRed(50);
}
return d3.rgb(255,d.c*255/100,d.c*255/100);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));})
};
function require(script) {
$.ajax({
url: script,
dataType: "script",
async: false,
success: function () {
},
error: function () {
throw new Error("Could not load script " + script);
}
});
}
function showDensity() {
var start = parseInt(document.getElementById('stt').value);
document.getElementById('valueSlider').value = start;
var end = start + parseInt(document.getElementById('gap').value);
var data2 = [];
$.ajax({
url: 'http://localhost:8080/service/data/density',
type: 'GET',
data: 'start=' + parseInt(document.getElementById('stt').value) + '&end=' +(parseInt(document.getElementById('stt').value)+ parseInt(document.getElementById('gap').value)), // or $('#myform').serializeArray()
dataType: 'json',
success: function (data) {
var X = JSON.parse(JSON.stringify(data.map.X.myArrayList));
var Y = JSON.parse(JSON.stringify(data.map.Y.myArrayList));
var D = JSON.parse(JSON.stringify(data.map.D.myArrayList));
var ID = JSON.parse(JSON.stringify(data.map.ID.myArrayList));
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i], c:parseInt(D[i]), id:ID[i]});
}
var max=D[0];
var min=D[0];
for (j=1;j<X.length;j++){
if(D[j]>max){
max=D[j];
}
if(D[j]<min){
min=D[j];
}
}
drawDensity(data2,max,min);
//alert(JSON.stringify(data));
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
var drawDensity=function (data,max,min) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+(parseFloat(d.c)-min)*100/(max-min), id:parseInt(d.id)};
});
});
// Compute the scales domains.
x.domain(d3.extent([-71,40])).nice();
y.domain(d3.extent([4,65])).nice();
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(d.c==0){
return d3.rgb(255,255,255);
}
else if(d.c>20){
return colorRed(d.c);
}
else if(d.c>10){
return colorBlue(d.c);
}
else if(d.c>=0){
return colorGreen(d.c);
}
else{
return d3.rgb(255,255,255);
}
})
.on("mouseover", function(d) {
tooltip.transition()
.duration(200)
.style("opacity", .9);
tooltip.html((d.c).toFixed(2) )
.style("left", (x(parseInt(d.x)) + "px"))
.style("top", (y(parseInt(d.y)) + "px"));
})
.on("mouseout", function(d) {
tooltip.transition()
.duration(500)
.style("opacity", 0);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));})
.on("click",function (d){
var id=d.id;
getFrequency(id);
});
};
function getFrequency(id) {
var start = parseInt(document.getElementById('stt').value);
document.getElementById('valueSlider').value = start;
var gap = parseInt(document.getElementById('gap').value);
var data1 = [];
$.ajax({
url:'http://localhost:8080/service/data/count',
type: 'GET',
data: 'start=' + start + '&gap=' + gap + '&sensor=' + id, // or $('#myform').serializeArray()
dataType: 'json',
success: function (data) {
var count = JSON.parse(JSON.stringify(data.map.Count.myArrayList));
for (i = 0; i < count.length; i++) {
var gap = parseInt(document.getElementById('gap').value);
data1.push({x: tsToCal(gap,(gap*i)+start+(gap/2.0)), y: count[i]});
}
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +i, y: d.y};
});
});
var stt = parseInt(document.getElementById("stt").value);
var gap = parseInt(document.getElementById("gap").value);
d3.select("#barChart").remove();
var margin = {top: 40, right: 20, bottom: 30, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var svg2 = d3.select("#modal_body").append("svg")
.attr("id","barChart")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function (d) {
return d.y;
});
svg2.call(tip);
x.domain(data1.map(function(d) {
return d.x; }));
y.domain([0, d3.max(data1, function(d) {
return d.y; })]);
svg2.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg2.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Frequency");
svg2.selectAll(".bar")
.data(data1)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) {return x(d.x); })
.attr("width", x.rangeBand())
.attr("y", function(d) {return y(d.y); })
.attr("height", function(d) { return height - y(d.y); })
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
function type(d) {
d.y = +d.y;
return d;
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
$("#frequency_view").modal("show");
}

@ -0,0 +1,111 @@
/**
* Created by dimuth on 10/25/16.
*/
function setCalendarDate(start){
var calendarTime=timeStampToCalendarDate(start);
document.getElementById("calenderDate").innerHTML=calendarTime;
}
var showNext =function () {
var currentStart = parseInt(document.getElementById('stt').value);
var duration = parseInt(document.getElementById('gap').value);
document.getElementById("stt").value =currentStart+duration;
show();
};
var showPrevious =function () {
var currentStart = parseInt(document.getElementById('stt').value);
var duration = parseInt(document.getElementById('gap').value);
document.getElementById("stt").value =currentStart-duration;
show();
};
function outputUpdate(num) {
document.querySelector('#output').value = num;
document.getElementById('stt').value =num;
setCalendarDate(num);
show();
}
function changeStep() {
document.getElementById("valueSlider").step =document.getElementById("gap").value;
}
function timeStampToCalendarDate(time) {
var date = new Date(parseInt(time));
var Months =["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
return date.getFullYear()+" "+Months[date.getMonth()]+" "+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
}
function showChunk(start,chunk,tList,xList,yList) {
var data2=[];
var gap=document.getElementById("gap").value;
var e=parseInt(start)+parseInt(chunk);
for(i=0;i<tList.length;i++ ){
if(parseInt(tList[i])<e && parseInt(tList[i])>parseInt(start)){
data2.push({x:xList[i] ,y:yList[i], c:((e-parseInt(tList[i]))*100/parseInt(gap))});
}
}
return data2;
}
function doScaledTimeout(j,start,tList,chunk,xList,yList,cList) {
setTimeout(function() {
document.getElementById('stt').value=start;
document.getElementById('output').value=start;
setCalendarDate(start);
var data2=showChunk(start,chunk,tList,xList,yList,cList);
draw(data2);
}, j * 300);
}
colorRed = d3.scale.linear().domain([20,100])
.interpolate(d3.interpolateHcl)
.range([d3.rgb('#F99FA2'),d3.rgb("#F72128"),]);
colorBlue = d3.scale.linear().domain([10,20])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#00C1FF"),d3.rgb('#6670AC')]);
colorGreen = d3.scale.linear().domain([10,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#0A7E03"),d3.rgb('#0FF300')]);
var tooltip = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
function tsToCal(gap,time) {
var date = new Date(parseInt(time));
var Months =["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
if(gap < 60000){
return date.getMinutes()+":"+date.getSeconds();
}
else if(gap <=7200000) {
return Months[date.getMonth()]+" "+date.getDate() + " " + date.getHours() + ":" + date.getMinutes();
}
else{
return date.getFullYear()+" "+Months[date.getMonth()]+" "+date.getDate();
}
}
function display() {
window.location.reload();
};
function loadImage(x,y) {
var image = d3.select("g").append("svg:image")
.attr("xlink:href", "img/floor.jpg")
.attr("width", 1500)
.attr("height", 699)
.attr("x",x)
.attr("y",y);
}
function changeImage(x,y) {
imageX=imageX+x;
imageY=imageY+y;
loadImage(imageX,imageY);
}
colorData = d3.scale.linear().domain([10,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb(125,0,0),d3.rgb(255,0,0)]);

@ -0,0 +1,130 @@
/**
* Created by dimuth on 11/2/16.
*/
var drawScene=function (data) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+(parseFloat(d.c)), id:parseInt(d.id)};
});
});
// Compute the scales domains.
x.domain(d3.extent([-71,40])).nice();
y.domain(d3.extent([4,65])).nice();
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(d.c==0){
return d3.rgb(255,255,255);
}
else if(d.c>10){
return colorRed(d.c);
}
else if(d.c>3){
return colorBlue(d.c);
}
else if(d.c>=0){
return colorGreen(d.c);
}
else{
return d3.rgb(255,255,255);
}
})
.on("mouseover", function(d) {
tooltip.transition()
.duration(200)
.style("opacity", .9);
tooltip.html((d.c).toFixed(2) )
.style("left", (x(parseInt(d.x)) + "px"))
.style("top", (y(parseInt(d.y)) + "px"));
})
.on("mouseout", function(d) {
tooltip.transition()
.duration(500)
.style("opacity", 0);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));});
};
function showScene() {
var data2 = [];
$.ajax({
url: 'http://localhost:8080/service/typical/scene',
type: 'GET',
data: 'hour=' + document.getElementById('time').value + '&day=' +document.getElementById('day').value, // or $('#myform').serializeArray()
dataType: 'json',
success: function (data) {
var X = JSON.parse(JSON.stringify(data.X));
var Y = JSON.parse(JSON.stringify(data.Y));
var C = JSON.parse(JSON.stringify(data.C));
var ID = JSON.parse(JSON.stringify(data.ID));
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i], c:C[i], id:ID[i]});
}
drawScene(data2);
//alert(JSON.stringify(data));
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
};
colorRed2 = d3.scale.linear().domain([10,100])
.interpolate(d3.interpolateHcl)
.range([d3.rgb('#F99FA2'),d3.rgb("#F72128"),]);
colorBlue2 = d3.scale.linear().domain([3,10])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#00C1FF"),d3.rgb('#6670AC')]);
colorGreen2 = d3.scale.linear().domain([3,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#0A7E03"),d3.rgb('#0FF300')]);

File diff suppressed because it is too large Load Diff

@ -0,0 +1,352 @@
/**
* d3.tip
* Copyright (c) 2013 Justin Palmer
*
* Tooltips for d3.js SVG visualizations
*/
// eslint-disable-next-line no-extra-semi
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module with d3 as a dependency.
define([
'd3-collection',
'd3-selection'
], factory)
} else if (typeof module === 'object' && module.exports) {
/* eslint-disable global-require */
// CommonJS
var d3Collection = require('d3-collection'),
d3Selection = require('d3-selection')
module.exports = factory(d3Collection, d3Selection)
/* eslint-enable global-require */
} else {
// Browser global.
var d3 = root.d3
// eslint-disable-next-line no-param-reassign
root.d3.tip = factory(d3, d3)
}
}(this, function(d3Collection, d3Selection) {
// Public - contructs a new tooltip
//
// Returns a tip
return function() {
var direction = d3TipDirection,
offset = d3TipOffset,
html = d3TipHTML,
rootElement = document.body,
node = initNode(),
svg = null,
point = null,
target = null
function tip(vis) {
svg = getSVGNode(vis)
if (!svg) return
point = svg.createSVGPoint()
rootElement.appendChild(node)
}
// Public - show the tooltip on the screen
//
// Returns a tip
tip.show = function() {
var args = Array.prototype.slice.call(arguments)
if (args[args.length - 1] instanceof SVGElement) target = args.pop()
var content = html.apply(this, args),
poffset = offset.apply(this, args),
dir = direction.apply(this, args),
nodel = getNodeEl(),
i = directions.length,
coords,
scrollTop = document.documentElement.scrollTop ||
rootElement.scrollTop,
scrollLeft = document.documentElement.scrollLeft ||
rootElement.scrollLeft
nodel.html(content)
.style('opacity', 1).style('pointer-events', 'all')
while (i--) nodel.classed(directions[i], false)
coords = directionCallbacks.get(dir).apply(this)
nodel.classed(dir, true)
.style('top', (coords.top + poffset[0]) + scrollTop + 'px')
.style('left', (coords.left + poffset[1]) + scrollLeft + 'px')
return tip
}
// Public - hide the tooltip
//
// Returns a tip
tip.hide = function() {
var nodel = getNodeEl()
nodel.style('opacity', 0).style('pointer-events', 'none')
return tip
}
// Public: Proxy attr calls to the d3 tip container.
// Sets or gets attribute value.
//
// n - name of the attribute
// v - value of the attribute
//
// Returns tip or attribute value
// eslint-disable-next-line no-unused-vars
tip.attr = function(n, v) {
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().attr(n)
}
var args = Array.prototype.slice.call(arguments)
d3Selection.selection.prototype.attr.apply(getNodeEl(), args)
return tip
}
// Public: Proxy style calls to the d3 tip container.
// Sets or gets a style value.
//
// n - name of the property
// v - value of the property
//
// Returns tip or style property value
// eslint-disable-next-line no-unused-vars
tip.style = function(n, v) {
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().style(n)
}
var args = Array.prototype.slice.call(arguments)
d3Selection.selection.prototype.style.apply(getNodeEl(), args)
return tip
}
// Public: Set or get the direction of the tooltip
//
// v - One of n(north), s(south), e(east), or w(west), nw(northwest),
// sw(southwest), ne(northeast) or se(southeast)
//
// Returns tip or direction
tip.direction = function(v) {
if (!arguments.length) return direction
direction = v == null ? v : functor(v)
return tip
}
// Public: Sets or gets the offset of the tip
//
// v - Array of [x, y] offset
//
// Returns offset or
tip.offset = function(v) {
if (!arguments.length) return offset
offset = v == null ? v : functor(v)
return tip
}
// Public: sets or gets the html value of the tooltip
//
// v - String value of the tip
//
// Returns html value or tip
tip.html = function(v) {
if (!arguments.length) return html
html = v == null ? v : functor(v)
return tip
}
// Public: sets or gets the root element anchor of the tooltip
//
// v - root element of the tooltip
//
// Returns root node of tip
tip.rootElement = function(v) {
if (!arguments.length) return rootElement
rootElement = v == null ? v : functor(v)
return tip
}
// Public: destroys the tooltip and removes it from the DOM
//
// Returns a tip
tip.destroy = function() {
if (node) {
getNodeEl().remove()
node = null
}
return tip
}
function d3TipDirection() { return 'n' }
function d3TipOffset() { return [0, 0] }
function d3TipHTML() { return ' ' }
var directionCallbacks = d3Collection.map({
n: directionNorth,
s: directionSouth,
e: directionEast,
w: directionWest,
nw: directionNorthWest,
ne: directionNorthEast,
sw: directionSouthWest,
se: directionSouthEast
}),
directions = directionCallbacks.keys()
function directionNorth() {
var bbox = getScreenBBox()
return {
top: bbox.n.y - node.offsetHeight,
left: bbox.n.x - node.offsetWidth / 2
}
}
function directionSouth() {
var bbox = getScreenBBox()
return {
top: bbox.s.y,
left: bbox.s.x - node.offsetWidth / 2
}
}
function directionEast() {
var bbox = getScreenBBox()
return {
top: bbox.e.y - node.offsetHeight / 2,
left: bbox.e.x
}
}
function directionWest() {
var bbox = getScreenBBox()
return {
top: bbox.w.y - node.offsetHeight / 2,
left: bbox.w.x - node.offsetWidth
}
}
function directionNorthWest() {
var bbox = getScreenBBox()
return {
top: bbox.nw.y - node.offsetHeight,
left: bbox.nw.x - node.offsetWidth
}
}
function directionNorthEast() {
var bbox = getScreenBBox()
return {
top: bbox.ne.y - node.offsetHeight,
left: bbox.ne.x
}
}
function directionSouthWest() {
var bbox = getScreenBBox()
return {
top: bbox.sw.y,
left: bbox.sw.x - node.offsetWidth
}
}
function directionSouthEast() {
var bbox = getScreenBBox()
return {
top: bbox.se.y,
left: bbox.se.x
}
}
function initNode() {
var div = d3Selection.select(document.createElement('div'))
div
.style('position', 'absolute')
.style('top', 0)
.style('opacity', 0)
.style('pointer-events', 'none')
.style('box-sizing', 'border-box')
return div.node()
}
function getSVGNode(element) {
var svgNode = element.node()
if (!svgNode) return null
if (svgNode.tagName.toLowerCase() === 'svg') return svgNode
return svgNode.ownerSVGElement
}
function getNodeEl() {
if (node == null) {
node = initNode()
// re-add node to DOM
rootElement.appendChild(node)
}
return d3Selection.select(node)
}
// Private - gets the screen coordinates of a shape
//
// Given a shape on the screen, will return an SVGPoint for the directions
// n(north), s(south), e(east), w(west), ne(northeast), se(southeast),
// nw(northwest), sw(southwest).
//
// +-+-+
// | |
// + +
// | |
// +-+-+
//
// Returns an Object {n, s, e, w, nw, sw, ne, se}
function getScreenBBox() {
var targetel = target || d3Selection.event.target
while (targetel.getScreenCTM == null && targetel.parentNode == null) {
targetel = targetel.parentNode
}
var bbox = {},
matrix = targetel.getScreenCTM(),
tbbox = targetel.getBBox(),
width = tbbox.width,
height = tbbox.height,
x = tbbox.x,
y = tbbox.y
point.x = x
point.y = y
bbox.nw = point.matrixTransform(matrix)
point.x += width
bbox.ne = point.matrixTransform(matrix)
point.y += height
bbox.se = point.matrixTransform(matrix)
point.x -= width
bbox.sw = point.matrixTransform(matrix)
point.y -= height / 2
bbox.w = point.matrixTransform(matrix)
point.x += width
bbox.e = point.matrixTransform(matrix)
point.x -= width / 2
point.y -= height / 2
bbox.n = point.matrixTransform(matrix)
point.y += height
bbox.s = point.matrixTransform(matrix)
return bbox
}
// Private - replace D3JS 3.X d3.functor() function
function functor(v) {
return typeof v === 'function' ? v : function() {
return v
}
}
return tip
}
// eslint-disable-next-line semi
}));

File diff suppressed because it is too large Load Diff

@ -6,27 +6,6 @@
<jndiConfig>
<name>jdbc/WSO2CarbonDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>false</defaultAutoCommit>
</configuration>
</definition>
</datasource>
<datasource>
<name>WSO2_UM_DB</name>
<description>The datasource used for registry and user manager</description>
<jndiConfig>
<name>jdbc/WSO2UMDB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:h2:../core/repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;AUTO_SERVER=TRUE;AUTO_SERVER_PORT=9095</url>

@ -27,10 +27,9 @@
<property key="maximumTotalHttpConnection">100</property>
<property key="authorizer">org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.DeviceAuthorizer</property>
<property key="tokenUrl">https://${iot.gateway.host}:${iot.gateway.https.port}/token</property>
<property key="deviceMgtServerUrl">https://${iot.core.host}:${iot.core.https.port}</property>
<property key="deviceMgtServerUrl">https://${iot.gateway.host}:${iot.gateway.https.port}</property>
<property key="username">admin</property>
<property key="password">admin</property>
<property key="scopes"></property>
<!--websocket connection permissions which are validated for grouping (can have multiple permission.)-->
<property key="statsPermission">/permission/device-mgt/realtime_analytics</property>
<!--offset time from expiry time to trigger refresh call (in seconds)-->

@ -176,7 +176,6 @@
<!-- commenting "GetAllRolesOfUserEnabled" property to fix
https://wso2.org/jira/browse/IDENTITY-3489 -->
<replace file="target/wso2carbon-core-${carbon.kernel.version}/repository/conf/user-mgt.xml" token="&lt;Property name=&quot;GetAllRolesOfUserEnabled&quot;&gt;true&lt;/Property&gt;" value="&lt;!--Property name=&quot;GetAllRolesOfUserEnabled&quot;&gt;true&lt;/Property--&gt;" />
<replace file="target/wso2carbon-core-${carbon.kernel.version}/repository/conf/user-mgt.xml" token="&lt;Property name=&quot;dataSource&quot;&gt;jdbc/WSO2CarbonDB&lt;/Property&gt;" value="&lt;Property name=&quot;dataSource&quot;&gt;jdbc/WSO2UMDB&lt;/Property&gt;" />
<!-- Move IS UI to configure menu -->
<property name="tempdir2" value="target/identity-ui" />
<mkdir dir="${tempdir2}" />

@ -196,7 +196,7 @@ set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH%
set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed"
set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Analytics" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gatway.host="localhost" -Diot.gateway.https.port="8243" -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8
set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Analytics" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gatway.host="localhost" -Diot.gateway.https.port="8243" -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8
:runJava
echo JAVA_HOME environment variable is set to %JAVA_HOME%

@ -324,8 +324,6 @@ do
-Dcom.ibm.cacheLocalHost=true \
-Dmqtt.broker.host="localhost" \
-Dmqtt.broker.port="1886" \
-Diot.core.host="localhost" \
-Diot.core.https.port="9443" \
-Diot.keymanager.host="localhost" \
-Diot.keymanager.https.port="9443" \
-Diot.gateway.host="localhost" \

@ -17,13 +17,13 @@
#
#issuer of the JWT
iss=iot_default
iss=wso2.org/products/iot
TokenEndpoint=https://localhost:${iot.core.https.port}/oauth2/token
TokenEndpoint=https://${iot.keymanager.host}:${iot.keymanager.https.port}/oauth2/token
#audience of JWT claim
#comma seperated values
aud=wso2.org/products/iot
aud=devicemgt
#expiration time of JWT (number of minutes from the current time)
exp=1000

@ -185,10 +185,10 @@ This file is ciphertool compliant. Refer PRODUCT_HOME/repository/conf/security/c
<property name="username">admin</property>
<property name="password">admin</property>
<property name="tokenEndpoint">https://localhost:9443/oauth2</property>
<property name="tokenEndpoint">https://localhost:8243</property>
<!--offset time from expiry time to trigger refresh call - seconds -->
<property name="tokenRefreshTimeOffset">100</property>
<property name="deviceMgtServerUrl">https://localhost:9443</property>
<property name="deviceMgtServerUrl">https://localhost:8243</property>
</authorizer>
</security>
</mqtt>

@ -0,0 +1,32 @@
<processor>
<!-- Remove the scope validator from the identity.xml if it exists. Otherwise running the build several times
causes several scope validator elements to be added-->
<remove>
<name>//s:Server/s:OAuth/s:OAuthScopeValidator</name>
</remove>
<!-- Add the scope validator config element -->
<add>
<after>//s:Server/s:OAuth/s:OAuthCallbackHandlers</after>
<value><![CDATA[<OAuthScopeValidator class="org.wso2.carbon.device.mgt.oauth.extensions.validators.ExtendedJDBCScopeValidator"/>]]></value>
</add>
<!-- Add the ntlm grant type validator config element -->
<add>
<after>//s:Server/s:OAuth/s:SupportedGrantTypes/s:SupportedGrantType[s:GrantTypeName='iwa:ntlm']/s:GrantTypeName</after>
<value>
<![CDATA[<GrantTypeValidatorImplClass>org.wso2.carbon.identity.oauth.common.NTLMAuthenticationValidator</GrantTypeValidatorImplClass>]]></value>
</add>
<add>
<after>//s:Server/s:OAuth/s:SupportedGrantTypes/s:SupportedGrantType[s:GrantTypeName='iwa:ntlm']/s:GrantTypeName</after>
<value>
<![CDATA[<GrantTypeValidatorImplClass>org.wso2.carbon.identity.oauth.common.NTLMAuthenticationValidator</GrantTypeValidatorImplClass>]]></value>
</add>
<add>
<after>//s:Server/s:OAuth/s:SupportedGrantTypes/s:SupportedGrantType[s:GrantTypeName='iwa:ntlm']</after>
<value>
<![CDATA[<SupportedGrantType>
<GrantTypeName>urn:ietf:params:oauth:grant-type:jwt-bearer</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler</GrantTypeHandlerImplClass>
<GrantTypeValidatorImplClass>org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator</GrantTypeValidatorImplClass>
</SupportedGrantType>]]></value>
</add>
</processor>

@ -27,10 +27,9 @@
<property key="maximumTotalHttpConnection">100</property>
<property key="authorizer">org.wso2.carbon.device.mgt.output.adapter.websocket.authorization.DeviceAuthorizer</property>
<property key="tokenUrl">https://${iot.gateway.host}:${iot.gateway.https.port}/token</property>
<property key="deviceMgtServerUrl">https://${iot.core.host}:${iot.core.https.port}</property>
<property key="deviceMgtServerUrl">https://${iot.gateway.host}:${iot.gateway.https.port}</property>
<property key="username">admin</property>
<property key="password">admin</property>
<property key="scopes"></property>
<!--websocket connection permissions which are validated for grouping (can have multiple permission.)-->
<property key="statsPermission">/permission/device-mgt/realtime_analytics</property>
<!--offset time from expiry time to trigger refresh call (in seconds)-->

@ -90,6 +90,83 @@
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<!-- Replace Datasource, Scope mpl classes and OAuth callback class in identity.xml -->
<execution>
<id>replace-for-identity</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/identity.xml</file>
<replacements>
<replacement>
<xpath>/Server/JDBCPersistenceManager/DataSource/Name</xpath>
<token>(jdbc/WSO2CarbonDB)</token>
<value>jdbc/WSO2AM_DB</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/SupportedGrantTypes/SupportedGrantType</xpath>
<token>(org.wso2.carbon.identity.oauth2.token.handlers.grant.AuthorizationCodeGrantHandler)</token>
<value>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedAuthorizationCodeGrantHandler</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/SupportedGrantTypes/SupportedGrantType</xpath>
<token>(org.wso2.carbon.identity.oauth2.token.handlers.grant.PasswordGrantHandler)</token>
<value>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/SupportedGrantTypes/SupportedGrantType</xpath>
<token>(org.wso2.carbon.identity.oauth2.token.handlers.grant.ClientCredentialsGrantHandler)</token>
<value>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedClientCredentialsGrantHandler</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/SupportedGrantTypes/SupportedGrantType</xpath>
<token>(org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler)</token>
<value>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedSAML2BearerGrantHandler</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/SupportedGrantTypes/SupportedGrantType</xpath>
<token>(org.wso2.carbon.identity.oauth2.token.handlers.grant.iwa.ntlm.NTLMAuthenticationGrantHandler)</token>
<value>org.wso2.carbon.identity.oauth2.token.handlers.grant.iwa.ntlm.NTLMAuthenticationGrantHandlerWithHandshake</value>
</replacement>
<replacement>
<xpath>/Server/OAuth/OAuthCallbackHandlers</xpath>
<token>(org.wso2.carbon.identity.oauth.callback.DefaultCallbackHandler)</token>
<value>org.wso2.carbon.apimgt.keymgt.util.APIManagerOAuthCallbackHandler</value>
</replacement>
</replacements>
</configuration>
</execution>
<!-- Replace Datasource, Scope mpl classes and OAuth callback class in identity.xml -->
<!-- Replace the Datasource in the thrift-authentication.xml file -->
<execution>
<id>replace-for-thrift</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/thrift-authentication.xml</file>
<replacements>
<replacement>
<xpath>/Server/JDBCPersistenceManager/DataSource/Name</xpath>
<token>(jdbc/WSO2CarbonDB)</token>
<value>jdbc/WSO2AM_DB</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
<!-- Add the input and output adapter configs to the file -->
<plugin>
<groupId>com.google.code.maven-config-processor-plugin</groupId>
@ -130,6 +207,43 @@
</transformations>
</configuration>
</execution>
<execution>
<id>add-scope-validator</id>
<phase>prepare-package</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<failOnMissingXpath>false</failOnMissingXpath>
<transformations>
<transformation>
<input>${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/identity.xml</input>
<output>../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/identity/identity.xml</output>
<config>identity_config_change.xml</config>
</transformation>
</transformations>
<namespaceContexts>
<s>http://wso2.org/projects/carbon/carbon.xml</s>
</namespaceContexts>
</configuration>
</execution>
<execution>
<id>init-claim-manager</id>
<phase>prepare-package</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<failOnMissingXpath>false</failOnMissingXpath>
<transformations>
<transformation>
<input>${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/user-mgt.xml</input>
<output>../../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/user-mgt.xml</output>
<config>user_mgt_config_change.xml</config>
</transformation>
</transformations>
</configuration>
</execution>
</executions>
</plugin>
@ -444,6 +558,7 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
@ -451,52 +566,6 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.2</version>
<executions>
<!-- Replace Datasource, Scope mpl classes and OAuth callback class in identity.xml -->
<execution>
<id>replace-for-api-manager</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/api-manager.xml
</file>
<replacements>
<replacement>
<xpath>/APIManager/GatewayType</xpath>
<token>Synapse</token>
<value>None</value>
</replacement>
</replacements>
</configuration>
</execution>
<execution>
<id>replace-for-api-store</id>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
<configuration>
<file>
${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/jaggeryapps/api-store/site/conf/site.json
</file>
<replacements>
<replacement>
<token>(/store)</token>
<value>/api-store</value>
</replacement>
</replacements>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

@ -1,25 +0,0 @@
<api xmlns="http://ws.apache.org/ns/synapse" name="_WSO2DCRAPI_" context="/dynamic-client-web/register">
<resource methods="POST DELETE" url-mapping="/*" faultSequence="_dcr_fault_">
<inSequence>
<property name="uri.var.portnum" expression="get-property('keyManager.port')"/>
<property name="uri.var.hostname" expression="get-property('keyManager.hostname')"/>
<send>
<endpoint>
<http uri-template="https://{uri.var.hostname}:{uri.var.portnum}/dynamic-client-web/register">
<timeout>
<duration>60000</duration>
<responseAction>fault</responseAction>
</timeout>
</http>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</resource>
<handlers>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerCacheExtensionHandler"/>
<handler class="org.wso2.carbon.apimgt.gateway.handlers.common.SynapsePropertiesHandler"/>
</handlers>
</api>

@ -74,6 +74,7 @@
<exclude>**/lib/encoder*</exclude>
<exclude>**/plugins/jaxb*</exclude>
<exclude>**/security/authenticators.xml</exclude>
<exclude>**/user-mgt.xml</exclude>
<exclude>**/plugins/org.wso2.carbon.localentry.ui*</exclude>
<exclude>**/plugins/org.wso2.carbon.mediation.security.ui*</exclude>
@ -224,6 +225,7 @@
<include>**/log4j.properties</include>
<include>**/nhttp.properties</include>
<include>**/passthru-http.properties</include>
<include>**/user-mgt.xml</include>
</includes>
</fileSet>
<fileSet>
@ -447,6 +449,15 @@
</includes>
</fileSet>
<!-- Copying Authentication Endpoint webapp -->
<fileSet>
<directory>
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/devicetypes
</directory>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/deployment/server/devicetypes
</outputDirectory>
</fileSet>
<!-- Copying mdm app from devicemgt app-->
<fileSet>
<directory>
@ -604,6 +615,8 @@
<include>**/msg-mgt.properties</include>
<include>**/entitlement.properties</include>
<include>**/EndpointConfig.properties</include>
<include>**/identity.xml</include>
<include>**/thrift-authentication.xml</include>
</includes>
</fileSet>
<fileSet>
@ -860,24 +873,12 @@
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file>
<source>src/repository/conf/identity/identity.xml</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity
</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>src/repository/conf/identity/application-authentication.xml</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity
</outputDirectory>
<fileMode>644</fileMode>
</file>
<file>
<source>src/repository/conf/identity/thrift-authentication.xml</source>
<outputDirectory>${pom.artifactId}-${pom.version}/repository/conf/identity</outputDirectory>
<filtered>true</filtered>
<fileMode>644</fileMode>
</file>
<file>
<source>
src/repository/conf/identity/identity-providers/iot_default.xml

@ -162,7 +162,7 @@ set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH%
set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed"
set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Core" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -Dorg.wso2.ignoreHostnameVerification=true -Dorg.opensaml.httpclient.https.disableHostnameVerification=true -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gateway.host="localhost" -Diot.gateway.https.port="8243"
set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dlogger.server.name="IoT-Core" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -Dorg.wso2.ignoreHostnameVerification=true -Dorg.opensaml.httpclient.https.disableHostnameVerification=true -Dmqtt.broker.host="localhost" -Dmqtt.broker.port="1886" -Diot.core.host="localhost" -Diot.core.https.port="9443" -Diot.keymanager.host="localhost" -Diot.keymanager.https.port="9443" -Diot.gateway.host="localhost" -Diot.gateway.https.port="8243" -Diot.gateway.http.port="8280"
:runJava
echo JAVA_HOME environment variable is set to %JAVA_HOME%

@ -315,6 +315,7 @@ do
-Diot.keymanager.https.port="9443" \
-Diot.gateway.host="localhost" \
-Diot.gateway.https.port="8243" \
-Diot.gateway.http.port="8280" \
org.wso2.carbon.bootstrap.Bootstrap $*
status=$?
done

@ -47,12 +47,13 @@
This is will become part of the End Point Reference of the
services deployed on this server instance.
-->
<!--<HostName>localhost</HostName>-->
<HostName>localhost</HostName>
<!--
Host name to be used for the Carbon management console
-->
<!--<MgtHostName>localhost</MgtHostName>-->
<MgtHostName>localhost</MgtHostName>
<!--
The URL of the back end server. This is where the admin services are hosted and

@ -23,18 +23,18 @@
-->
<WebappPublisherConfigs>
<!-- This host is used to define the host address which is used to publish APIs -->
<Host>https://localhost:${carbon.https.port}</Host>
<!-- This host is used to define the host address which is used to publish APIs -->
<Host>https://${iot.core.host}:${iot.core.https.port}</Host>
<!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI>
<!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI>
<!-- If it is true, the APIs of this instance will be updated when the webapps are redeployed -->
<EnabledUpdateApi>false</EnabledUpdateApi>
<!-- If it is true, the APIs of this instance will be updated when the webapps are redeployed -->
<EnabledUpdateApi>true</EnabledUpdateApi>
<!--Webapp will be published only when running below profiles-->
<Profiles>
<Profile>default</Profile>
<Profile>devicetype-publisher</Profile>
</Profiles>
<!--Webapp will be published only when running below profiles-->
<Profiles>
<Profile>default</Profile>
<Profile>devicetype-publisher</Profile>
</Profiles>
</WebappPublisherConfigs>

@ -17,10 +17,10 @@
-->
<IdentityProvider>
<IdentityProviderName>iot_default</IdentityProviderName>
<DisplayName>iot_default</DisplayName>
<IdentityProviderName>wso2.org/products/iot</IdentityProviderName>
<DisplayName>wso2.org/products/iot</DisplayName>
<IdentityProviderDescription></IdentityProviderDescription>
<Alias>wso2.org/products/iot</Alias>
<Alias>devicemgt</Alias>
<IsPrimary>true</IsPrimary>
<IsFederationHub></IsFederationHub>
<HomeRealmId></HomeRealmId>

@ -1,286 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<Server xmlns="http://wso2.org/projects/carbon/carbon.xml">
<JDBCPersistenceManager>
<DataSource>
<!-- Include a data source name (jndiConfigName) from the set of data
sources defined in master-datasources.xml -->
<Name>jdbc/WSO2AM_DB</Name>
</DataSource>
<!-- If the identity database is created from another place and if it is
required to skip schema initialization during the server start up, set the
following property to "true". -->
<!-- <SkipDBSchemaCreation>false</SkipDBSchemaCreation> -->
<SessionDataPersist>
<Enable>false</Enable>
<!--RememberMePeriod>20160</RememberMePeriod-->
<!--CleanUp>
<Enable>true</Enable>
<Period>1</Period>
<TimeOut>20160</TimeOut-->
<!--/CleanUp>
<Temporary>false</Temporary-->
</SessionDataPersist>
</JDBCPersistenceManager>
<!-- Security configurations -->
<Security>
<UserTrustedRPStore>
<Location>${carbon.home}/repository/resources/security/userRP.jks
</Location>
<!-- Keystore type (JKS/PKCS12 etc.) -->
<Type>JKS</Type>
<!-- Keystore password -->
<Password>wso2carbon</Password>
<!-- Private Key password -->
<KeyPassword>wso2carbon</KeyPassword>
</UserTrustedRPStore>
<!-- The directory under which all other KeyStore files will be stored -->
<KeyStoresDir>${carbon.home}/conf/keystores</KeyStoresDir>
</Security>
<Identity>
<IssuerPolicy>SelfAndManaged</IssuerPolicy>
<TokenValidationPolicy>CertValidate</TokenValidationPolicy>
<BlackList/>
<WhiteList/>
<System>
<KeyStore/>
<StorePass/>
</System>
</Identity>
<OpenID>
<OpenIDServerUrl>https://localhost:9443/openidserver</OpenIDServerUrl>
<OpenIDUserPattern>https://localhost:9443/openid/</OpenIDUserPattern>
<!-- If the users must be prompted for approval -->
<OpenIDSkipUserConsent>false</OpenIDSkipUserConsent>
<!-- Expiry time of the OpenID RememberMe token in minutes -->
<OpenIDRememberMeExpiry>7200</OpenIDRememberMeExpiry>
<!-- Multifactor Authentication configuration -->
<UseMultifactorAuthentication>false</UseMultifactorAuthentication>
<!-- To enable or disable openid dumb mode -->
<DisableOpenIDDumbMode>false</DisableOpenIDDumbMode>
<!-- remember me session timeout in seconds -->
<SessionTimeout>36000</SessionTimeout>
<!-- skips authentication if valid SAML2 Web SSO browser session available -->
<AcceptSAMLSSOLogin>false</AcceptSAMLSSOLogin>
<ClaimsRetrieverImplClass>org.wso2.carbon.identity.provider.openid.claims.DefaultClaimsRetriever</ClaimsRetrieverImplClass>
</OpenID>
<OAuth>
<RequestTokenUrl>https://localhost:9443/oauth/request-token</RequestTokenUrl>
<AccessTokenUrl>https://localhost:9443/oauth/access-token</AccessTokenUrl>
<AuthorizeUrl>https://localhost:9443/oauth/authorize-url</AuthorizeUrl>
<OAuth2TokenEPUrl>https://localhost:${mgt.transport.https.port}/oauth2/token</OAuth2TokenEPUrl>
<!-- Default validity period for Authorization Code in seconds -->
<AuthorizationCodeDefaultValidityPeriod>300</AuthorizationCodeDefaultValidityPeriod>
<!-- Default validity period for user access tokens in seconds -->
<AccessTokenDefaultValidityPeriod>3600</AccessTokenDefaultValidityPeriod>
<!-- Default validity period for application access tokens in seconds -->
<UserAccessTokenDefaultValidityPeriod>3600</UserAccessTokenDefaultValidityPeriod>
<!-- Validity period for refresh token -->
<RefreshTokenValidityPeriod>84600</RefreshTokenValidityPeriod>
<!-- Timestamp skew in seconds -->
<TimestampSkew>300</TimestampSkew>
<!-- Enable OAuth caching -->
<EnableOAuthCache>true</EnableOAuthCache>
<!-- Enable renewal of refresh token for refresh_token grant -->
<RenewRefreshTokenForRefreshGrant>true</RenewRefreshTokenForRefreshGrant>
<!-- Process the token before storing it in database, e.g. encrypting -->
<TokenPersistenceProcessor>org.wso2.carbon.identity.oauth.tokenprocessor.PlainTextPersistenceProcessor</TokenPersistenceProcessor>
<!-- Supported Client Autnetication Methods -->
<ClientAuthHandlers>
<ClientAuthHandler Class="org.wso2.carbon.identity.oauth2.token.handlers.clientauth.BasicAuthClientAuthHandler">
<Property Name="StrictClientCredentialValidation">false</Property>
</ClientAuthHandler>
</ClientAuthHandlers>
<!-- Supported Response Types -->
<SupportedResponseTypes>
<SupportedResponseType>
<ResponseTypeName>token</ResponseTypeName>
<ResponseTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.authz.handlers.TokenResponseTypeHandler</ResponseTypeHandlerImplClass>
</SupportedResponseType>
<SupportedResponseType>
<ResponseTypeName>code</ResponseTypeName>
<ResponseTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.authz.handlers.CodeResponseTypeHandler</ResponseTypeHandlerImplClass>
</SupportedResponseType>
</SupportedResponseTypes>
<!-- Supported Grant Types -->
<SupportedGrantTypes>
<SupportedGrantType>
<GrantTypeName>authorization_code</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.AuthorizationCodeGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>password</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.apimgt.keymgt.handlers.ExtendedPasswordGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>refresh_token</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.RefreshGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>client_credentials</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.ClientCredentialsGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>urn:ietf:params:oauth:grant-type:saml2-bearer</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.saml.SAML2BearerGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>iwa:ntlm</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.token.handlers.grant.iwa.ntlm.NTLMAuthenticationGrantHandler</GrantTypeHandlerImplClass>
</SupportedGrantType>
<SupportedGrantType>
<GrantTypeName>urn:ietf:params:oauth:grant-type:jwt-bearer</GrantTypeName>
<GrantTypeHandlerImplClass>org.wso2.carbon.identity.oauth2.grant.jwt.JWTBearerGrantHandler</GrantTypeHandlerImplClass>
<GrantTypeValidatorImplClass>org.wso2.carbon.identity.oauth2.grant.jwt.JWTGrantValidator</GrantTypeValidatorImplClass>
</SupportedGrantType>
</SupportedGrantTypes>
<OAuthCallbackHandlers>
<OAuthCallbackHandler Class="org.wso2.carbon.device.mgt.oauth.extensions.handlers.DeviceMgtOAuthCallbackHandler"/>
</OAuthCallbackHandlers>
<OAuthScopeValidator class="org.wso2.carbon.device.mgt.oauth.extensions.validators.ExtendedJDBCScopeValidator"/>
<TokenValidators>
<TokenValidator type="bearer" class="org.wso2.carbon.identity.oauth2.validators.DefaultOAuth2TokenValidator"/>
</TokenValidators>
<!-- Assertions can be used to embedd parameters into access token. -->
<EnableAssertions>
<UserName>false</UserName>
</EnableAssertions>
<!-- This should be set to true when using multiple user stores and keys
should saved into different tables according to the user store. By default
all the application keys are saved in to the same table. UserName Assertion
should be 'true' to use this. -->
<EnableAccessTokenPartitioning>false</EnableAccessTokenPartitioning>
<!-- user store domain names and mapping to new table name. eg: if you
provide 'A:foo.com', foo.com should be the user store domain name and 'A'
represent the relavant mapping of token store table, i.e. tokens will be
added to a table called IDN_OAUTH2_ACCESS_TOKEN_A. -->
<AccessTokenPartitioningDomains><!-- A:foo.com, B:bar.com -->
</AccessTokenPartitioningDomains>
<AuthorizationContextTokenGeneration>
<Enabled>false</Enabled>
<TokenGeneratorImplClass>org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator</TokenGeneratorImplClass>
<ClaimsRetrieverImplClass>org.wso2.carbon.identity.oauth2.authcontext.DefaultClaimsRetriever</ClaimsRetrieverImplClass>
<ConsumerDialectURI>http://wso2.org/claims</ConsumerDialectURI>
<SignatureAlgorithm>SHA256withRSA</SignatureAlgorithm>
<AuthorizationContextTTL>15</AuthorizationContextTTL>
</AuthorizationContextTokenGeneration>
<SAML2Grant>
<!--SAML2TokenHandler></SAML2TokenHandler-->
</SAML2Grant>
<OpenIDConnect>
<IDTokenBuilder>org.wso2.carbon.identity.openidconnect.DefaultIDTokenBuilder</IDTokenBuilder>
<IDTokenIssuerID>https://localhost:9443/oauth2endpoints/token</IDTokenIssuerID>
<IDTokenSubjectClaim>http://wso2.org/claims/givenname</IDTokenSubjectClaim>
<IDTokenCustomClaimsCallBackHandler>org.wso2.carbon.identity.openidconnect.SAMLAssertionClaimsCallback</IDTokenCustomClaimsCallBackHandler>
<IDTokenExpiration>3600</IDTokenExpiration>
<UserInfoEndpointClaimDialect>http://wso2.org/claims</UserInfoEndpointClaimDialect>
<UserInfoEndpointClaimRetriever>org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoUserStoreClaimRetriever</UserInfoEndpointClaimRetriever>
<UserInfoEndpointRequestValidator>org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInforRequestDefaultValidator</UserInfoEndpointRequestValidator>
<UserInfoEndpointAccessTokenValidator>org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoISAccessTokenValidator</UserInfoEndpointAccessTokenValidator>
<UserInfoEndpointResponseBuilder>org.wso2.carbon.identity.oauth.endpoint.user.impl.UserInfoJSONResponseBuilder</UserInfoEndpointResponseBuilder>
<SkipUserConsent>false</SkipUserConsent>
</OpenIDConnect>
</OAuth>
<MultifactorAuthentication>
<XMPPSettings>
<XMPPConfig>
<XMPPProvider>gtalk</XMPPProvider>
<XMPPServer>talk.google.com</XMPPServer>
<XMPPPort>5222</XMPPPort>
<XMPPExt>gmail.com</XMPPExt>
<XMPPUserName>multifactor1@gmail.com</XMPPUserName>
<XMPPPassword>wso2carbon</XMPPPassword>
</XMPPConfig>
</XMPPSettings>
</MultifactorAuthentication>
<SSOService>
<EntityId>localhost</EntityId>
<IdentityProviderURL>https://localhost:9443/samlsso</IdentityProviderURL>
<SingleLogoutRetryCount>5</SingleLogoutRetryCount>
<SingleLogoutRetryInterval>60000</SingleLogoutRetryInterval> <!-- in milli seconds -->
<TenantPartitioningEnabled>false</TenantPartitioningEnabled>
<PersistanceCacheTimeout>157680000</PersistanceCacheTimeout>
<SessionIndexCacheTimeout>157680000</SessionIndexCacheTimeout>
<SessionTimeout>36000</SessionTimeout> <!-- remember me session timeout in seconds -->
<!-- skips authentication if valid SAML2 Web SSO browser session available -->
<AttributeStatementBuilder>org.wso2.carbon.identity.sso.saml.attributes.UserAttributeStatementBuilder</AttributeStatementBuilder>
<AttributesClaimDialect>http://wso2.org/claims</AttributesClaimDialect>
<AcceptOpenIDLogin>false</AcceptOpenIDLogin>
<ClaimsRetrieverImplClass>org.wso2.carbon.identity.sso.saml.builders.claims.DefaultClaimsRetriever</ClaimsRetrieverImplClass>
<SAMLSSOAssertionBuilder>org.wso2.carbon.identity.sso.saml.builders.assertion.DefaultSAMLAssertionBuilder</SAMLSSOAssertionBuilder>
<SAMLSSOEncrypter>org.wso2.carbon.identity.sso.saml.builders.encryption.DefaultSSOEncrypter</SAMLSSOEncrypter>
<SAMLSSOSigner>org.wso2.carbon.identity.sso.saml.builders.signature.DefaultSSOSigner</SAMLSSOSigner>
<SAML2HTTPRedirectSignatureValidator>org.wso2.carbon.identity.sso.saml.validators.SAML2HTTPRedirectDeflateSignatureValidator</SAML2HTTPRedirectSignatureValidator>
<!--SAMLSSOResponseBuilder>org.wso2.carbon.identity.sso.saml.builders.DefaultResponseBuilder</SAMLSSOResponseBuilder-->
<!-- SAML Token validity period in minutes -->
<SAMLResponseValidityPeriod>5</SAMLResponseValidityPeriod>
<UseAuthenticatedUserDomainCrypto>false</UseAuthenticatedUserDomainCrypto>
</SSOService>
<EntitlementSettings>
<!-- Uncomment this to enable on-demand policy loading -->
<!--OnDemandPolicyLoading> <Enable>true</Enable> <MaxInMemoryPolicies>100</MaxInMemoryPolicies>
</OnDemandPolicyLoading -->
<DecisionCaching>
<Enable>true</Enable>
<CachingInterval>36000</CachingInterval>
</DecisionCaching>
<AttributeCaching>
<Enable>true</Enable>
</AttributeCaching>
<ThirftBasedEntitlementConfig>
<EnableThriftService>true</EnableThriftService>
<ReceivePort>${Ports.ThriftEntitlementReceivePort}</ReceivePort>
<ClientTimeout>10000</ClientTimeout>
<KeyStore>
<Location>${carbon.home}/repository/resources/security/wso2carbon.jks</Location>
<Password>wso2carbon</Password>
</KeyStore>
<!-- Enable this element to mention the host-name of your IS machine -->
<ThriftHostName>localhost</ThriftHostName>
</ThirftBasedEntitlementConfig>
</EntitlementSettings>
<SCIMAuthenticators>
<Authenticator class="org.wso2.carbon.identity.scim.provider.auth.BasicAuthHandler">
<Property name="Priority">5</Property>
</Authenticator>
<Authenticator class="org.wso2.carbon.identity.scim.provider.auth.OAuthHandler">
<Property name="Priority">10</Property>
<Property name="AuthorizationServer">local://services</Property>
<!--Property name="AuthorizationServer">https://localhost:9443/services</Property>
<Property name="UserName">admin</Property>
<Property name="Password">admin</Property-->
</Authenticator>
</SCIMAuthenticators>
<!--SessionContextCache>
<Enable>true</Enable>
<Capacity>100000</Capacity>
</SessionContextCache-->
</Server>

@ -1,44 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<Server xmlns="http://wso2.org/projects/carbon/carbon.xml">
<JDBCPersistenceManager>
<DataSource>
<!-- Include a data source name (jndiConfigName) from the set of data sources defined in master-datasources.xml -->
<Name>jdbc/WSO2AM_DB</Name>
</DataSource>
<!-- If the identity database is created from another place and if it is required to skip schema initialization during the server start up, set the following
property to "true". -->
<!--<SkipDBSchemaCreation>true</SkipDBSchemaCreation>-->
</JDBCPersistenceManager>
<ThriftSessionDAO>org.wso2.carbon.identity.thrift.authentication.dao.DBThriftSessionDAO</ThriftSessionDAO>
<!--<ThriftSessionDAO>org.wso2.carbon.identity.thrift.authentication.dao.InMemoryThriftSessionDAO</ThriftSessionDAO>-->
<ClientTimeout>30000</ClientTimeout>
<!--<Hostname>localhost</Hostname>-->
<Port>10711</Port>
<!--30 min-->
<ThriftSessionTimeout>1800000</ThriftSessionTimeout>
</Server>

@ -461,4 +461,12 @@ org.owasp.csrfguard.unprotected.publisherRestApi=%servletContext%/api/appm/publi
org.owasp.csrfguard.unprotected.storeRestApi=%servletContext%/api/appm/store/*
org.owasp.csrfguard.unprotected.certificateMgtRestApi=%servletContext%/api/certificate-mgt/*
org.owasp.csrfguard.unprotected.deviceMgtRestApi=%servletContext%/api/device-mgt/*
org.owasp.csrfguard.unprotected.dcrRestApi=%servletContext%/dynamic-client-web/*
org.owasp.csrfguard.unprotected.dcrRestApi=%servletContext%/dynamic-client-web/*
#carbon
org.owasp.csrfguard.unprotected.Services=%servletContext%/services/*
#identity
org.owasp.csrfguard.unprotected.acs=%servletContext%/acs/*
org.owasp.csrfguard.unprotected.iwa=%servletContext%/iwa/*
org.owasp.csrfguard.unprotected.oauthiwa=%servletContext%/commonauth/iwa/*

@ -0,0 +1,260 @@
<!--
~ Copyright WSO2, Inc. (http://wso2.com)
~
~ 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.
-->
<UserManager>
<Realm>
<Configuration>
<AddAdmin>true</AddAdmin>
<AdminRole>admin</AdminRole>
<AdminUser>
<UserName>admin</UserName>
<Password>admin</Password>
</AdminUser>
<EveryOneRoleName>everyone</EveryOneRoleName> <!-- By default users in this role sees the registry root -->
<Property name="isCascadeDeleteEnabled">true</Property>
<Property name="initializeNewClaimManager">true</Property>
<Property name="dataSource">jdbc/WSO2CarbonDB</Property>
</Configuration>
<!-- Following is the configuration for internal JDBC user store. This user store manager is based on JDBC.
In case if application needs to manage passwords externally set property
<Property name="PasswordsExternallyManaged">true</Property>.
In case if user core cache domain is needed to identify uniquely set property
<Property name="UserCoreCacheIdentifier">domain</Property>.
Furthermore properties, IsEmailUserName and DomainCalculation are readonly properties.
Note: Do not comment within UserStoreManager tags. Cause, specific tag names are used as tokens
when building configurations for products.
-->
<UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property>
<Property name="ReadOnly">false</Property>
<Property name="ReadGroups">true</Property>
<Property name="WriteGroups">true</Property>
<Property name="UsernameJavaRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be within 5 to 30 characters</Property>
<Property name="RolenameJavaRegEx">^[\S]{3,30}$</Property>
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="CaseInsensitiveUsername">true</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="IsBulkImportSupported">true</Property>
<Property name="PasswordDigest">SHA-256</Property>
<Property name="StoreSaltedPassword">true</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="UserNameUniqueAcrossTenants">false</Property>
</UserStoreManager>
<!-- If product is using an external LDAP as the user store in READ ONLY mode, use following user manager.
In case if user core cache domain is needed to identify uniquely set property
<Property name="UserCoreCacheIdentifier">domain</Property>
-->
<!--UserStoreManager class="org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://localhost:10389</Property>
<Property name="ConnectionName">uid=admin,ou=system</Property>
<Property name="ConnectionPassword">admin</Property>
<Property name="AnonymousBind">false</Property>
<Property name="UserSearchBase">ou=system</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">(&amp;(objectClass=person)(uid=?))</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="GroupSearchBase">ou=system</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&amp;(objectClass=groupOfNames)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">true</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
<Property name="ReplaceEscapeCharactersAtUserLogin">true</Property>
</UserStoreManager-->
<!-- Active directory configuration is as follows.
In case if user core cache domain is needed to identify uniquely set property
<Property name="UserCoreCacheIdentifier">domain</Property>
There are few special properties for "Active Directory".
They are :
1.Referral - (comment out this property if this feature is not reuired) This enables LDAP referral support.
2.BackLinksEnabled - (Do not comment, set to true or false) In some cases LDAP works with BackLinksEnabled.
In which role is stored at user level. Depending on this value we need to change the Search Base within code.
isADLDSRole - (Do not comment) Set to true if connecting to an AD LDS instance else set to false.
-->
<!--UserStoreManager class="org.wso2.carbon.user.core.ldap.ActiveDirectoryUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldaps://10.100.1.100:636</Property>
<Property name="ConnectionName">CN=admin,CN=Users,DC=WSO2,DC=Com</Property>
<Property name="ConnectionPassword">A1b2c3d4</Property>
<Property name="AnonymousBind">false</Property>
<Property name="UserSearchBase">CN=Users,DC=WSO2,DC=Com</Property>
<Property name="UserEntryObjectClass">user</Property>
<Property name="UserNameAttribute">cn</Property>
<Property name="UserNameSearchFilter">(&amp;(objectClass=user)(cn=?))</Property>
<Property name="UserNameListFilter">(objectClass=user)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="WriteGroups">true</Property>
<Property name="GroupSearchBase">CN=Users,DC=WSO2,DC=Com</Property>
<Property name="GroupEntryObjectClass">group</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&amp;(objectClass=group)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectcategory=group)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="MemberOfAttribute">memberOf</Property>
<Property name="BackLinksEnabled">true</Property>
<Property name="Referral">follow</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be within 5 to 30 characters</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="SCIMEnabled">false</Property>
<Property name="IsBulkImportSupported">true</Property>
<Property name="EmptyRolesAllowed">true</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="isADLDSRole">false</Property>
<Property name="userAccountControl">512</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="kdcEnabled">false</Property>
<Property name="defaultRealmName">WSO2.ORG</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">false</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
</UserStoreManager-->
<!-- Following user manager is used by Identity Server (IS) as its default user manager.
IS will do token replacement when building the product. Therefore do not change the syntax.
If "kdcEnabled" parameter is true, IS will allow service principle management.
Thus "ServicePasswordJavaRegEx", "ServiceNameJavaRegEx" properties control the service name format and
service password formats. In case if user core cache domain is needed to identify uniquely set property
<Property name="UserCoreCacheIdentifier">domain</Property>
-->
<!--ISUserStoreManager class="org.wso2.carbon.user.core.ldap.ReadWriteLDAPUserStoreManager">
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.CommonHybridLDAPTenantManager</Property>
<Property name="ConnectionURL">ldap://localhost:${Ports.EmbeddedLDAP.LDAPServerPort}</Property>
<Property name="ConnectionName">uid=admin,ou=system</Property>
<Property name="ConnectionPassword">admin</Property>
<Property name="AnonymousBind">false</Property>
<Property name="UserSearchBase">ou=Users,dc=wso2,dc=org</Property>
<Property name="UserEntryObjectClass">identityPerson</Property>
<Property name="UserNameAttribute">uid</Property>
<Property name="UserNameSearchFilter">(&amp;(objectClass=person)(uid=?))</Property>
<Property name="UserNameListFilter">(objectClass=person)</Property>
<Property name="DisplayNameAttribute"/>
<Property name="ReadGroups">true</Property>
<Property name="WriteGroups">true</Property>
<Property name="GroupSearchBase">ou=Groups,dc=wso2,dc=org</Property>
<Property name="GroupEntryObjectClass">groupOfNames</Property>
<Property name="GroupNameAttribute">cn</Property>
<Property name="GroupNameSearchFilter">(&amp;(objectClass=groupOfNames)(cn=?))</Property>
<Property name="GroupNameListFilter">(objectClass=groupOfNames)</Property>
<Property name="MembershipAttribute">member</Property>
<Property name="BackLinksEnabled">false</Property>
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="UsernameJavaRegExViolationErrorMsg">Username pattern policy violated</Property>
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be within 5 to 30 characters</Property>
<Property name="RolenameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
<Property name="SCIMEnabled">true</Property>
<Property name="IsBulkImportSupported">true</Property>
<Property name="EmptyRolesAllowed">true</Property>
<Property name="PasswordHashMethod">PLAIN_TEXT</Property>
<Property name="MultiAttributeSeparator">,</Property>
<Property name="MaxUserNameListLength">100</Property>
<Property name="MaxRoleNameListLength">100</Property>
<Property name="kdcEnabled">false</Property>
<Property name="defaultRealmName">WSO2.ORG</Property>
<Property name="UserRolesCacheEnabled">true</Property>
<Property name="ConnectionPoolingEnabled">false</Property>
<Property name="LDAPConnectionTimeout">5000</Property>
<Property name="ReadTimeout"/>
<Property name="RetryAttempts"/>
</ISUserStoreManager-->
<AuthorizationManager class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
<Property name="AdminRoleManagementPermissions">/permission</Property>
<Property name="AuthorizationCacheEnabled">true</Property>
<Property name="GetAllRolesOfUserEnabled">false</Property>
</AuthorizationManager>
</Realm>
</UserManager>
<!--
************* Description of some of the configuration properties used in user-mgt.xml *********************************
DomainName -
This property must be used by all secondary user store managers in multiple user store configuration.
DomainName is a unique identifier given to the user store. Users must provide both the domain name and
username at log-in as "DomainName\Username"
UserRolesCacheEnabled -
This is to indicate whether to cache role list of a user. By default it is set to true.
You may need to disable it if user-roles are changed by external means and need to reflect
those changes in the carbon product immediately.
ReplaceEscapeCharactersAtUserLogin -
This is to configure whether escape characters in user name needs to be replaced at user login.
Currently the identified escape characters that needs to be replaced are '\' & '\\'
UserDNPattern -
This property will be used when authenticating users. During authentication we do a bind. But if the user is login
with email address or some other property we need to first lookup LDAP and retrieve DN for the user.
This involves an additional step. If UserDNPattern is specified the DN will be constructed using the pattern
specified in this property. Performance of this is much better than looking up DN and binding user.
RoleDNPattern -
This property will be used when checking whether user has been assigned to a given role.
Rather than searching the role in search base, by using this property direct search can be done.
PasswordHashMethod -
This says how the password should be stored. Allowed values are as follows,
SHA - Uses SHA digest method
MD5 - Uses MD 5 digest method
PLAIN_TEXT - Plain text passwords
In addition to above this supports all digest methods supported by http://docs.oracle.com/javase/6/docs/api/java/security/MessageDigest.html.
DisplayNameAttribute -
This is to have a dedicated LDAP attribute to display an entity(User/Role) in UI, in addition to the UserNameAttribute which is used for IS-UserStore interactions.
-->

@ -0,0 +1,9 @@
<processor>
<remove>
<name>//UserManager/Realm/Configuration/Property[@name='initializeNewClaimManager']</name>
</remove>
<add>
<after>//UserManager/Realm/Configuration/Property[@name='isCascadeDeleteEnabled']</after>
<value><![CDATA[<Property name="initializeNewClaimManager">true</Property>]]></value>
</add>
</processor>

@ -163,6 +163,15 @@
</featureArtifactDef>
<!-- End of Device Management Features -->
<!-- Device Management Plugin Features -->
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.feature:${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows.feature:${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<!-- End of Device Management Plugin Features -->
<!-- IoT Device Management Features -->
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.adapter.feature:${carbon.device.mgt.plugin.version}
@ -221,6 +230,9 @@
<featureArtifactDef>
org.wso2.carbon.apimgt:org.wso2.carbon.apimgt.gateway.feature:${carbon.api.mgt.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.apimgt:org.wso2.carbon.apimgt.keymanager.feature:${carbon.api.mgt.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.apimgt:org.wso2.carbon.forum.server.feature:${carbon.api.mgt.version}
</featureArtifactDef>
@ -938,6 +950,14 @@
<id>org.wso2.carbon.device.mgt.analytics.dashboard.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<!-- End of Device Management Features -->
<feature>
<id>org.wso2.carbon.device.mgt.adapter.feature.group</id>
@ -1017,6 +1037,11 @@
<!-- End of Dashboard Features -->
<!-- API Management Features -->
<feature>
<id>org.wso2.carbon.apimgt.keymanager.feature.group</id>
<version>${carbon.api.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.core.feature.group</id>
<version>${carbon.api.mgt.version}</version>
@ -1581,6 +1606,10 @@
<id>org.wso2.carbon.module.mgt.server.feature.group</id>
<version>${carbon.deployment.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.databridge.datapublisher.feature.group</id>
<version>${carbon.analytics.common.version}</version>
</feature>
<feature>
<id>org.apache.synapse.wso2.feature.group</id>
<version>${carbon.mediation.version}</version>
@ -1614,6 +1643,11 @@
<id>org.wso2.carbon.mediation.configadmin.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.mediator.cache.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<!--feature>
<id>org.wso2.carbon.mediation.tracer.feature.group</id>
<version>${carbon.mediation.version}</version>
@ -1846,6 +1880,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.gateway.feature.group</id>
<version>${carbon.api.mgt.version}</version>
@ -1870,6 +1912,10 @@
<id>org.wso2.carbon.certificate.mgt.api.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.analytics.data.publisher.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.certificate.mgt.cert.admin.api.feature.group</id>
<version>${carbon.device.mgt.version}</version>
@ -1878,6 +1924,14 @@
<id>org.wso2.carbon.device.mgt.analytics.dashboard.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.jwt.client.extension.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.analytics.api.client.feature.group</id>
<version>${carbon.analytics.version}</version>
</feature>
</features>
</configuration>
</execution>
@ -1953,6 +2007,10 @@
<id>org.wso2.carbon.identity.thrift.authentication.feature.group</id>
<version>${carbon.identity.framework.version.iotcore}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.oauth2.grant.jwt.feature.group</id>
<version>${identity.jwt.extension.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.tenant.common.feature.group</id>
<version>${carbon.multitenancy.version}</version>
@ -1990,6 +2048,11 @@
<id>org.wso2.carbon.core.common.feature.group</id>
<version>${carbon.kernel.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.um.ws.service.server.feature.group</id>
<version>${identity.user.ws.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.application.mgt.server.feature.group</id>
<version>${carbon.identity.framework.version.iotcore}</version>
@ -2042,6 +2105,10 @@
<id>org.wso2.carbon.mediation.configadmin.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.mediator.cache.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<!--feature>
<id>org.wso2.carbon.mediation.statistics.feature.group</id>
<version>${carbon.mediation.version}</version>
@ -2205,6 +2272,10 @@
<id>org.wso2.carbon.apimgt.gateway.feature.group</id>
<version>${carbon.api.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.keymanager.feature.group</id>
<version>${carbon.api.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.registry.extensions.feature.group</id>
<version>${carbon.governance.version}</version>
@ -2253,6 +2324,10 @@
<id>org.wso2.carbon.dynamic.client.registration.server.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.analytics.data.publisher.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<!--required for context.xml-->
<feature>
@ -2288,6 +2363,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.gateway.feature.group</id>
<version>${carbon.api.mgt.version}</version>
@ -2324,6 +2407,14 @@
<id>org.wso2.carbon.device.mgt.analytics.dashboard.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.jwt.client.extension.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.analytics.api.client.feature.group</id>
<version>${carbon.analytics.version}</version>
</feature>
</features>
</configuration>
</execution>
@ -2377,6 +2468,25 @@
</feature>
<!-- End of app management features-->
<!-- Dashboard Features -->
<feature>
<id>org.wso2.carbon.dashboards.shindig.feature.group</id>
<version>${carbon.dashboard.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.dashboards.portal.feature.group</id>
<version>${carbon.dashboard.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.dashboard.deployment.feature.group</id>
<version>${carbon.dashboard.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.iot.device.statistics.dashboard.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<!-- End of Dashboard Features -->
<!-- Device Management Features -->
<feature>
@ -2455,6 +2565,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.analytics.dashboard.feature.group</id>
<version>${carbon.device.mgt.version}</version>
@ -2573,6 +2691,10 @@
<id>org.wso2.carbon.mediation.configadmin.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.mediator.cache.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<!--feature>
<id>org.wso2.carbon.mediation.statistics.feature.group</id>
<version>${carbon.mediation.version}</version>
@ -2872,6 +2994,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.gateway.feature.group</id>
<version>${carbon.api.mgt.version}</version>
@ -2928,6 +3058,17 @@
<id>org.wso2.carbon.analytics.api.client.feature.group</id>
<version>${carbon.analytics.version}</version>
</feature>
<!-- SSO Features -->
<feature>
<id>org.wso2.carbon.identity.authenticator.saml2.sso.feature.group</id>
<version>${identity.carbon.auth.saml2.version.iotcore}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.sso.saml.feature.group</id>
<version>${identity.inbound.auth.saml.version.iotcore}</version>
</feature>
<!-- SSO Fix-->
</features>
</configuration>
</execution>
@ -3050,6 +3191,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.analytics.dashboard.feature.group</id>
<version>${carbon.device.mgt.version}</version>
@ -3451,6 +3600,14 @@
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature.group</id>
<version>${carbon.device.mgt.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.apimgt.gateway.feature.group</id>
<version>${carbon.api.mgt.version}</version>
@ -3499,6 +3656,21 @@
<id>org.wso2.carbon.analytics.api.client.feature.group</id>
<version>${carbon.analytics.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.mediator.cache.feature.group</id>
<version>${carbon.mediation.version}</version>
</feature>
<!-- SSO Features -->
<feature>
<id>org.wso2.carbon.identity.authenticator.saml2.sso.feature.group</id>
<version>${identity.carbon.auth.saml2.version.iotcore}</version>
</feature>
<feature>
<id>org.wso2.carbon.identity.sso.saml.feature.group</id>
<version>${identity.inbound.auth.saml.version.iotcore}</version>
</feature>
<!-- SSO Fix-->
</features>
</configuration>
</execution>

@ -45,14 +45,14 @@
<include>*/**</include>
</includes>
</fileSet>
<fileSet>
<directory>src/resources/bin</directory>
<outputDirectory>wso2iot-${product.iot.version}/bin</outputDirectory>
<includes>
<include>*/**</include>
</includes>
<fileMode>755</fileMode>
</fileSet>
<!--<fileSet>-->
<!--<directory>src/resources/bin</directory>-->
<!--<outputDirectory>wso2iot-${product.iot.version}/bin</outputDirectory>-->
<!--<includes>-->
<!--<include>*/**</include>-->
<!--</includes>-->
<!--<fileMode>755</fileMode>-->
<!--</fileSet>-->
<fileSet>
<directory>src/resources/plugins</directory>
<outputDirectory>wso2iot-${product.iot.version}/plugins</outputDirectory>

@ -63,12 +63,6 @@
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature:\${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.android.feature:\${carbon.device.mgt.plugin.version}
</featureArtifactDef>
<featureArtifactDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.mobile.windows.feature:\${carbon.device.mgt.plugin.version}
</featureArtifactDef>
</featureArtifacts>
</configuration>
</execution>
@ -99,14 +93,6 @@
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.iot.virtualfirealarm.feature.group</id>
<version>${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.android.feature.group</id>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
<feature>
<id>org.wso2.carbon.device.mgt.mobile.windows.feature.group</id>
<version>\${carbon.device.mgt.plugin.version}</version>
</feature>
</features>

@ -0,0 +1 @@
Subproject commit ec24a6d552876d517c2070fdce5ccbff1b4c15bb

@ -0,0 +1,19 @@
<project name="create-data-analytics-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="location_dir" value="locationTraker"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<mkdir dir="${target-dir}"/>
<zip destfile="${target-dir}/${location_dir}.car">
<zipfileset dir="${src-dir}/${location_dir}"/>
</zip>
</target>
</project>

@ -0,0 +1,73 @@
<?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">
<groupId>org.wso2.sample</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.sample.x</artifactId>
<name>WSO2 Carbon - IoT Server Location Data Analytics Application</name>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</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}-${project.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>
<properties>
<project.version>1.0.0-SNAPSHOT</project.version>
</properties>
</project>

@ -0,0 +1,37 @@
<!--
~ 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,25 @@
<?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="turn" version="1.0.0" type="carbon/application">
<dependency artifact="location_data_visualizer_dashboard" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
<dependency artifact="location_data_visualizer_gadget" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -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="location_data_visualizer_dashboard" version="1.0.0" type="dashboards/dashboard" serverRole="DataAnalyticsServer">
<file>location-data-dashboard.json</file>
</artifact>

@ -0,0 +1 @@
{"id" : "location-data-dashboard", "title" : "Location Data Dashboard", "description" : "Location data viewer", "permissions" : {"viewers" : ["Internal/location-data-dashboard-viewer"], "editors" : ["Internal/location-data-dashboard-editor"], "owners" : ["Internal/location-data-dashboard-owner"]}, "pages" : [{"id" : "page1", "title" : "Page 1", "layout" : {"content" : {"loggedIn" : {"blocks" : [{"id" : "e5070bafe141065d065bcd63786ad9c9", "x" : 0, "y" : 0, "width" : 12, "height" : 11, "banner" : false}]}}, "fluidLayout" : false}, "isanon" : false, "content" : {"default" : {"a" : [], "b" : [], "e5070bafe141065d065bcd63786ad9c9" : [{"id" : "location-data-visualizer-0", "content" : {"id" : "location-data-visualizer", "title" : "Location Data Visuializer", "type" : "gadget", "thumbnail" : "fs://gadget/location-data-visualizer/index.jpg", "settings" : {"personalize" : true}, "data" : {"url" : "fs://gadget/location-data-visualizer/index.xml"}, "description" : "Allows to view and select US states", "notify" : {"state" : {"type" : "address", "description" : "This notifies selected state"}, "cancel" : {"type" : "boolean", "description" : "This notifies cancellation of state selection"}}, "styles" : {"title" : "Location Data Visuializer", "borders" : true}, "options" : {}, "locale_titles" : {}}}]}, "anon" : {}}}], "menu" : [{"id" : "page1", "isanon" : false, "ishidden" : false, "title" : "Page 1", "subordinates" : []}], "hideAllMenuItems" : false, "identityServerUrl" : "", "accessTokenUrl" : "", "apiKey" : "", "apiSecret" : "", "theme" : "Default Theme", "shareDashboard" : false, "isUserCustom" : false, "isEditorEnable" : false, "banner" : {"globalBannerExists" : false, "customBannerExists" : false}, "landing" : "page1", "isanon" : false, "defaultPriority" : "5"}

@ -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= "location_data_visualizer_gadget" version="1.0.0" type="dashboards/gadget" serverRole="DataAnalyticsServer">
<file>location-data-visualizer</file>
</artifact>

@ -0,0 +1,97 @@
body {
font: 10px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.point {
stroke: #000;
}
form {
margin-top: 25px;
text-align: center;
}
.slider {
width: 80%;
display: block;
margin: 0 auto;
}
output {
display: block;
margin: 25px auto;
font-size:2em;
}
div.tooltip {
position: absolute;
text-align: center;
width: 60px;
height: 28px;
padding: 2px;
font: 12px sans-serif;
background: lightsteelblue;
border: 0px;
border-radius: 8px;
pointer-events: none;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.bar {
fill: orange;
}
.bar:hover {
fill: orangered ;
}
.x.axis path {
display: none;
}
.d3-tip {
line-height: 1;
font-weight: bold;
padding: 12px;
background: rgba(0, 0, 0, 0.8);
color: #fff;
border-radius: 2px;
z-index: 1000;
}
/* Creates a small triangle extender for the tooltip */
.d3-tip:after {
box-sizing: border-box;
display: inline;
font-size: 10px;
width: 100%;
line-height: 1;
color: rgba(0, 0, 0, 0.8);
content: "\25BC";
position: absolute;
text-align: center;
}
/* Style northward tooltips differently */
.d3-tip.n:after {
margin: -1px 0 0 0;
top: 100%;
left: 0;
}
.btn-space {
margin-right: 30px;
margin-bottom: 10px;
margin-top: 10px;
}
.element-space{
margin-right: 30px;
margin-bottom: 10px;
margin-top: 10px;
}

@ -0,0 +1,23 @@
{
"id": "location-data-visualizer",
"title": "Location Data Visuializer",
"type": "gadget",
"thumbnail": "gadget/location-data-visualizer/index.jpg",
"settings": {
"personalize": true
},
"data": {
"url": "gadget/location-data-visualizer/index.xml"
},
"description": "Allows to view and select US states",
"notify": {
"state": {
"type": "address",
"description": "This notifies selected state"
},
"cancel": {
"type": "boolean",
"description": "This notifies cancellation of state selection"
}
}
}

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Location Data Visualizer" description="g1">
<Require feature="pubsub-2"/>
<Require feature="dynamic-height"/>
<Require feature="wso2-gadgets-remoteClient" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<head>
<!--
-->
<!--
loading stylesheets
-->
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" type="text/css" href="lib/css/bootstrap.css">
<!--
loading javascript libraries
-->
<script src="lib/js/jquery.js"></script>
<script src="lib/js/bootstrap.js"></script>
<script src="lib/js/d3.js"></script>
<script src="lib/js/d3tip.js"></script>
<!--
Loading created javascript functions
-->
<script src="js/RestCaller.js"></script>
<script src="js/graph.js"></script>
<script src="js/traffic.js"></script>
</head>
<body>
<script src="lib/js/d3.js"></script>
<script src="lib/js/d3tip.js"></script>
<script>
//initializing variables
var imageX=-30;
var imageY=-5;
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 1400 - margin.left - margin.right,
height = 744 - margin.top - margin.bottom;
//setting axises
var x = d3.scale.linear()
.range([0, width]);
var y = d3.scale.linear()
.range([0,height]);
loadImage(imageX,imageY);
//adding a SVG element to hold the map image
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
loadImage(imageX,imageY);
//initializing axises with database and slider with file values
getDimension();
GetInitStartTime();
GetEndTime();
</script>
<div class="well">
<div class="container">
<div class="col-sm-4">
<h3 class="text-primary">Select Time</h3>
<input class="slider form-control input-sm" type="range" id="valueSlider" value="" step="1000" min="01170000853070" max="01172715042247" oninput="outputUpdate(value)">
<output for=value id="output" hidden="true"></output>
<output id="calenderDate"></output>
<div hidden="true">
<label for="stt">Starting Time</label>
<input id="stt" name="stt" onchange="show()">
</div>
</div>
<div class="col-sm-5">
<h3 class="text-primary">Select Duration</h3>
<select class="form-control input-sm-4" id="gap" name="gap" onclick="changeStep()">
<option value=1000>1s</option>
<option value=5000>5s</option>
<option value=15000>15s</option>
<option value=30000>30s</option>
<option value=60000>1min</option>
<option value=300000>5min</option>
<option value=600000>10min</option>
<option value=3600000>1hour</option>
<option value=7200000>2hour</option>
<option value=86400000>1day</option>
</select>
</br>
<button class="btn btn-default btn-space" onclick="show() "style="align-content: center;width: 110px;height: 40px" >Show</button>
<button class="btn btn-default btn-space" onclick="showPrevious()"style="align-content: center;width: 110px;height: 40px">Previous</button>
<button class="btn btn-default btn-space" onclick="showNext()"style="align-content: center;width: 110px;height: 40px">Next</button>
<button class="btn btn-primary btn-space" onclick="play()"style="align-content: center;width: 110px;height: 40px">Play</button>
<button class="btn btn-default btn-space" onclick="showDensity()"style="align-content: center;width: 110px;height: 40px">Show Density</button>
<button class="btn btn-default btn-space" onclick="display()"style="align-content: center;width: 110px;height: 40px">Reset</button>
</div>
</div>
</div>
<div class="well">
<div class="container">
<div class="col-sm-4">
<div class="container">
<h3 class="text-primary">Typical Scenario</h3>
<select class="form-control input-sm-4 element-space" id="time" name="time" style="width: 200px" >
<option value=00>0AM</option>
<option value=01>1AM</option>
<option value=02>2AM</option>
<option value=03>3AM</option>
<option value=04>4AM</option>
<option value=05>5AM</option>
<option value=06>6AM</option>
<option value=07>7AM</option>
<option value=08>8AM</option>
<option value=09>9AM</option>
<option value=10>10AM</option>
<option value=11>11AM</option>
<option value=12>12AM</option>
<option value=13>1PM</option>
<option value=14>2PM</option>
<option value=15>3PM</option>
<option value=16>4PM</option>
<option value=17>5PM</option>
<option value=18>6PM</option>
<option value=19>7PM</option>
<option value=20>8PM</option>
<option value=21>9PM</option>
<option value=22>10PM</option>
<option value=23>11PM</option>
</select>
<select class="form-control input-sm-4 element-space" id="day" name="day" style="width: 200px" >
<option value=mon>Monday</option>
<option value=tue>Tuesday</option>
<option value=wed>Wednesday</option>
<option value=thu>Thursday</option>
<option value=fri>Friday</option>
<option value=sat>Saturday</option>
<option value=sun>Sunday</option>
</select>
<button class="btn btn-primary element-space" onclick="showScene()"style="align-content: center;width: 110px;height: 40px" >View Scenario</button>
</div>
</div>
<div class="col-sm-4 " >
<h3 class="text-primary">Upload Data file</h3>
<input class="form-control input-sm-4 element-space" id="fileupload" type="file" />
<Button class="btn btn-primary element-space" onclick="sendFile()" id="submit" style="align-content: center;width: 110px;height: 40px">Submit</Button>
</div>
<div class="col-sm-4 " >
<h3 class="text-primary">Change Image</h3>
<button class="btn btn-default btn-space" onclick="changeImage(0,1)"style="align-content: center;width: 110px;height: 40px" >Up</button>
<button class="btn btn-default btn-space" onclick="changeImage(0,-1)"style="align-content: center;width: 110px;height: 40px">Down</button>
<button class="btn btn-default btn-space" onclick="changeImage(1,0)"style="align-content: center;width: 110px;height: 40px">Left</button>
<button class="btn btn-default btn-space" onclick="changeImage(-1,0)"style="align-content: center;width: 110px;height: 40px">Right</button>
<button class="btn btn-default btn-space" onclick="showDensity()"style="align-content: center;width: 110px;height: 40px">Show Density</button>
</div>
</div>
</div>
<!-- Modal for showing frequencies-->
<div class="modal fade row-fluid" id="frequency_view" role="dialog" >
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="width: 1000px">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Sensor Triggered Frequencies</h4>
</div>
<div id="modal_body" name="modal_body" class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
]]>
</Content>
</Module>

@ -0,0 +1,511 @@
/*
* 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.
*/
//this method request starting timestamp and set it in relevant UI components
var GetInitStartTime = function(){
var endpointUrl = 'http://localhost:9763/location-data-visualizer/service/time/start' ;
wso2.gadgets.XMLHttpRequest.get(endpointUrl,
function(data){
var start =JSON.parse(JSON.stringify(data.stt));
document.getElementById("stt").value=start;
var valueSlider =document.getElementById("valueSlider");
valueSlider.innerHTML=start;
valueSlider.value=start;
valueSlider.min=parseInt(start);
setCalendarDate(start);
},
function(error){
alert(error);
}
);
}
//this method request ending timestamp and set it in relevant UI components
var GetEndTime = function(){
var url = 'http://localhost:9763/location-data-visualizer/service/time/end'
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
var end =JSON.parse(JSON.stringify(data.stt));
document.getElementById("valueSlider").max =end;
show();
},
function(error){
alert(error);
}
);
}
//when this method is called, it fletch starting time and range from UI components and request triggered sensor data in that range and draw them in the map
var show = function(){
var start = parseInt(document.getElementById('stt').value);
document.getElementById('valueSlider').value = start;
var end = start + parseInt(document.getElementById('gap').value);
var url ='http://localhost:9763/location-data-visualizer/service/data'+'?start=' + start + '&end=' + end;
var data2=[];
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
var X = data.X;
var Y = data.Y;
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i]});
}
draw(data2);
},
function(error){
alert(error);
}
);
}
//this method send a file to evaluate for typical scenario and save as output.txt
var sendFile = function(){
var file = document.getElementById('fileupload').files[0];
var fd = new FormData();
fd.append( 'file', file);
var url ='https://localhost:9763/location-data-visualizer/service/file/upload';
wso2.gadgets.XMLHttpRequest.post(url,fd,
function(data){
GetInitStartTime();
GetEndTime();
show();
},
function(error){
alert(error);
},
'application/x-www-form-urlencoded; charset=UTF-8'
);
}
//request dimension of map area. Then set those values in axises
var getDimension = function(){
var url='http://localhost:9763/location-data-visualizer/service/get/dimension';
var value;
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
Xmax = JSON.parse(JSON.stringify(data.maxX));
Ymax = JSON.parse(JSON.stringify(data.maxY));
Xmin = JSON.parse(JSON.stringify(data.minX));
Ymin = JSON.parse(JSON.stringify(data.minY));
x.domain(d3.extent([Xmin,Xmax])).nice();
y.domain(d3.extent([Ymin,Ymax])).nice();
return value;
},
function(error){
alert(error);
}
);
}
//request data chunk and call play it using doScaledTimeout Method
var play = function(){
var start=parseInt(document.getElementById('stt').value);
var chunk =parseInt(document.getElementById('gap').value)
var end = parseInt(start) + (500*parseInt(chunk));
var url= 'http://localhost:9763/location-data-visualizer/service/data/chunk'+'?start='+start+'&end='+end;
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
xList=data.X;
yList=data.Y;
tList=data.T;
cList=data.C;
var i=0;
while(i<500){
var s=parseInt(start)+(i*1000);
doScaledTimeout(i,s,tList,chunk,xList,yList,cList);
i+=1;
}
},
function(error){
alert(error);
}
);
}
//when a dataset in appropriate format is given to this function, this method will visualize that dataset on the map
var draw=function (data) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+parseFloat(d.c)};
});
});
// Compute the scales domains.
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"))
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
var div = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(isNaN(d.c)){
return colorRed(50);
}
return d3.rgb(255,d.c*255/100,d.c*255/100);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));})
};
//request triggering densities and show them with colour variations when respond comes
var showDensity = function(){
var start = parseInt(document.getElementById('stt').value);
var data2 = [];
document.getElementById('valueSlider').value = start;
var end = start + parseInt(document.getElementById('gap').value);
var url= 'http://localhost:9763/location-data-visualizer/service/data/density'+'?start=' + parseInt(document.getElementById('stt').value) + '&end=' +(parseInt(document.getElementById('stt').value)+ parseInt(document.getElementById('gap').value));
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
var X = data.X;
var Y = data.Y;
var D = data.D;
var ID = data.ID;
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i], c:parseInt(D[i]), id:ID[i]});
}
var max=D[0];
var min=D[0];
for (j=1;j<X.length;j++){
if(D[j]>max){
max=D[j];
}
if(D[j]<min){
min=D[j];
}
}
drawDensity(data2,max,min);
//alert(JSON.stringify(data));
},
function(error){
alert(error);
}
);
}
//drawing function with color variations
var drawDensity=function (data,max,min) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+(parseFloat(d.c)-min)*100/(max-min), id:parseInt(d.id)};
});
});
// Compute the scales domains.
x.domain(d3.extent([-71,40])).nice();
y.domain(d3.extent([4,65])).nice();
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(d.c==0){
return d3.rgb(255,255,255);
}
else if(d.c>20){
return colorRed(d.c);
}
else if(d.c>10){
return colorBlue(d.c);
}
else if(d.c>=0){
return colorGreen(d.c);
}
else{
return d3.rgb(255,255,255);
}
})
.on("mouseover", function(d) {
tooltip.transition()
.duration(200)
.style("opacity", .9);
tooltip.html((d.c).toFixed(2) )
.style("left", (x(parseInt(d.x)) + "px"))
.style("top", (y(parseInt(d.y)) + "px"));
})
.on("mouseout", function(d) {
tooltip.transition()
.duration(500)
.style("opacity", 0);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));})
.on("click",function (d){
var id=d.id;
getFrequency(id);
});
};
//request upcoming frequencies of a particular sensor. Show them in a modal when respond comes. Range in UI will used as range in here too
var getFrequency = function(id){
var start = parseInt(document.getElementById('stt').value);
document.getElementById('valueSlider').value = start;
var gap = parseInt(document.getElementById('gap').value);
var data1 = [];
var url='http://localhost:9763/location-data-visualizer/service/data/count'+'?start=' + start + '&gap=' + gap + '&sensor=' + id;
wso2.gadgets.XMLHttpRequest.get(url,
function(data){
var count =data.Count;
for (i = 0; i < count.length; i++) {
var gap = parseInt(document.getElementById('gap').value);
data1.push({x: tsToCal(gap,(gap*i)+start+(gap/2.0)), y: count[i]});
}
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +i, y: d.y};
});
});
var stt = parseInt(document.getElementById("stt").value);
var gap = parseInt(document.getElementById("gap").value);
d3.select("#barChart").remove();
var margin = {top: 40, right: 20, bottom: 30, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var svg2 = d3.select("#modal_body").append("svg")
.attr("id","barChart")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function (d) {
return d.y;
});
svg2.call(tip);
x.domain(data1.map(function(d) {
return d.x; }));
y.domain([0, d3.max(data1, function(d) {
return d.y; })]);
svg2.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg2.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Frequency");
svg2.selectAll(".bar")
.data(data1)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) {return x(d.x); })
.attr("width", x.rangeBand())
.attr("y", function(d) {return y(d.y); })
.attr("height", function(d) { return height - y(d.y); })
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
function type(d) {
d.y = +d.y;
return d;
}
},
function(error){
alert(error);
}
);
$("#frequency_view").modal("show");
}
var showScene = function(){
var data2=[];
var endpointUrl = 'http://localhost:9763/location-data-visualizer/service/typical/scene'+'?hour=' + document.getElementById('time').value + '&day=' +document.getElementById('day').value;
wso2.gadgets.XMLHttpRequest.get(endpointUrl,
function(data){
var X = JSON.parse(JSON.stringify(data.X));
var Y = JSON.parse(JSON.stringify(data.Y));
var C = JSON.parse(JSON.stringify(data.C));
var ID = JSON.parse(JSON.stringify(data.ID));
for (i = 0; i < X.length; i++) {
data2.push({x: X[i], y: Y[i], c:C[i], id:ID[i]});
}
drawScene(data2);
},
function(error){
alert(error);
}
);
}

@ -0,0 +1,136 @@
/*
* 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.
*/
//method to set starting time to UI component calender date
function setCalendarDate(start){
var calendarTime=timeStampToCalendarDate(start);
document.getElementById("calenderDate").innerHTML=calendarTime;
}
//method that show triggered data in the upcoming range
var showNext =function () {
var currentStart = parseInt(document.getElementById('stt').value);
var duration = parseInt(document.getElementById('gap').value);
document.getElementById("stt").value =currentStart+duration;
show();
};
//method that show triggered data in the previous range
var showPrevious =function () {
var currentStart = parseInt(document.getElementById('stt').value);
var duration = parseInt(document.getElementById('gap').value);
document.getElementById("stt").value =currentStart-duration;
show();
};
//method will update output UI component
function outputUpdate(num) {
document.querySelector('#output').value = num;
document.getElementById('stt').value =num;
setCalendarDate(num);
show();
}
//this will change value slider value according to current gap value
function changeStep() {
document.getElementById("valueSlider").step =document.getElementById("gap").value;
}
function timeStampToCalendarDate(time) {
var date = new Date(parseInt(time));
var Months =["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
return date.getFullYear()+" "+Months[date.getMonth()]+" "+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
}
//show data chunk
function showChunk(start,chunk,tList,xList,yList) {
var data2=[];
var gap=document.getElementById("gap").value;
var e=parseInt(start)+parseInt(chunk);
for(i=0;i<tList.length;i=i+1){
if(parseInt(tList[i])<e && parseInt(tList[i])>parseInt(start)){
data2.push({x:xList[i] ,y:yList[i], c:((e-parseInt(tList[i]))*100/parseInt(gap))});
}
}
return data2;
}
//show play data
function doScaledTimeout(j,start,tList,chunk,xList,yList,cList) {
setTimeout(function() {
document.getElementById('stt').value=start;
document.getElementById('output').value=start;
setCalendarDate(start);
var data2=showChunk(start,chunk,tList,xList,yList,cList);
draw(data2);
}, j * 300);
}
//colour schema for
colorRed = d3.scale.linear().domain([20,100])
.interpolate(d3.interpolateHcl)
.range([d3.rgb('#F99FA2'),d3.rgb("#F72128"),]);
colorBlue = d3.scale.linear().domain([10,20])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#00C1FF"),d3.rgb('#6670AC')]);
colorGreen = d3.scale.linear().domain([10,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#0A7E03"),d3.rgb('#0FF300')]);
var tooltip = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
//timestamp to calendar date
function tsToCal(gap,time) {
var date = new Date(parseInt(time));
var Months =["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
if(gap < 60000){
return date.getMinutes()+":"+date.getSeconds();
}
else if(gap <=7200000) {
return Months[date.getMonth()]+" "+date.getDate() + " " + date.getHours() + ":" + date.getMinutes();
}
else{
return date.getFullYear()+" "+Months[date.getMonth()]+" "+date.getDate();
}
}
//reload UI
function display() {
window.location.reload();
};
//loading image to svg element
function loadImage(x,y) {
var image = d3.select("g").append("svg:image")
.attr("xlink:href", "/portal/store/carbon.super/fs/gadget/location-data-visualizer/img/floor.jpg")
.attr("width", 1500)
.attr("height", 699)
.attr("x",x)
.attr("y",y);
}
function changeImage(x,y) {
imageX=imageX+x;
imageY=imageY+y;
loadImage(imageX,imageY);
}
//colour schema
colorData = d3.scale.linear().domain([10,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb(125,0,0),d3.rgb(255,0,0)]);

@ -0,0 +1,153 @@
/*
* 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.
*/
//when a data related to typical Scenario is passed,this method will draw it with color variations
var drawScene=function (data) {
svg.selectAll(".series").remove();
svg.selectAll(".g").remove();
var seriesNames = d3.keys(data[0])
.filter(function(d) { return d !== "x" && d!=="c" && d!="id"; })
.sort();
var series = seriesNames.map(function(series) {
return data.map(function(d) {
return {x: +parseFloat(d.x), y: +parseFloat(d.y),c:+(parseFloat(d.c)), id:parseInt(d.id)};
});
});
// Compute the scales domains.
x.domain(d3.extent([-71,40])).nice();
y.domain(d3.extent([4,65])).nice();
// Add the x-axis.
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(d3.svg.axis().scale(x).orient("bottom"));
// Add the y-axis.
svg.append("g")
.attr("class", "y axis")
.call(d3.svg.axis().scale(y).orient("left"));
// Add the points!
svg.selectAll(".series")
.data(series)
.enter().append("g")
.attr("class", "series")
.selectAll(".point")
.data(function(d) {
return d; })
.enter().append("circle")
.attr("class", "point")
.style("fill", function (d) {
if(d.c==0){
return d3.rgb(255,255,255);
}
else if(d.c>10){
return colorRed(d.c);
}
else if(d.c>3){
return colorBlue(d.c);
}
else if(d.c>=0){
return colorGreen(d.c);
}
else{
return d3.rgb(255,255,255);
}
})
.on("mouseover", function(d) {
tooltip.transition()
.duration(200)
.style("opacity", 0.9);
tooltip.html((d.c).toFixed(2) )
.style("left", (x(parseInt(d.x)) + "px"))
.style("top", (y(parseInt(d.y)) + "px"));
})
.on("mouseout", function(d) {
tooltip.transition()
.duration(500)
.style("opacity", 0);
})
.attr("r", 4.5)
.attr("cx", function(d) {
return x(parseFloat(d.x));})
.attr("cy", function(d) {
return y(parseFloat(d.y));});
};
//this method request data on typical scenario and ask to draw them in the map
function showScene() {
var data2 = [];
$.ajax({
url: "http://localhost:8080/service/typical/scene",
type: "GET",
data: "hour=" + document.getElementById("time").value + "&day=" +document.getElementById("day").value, // or $('#myform').serializeArray()
dataType: "json",
success: function (data) {
var X = JSON.parse(JSON.stringify(data.X));
var Y = JSON.parse(JSON.stringify(data.Y));
var C = JSON.parse(JSON.stringify(data.C));
var ID = JSON.parse(JSON.stringify(data.ID));
for(i = 0; i < X.length; i+=1) {
data2.push({x: X[i], y: Y[i], c:C[i], id:ID[i]});
}
drawScene(data2);
//alert(JSON.stringify(data));
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
}
//color schemas to show traffic. Red for high traffic, blue for medium traffic, green for low traffic
colorRed2 = d3.scale.linear().domain([10,100])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#F99FA2"),d3.rgb("#F72128"),]);
colorBlue2 = d3.scale.linear().domain([3,10])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#00C1FF"),d3.rgb("#6670AC")]);
colorGreen2 = d3.scale.linear().domain([3,0])
.interpolate(d3.interpolateHcl)
.range([d3.rgb("#0A7E03"),d3.rgb("#0FF300")]);

@ -0,0 +1,352 @@
/**
* d3.tip
* Copyright (c) 2013 Justin Palmer
*
* Tooltips for d3.js SVG visualizations
*/
// eslint-disable-next-line no-extra-semi
;(function(root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module with d3 as a dependency.
define([
'd3-collection',
'd3-selection'
], factory)
} else if (typeof module === 'object' && module.exports) {
/* eslint-disable global-require */
// CommonJS
var d3Collection = require('d3-collection'),
d3Selection = require('d3-selection')
module.exports = factory(d3Collection, d3Selection)
/* eslint-enable global-require */
} else {
// Browser global.
var d3 = root.d3
// eslint-disable-next-line no-param-reassign
root.d3.tip = factory(d3, d3)
}
}(this, function(d3Collection, d3Selection) {
// Public - contructs a new tooltip
//
// Returns a tip
return function() {
var direction = d3TipDirection,
offset = d3TipOffset,
html = d3TipHTML,
rootElement = document.body,
node = initNode(),
svg = null,
point = null,
target = null
function tip(vis) {
svg = getSVGNode(vis)
if (!svg) return
point = svg.createSVGPoint()
rootElement.appendChild(node)
}
// Public - show the tooltip on the screen
//
// Returns a tip
tip.show = function() {
var args = Array.prototype.slice.call(arguments)
if (args[args.length - 1] instanceof SVGElement) target = args.pop()
var content = html.apply(this, args),
poffset = offset.apply(this, args),
dir = direction.apply(this, args),
nodel = getNodeEl(),
i = directions.length,
coords,
scrollTop = document.documentElement.scrollTop ||
rootElement.scrollTop,
scrollLeft = document.documentElement.scrollLeft ||
rootElement.scrollLeft
nodel.html(content)
.style('opacity', 1).style('pointer-events', 'all')
while (i--) nodel.classed(directions[i], false)
coords = directionCallbacks.get(dir).apply(this)
nodel.classed(dir, true)
.style('top', (coords.top + poffset[0]) + scrollTop + 'px')
.style('left', (coords.left + poffset[1]) + scrollLeft + 'px')
return tip
}
// Public - hide the tooltip
//
// Returns a tip
tip.hide = function() {
var nodel = getNodeEl()
nodel.style('opacity', 0).style('pointer-events', 'none')
return tip
}
// Public: Proxy attr calls to the d3 tip container.
// Sets or gets attribute value.
//
// n - name of the attribute
// v - value of the attribute
//
// Returns tip or attribute value
// eslint-disable-next-line no-unused-vars
tip.attr = function(n, v) {
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().attr(n)
}
var args = Array.prototype.slice.call(arguments)
d3Selection.selection.prototype.attr.apply(getNodeEl(), args)
return tip
}
// Public: Proxy style calls to the d3 tip container.
// Sets or gets a style value.
//
// n - name of the property
// v - value of the property
//
// Returns tip or style property value
// eslint-disable-next-line no-unused-vars
tip.style = function(n, v) {
if (arguments.length < 2 && typeof n === 'string') {
return getNodeEl().style(n)
}
var args = Array.prototype.slice.call(arguments)
d3Selection.selection.prototype.style.apply(getNodeEl(), args)
return tip
}
// Public: Set or get the direction of the tooltip
//
// v - One of n(north), s(south), e(east), or w(west), nw(northwest),
// sw(southwest), ne(northeast) or se(southeast)
//
// Returns tip or direction
tip.direction = function(v) {
if (!arguments.length) return direction
direction = v == null ? v : functor(v)
return tip
}
// Public: Sets or gets the offset of the tip
//
// v - Array of [x, y] offset
//
// Returns offset or
tip.offset = function(v) {
if (!arguments.length) return offset
offset = v == null ? v : functor(v)
return tip
}
// Public: sets or gets the html value of the tooltip
//
// v - String value of the tip
//
// Returns html value or tip
tip.html = function(v) {
if (!arguments.length) return html
html = v == null ? v : functor(v)
return tip
}
// Public: sets or gets the root element anchor of the tooltip
//
// v - root element of the tooltip
//
// Returns root node of tip
tip.rootElement = function(v) {
if (!arguments.length) return rootElement
rootElement = v == null ? v : functor(v)
return tip
}
// Public: destroys the tooltip and removes it from the DOM
//
// Returns a tip
tip.destroy = function() {
if (node) {
getNodeEl().remove()
node = null
}
return tip
}
function d3TipDirection() { return 'n' }
function d3TipOffset() { return [0, 0] }
function d3TipHTML() { return ' ' }
var directionCallbacks = d3Collection.map({
n: directionNorth,
s: directionSouth,
e: directionEast,
w: directionWest,
nw: directionNorthWest,
ne: directionNorthEast,
sw: directionSouthWest,
se: directionSouthEast
}),
directions = directionCallbacks.keys()
function directionNorth() {
var bbox = getScreenBBox()
return {
top: bbox.n.y - node.offsetHeight,
left: bbox.n.x - node.offsetWidth / 2
}
}
function directionSouth() {
var bbox = getScreenBBox()
return {
top: bbox.s.y,
left: bbox.s.x - node.offsetWidth / 2
}
}
function directionEast() {
var bbox = getScreenBBox()
return {
top: bbox.e.y - node.offsetHeight / 2,
left: bbox.e.x
}
}
function directionWest() {
var bbox = getScreenBBox()
return {
top: bbox.w.y - node.offsetHeight / 2,
left: bbox.w.x - node.offsetWidth
}
}
function directionNorthWest() {
var bbox = getScreenBBox()
return {
top: bbox.nw.y - node.offsetHeight,
left: bbox.nw.x - node.offsetWidth
}
}
function directionNorthEast() {
var bbox = getScreenBBox()
return {
top: bbox.ne.y - node.offsetHeight,
left: bbox.ne.x
}
}
function directionSouthWest() {
var bbox = getScreenBBox()
return {
top: bbox.sw.y,
left: bbox.sw.x - node.offsetWidth
}
}
function directionSouthEast() {
var bbox = getScreenBBox()
return {
top: bbox.se.y,
left: bbox.se.x
}
}
function initNode() {
var div = d3Selection.select(document.createElement('div'))
div
.style('position', 'absolute')
.style('top', 0)
.style('opacity', 0)
.style('pointer-events', 'none')
.style('box-sizing', 'border-box')
return div.node()
}
function getSVGNode(element) {
var svgNode = element.node()
if (!svgNode) return null
if (svgNode.tagName.toLowerCase() === 'svg') return svgNode
return svgNode.ownerSVGElement
}
function getNodeEl() {
if (node == null) {
node = initNode()
// re-add node to DOM
rootElement.appendChild(node)
}
return d3Selection.select(node)
}
// Private - gets the screen coordinates of a shape
//
// Given a shape on the screen, will return an SVGPoint for the directions
// n(north), s(south), e(east), w(west), ne(northeast), se(southeast),
// nw(northwest), sw(southwest).
//
// +-+-+
// | |
// + +
// | |
// +-+-+
//
// Returns an Object {n, s, e, w, nw, sw, ne, se}
function getScreenBBox() {
var targetel = target || d3Selection.event.target
while (targetel.getScreenCTM == null && targetel.parentNode == null) {
targetel = targetel.parentNode
}
var bbox = {},
matrix = targetel.getScreenCTM(),
tbbox = targetel.getBBox(),
width = tbbox.width,
height = tbbox.height,
x = tbbox.x,
y = tbbox.y
point.x = x
point.y = y
bbox.nw = point.matrixTransform(matrix)
point.x += width
bbox.ne = point.matrixTransform(matrix)
point.y += height
bbox.se = point.matrixTransform(matrix)
point.x -= width
bbox.sw = point.matrixTransform(matrix)
point.y -= height / 2
bbox.w = point.matrixTransform(matrix)
point.x += width
bbox.e = point.matrixTransform(matrix)
point.x -= width / 2
point.y -= height / 2
bbox.n = point.matrixTransform(matrix)
point.y += height
bbox.s = point.matrixTransform(matrix)
return bbox
}
// Private - replace D3JS 3.X d3.functor() function
function functor(v) {
return typeof v === 'function' ? v : function() {
return v
}
}
return tip
}
// eslint-disable-next-line semi
}));

@ -1507,9 +1507,9 @@
<identity.carbon.auth.saml2.version>5.1.3</identity.carbon.auth.saml2.version>
<identity.carbon.auth.saml2.version.iotcore>5.1.6</identity.carbon.auth.saml2.version.iotcore>
<identity.inbound.auth.oauth.version>5.1.2</identity.inbound.auth.oauth.version>
<identity.inbound.auth.oauth.version.iotcore>5.3.1</identity.inbound.auth.oauth.version.iotcore>
<identity.inbound.auth.oauth.version.iotcore>5.3.4</identity.inbound.auth.oauth.version.iotcore>
<identity.carbon.auth.mutual.ssl.version>5.1.1</identity.carbon.auth.mutual.ssl.version>
<identity.user.ws.version>5.1.3</identity.user.ws.version>
<identity.user.ws.version>5.1.4</identity.user.ws.version>
<identity.outbound.auth.requestpath.basicauth.version>5.1.1</identity.outbound.auth.requestpath.basicauth.version>
<identity.outbound.auth.requestpath.oauth.version>5.1.1</identity.outbound.auth.requestpath.oauth.version>
<identity.outbound.auth.samlsso.version>5.1.4</identity.outbound.auth.samlsso.version>

Loading…
Cancel
Save