mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
resolved issues in connected cup sample
This commit is contained in:
parent
67c5b493af
commit
ad237ffd34
@ -29,5 +29,5 @@ public interface ContentValidator {
|
||||
* @param params that related to input adapter to identify the client and the content
|
||||
* @return
|
||||
*/
|
||||
ContentInfo validate(Map<String, String> params);
|
||||
ContentInfo validate(String msgPayload, Map<String, String> params);
|
||||
}
|
||||
|
||||
@ -120,7 +120,6 @@ public class HTTPEventAdapterFactory extends InputEventAdapterFactory {
|
||||
contentValidator.setRequired(false);
|
||||
contentValidator.setHint(
|
||||
resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME_HINT));
|
||||
propertyList.add(contentValidator);
|
||||
contentValidator.setDefaultValue(HTTPEventAdapterConstants.DEFAULT);
|
||||
propertyList.add(contentValidator);
|
||||
|
||||
@ -131,7 +130,6 @@ public class HTTPEventAdapterFactory extends InputEventAdapterFactory {
|
||||
contentValidatorParams.setRequired(false);
|
||||
contentValidatorParams.setHint(
|
||||
resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_PARAMS_HINT));
|
||||
propertyList.add(contentValidatorParams);
|
||||
contentValidatorParams.setDefaultValue(HTTPEventAdapterConstants.MQTT_CONTENT_VALIDATION_DEFAULT_PARAMETERS);
|
||||
propertyList.add(contentValidatorParams);
|
||||
return propertyList;
|
||||
|
||||
@ -30,6 +30,7 @@ import org.wso2.carbon.event.input.adapter.extensions.http.util.AuthenticationIn
|
||||
import org.wso2.carbon.event.input.adapter.extensions.http.util.HTTPContentValidator;
|
||||
import org.wso2.carbon.event.input.adapter.extensions.http.util.HTTPEventAdapterConstants;
|
||||
import org.wso2.carbon.event.input.adapter.extensions.internal.EventAdapterServiceDataHolder;
|
||||
import org.wso2.carbon.event.input.adapter.extensions.mqtt.exception.MQTTContentValidatorInitializationException;
|
||||
import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub;
|
||||
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO;
|
||||
import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken;
|
||||
@ -64,7 +65,8 @@ public class HTTPMessageServlet extends HttpServlet {
|
||||
private static String cookie;
|
||||
private static Log log = LogFactory.getLog(HTTPMessageServlet.class);
|
||||
private GenericObjectPool stubs;
|
||||
|
||||
private static Map<String, String> contentValidationProperties;
|
||||
private static ContentValidator contentValidator;
|
||||
private InputEventAdapterListener eventAdaptorListener;
|
||||
private int tenantId;
|
||||
private String exposedTransports;
|
||||
@ -76,6 +78,38 @@ public class HTTPMessageServlet extends HttpServlet {
|
||||
this.exposedTransports = eventAdapterConfiguration.getProperties().get(
|
||||
HTTPEventAdapterConstants.EXPOSED_TRANSPORTS);
|
||||
this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(eventAdapterConfiguration));
|
||||
this.contentValidationProperties = new HashMap<String, String>();
|
||||
String contentValidationParams = eventAdapterConfiguration.getProperties().get(
|
||||
HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_PARAMS);
|
||||
if (contentValidationParams != null && !contentValidationParams.isEmpty()) {
|
||||
String validationParams[] = contentValidationParams.split(",");
|
||||
for (String validationParam : validationParams) {
|
||||
String[] validationProperty = validationParam.split(":");
|
||||
if (validationProperty.length == 2) {
|
||||
contentValidationProperties.put(validationProperty[0], validationProperty[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String className = eventAdapterConfiguration.getProperties().get(
|
||||
HTTPEventAdapterConstants.ADAPTER_CONF_CONTENT_VALIDATOR_CLASSNAME);
|
||||
if (HTTPEventAdapterConstants.DEFAULT.equals(className)) {
|
||||
contentValidator = new HTTPContentValidator();
|
||||
} else {
|
||||
try {
|
||||
Class<? extends ContentValidator> contentValidatorClass = Class.forName(className)
|
||||
.asSubclass(ContentValidator.class);
|
||||
contentValidator = contentValidatorClass.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new MQTTContentValidatorInitializationException(
|
||||
"Unable to find the class authorizer: " + className, e);
|
||||
} catch (InstantiationException e) {
|
||||
throw new MQTTContentValidatorInitializationException(
|
||||
"Unable to create an instance of :" + className, e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new MQTTContentValidatorInitializationException("Access of the instance in not allowed.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getBearerToken(HttpServletRequest request) {
|
||||
@ -254,7 +288,6 @@ public class HTTPMessageServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (req.isSecure()) {
|
||||
authenticationInfo = this.checkAuthentication(req);
|
||||
int tenantId = authenticationInfo != null ? authenticationInfo.getTenantId() : -1;
|
||||
if (tenantId == -1) {
|
||||
@ -270,31 +303,28 @@ public class HTTPMessageServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Message : " + data);
|
||||
}
|
||||
|
||||
if (authenticationInfo != null) {
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.putAll(contentValidationProperties);
|
||||
Enumeration<String> reqParameterNames = req.getParameterNames();
|
||||
while (reqParameterNames.hasMoreElements()) {
|
||||
paramMap.put(reqParameterNames.nextElement(), req.getParameter(reqParameterNames.nextElement()));
|
||||
String paramterName = reqParameterNames.nextElement();
|
||||
paramMap.put(paramterName, req.getParameter(paramterName));
|
||||
}
|
||||
paramMap.put(HTTPEventAdapterConstants.USERNAME_TAG, authenticationInfo.getUsername());
|
||||
paramMap.put(HTTPEventAdapterConstants.TENANT_DOMAIN_TAG, authenticationInfo.getTenantDomain());
|
||||
paramMap.put(HTTPEventAdapterConstants.PAYLOAD_TAG, data);
|
||||
ContentValidator contentValidator = new HTTPContentValidator();
|
||||
ContentInfo contentInfo = contentValidator.validate(paramMap);
|
||||
if (contentValidator != null) {
|
||||
ContentInfo contentInfo = contentValidator.validate(data, paramMap);
|
||||
if (contentInfo != null && contentInfo.isValidContent()) {
|
||||
HTTPEventAdapter.executorService.submit(new HTTPRequestProcessor(eventAdaptorListener,
|
||||
contentInfo.getMsgText(), tenantId));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -34,9 +34,9 @@ public class HTTPContentValidator implements ContentValidator {
|
||||
private static String JSON_ARRAY_START_CHAR = "[";
|
||||
|
||||
@Override
|
||||
public ContentInfo validate(Map<String, String> paramMap) {
|
||||
public ContentInfo validate(String msgPayload, Map<String, String> paramMap) {
|
||||
String deviceId = paramMap.get("deviceId");
|
||||
String msg = paramMap.get(HTTPEventAdapterConstants.PAYLOAD_TAG);
|
||||
String msg = msgPayload;
|
||||
String deviceIdJsonPath = paramMap.get(HTTPEventAdapterConstants.DEVICE_ID_JSON_PATH);
|
||||
boolean status;
|
||||
if (msg.startsWith(JSON_ARRAY_START_CHAR)) {
|
||||
|
||||
@ -240,8 +240,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
|
||||
ContentInfo contentInfo;
|
||||
synchronized (contentValidationParams) {
|
||||
contentValidationParams.put(Constants.TOPIC, topic);
|
||||
contentValidationParams.put(Constants.PAYLOAD, msgText);
|
||||
contentInfo = contentValidator.validate(contentValidationParams);
|
||||
contentInfo = contentValidator.validate(msgText,contentValidationParams);
|
||||
contentValidationParams.remove(Constants.TOPIC);
|
||||
contentValidationParams.remove(Constants.PAYLOAD);
|
||||
}
|
||||
|
||||
@ -36,11 +36,11 @@ public class MQTTContentValidator implements ContentValidator {
|
||||
private static final Log log = LogFactory.getLog(MQTTContentValidator.class);
|
||||
|
||||
@Override
|
||||
public ContentInfo validate(Map<String, String> params) {
|
||||
public ContentInfo validate(String msgPayload, Map<String, String> params) {
|
||||
String topic = params.get(Constants.TOPIC);
|
||||
String topics[] = topic.split("/");
|
||||
|
||||
String msg = params.get(Constants.PAYLOAD);
|
||||
String msg = msgPayload;
|
||||
String deviceIdJsonPath = params.get(Constants.DEVICE_ID_JSON_PATH);
|
||||
String deviceIdInTopicHierarchyLevel = params.get(Constants.DEVICE_ID_TOPIC_HIERARCHY_INDEX);
|
||||
int deviceIdInTopicHierarchyLevelIndex = 0;
|
||||
|
||||
@ -20,14 +20,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.agent</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Agent Web app</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
@ -150,21 +150,6 @@
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>gcm-server-repository</id>
|
||||
<name>GCM Server repository - GitHub</name>
|
||||
<url>https://github.com/slorber/gcm-server-repository/raw/master/releases/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>wso2-staging</id>
|
||||
<name>WSO2 internal Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/repositories/orgwso2carbonapimgt-174/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
@ -1,5 +1,7 @@
|
||||
package org.coffeeking.agent.datasense;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.agent.transport.TransportHandlerException;
|
||||
import org.coffeeking.agent.transport.mqtt.ConnectedCupMQttTransportHandler;
|
||||
import org.json.JSONObject;
|
||||
@ -12,7 +14,7 @@ import java.io.IOException;
|
||||
import java.io.StreamCorruptedException;
|
||||
|
||||
public class PushLevel extends HttpServlet {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PushLevel.class);
|
||||
private ConnectedCupMQttTransportHandler connectedCupMQttTransportHandler;
|
||||
|
||||
public PushLevel() {
|
||||
@ -22,14 +24,26 @@ public class PushLevel extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String deviceId = req.getParameter("deviceId");
|
||||
String tenantDomain = req.getParameter("tenantDomain");
|
||||
String deviceOwner = req.getParameter("deviceOwner");
|
||||
String payload = req.getParameter("payload");
|
||||
|
||||
payload = " {\"event\": {\"metaData\": {\"owner\": \"" + deviceOwner +
|
||||
"\", \"type\": \"coffeelevel\",\"deviceId\": " +
|
||||
"\"" + deviceId + "\",\"timestamp\": " + System.currentTimeMillis() +
|
||||
"},\"payloadData\": { \"coffeelevel\": " + Float.parseFloat(payload) + ", \"temperature\": 0} }}";
|
||||
String token = (String) req.getSession().getAttribute("token");
|
||||
if (!connectedCupMQttTransportHandler.isConnected()) {
|
||||
connectedCupMQttTransportHandler.setToken(token);
|
||||
connectedCupMQttTransportHandler.connect();
|
||||
}
|
||||
try {
|
||||
connectedCupMQttTransportHandler.publishToConnectedCup(deviceOwner,deviceId,payload,0,true);
|
||||
if (connectedCupMQttTransportHandler.isConnected()) {
|
||||
connectedCupMQttTransportHandler.publishToConnectedCup(deviceOwner, deviceId, payload, tenantDomain, 0,
|
||||
true);
|
||||
}
|
||||
} catch (TransportHandlerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
log.error(e);
|
||||
resp.sendError(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package org.coffeeking.agent.datasense;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.agent.transport.TransportHandlerException;
|
||||
import org.coffeeking.agent.transport.mqtt.ConnectedCupMQttTransportHandler;
|
||||
|
||||
@ -10,7 +12,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PushTemperature extends HttpServlet {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PushTemperature.class);
|
||||
private ConnectedCupMQttTransportHandler connectedCupMQttTransportHandler;
|
||||
|
||||
public PushTemperature() {
|
||||
@ -20,13 +22,26 @@ public class PushTemperature extends HttpServlet {
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
String deviceId = req.getParameter("deviceId");
|
||||
String deviceOwner = req.getParameter("deviceOwner");
|
||||
String tenantDomain = req.getParameter("tenantDomain");
|
||||
String payload = req.getParameter("payload");
|
||||
|
||||
String deviceOwner = req.getParameter("deviceOwner");
|
||||
payload = " {\"event\": {\"metaData\": {\"owner\": \"" + deviceOwner +
|
||||
"\", \"type\": \"temperature\",\"deviceId\": " +
|
||||
"\"" + deviceId + "\",\"timestamp\": " + System.currentTimeMillis() +
|
||||
"},\"payloadData\": { \"temperature\": " + Float.parseFloat(payload) + ", \"coffeelevel\": 0} }}";
|
||||
String token = (String) req.getSession().getAttribute("token");
|
||||
if (!connectedCupMQttTransportHandler.isConnected()) {
|
||||
connectedCupMQttTransportHandler.setToken(token);
|
||||
connectedCupMQttTransportHandler.connect();
|
||||
}
|
||||
try {
|
||||
connectedCupMQttTransportHandler.publishToConnectedCup(deviceOwner,deviceId,payload,0,true);
|
||||
if (connectedCupMQttTransportHandler.isConnected()) {
|
||||
connectedCupMQttTransportHandler.publishToConnectedCup(deviceOwner, deviceId, payload, tenantDomain, 0,
|
||||
true);
|
||||
}
|
||||
} catch (TransportHandlerException e) {
|
||||
e.printStackTrace();
|
||||
log.error(e);
|
||||
resp.sendError(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -20,9 +20,7 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
|
||||
private static ConnectedCupMQttTransportHandler connectedCupMQttTransportHandler;
|
||||
|
||||
private static String publishTopic = "wso2" + File.separator + "%s" + File.separator +
|
||||
DEVICE_TYPE + File.separator + "%s" + File.separator
|
||||
+ "connected_publisher";
|
||||
private static String publishTopic = "wso2/%s/" + DEVICE_TYPE + "/%s";
|
||||
|
||||
protected ConnectedCupMQttTransportHandler() {
|
||||
super(iotServerSubscriber, DEVICE_TYPE, "tcp://localhost:1883", "");
|
||||
@ -34,6 +32,10 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
return dataPushServiceHandler;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
setUsernameAndPassword(token, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
Runnable connect = new Runnable() {
|
||||
@ -61,7 +63,6 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
};
|
||||
|
||||
Thread connectorThread = new Thread(connect);
|
||||
connectorThread.setDaemon(true);
|
||||
connectorThread.start();
|
||||
|
||||
}
|
||||
@ -70,9 +71,9 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
public void processIncomingMessage(MqttMessage message, String... messageParams) {
|
||||
}
|
||||
|
||||
public void publishToConnectedCup(String owner , String deviceId, String payLoad, int qos, boolean retained)
|
||||
public void publishToConnectedCup(String deviceOwner , String deviceId, String payLoad, String tenantDomain, int qos, boolean retained)
|
||||
throws TransportHandlerException{
|
||||
String topic = String.format(publishTopic,owner,deviceId);
|
||||
String topic = String.format(publishTopic, tenantDomain, deviceId);
|
||||
publishToQueue(topic, payLoad, qos, retained);
|
||||
}
|
||||
|
||||
@ -102,7 +103,6 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
};
|
||||
|
||||
Thread terminatorThread = new Thread(stopConnection);
|
||||
terminatorThread.setDaemon(true);
|
||||
terminatorThread.start();
|
||||
}
|
||||
|
||||
@ -135,7 +135,6 @@ public class ConnectedCupMQttTransportHandler extends MQTTTransportHandler {
|
||||
public static ConnectedCupMQttTransportHandler getInstance(){
|
||||
if(connectedCupMQttTransportHandler == null){
|
||||
connectedCupMQttTransportHandler = new ConnectedCupMQttTransportHandler();
|
||||
connectedCupMQttTransportHandler.connect();
|
||||
}
|
||||
return connectedCupMQttTransportHandler;
|
||||
}
|
||||
|
||||
@ -100,6 +100,11 @@ public abstract class MQTTTransportHandler
|
||||
this.initSubscriber();
|
||||
}
|
||||
|
||||
public void setUsernameAndPassword (String username, String password) {
|
||||
options.setUserName(username);
|
||||
options.setPassword(password.toCharArray());
|
||||
}
|
||||
|
||||
public void setTimeoutInterval(int timeoutInterval) {
|
||||
this.timeoutInterval = timeoutInterval;
|
||||
}
|
||||
|
||||
@ -39,6 +39,11 @@
|
||||
request.getSession().setAttribute("deviceOwner", deviceOwner);
|
||||
}
|
||||
|
||||
String tenantDomain = request.getParameter("tenantDomain");
|
||||
if (tenantDomain != null) {
|
||||
request.getSession().setAttribute("tenantDomain", tenantDomain);
|
||||
}
|
||||
|
||||
String token = request.getParameter("token");
|
||||
if (token != null) {
|
||||
request.getSession().setAttribute("token", token);
|
||||
@ -116,12 +121,16 @@
|
||||
function sendData() {
|
||||
var deviceId = '<%=request.getSession().getAttribute("deviceId")%>';
|
||||
var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>';
|
||||
var tempPayload = "temperature:" + temperature;
|
||||
var levelPayload = "coffeelevel:" + coffee_amount;
|
||||
var tenantDomain = '<%=request.getSession().getAttribute("tenantDomain")%>';
|
||||
if (tenantDomain == null) {
|
||||
tenantDomain = "carbon.super";
|
||||
}
|
||||
var tempPayload = temperature;
|
||||
var levelPayload = coffee_amount;
|
||||
$.post("/connected-cup-agent/push_temperature?deviceId=" + deviceId + "&deviceOwner=" + deviceOwner +
|
||||
"&payload=" + tempPayload);
|
||||
"&payload=" + tempPayload + "&tenantDomain=" + tenantDomain );
|
||||
$.post("/connected-cup-agent/push_level?deviceId=" + deviceId + "&deviceOwner=" + deviceOwner +
|
||||
"&payload=" + levelPayload);
|
||||
"&payload=" + levelPayload + "&tenantDomain=" + tenantDomain);
|
||||
setTimeout(sendData, 5000);
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
<property name="target-dir" value="target/carbonapps"/>
|
||||
<property name="src-dir" value="src/main/resources/carbonapps"/>
|
||||
|
||||
<property name="Temperature_Sensor_dir" value="Temperature_Sensor"/>
|
||||
<property name="ConnectedCup_dir" value="ConnectedCup"/>
|
||||
<property name="CoffeeLevel_Sensor_dir" value="CoffeeLevel_Sensor"/>
|
||||
|
||||
<target name="clean">
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
<target name="zip" depends="clean">
|
||||
<mkdir dir="${target-dir}"/>
|
||||
<zip destfile="${target-dir}/${Temperature_Sensor_dir}.car">
|
||||
<zipfileset dir="${src-dir}/${Temperature_Sensor_dir}"/>
|
||||
<zip destfile="${target-dir}/${ConnectedCup_dir}.car">
|
||||
<zipfileset dir="${src-dir}/${ConnectedCup_dir}"/>
|
||||
</zip>
|
||||
<zip destfile="${target-dir}/${CoffeeLevel_Sensor_dir}.car">
|
||||
<zipfileset dir="${src-dir}/${CoffeeLevel_Sensor_dir}"/>
|
||||
|
||||
@ -23,15 +23,15 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.analytics</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Analytics capp</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@ -28,8 +28,7 @@
|
||||
STRING -i,
|
||||
time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
|
||||
|
||||
|
||||
insert overwrite table DeviceCoffeeLevelSummaryData select coffeelevel, meta_deviceType as deviceType,
|
||||
insert into table DeviceCoffeeLevelSummaryData select coffeelevel, meta_deviceType as deviceType,
|
||||
meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from
|
||||
DeviceCoffeeLevelData group by coffeelevel, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as
|
||||
BIGINT);
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
/* Enter a unique ExecutionPlan */
|
||||
@Plan:name('connectedcup_execution')
|
||||
|
||||
/* Enter a unique description for ExecutionPlan */
|
||||
-- @Plan:description('connectedcup_execution')
|
||||
|
||||
/* define streams/tables and write queries here ... */
|
||||
|
||||
@Export('org.wso2.iot.devices.temperature:1.0.0')
|
||||
define stream temperature (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, temperature float);
|
||||
|
||||
@Export('org.wso2.iot.devices.coffeelevel:1.0.0')
|
||||
define stream coffeelevel (meta_owner string, meta_deviceType string, meta_deviceId string, meta_time long, coffeelevel float);
|
||||
|
||||
@Import('org.wso2.iot.connectedcup:1.0.0')
|
||||
define stream connectedcup (meta_owner string, meta_deviceId string, meta_type string, meta_timestamp long, temperature float, coffeelevel float);
|
||||
|
||||
from connectedcup[meta_type == 'coffeelevel']
|
||||
select meta_owner, 'connectedcup' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, coffeelevel
|
||||
insert into coffeelevel;
|
||||
|
||||
from connectedcup[meta_type == 'temperature']
|
||||
select meta_owner, 'connectedcup' as meta_deviceType, meta_deviceId, meta_timestamp as meta_time, temperature
|
||||
insert into temperature;
|
||||
@ -17,6 +17,7 @@
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<artifact name="Eventstore_temperature" version="1.0.0" type="analytics/eventstore" serverRole="DataAnalyticsServer">
|
||||
<file>org_wso2_iot_devices_temperature.xml</file>
|
||||
<artifact name="EventExecution_ConnectedCup" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
|
||||
<file>EventExecution_ConnectedCup.siddhiql</file>
|
||||
</artifact>
|
||||
|
||||
@ -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.
|
||||
-->
|
||||
|
||||
<eventPublisher name="EventPublisher_ConnectedCup" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventpublisher">
|
||||
<from streamName="org.wso2.iot.connectedcup" version="1.0.0"/>
|
||||
<mapping customMapping="disable" type="wso2event"/>
|
||||
<to eventAdapterType="iot-ui"/>
|
||||
</eventPublisher>
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<artifact name="Eventstream_temperature" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
|
||||
<file>org.wso2.iot.devices.temperature_1.0.0.json</file>
|
||||
<artifact name="EventPublisher_ConnectedCup" version="1.0.0" type="event/publisher" serverRole="DataAnalyticsServer">
|
||||
<file>EventPublisher_ConnectedCup.xml</file>
|
||||
</artifact>
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<eventReceiver name="EventReceiver_ConnectedCup" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
|
||||
<from eventAdapterType="oauth-mqtt">
|
||||
<property name="topic">wso2/carbon.super/connectedcup/#</property>
|
||||
<property name="username">admin</property>
|
||||
<property name="contentValidationParams">device_id_json_path:event.metaData.deviceId,device_id_topic_hierarchy_index:3</property>
|
||||
<property name="contentValidation">default</property>
|
||||
<property name="dcrUrl">https://localhost:9443/dynamic-client-web/register</property>
|
||||
<property name="url">tcp://localhost:1883</property>
|
||||
<property name="cleanSession">true</property>
|
||||
</from>
|
||||
<mapping customMapping="disable" type="json"/>
|
||||
<to streamName="org.wso2.iot.connectedcup" version="1.0.0"/>
|
||||
</eventReceiver>
|
||||
|
||||
@ -17,6 +17,6 @@
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<artifact name="Sparkscripts" version="1.0.0" type="analytics/spark" serverRole="DataAnalyticsServer">
|
||||
<file>Temperature_Sensor_Script.xml</file>
|
||||
<artifact name="EventReceiver_ConnectedCup" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
|
||||
<file>EventReceiver_ConnectedCup.xml</file>
|
||||
</artifact>
|
||||
@ -17,6 +17,7 @@
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<artifact name="Eventreceiver_temperature" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
|
||||
<file>EventReceiver_temperature.xml</file>
|
||||
<artifact name="EventStream_ConnectedCup" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
|
||||
<file>org.wso2.iot.connectedcup_1.0.0.json</file>
|
||||
</artifact>
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "org.wso2.iot.connectedcup",
|
||||
"version": "1.0.0",
|
||||
"nickName": "connectedcup stream",
|
||||
"description": "This hold the device type stream of connectedcup",
|
||||
"metaData": [
|
||||
{"name": "owner", "type": "STRING"},
|
||||
{"name": "deviceId", "type": "STRING"},
|
||||
{"name": "type", "type": "STRING"},
|
||||
{"name": "timestamp", "type": "LONG"}
|
||||
],
|
||||
"payloadData": [
|
||||
{"name": "temperature", "type": "FLOAT"},
|
||||
{"name": "coffeelevel", "type": "FLOAT"}
|
||||
]
|
||||
}
|
||||
@ -18,12 +18,10 @@
|
||||
-->
|
||||
|
||||
<artifacts>
|
||||
<artifact name="IoTServer_Sensors_CAPP" version="1.0.0" type="carbon/application">
|
||||
|
||||
<dependency artifact="Eventstream_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<dependency artifact="Eventstore_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<dependency artifact="Eventreceiver_temperature" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
|
||||
<dependency artifact="Sparkscripts" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<artifact name="ConnectedCup_CAPP" version="1.0.0" type="carbon/application">
|
||||
<dependency artifact="EventStream_ConnectedCup" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<dependency artifact="EventReceiver_ConnectedCup" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<dependency artifact="EventPublisher_ConnectedCup" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
<dependency artifact="EventExecution_ConnectedCup" version="1.0.0" include="true" serverRole="DataAnalyticsServer"/>
|
||||
</artifact>
|
||||
</artifacts>
|
||||
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<eventReceiver name="EventReceiver_temperature" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
|
||||
<from eventAdapterType="wso2event">
|
||||
<property name="events.duplicated.in.cluster">false</property>
|
||||
</from>
|
||||
<mapping customMapping="disable" type="wso2event"/>
|
||||
<to streamName="org.wso2.iot.devices.temperature" version="1.0.0"/>
|
||||
</eventReceiver>
|
||||
@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<EventStoreConfiguration>
|
||||
<Source>
|
||||
<StreamId>org.wso2.iot.devices.temperature:1.0.0</StreamId>
|
||||
</Source>
|
||||
<RecordStoreName>EVENT_STORE</RecordStoreName>
|
||||
<TableSchema>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_owner</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceType</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_deviceId</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>STRING</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>meta_time</Name>
|
||||
<EnableIndexing>true</EnableIndexing>
|
||||
<IsPrimaryKey>true</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>LONG</Type>
|
||||
</ColumnDefinition>
|
||||
<ColumnDefinition>
|
||||
<Name>temperature</Name>
|
||||
<EnableIndexing>false</EnableIndexing>
|
||||
<IsPrimaryKey>false</IsPrimaryKey>
|
||||
<EnableScoreParam>false</EnableScoreParam>
|
||||
<Type>FLOAT</Type>
|
||||
</ColumnDefinition>
|
||||
</TableSchema>
|
||||
</EventStoreConfiguration>
|
||||
@ -1,20 +0,0 @@
|
||||
{
|
||||
"name": "org.wso2.iot.devices.temperature",
|
||||
"version": "1.0.0",
|
||||
"nickName": "Temperature Data",
|
||||
"description": "Temperature data received from the Device",
|
||||
"metaData": [
|
||||
{"name":"owner","type":"STRING"},
|
||||
{"name":"deviceType","type":"STRING"},
|
||||
{"name":"deviceId","type":"STRING"},
|
||||
{"name":"time","type":"LONG"}
|
||||
],
|
||||
"payloadData": [
|
||||
{
|
||||
"name": "temperature","type": "FLOAT"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<Analytics>
|
||||
<Name>Temperature_Sensor_Script</Name>
|
||||
<Script>
|
||||
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");
|
||||
|
||||
CREATE TEMPORARY TABLE DeviceTemperatureSummaryData USING CarbonAnalytics OPTIONS (tableName "DEVICE_TEMPERATURE_SUMMARY", schema "temperature FLOAT, deviceType STRING -i, deviceId STRING -i, owner STRING -i, time LONG -i",primaryKeys "deviceType, deviceId, owner, time");
|
||||
|
||||
|
||||
insert overwrite table DeviceTemperatureSummaryData select temperature, meta_deviceType as deviceType, meta_deviceId as deviceId, meta_owner as owner, cast(meta_time/1000 as BIGINT)as time from DeviceTemperatureData group by temperature, meta_deviceType, meta_deviceId, meta_owner, cast(meta_time/1000 as BIGINT);
|
||||
</Script>
|
||||
<CronExpression>0 * * * * ?</CronExpression>
|
||||
</Analytics>
|
||||
@ -22,14 +22,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.api</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup API</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup API</description>
|
||||
@ -40,10 +40,12 @@
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
@ -52,65 +54,47 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!--CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--MQTT -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--IOT -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--JAX-RS -->
|
||||
<dependency>
|
||||
@ -124,123 +108,44 @@
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle.wso2</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.base</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-fileupload.wso2</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<!--plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin-->
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
||||
@ -22,10 +22,12 @@ import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
||||
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.Feature;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
@ -39,6 +41,16 @@ public interface ConnectedCupControllerService {
|
||||
@POST
|
||||
@Feature(code = "ordercoffee", name = "Order Coffee", type = "control",
|
||||
description = "Order coffee cup")
|
||||
Response orderCoffee(@QueryParam("deviceId") String deviceId, @QueryParam("deviceOwner") String deviceOwner);
|
||||
Response orderCoffee(@QueryParam("deviceId") String deviceId);
|
||||
|
||||
/**
|
||||
* Retrieve Sensor data for the device type
|
||||
*/
|
||||
@Path("stats/{deviceId}/sensors/{sensorName}")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
Response getDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor,
|
||||
@QueryParam("from") long from, @QueryParam("to") long to);
|
||||
|
||||
}
|
||||
|
||||
@ -20,73 +20,98 @@ package org.coffeeking.api;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.api.util.APIUtil;
|
||||
import org.coffeeking.api.util.SensorRecord;
|
||||
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.coffeeking.api.transport.ConnectedCupMQTTConnector;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttConfig;
|
||||
import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
|
||||
import org.wso2.carbon.device.mgt.iot.service.IoTServerStartupListener;
|
||||
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SORT;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
|
||||
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConnectedCupControllerServiceImpl implements ConnectedCupControllerService {
|
||||
|
||||
private static Log log = LogFactory.getLog(ConnectedCupControllerServiceImpl.class);
|
||||
private static ConnectedCupMQTTConnector connectedCupMQTTConnector;
|
||||
|
||||
@Path("device/ordercoffee")
|
||||
@POST
|
||||
public Response orderCoffee(@QueryParam("deviceId") String deviceId, @QueryParam("deviceOwner") String deviceOwner) {
|
||||
public Response orderCoffee(@QueryParam("deviceId") String deviceId) {
|
||||
try {
|
||||
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(new DeviceIdentifier(deviceId,
|
||||
ConnectedCupConstants.DEVICE_TYPE))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
log.info("Coffee ordered....!");
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sending request to read liquid level value of device [" + deviceId + "] via MQTT");
|
||||
}
|
||||
return Response.ok().entity("Coffee ordered.").build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public ConnectedCupMQTTConnector getConnectedCupMQTTConnector() {
|
||||
return ConnectedCupControllerServiceImpl.connectedCupMQTTConnector;
|
||||
}
|
||||
@Path("stats/{deviceId}/sensors/{sensorName}")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
public Response getDeviceStats(@PathParam("deviceId") String deviceId, @PathParam("sensorName") String sensor,
|
||||
@QueryParam("from") long from, @QueryParam("to") long to) {
|
||||
String fromDate = String.valueOf(from);
|
||||
String toDate = String.valueOf(to);
|
||||
String query = " deviceId:" + deviceId + " AND deviceType:" +
|
||||
ConnectedCupConstants.DEVICE_TYPE + " AND time : [" + fromDate + " TO " + toDate + "]";
|
||||
String sensorTableName = getSensorEventTableName(sensor);
|
||||
|
||||
public void setConnectedCupMQTTConnector(
|
||||
final ConnectedCupMQTTConnector connectedCupMQTTConnector) {
|
||||
|
||||
Runnable connector = new Runnable() {
|
||||
public void run() {
|
||||
if (waitForServerStartup()) {
|
||||
return;
|
||||
}
|
||||
ConnectedCupControllerServiceImpl.connectedCupMQTTConnector = connectedCupMQTTConnector;
|
||||
if (MqttConfig.getInstance().isEnabled()) {
|
||||
connectedCupMQTTConnector.connect();
|
||||
} else {
|
||||
log.warn("MQTT disabled in 'devicemgt-config.xml'. " +
|
||||
"Hence, ConnectedCupMQTTConnector not started.");
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread connectorThread = new Thread(connector);
|
||||
connectorThread.setDaemon(true);
|
||||
connectorThread.start();
|
||||
}
|
||||
|
||||
private boolean waitForServerStartup() {
|
||||
while (!IoTServerStartupListener.isServerReady()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
return true;
|
||||
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(new DeviceIdentifier(deviceId,
|
||||
ConnectedCupConstants.DEVICE_TYPE))) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
List<SensorRecord> sensorDatas;
|
||||
List<SortByField> sortByFields = new ArrayList<>();
|
||||
SortByField sortByField = new SortByField("time", SORT.ASC, false);
|
||||
sortByFields.add(sortByField);
|
||||
sensorDatas = APIUtil.getAllEventsForDevice(sensorTableName, query, sortByFields);
|
||||
return Response.ok().entity(sensorDatas).build();
|
||||
} catch (AnalyticsException e) {
|
||||
String errorMsg = "Error on retrieving stats on table " + sensorTableName + " with query " + query;
|
||||
log.error(errorMsg);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).entity(errorMsg).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage());
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
/**
|
||||
* get the event table from the sensor name.
|
||||
*/
|
||||
private String getSensorEventTableName(String sensorName) {
|
||||
String sensorEventTableName;
|
||||
switch (sensorName) {
|
||||
case "temperature":
|
||||
sensorEventTableName = "DEVICE_TEMPERATURE_SUMMARY";
|
||||
break;
|
||||
case "coffeelevel":
|
||||
sensorEventTableName = "DEVICE_COFFEELEVEL_SUMMARY";
|
||||
break;
|
||||
default:
|
||||
sensorEventTableName = "";
|
||||
}
|
||||
return sensorEventTableName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
@ -37,19 +38,23 @@ import javax.ws.rs.core.Response;
|
||||
@DeviceType("connectedcup")
|
||||
public interface ConnectedCupManagerService {
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@DELETE
|
||||
Response removeDevice(@PathParam("device_id") String deviceId);
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@PUT
|
||||
Response updateDevice(@PathParam("device_id") String deviceId,
|
||||
@QueryParam("name") String name);
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@GET
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
Response getDevice(@PathParam("device_id") String deviceId);
|
||||
|
||||
@Path("/devices")
|
||||
@POST
|
||||
boolean register(@QueryParam("name") String name);
|
||||
|
||||
}
|
||||
|
||||
@ -26,10 +26,12 @@ import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
@ -47,13 +49,16 @@ public class ConnectedCupManagerServiceImpl implements ConnectedCupManagerServic
|
||||
|
||||
private static Log log = LogFactory.getLog(ConnectedCupManagerServiceImpl.class);
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@DELETE
|
||||
public Response removeDevice(@PathParam("device_id") String deviceId) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(ConnectedCupConstants.DEVICE_TYPE);
|
||||
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(deviceIdentifier)) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
boolean removed = APIUtil.getDeviceManagementService().disenrollDevice(
|
||||
deviceIdentifier);
|
||||
if (removed) {
|
||||
@ -63,16 +68,22 @@ public class ConnectedCupManagerServiceImpl implements ConnectedCupManagerServic
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@PUT
|
||||
public Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name) {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(ConnectedCupConstants.DEVICE_TYPE);
|
||||
try {
|
||||
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(deviceIdentifier)) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
Device device = APIUtil.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
device.setDeviceIdentifier(deviceId);
|
||||
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
||||
@ -87,29 +98,42 @@ public class ConnectedCupManagerServiceImpl implements ConnectedCupManagerServic
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error(e.getErrorMessage());
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@Path("/devices/{device_id}")
|
||||
@GET
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Response getDevice(@PathParam("device_id") String deviceId) {
|
||||
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(ConnectedCupConstants.DEVICE_TYPE);
|
||||
try {
|
||||
if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized(deviceIdentifier)) {
|
||||
return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build();
|
||||
}
|
||||
Device device = APIUtil.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
return Response.ok().entity(device).build();
|
||||
} catch (DeviceManagementException ex) {
|
||||
log.error("Error occurred while retrieving device with Id " + deviceId + "\n" + ex);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
} catch (DeviceAccessAuthorizationException e) {
|
||||
log.error(e.getErrorMessage(), e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean register(String deviceId, String name) {
|
||||
@Path("/devices")
|
||||
@POST
|
||||
public boolean register(@QueryParam("name") String name) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
String deviceId = shortUUID();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(ConnectedCupConstants.DEVICE_TYPE);
|
||||
if (APIUtil.getDeviceManagementService().isEnrolled(deviceIdentifier)) {
|
||||
@ -121,12 +145,12 @@ public class ConnectedCupManagerServiceImpl implements ConnectedCupManagerServic
|
||||
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
|
||||
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
|
||||
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
||||
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
||||
device.setName(name);
|
||||
device.setType(ConnectedCupConstants.DEVICE_TYPE);
|
||||
enrolmentInfo.setOwner(APIUtil.getAuthenticatedUser());
|
||||
device.setEnrolmentInfo(enrolmentInfo);
|
||||
boolean added = APIUtil.getDeviceManagementService().enrollDevice(device);
|
||||
return added;
|
||||
return APIUtil.getDeviceManagementService().enrollDevice(device);
|
||||
} catch (DeviceManagementException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.coffeeking.api.dto;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class DeviceJSON {
|
||||
|
||||
@XmlElement(required = true)
|
||||
public String owner;
|
||||
@XmlElement(required = true)
|
||||
public String deviceId;
|
||||
@XmlElement(required = true)
|
||||
public String reply;
|
||||
@XmlElement
|
||||
public Long time;
|
||||
@XmlElement
|
||||
public String key;
|
||||
@XmlElement
|
||||
public float value;
|
||||
|
||||
}
|
||||
@ -1,200 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.coffeeking.api.transport;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.api.util.ConnectedCupServiceUtils;
|
||||
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.iot.config.server.DeviceManagementConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttConfig;
|
||||
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
|
||||
import org.wso2.carbon.device.mgt.iot.transport.mqtt.MQTTTransportHandler;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Calendar;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("no JAX-WS annotation")
|
||||
public class ConnectedCupMQTTConnector extends MQTTTransportHandler {
|
||||
|
||||
private static Log log = LogFactory.getLog(ConnectedCupMQTTConnector.class);
|
||||
private static final String subscribeTopic = "wso2/" + ConnectedCupConstants.DEVICE_TYPE + "/+/publisher";
|
||||
private static String iotServerSubscriber = UUID.randomUUID().toString().substring(0, 5);
|
||||
|
||||
private ConnectedCupMQTTConnector() {
|
||||
super(iotServerSubscriber, ConnectedCupConstants.DEVICE_TYPE,
|
||||
MqttConfig.getInstance().getMqttQueueEndpoint(), subscribeTopic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
Runnable connector = new Runnable() {
|
||||
public void run() {
|
||||
while (!isConnected()) {
|
||||
try {
|
||||
connectToQueue();
|
||||
subscribeToQueue();
|
||||
} catch (TransportHandlerException e) {
|
||||
log.warn("Connection/Subscription to MQTT Broker at: " + mqttBrokerEndPoint + " failed");
|
||||
try {
|
||||
Thread.sleep(timeoutInterval);
|
||||
} catch (InterruptedException ex) {
|
||||
log.error("MQTT-Subscriber: Thread Sleep Interrupt Exception.", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Thread connectorThread = new Thread(connector);
|
||||
connectorThread.setDaemon(true);
|
||||
connectorThread.start();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void publishDeviceData(String... publishData) throws TransportHandlerException {
|
||||
if (publishData.length != 4) {
|
||||
String errorMsg = "Incorrect number of arguments received to SEND-MQTT Message. " +
|
||||
"Need to be [owner, deviceId, resource{BULB/TEMP}, state{ON/OFF or null}]";
|
||||
log.error(errorMsg);
|
||||
throw new TransportHandlerException(errorMsg);
|
||||
}
|
||||
|
||||
String deviceOwner = publishData[0];
|
||||
String deviceId = publishData[1];
|
||||
String resource = publishData[2];
|
||||
String state = publishData[3];
|
||||
|
||||
MqttMessage pushMessage = new MqttMessage();
|
||||
String publishTopic =
|
||||
"wso2" + File.separator + deviceOwner + File.separator + ConnectedCupConstants.DEVICE_TYPE +
|
||||
File.separator + deviceId;
|
||||
|
||||
try {
|
||||
String actualMessage = resource + ":" + state;
|
||||
pushMessage.setPayload(actualMessage.getBytes(StandardCharsets.UTF_8));
|
||||
pushMessage.setQos(DEFAULT_MQTT_QUALITY_OF_SERVICE);
|
||||
pushMessage.setRetained(false);
|
||||
publishToQueue(publishTopic, pushMessage);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = "Preparing payload failed for device - [" + deviceId + "] of owner - " +
|
||||
"[" + deviceOwner + "].";
|
||||
log.error(errorMsg);
|
||||
throw new TransportHandlerException(errorMsg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage(MqttMessage message, String... messageParams) throws TransportHandlerException {
|
||||
if (messageParams.length != 0) {
|
||||
String topic = messageParams[0];
|
||||
String[] topicParams = topic.split("/");
|
||||
String deviceId = topicParams[2];
|
||||
String receivedMessage = message.toString();
|
||||
String[] messageData = receivedMessage.split(":");
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Received MQTT message for: [DEVICE.ID-" + deviceId + "]");
|
||||
log.debug("Message [" + receivedMessage + "] topic: [" + topic + "]");
|
||||
}
|
||||
|
||||
try {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService != null) {
|
||||
DeviceIdentifier identifier = new DeviceIdentifier(deviceId, ConnectedCupConstants.DEVICE_TYPE);
|
||||
Device device = deviceManagementProviderService.getDevice(identifier);
|
||||
if (device != null) {
|
||||
String owner = device.getEnrolmentInfo().getOwner();
|
||||
ctx.setTenantDomain(MultitenantUtils.getTenantDomain(owner), true);
|
||||
ctx.setUsername(owner);
|
||||
if (!ConnectedCupServiceUtils.publishToDAS(deviceId, messageData[0], Float.parseFloat
|
||||
(messageData[1]))) {
|
||||
log.error("MQTT Subscriber: Publishing data to DAS failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Failed to retreive the device managment service for device type " +
|
||||
ConnectedCupConstants.DEVICE_TYPE, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
Runnable stopConnection = new Runnable() {
|
||||
public void run() {
|
||||
while (isConnected()) {
|
||||
try {
|
||||
closeConnection();
|
||||
} catch (MqttException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.warn("Unable to 'STOP' MQTT connection at broker at: " + mqttBrokerEndPoint
|
||||
+ " for device-type - " + ConnectedCupConstants.DEVICE_TYPE, e);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(timeoutInterval);
|
||||
} catch (InterruptedException e1) {
|
||||
log.error("MQTT-Terminator: Thread Sleep Interrupt Exception at device-type - " +
|
||||
ConnectedCupConstants.DEVICE_TYPE, e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread terminatorThread = new Thread(stopConnection);
|
||||
terminatorThread.setDaemon(true);
|
||||
terminatorThread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDeviceData() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDeviceData(MqttMessage publishData) throws TransportHandlerException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage(MqttMessage message) throws TransportHandlerException {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,9 +2,22 @@ package org.coffeeking.api.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.analytics.api.AnalyticsDataAPI;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry;
|
||||
import org.wso2.carbon.analytics.dataservice.commons.SortByField;
|
||||
import org.wso2.carbon.analytics.dataservice.core.AnalyticsDataServiceUtils;
|
||||
import org.wso2.carbon.analytics.datasource.commons.Record;
|
||||
import org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class provides utility functions used by REST-API.
|
||||
@ -23,12 +36,6 @@ public class APIUtil {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static String getTenantDomainOftheUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
@ -41,15 +48,90 @@ public class APIUtil {
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public static APIManagementProviderService getAPIManagementProviderService() {
|
||||
public static DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
APIManagementProviderService apiManagementProviderService =
|
||||
(APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null);
|
||||
if (apiManagementProviderService == null) {
|
||||
String msg = "API management provider service has not initialized.";
|
||||
DeviceAccessAuthorizationService deviceAccessAuthorizationService =
|
||||
(DeviceAccessAuthorizationService) ctx.getOSGiService(DeviceAccessAuthorizationService.class, null);
|
||||
if (deviceAccessAuthorizationService == null) {
|
||||
String msg = "Device Authorization service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return apiManagementProviderService;
|
||||
return deviceAccessAuthorizationService;
|
||||
}
|
||||
|
||||
public static AnalyticsDataAPI getAnalyticsDataAPI() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
AnalyticsDataAPI analyticsDataAPI =
|
||||
(AnalyticsDataAPI) ctx.getOSGiService(AnalyticsDataAPI.class, null);
|
||||
if (analyticsDataAPI == null) {
|
||||
String msg = "Analytics api service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return analyticsDataAPI;
|
||||
}
|
||||
|
||||
public static List<SensorRecord> getAllEventsForDevice(String tableName, String query,
|
||||
List<SortByField> sortByFields) throws AnalyticsException {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
AnalyticsDataAPI analyticsDataAPI = getAnalyticsDataAPI();
|
||||
int eventCount = analyticsDataAPI.searchCount(tenantId, tableName, query);
|
||||
if (eventCount == 0) {
|
||||
return null;
|
||||
}
|
||||
List<SearchResultEntry> resultEntries = analyticsDataAPI.search(tenantId, tableName, query, 0, eventCount,
|
||||
sortByFields);
|
||||
List<String> recordIds = getRecordIds(resultEntries);
|
||||
AnalyticsDataResponse response = analyticsDataAPI.get(tenantId, tableName, 1, null, recordIds);
|
||||
Map<String, SensorRecord> sensorDatas = createSensorData(AnalyticsDataServiceUtils.listRecords(
|
||||
analyticsDataAPI, response));
|
||||
List<SensorRecord> sortedSensorData = getSortedSensorData(sensorDatas, resultEntries);
|
||||
return sortedSensorData;
|
||||
}
|
||||
|
||||
private static List<String> getRecordIds(List<SearchResultEntry> searchResults) {
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (SearchResultEntry searchResult : searchResults) {
|
||||
ids.add(searchResult.getId());
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static List<SensorRecord> getSortedSensorData(Map<String, SensorRecord> sensorDatas,
|
||||
List<SearchResultEntry> searchResults) {
|
||||
List<SensorRecord> sortedRecords = new ArrayList<>();
|
||||
for (SearchResultEntry searchResultEntry : searchResults) {
|
||||
sortedRecords.add(sensorDatas.get(searchResultEntry.getId()));
|
||||
}
|
||||
return sortedRecords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the SensorDatas from records.
|
||||
*
|
||||
* @param records the records
|
||||
* @return the Map of SensorRecord <id, SensorRecord>
|
||||
*/
|
||||
public static Map<String, SensorRecord> createSensorData(List<Record> records) {
|
||||
Map<String, SensorRecord> sensorDatas = new HashMap<>();
|
||||
for (Record record : records) {
|
||||
SensorRecord sensorData = createSensorData(record);
|
||||
sensorDatas.put(sensorData.getId(), sensorData);
|
||||
}
|
||||
return sensorDatas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a SensorRecord object out of a Record object
|
||||
*
|
||||
* @param record the record object
|
||||
* @return SensorRecord object
|
||||
*/
|
||||
public static SensorRecord createSensorData(Record record) {
|
||||
SensorRecord recordBean = new SensorRecord();
|
||||
recordBean.setId(record.getId());
|
||||
recordBean.setValues(record.getValues());
|
||||
return recordBean;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,218 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.coffeeking.api.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.concurrent.FutureCallback;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClients;
|
||||
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.analytics.data.publisher.exception.DataPublisherConfigurationException;
|
||||
import org.wso2.carbon.device.mgt.analytics.data.publisher.service.EventsPublisherService;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class ConnectedCupServiceUtils {
|
||||
private static final Log log = LogFactory.getLog(ConnectedCupServiceUtils.class);
|
||||
|
||||
private static final String TEMPERATURE_STREAM_DEFINITION = "org.wso2.iot.devices.temperature";
|
||||
private static final String COFFEE_LEVEL_STREAM_DEFINITION = "org.wso2.iot.devices.coffeelevel";
|
||||
|
||||
public static String sendCommandViaHTTP(final String deviceHTTPEndpoint, String urlContext,
|
||||
boolean fireAndForgot) throws DeviceManagementException {
|
||||
|
||||
String responseMsg = "";
|
||||
String urlString = ConnectedCupConstants.URL_PREFIX + deviceHTTPEndpoint + urlContext;
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(urlString);
|
||||
}
|
||||
|
||||
if (!fireAndForgot) {
|
||||
HttpURLConnection httpConnection = getHttpConnection(urlString);
|
||||
|
||||
try {
|
||||
httpConnection.setRequestMethod(HttpMethod.GET);
|
||||
} catch (ProtocolException e) {
|
||||
String errorMsg =
|
||||
"Protocol specific error occurred when trying to set method to GET" +
|
||||
" for:" + urlString;
|
||||
log.error(errorMsg);
|
||||
throw new DeviceManagementException(errorMsg, e);
|
||||
}
|
||||
|
||||
responseMsg = readResponseFromGetRequest(httpConnection);
|
||||
|
||||
} else {
|
||||
CloseableHttpAsyncClient httpclient = null;
|
||||
try {
|
||||
|
||||
httpclient = HttpAsyncClients.createDefault();
|
||||
httpclient.start();
|
||||
HttpGet request = new HttpGet(urlString);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
Future<HttpResponse> future = httpclient.execute(
|
||||
request, new FutureCallback<HttpResponse>() {
|
||||
@Override
|
||||
public void completed(HttpResponse httpResponse) {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Exception e) {
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelled() {
|
||||
latch.countDown();
|
||||
}
|
||||
});
|
||||
|
||||
latch.await();
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Sync Interrupted");
|
||||
}
|
||||
} finally {
|
||||
try {
|
||||
if (httpclient != null) {
|
||||
httpclient.close();
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Failed on close");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return responseMsg;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------
|
||||
Utility methods relevant to creating and sending http requests
|
||||
--------------------------------------------------------------------------------------- */
|
||||
|
||||
/* This methods creates and returns a http connection object */
|
||||
|
||||
public static HttpURLConnection getHttpConnection(String urlString) throws
|
||||
DeviceManagementException {
|
||||
|
||||
URL connectionUrl = null;
|
||||
HttpURLConnection httpConnection;
|
||||
|
||||
try {
|
||||
connectionUrl = new URL(urlString);
|
||||
httpConnection = (HttpURLConnection) connectionUrl.openConnection();
|
||||
} catch (MalformedURLException e) {
|
||||
String errorMsg =
|
||||
"Error occured whilst trying to form HTTP-URL from string: " + urlString;
|
||||
log.error(errorMsg);
|
||||
throw new DeviceManagementException(errorMsg, e);
|
||||
} catch (IOException e) {
|
||||
String errorMsg = "Error occured whilst trying to open a connection to: " +
|
||||
connectionUrl.toString();
|
||||
log.error(errorMsg);
|
||||
throw new DeviceManagementException(errorMsg, e);
|
||||
}
|
||||
|
||||
return httpConnection;
|
||||
}
|
||||
|
||||
/* This methods reads and returns the response from the connection */
|
||||
|
||||
public static String readResponseFromGetRequest(HttpURLConnection httpConnection)
|
||||
throws DeviceManagementException {
|
||||
BufferedReader bufferedReader;
|
||||
try {
|
||||
bufferedReader = new BufferedReader(new InputStreamReader(
|
||||
httpConnection.getInputStream()));
|
||||
} catch (IOException e) {
|
||||
String errorMsg =
|
||||
"There is an issue with connecting the reader to the input stream at: " +
|
||||
httpConnection.getURL();
|
||||
log.error(errorMsg);
|
||||
throw new DeviceManagementException(errorMsg, e);
|
||||
}
|
||||
|
||||
String responseLine;
|
||||
StringBuilder completeResponse = new StringBuilder();
|
||||
|
||||
try {
|
||||
while ((responseLine = bufferedReader.readLine()) != null) {
|
||||
completeResponse.append(responseLine);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
String errorMsg =
|
||||
"Error occured whilst trying read from the connection stream at: " +
|
||||
httpConnection.getURL();
|
||||
log.error(errorMsg);
|
||||
throw new DeviceManagementException(errorMsg, e);
|
||||
}
|
||||
try {
|
||||
bufferedReader.close();
|
||||
} catch (IOException e) {
|
||||
log.error(
|
||||
"Could not succesfully close the bufferedReader to the connection at: " +
|
||||
httpConnection.getURL());
|
||||
}
|
||||
|
||||
return completeResponse.toString();
|
||||
}
|
||||
|
||||
public static boolean publishToDAS(String deviceId, String sensor, float values) {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
EventsPublisherService deviceAnalyticsService = (EventsPublisherService) ctx.getOSGiService(
|
||||
EventsPublisherService.class, null);
|
||||
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
Object metdaData[] = {owner, ConnectedCupConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()};
|
||||
Object payloadData[] = {values};
|
||||
try {
|
||||
switch (sensor) {
|
||||
case "temperature":
|
||||
deviceAnalyticsService.publishEvent(TEMPERATURE_STREAM_DEFINITION, "1.0.0", metdaData,
|
||||
new Object[0], payloadData);
|
||||
break;
|
||||
case "coffeelevel":
|
||||
deviceAnalyticsService.publishEvent(COFFEE_LEVEL_STREAM_DEFINITION, "1.0.0", metdaData,
|
||||
new Object[0], payloadData);
|
||||
}
|
||||
} catch (DataPublisherConfigurationException e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.coffeeking.api.util;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* This stores sensor event data for android sense.
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class SensorRecord {
|
||||
|
||||
@XmlElementWrapper(required = true, name = "values")
|
||||
private Map<String, Object> values;
|
||||
|
||||
/** The id. */
|
||||
@XmlElement(required = false, name = "id")
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Gets the values.
|
||||
* @return the values
|
||||
*/
|
||||
public Map<String, Object> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the values.
|
||||
* @param values the values
|
||||
*/
|
||||
public void setValues(Map<String, Object> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
List<String> valueList = new ArrayList<String>();
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
valueList.add(entry.getKey() + ":" + entry.getValue());
|
||||
}
|
||||
return valueList.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -32,43 +32,43 @@
|
||||
<Permission>
|
||||
<name>Get device</name>
|
||||
<path>/device-mgt/user/devices/list</path>
|
||||
<url>/devices/*</url>
|
||||
<url>/enrollment/devices/*</url>
|
||||
<method>GET</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove device</name>
|
||||
<path>/device-mgt/user/devices/remove</path>
|
||||
<url>/devices/*</url>
|
||||
<url>/enrollment/devices/*</url>
|
||||
<method>DELETE</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update device</name>
|
||||
<path>/device-mgt/user/devices/update</path>
|
||||
<url>/devices/*</url>
|
||||
<url>/enrollment/devices/*</url>
|
||||
<method>PUT</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Register a device</name>
|
||||
<path>/device-mgt/user/devices</path>
|
||||
<url>/enrollment/devices</url>
|
||||
<method>POST</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Get coffee level</name>
|
||||
<path>/device-mgt/user/device/coffeelevel</path>
|
||||
<url>/device/coffeelevel</url>
|
||||
<method>GET</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Get temperature</name>
|
||||
<path>/device-mgt/user/device/temperature</path>
|
||||
<url>/device/temperature</url>
|
||||
<method>GET</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Order coffee cup</name>
|
||||
<path>/device-mgt/user/device/ordercoffee</path>
|
||||
<path>/device-mgt/user/operation</path>
|
||||
<url>/device/ordercoffee</url>
|
||||
<method>POST</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>get device stats</name>
|
||||
<path>/device-mgt/user/stats</path>
|
||||
<url>/stats/*/sensors/*</url>
|
||||
<method>GET</method>
|
||||
<scope>android_sense_device</scope>
|
||||
</Permission>
|
||||
</PermissionConfiguration>
|
||||
@ -29,7 +29,6 @@
|
||||
<jaxrs:serviceBeans>
|
||||
<bean id="ConnectedCupControllerService"
|
||||
class="org.coffeeking.api.ConnectedCupControllerServiceImpl">
|
||||
<property name="connectedCupMQTTConnector" ref="communicationHandler"/>
|
||||
</bean>
|
||||
<bean id="ConnectedCupManagerService"
|
||||
class="org.coffeeking.api.ConnectedCupManagerServiceImpl">
|
||||
@ -40,8 +39,4 @@
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
|
||||
<bean
|
||||
id="communicationHandler" class="org.coffeeking.api.transport.ConnectedCupMQTTConnector">
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>Request coffee level</name>
|
||||
<path>/device-mgt/devices/connectedcup/coffeelevel</path>
|
||||
<url>/controller/coffeelevel</url>
|
||||
<method>GET</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Request temperature</name>
|
||||
<path>/device-mgt/devices/connectedcup/temperature</path>
|
||||
<url>/controller/temperature</url>
|
||||
<method>GET</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Order coffee cup</name>
|
||||
<path>/device-mgt/devices/connectedcup/ordercoffee</path>
|
||||
<url>/controller/ordercoffee</url>
|
||||
<method>POST</method>
|
||||
<scope>connectedcup_user</scope>
|
||||
</Permission>
|
||||
</PermissionConfiguration>
|
||||
@ -1,36 +0,0 @@
|
||||
package org.coffeeking.manager.service.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
|
||||
/**
|
||||
* This class provides utility functions used by REST-API.
|
||||
*/
|
||||
public class APIUtil {
|
||||
|
||||
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||
|
||||
public static String getAuthenticatedUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String username = threadLocalCarbonContext.getUsername();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
if (username.endsWith(tenantDomain)) {
|
||||
return username.substring(0, username.lastIndexOf("@"));
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
}
|
||||
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
<APIVersion></APIVersion>
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>Get device</name>
|
||||
<path>/device-mgt/user/devices/list</path>
|
||||
<url>/manager/device/{device_id}</url>
|
||||
<method>GET</method>
|
||||
<scope></scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Add device</name>
|
||||
<path>/device-mgt/user/devices/add</path>
|
||||
<url>/manager/device</url>
|
||||
<method>POST</method>
|
||||
<scope></scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove device</name>
|
||||
<path>/device-mgt/user/devices/remove</path>
|
||||
<url>/manager/device/{device_id}</url>
|
||||
<method>DELETE</method>
|
||||
<scope></scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update device</name>
|
||||
<path>/device-mgt/user/devices/update</path>
|
||||
<url>/manager/device/{device_id}</url>
|
||||
<method>POST</method>
|
||||
<scope></scope>
|
||||
</Permission>
|
||||
</PermissionConfiguration>
|
||||
@ -21,14 +21,14 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup CDMF Plugin</description>
|
||||
@ -64,19 +64,19 @@
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
javax.xml.bind.*,
|
||||
javax.naming,
|
||||
javax.sql,
|
||||
javax.xml.bind.annotation.*,
|
||||
javax.xml.parsers,
|
||||
javax.net,
|
||||
javax.net.ssl,
|
||||
org.w3c.dom,
|
||||
javax.xml.bind.*;resolution:=optional,
|
||||
javax.naming;resolution:=optional,
|
||||
javax.sql;resolution:=optional,
|
||||
javax.xml.bind.annotation.*;resolution:=optional,
|
||||
javax.net;resolution:=optional,
|
||||
javax.net.ssl;resolution:=optional,
|
||||
org.w3c.dom;resolution:=optional,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.common,
|
||||
org.wso2.carbon.context.*,
|
||||
org.wso2.carbon.ndatasource.core,
|
||||
org.wso2.carbon.device.mgt.iot.*,
|
||||
javax.xml.parsers.*;resolution:=optional
|
||||
</Import-Package>
|
||||
|
||||
<Export-Package>
|
||||
|
||||
@ -7,8 +7,6 @@ public class ConnectedCupConstants {
|
||||
public final static String DEVICE_TYPE = "connectedcup";
|
||||
public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
|
||||
public final static String DEVICE_PLUGIN_DEVICE_ID = "CONNECTED_CUP_DEVICE_ID";
|
||||
public final static String DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN = "accessToken";
|
||||
public final static String DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN = "refreshToken";
|
||||
public final static String ORDER_ON = "YES";
|
||||
public final static String ORDER_OFF = "NO";
|
||||
|
||||
|
||||
@ -22,10 +22,12 @@ import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.ProvisioningConfig;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
|
||||
import java.util.List;
|
||||
@ -38,17 +40,6 @@ public class ConnectedCupManagerService implements DeviceManagementService{
|
||||
return ConnectedCupConstants.DEVICE_TYPE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getProviderTenantDomain() {
|
||||
return "carbon.super";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedWithAllTenants() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws DeviceManagementException {
|
||||
this.deviceManager=new ConnectedCupManager();
|
||||
@ -65,44 +56,13 @@ public class ConnectedCupManagerService implements DeviceManagementService{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
||||
throws DeviceManagementException {
|
||||
|
||||
public ProvisioningConfig getProvisioningConfig() {
|
||||
return new ProvisioningConfig("carbon.super", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application[] getApplications(String domain, int pageNumber, int size)
|
||||
throws ApplicationManagementException {
|
||||
return new Application[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
|
||||
String status) throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationStatus(DeviceIdentifier deviceId, Application application)
|
||||
throws ApplicationManagementException {
|
||||
public PushNotificationConfig getPushNotificationConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUsers(Operation operation, List<String> userNameList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUserRoles(Operation operation, List<String> userRoleList)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,13 +16,12 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.coffeeking.connectedcup.plugin.impl.dao.impl;
|
||||
package org.coffeeking.connectedcup.plugin.impl.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
|
||||
import org.coffeeking.connectedcup.plugin.impl.dao.ConnectedCupDAOUtil;
|
||||
import org.coffeeking.connectedcup.plugin.impl.dao.util.ConnectedCupUtils;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import java.sql.Connection;
|
||||
@ -48,25 +47,14 @@ public class ConnectedCupDAO {
|
||||
try {
|
||||
conn = ConnectedCupDAOUtil.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, ACCESS_TOKEN, REFRESH_TOKEN" +
|
||||
" FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
||||
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME FROM CONNECTED_CUP_DEVICE WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
resultSet = stmt.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
connectedCupDevice = new Device();
|
||||
connectedCupDevice.setName(resultSet.getString(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
||||
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
||||
propertyList.add(ConnectedCupUtils.getProperty(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN,
|
||||
resultSet.getString("ACCESS_TOKEN")));
|
||||
propertyList.add(ConnectedCupUtils.getProperty(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN,
|
||||
resultSet.getString("REFRESH_TOKEN")));
|
||||
connectedCupDevice.setProperties(propertyList);
|
||||
|
||||
connectedCupDevice.setName(resultSet.getString(ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Connected Cup service " + deviceId + " data has been fetched from" +
|
||||
"Connected Cup database.");
|
||||
@ -91,18 +79,11 @@ public class ConnectedCupDAO {
|
||||
try {
|
||||
conn = ConnectedCupDAOUtil.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO CONNECTED_CUP_DEVICE(CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, " +
|
||||
"ACCESS_TOKEN, REFRESH_TOKEN) VALUES (?, ?, ?, ?)";
|
||||
"INSERT INTO CONNECTED_CUP_DEVICE(CONNECTED_CUP_DEVICE_ID, DEVICE_NAME ) VALUES (?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, connectedCupDevice.getDeviceIdentifier());
|
||||
stmt.setString(2, connectedCupDevice.getName());
|
||||
stmt.setString(3, ConnectedCupUtils.getDeviceProperty(
|
||||
connectedCupDevice.getProperties(),
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
||||
stmt.setString(4, ConnectedCupUtils.getDeviceProperty(
|
||||
connectedCupDevice.getProperties(),
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN));
|
||||
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
@ -130,22 +111,11 @@ public class ConnectedCupDAO {
|
||||
try {
|
||||
conn = ConnectedCupDAOUtil.getConnection();
|
||||
String updateDBQuery =
|
||||
"UPDATE CONNECTED_CUP_DEVICE SET DEVICE_NAME = ?, ACCESS_TOKEN=?, " +
|
||||
"REFRESH_TOKEN=? WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
||||
"UPDATE CONNECTED_CUP_DEVICE SET DEVICE_NAME = ? WHERE CONNECTED_CUP_DEVICE_ID = ?";
|
||||
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
|
||||
if (connectedCupDevice.getProperties() == null) {
|
||||
connectedCupDevice.setProperties(new ArrayList<Device.Property>());
|
||||
}
|
||||
stmt.setString(1, connectedCupDevice.getName());
|
||||
stmt.setString(2, ConnectedCupUtils.getDeviceProperty(
|
||||
connectedCupDevice.getProperties(),
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN));
|
||||
stmt.setString(3, ConnectedCupUtils.getDeviceProperty(
|
||||
connectedCupDevice.getProperties(),
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN));
|
||||
stmt.setString(4, connectedCupDevice.getDeviceIdentifier());
|
||||
stmt.setString(2, connectedCupDevice.getDeviceIdentifier());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
@ -204,7 +174,7 @@ public class ConnectedCupDAO {
|
||||
try {
|
||||
conn = ConnectedCupDAOUtil.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME, ACCESS_TOKEN, REFRESH_TOKEN" +
|
||||
"SELECT CONNECTED_CUP_DEVICE_ID, DEVICE_NAME" +
|
||||
"FROM CONNECTED_CUP_DEVICE";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
resultSet = stmt.executeQuery();
|
||||
@ -214,15 +184,6 @@ public class ConnectedCupDAO {
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_ID));
|
||||
connectedCupDevice.setName(resultSet.getString(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
||||
|
||||
List<Device.Property> propertyList = new ArrayList<Device.Property>();
|
||||
propertyList.add(ConnectedCupUtils.getProperty(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_ACCESS_TOKEN,
|
||||
resultSet.getString("ACCESS_TOKEN")));
|
||||
propertyList.add(ConnectedCupUtils.getProperty(
|
||||
ConnectedCupConstants.DEVICE_PLUGIN_PROPERTY_REFRESH_TOKEN,
|
||||
resultSet.getString("REFRESH_TOKEN")));
|
||||
connectedCupDevice.setProperties(propertyList);
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("All Connected Cup device details have fetched from Connected Cup database" +
|
||||
@ -22,7 +22,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.coffeeking.connectedcup.plugin.constants.ConnectedCupConstants;
|
||||
import org.coffeeking.connectedcup.plugin.exception.ConnectedCupDeviceMgtPluginException;
|
||||
import org.coffeeking.connectedcup.plugin.impl.dao.impl.ConnectedCupDAO;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
@ -22,15 +22,15 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Component</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup Component</description>
|
||||
|
||||
@ -23,15 +23,15 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>device-mgt-iot-connectedcup</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.ui</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup UI</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
{{#zone "topCss"}}
|
||||
{{css "css/graph.css"}}
|
||||
{{/zone}}
|
||||
<span id="details" data-devicename="{{device.name}}" data-deviceid="{{device.deviceIdentifier}}"
|
||||
data-appcontext="{{@app.context}}"></span>
|
||||
<div id="device-chart" data-backend-api-url = {{backendApiUri}}>
|
||||
<div class="chartWrapper" id="chartWrapper-temperature">
|
||||
<span id="span-title">Temperature</span>
|
||||
<div id="y_axis-temperature" class="custom_y_axis"></div>
|
||||
<div class="legend_container">
|
||||
<div id="smoother-temperature" title="Smoothing"></div>
|
||||
<div id="legend-temperature"></div>
|
||||
</div>
|
||||
<div id="chart-temperature" class="custom_rickshaw_graph" ></div>
|
||||
<div id="x_axis-temperature" class="custom_x_axis"></div>
|
||||
<div id="slider-temperature" class="custom_slider"></div>
|
||||
</div>
|
||||
|
||||
<div class="chartWrapper" id="chartWrapper-coffeelevel">
|
||||
<span id="span-title">Coffee Level</span>
|
||||
<div id="y_axis-coffeelevel" class="custom_y_axis"></div>
|
||||
<div class="legend_container">
|
||||
<div id="smoother-coffeelevel" title="Smoothing"></div>
|
||||
<div id="legend-coffeelevel"></div>
|
||||
</div>
|
||||
<div id="chart-coffeelevel" class="custom_rickshaw_graph" ></div>
|
||||
<div id="x_axis-coffeelevel" class="custom_x_axis"></div>
|
||||
<div id="slider-coffeelevel" class="custom_slider"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/d3.min.js"}}
|
||||
{{js "js/rickshaw.min.js"}}
|
||||
{{js "js/moment.min.js"}}
|
||||
{{js "js/devicetype-graph.js"}}
|
||||
{{/zone}}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
var deviceType = context.uriParams.deviceType;
|
||||
var deviceId = request.getParameter("deviceId");
|
||||
|
||||
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
|
||||
var deviceModule = require("/app/modules/device.js").deviceModule;
|
||||
var device = deviceModule.viewDevice(deviceType, deviceId);
|
||||
if (device && device.status != "error") {
|
||||
return {"device": device, "backendApiUri" : devicemgtProps["httpsURL"] + "/connectedcup/stats/" + deviceId + "/sensors/"};
|
||||
} else {
|
||||
response.sendError(404, "Device Id " + deviceId + " of type " + deviceType + " cannot be found!");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@ -0,0 +1,470 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* graph */
|
||||
|
||||
.rickshaw_graph {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.rickshaw_graph svg {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ticks */
|
||||
|
||||
.rickshaw_graph .x_tick {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 0;
|
||||
border-left: 1px dotted rgba(0, 0, 0, 0.2);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick .title {
|
||||
position: absolute;
|
||||
font-size: 12px;
|
||||
font-family: Arial, sans-serif;
|
||||
opacity: 0.5;
|
||||
white-space: nowrap;
|
||||
margin-left: 3px;
|
||||
bottom: -20px;
|
||||
height: auto;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* annotations */
|
||||
|
||||
.rickshaw_annotation_timeline {
|
||||
height: 1px;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
margin-top: 10px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation {
|
||||
position: absolute;
|
||||
height: 6px;
|
||||
width: 6px;
|
||||
margin-left: -2px;
|
||||
top: -3px;
|
||||
border-radius: 5px;
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_line {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: -6px;
|
||||
width: 0;
|
||||
border-left: 2px solid rgba(0, 0, 0, 0.3);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_line.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: -6px;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range.active.offscreen {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content {
|
||||
background: white;
|
||||
color: black;
|
||||
opacity: 0.9;
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
font-size: 12px;
|
||||
padding: 6px 8px 8px;
|
||||
top: 18px;
|
||||
left: -11px;
|
||||
width: 160px;
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content:before {
|
||||
content: "\25b2";
|
||||
position: absolute;
|
||||
top: -11px;
|
||||
color: white;
|
||||
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation.active,
|
||||
.rickshaw_annotation_timeline .annotation:hover {
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
cursor: none;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content:hover {
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation.active .content {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation:hover .content {
|
||||
display: block;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_axis,
|
||||
.rickshaw_graph .x_axis_d3 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks .tick line,
|
||||
.rickshaw_graph .x_ticks_d3 .tick {
|
||||
stroke: rgba(0, 0, 0, 0.16);
|
||||
stroke-width: 2px;
|
||||
shape-rendering: crisp-edges;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid .tick,
|
||||
.rickshaw_graph .x_grid_d3 .tick {
|
||||
z-index: -1;
|
||||
stroke: rgba(0, 0, 0, 0.20);
|
||||
stroke-width: 1px;
|
||||
stroke-dasharray: 1 1;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid .tick[data-y-value="0"] {
|
||||
stroke-dasharray: 1 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid path,
|
||||
.rickshaw_graph .x_grid_d3 path {
|
||||
fill: none;
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks path,
|
||||
.rickshaw_graph .x_ticks_d3 path {
|
||||
fill: none;
|
||||
stroke: #808080;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks text,
|
||||
.rickshaw_graph .x_ticks_d3 text {
|
||||
opacity: 0.5;
|
||||
font-size: 12px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick.glow .title,
|
||||
.rickshaw_graph .y_ticks.glow text {
|
||||
fill: black;
|
||||
color: black;
|
||||
text-shadow: -1px 1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px -1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px 1px 0 rgba(255, 255, 255, 0.1),
|
||||
0 1px 0 rgba(255, 255, 255, 0.1),
|
||||
0 -1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px 0 0 rgba(255, 255, 255, 0.1),
|
||||
-1px 0 0 rgba(255, 255, 255, 0.1),
|
||||
-1px -1px 0 rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick.inverse .title,
|
||||
.rickshaw_graph .y_ticks.inverse text {
|
||||
fill: white;
|
||||
color: white;
|
||||
text-shadow: -1px 1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px -1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px 1px 0 rgba(0, 0, 0, 0.8),
|
||||
0 1px 0 rgba(0, 0, 0, 0.8),
|
||||
0 -1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px 0 0 rgba(0, 0, 0, 0.8),
|
||||
-1px 0 0 rgba(0, 0, 0, 0.8),
|
||||
-1px -1px 0 rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.custom_rickshaw_graph {
|
||||
position: relative;
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.custom_y_axis {
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.custom_slider {
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.custom_x_axis {
|
||||
position: relative;
|
||||
left: 40px;
|
||||
height: 30px;
|
||||
width: 97%;
|
||||
top: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.chartWrapper {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
/*detail*/
|
||||
|
||||
.rickshaw_graph .detail {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
transition: opacity 0.25s linear;
|
||||
-moz-transition: opacity 0.25s linear;
|
||||
-o-transition: opacity 0.25s linear;
|
||||
-webkit-transition: opacity 0.25s linear;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail.inactive {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label {
|
||||
font-family: Arial, sans-serif;
|
||||
border-radius: 3px;
|
||||
padding: 6px;
|
||||
opacity: 0.5;
|
||||
border: 1px solid #e0e0e0;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
background: white;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
border-radius: 3px;
|
||||
padding: 0.25em;
|
||||
font-size: 12px;
|
||||
font-family: Arial, sans-serif;
|
||||
opacity: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
color: white;
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
margin-top: -1em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.active {
|
||||
opacity: 1;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item:after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
content: "";
|
||||
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.left:after {
|
||||
top: 1em;
|
||||
left: -5px;
|
||||
margin-top: -5px;
|
||||
border-right-color: rgba(0, 0, 0, 0.8);
|
||||
border-left-width: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.right:after {
|
||||
top: 1em;
|
||||
right: -5px;
|
||||
margin-top: -5px;
|
||||
border-left-color: rgba(0, 0, 0, 0.8);
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .dot {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
margin-left: -3px;
|
||||
margin-top: -3.5px;
|
||||
border-radius: 5px;
|
||||
position: absolute;
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
|
||||
box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
background: white;
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
display: none;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .dot.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*legend*/
|
||||
.rickshaw_legend {
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
background: #404040;
|
||||
display: inline-block;
|
||||
padding: 12px 5px;
|
||||
border-radius: 2px;
|
||||
position: relative;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.rickshaw_legend:hover {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.rickshaw_legend .swatch {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.rickshaw_legend .line {
|
||||
clear: both;
|
||||
line-height: 140%;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .line .swatch {
|
||||
display: inline-block;
|
||||
margin-right: 3px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .label {
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
display: inline;
|
||||
font-size: inherit;
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
font-weight: normal;
|
||||
line-height: normal;
|
||||
padding: 0;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.rickshaw_legend .action:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.rickshaw_legend .action {
|
||||
margin-right: 0.2em;
|
||||
opacity: 0.2;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .line.disabled {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.rickshaw_legend ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rickshaw_legend li {
|
||||
padding: 0 0 0 2px;
|
||||
min-width: 80px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_legend li:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.rickshaw_legend li:active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.legend {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
.legend_container {
|
||||
float: right;
|
||||
padding-right: 10px;
|
||||
width: 0;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.spaced {
|
||||
margin-top: 20px !important;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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 palette = new Rickshaw.Color.Palette({scheme: "classic9"});
|
||||
|
||||
function drawGraph(from, to) {
|
||||
retrieveDataAndDrawLineGraph("temperature", from, to);
|
||||
retrieveDataAndDrawLineGraph("coffeelevel", from, to);
|
||||
}
|
||||
|
||||
function retrieveDataAndDrawLineGraph(sensorType, from, to) {
|
||||
var backendApiUrl = $("#device-chart").data("backend-api-url") + sensorType + "?from=" + from + "&to=" + to;
|
||||
var successCallback = function (data) {
|
||||
if (data) {
|
||||
drawLineGraph(JSON.parse(data), sensorType);
|
||||
}
|
||||
};
|
||||
invokerUtil.get(backendApiUrl, successCallback, function (message) {
|
||||
console.log(message);
|
||||
});
|
||||
}
|
||||
|
||||
function drawLineGraph(data, type) {
|
||||
var chartWrapperElmId = "#device-chart";
|
||||
var graphWidth = $(chartWrapperElmId).width() - 50;
|
||||
if (data.length == 0 || data.length == undefined) {
|
||||
$("#chart-" + type).html("<br/>No data available...");
|
||||
return;
|
||||
}
|
||||
$("#chart-" + type).empty();
|
||||
|
||||
var graphConfig = {
|
||||
element: document.getElementById("chart-" + type),
|
||||
width: graphWidth,
|
||||
height: 400,
|
||||
strokeWidth: 2,
|
||||
renderer: 'line',
|
||||
interpolation: "linear",
|
||||
unstack: true,
|
||||
stack: false,
|
||||
xScale: d3.time.scale(),
|
||||
padding: {top: 0.2, left: 0.02, right: 0.02, bottom: 0.2},
|
||||
series: []
|
||||
};
|
||||
|
||||
var tzOffset = new Date().getTimezoneOffset() * 60;
|
||||
var chartData = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var y_val = parseInt(getData(data[i], type));
|
||||
chartData.push(
|
||||
{
|
||||
x: parseInt(data[i].values.time) - tzOffset,
|
||||
y: y_val
|
||||
}
|
||||
);
|
||||
}
|
||||
graphConfig['series'].push(
|
||||
{
|
||||
'color': palette.color(),
|
||||
'data': chartData,
|
||||
'name': type,
|
||||
'scale': d3.scale.linear().domain([0,100]).nice()
|
||||
}
|
||||
);
|
||||
|
||||
var graph = new Rickshaw.Graph(graphConfig);
|
||||
|
||||
graph.render();
|
||||
|
||||
var xAxis = new Rickshaw.Graph.Axis.Time({
|
||||
graph: graph
|
||||
});
|
||||
|
||||
xAxis.render();
|
||||
|
||||
var yAxis = new Rickshaw.Graph.Axis.Y.Scaled({
|
||||
graph: graph,
|
||||
orientation: 'left',
|
||||
element: document.getElementById("y_axis-" + type),
|
||||
width: 40,
|
||||
height: 410,
|
||||
'scale': d3.scale.linear().domain([Math.min(min, range_min), Math.max(max, range_max)]).nice()
|
||||
});
|
||||
|
||||
yAxis.render();
|
||||
|
||||
var slider = new Rickshaw.Graph.RangeSlider.Preview({
|
||||
graph: graph,
|
||||
element: document.getElementById("slider-" + type)
|
||||
});
|
||||
|
||||
var legend = new Rickshaw.Graph.Legend({
|
||||
graph: graph,
|
||||
element: document.getElementById('legend-' + type)
|
||||
});
|
||||
|
||||
var hoverDetail = new Rickshaw.Graph.HoverDetail({
|
||||
graph: graph,
|
||||
formatter: function (series, x, y) {
|
||||
var date = '<span class="date">' +
|
||||
moment((x + tzOffset) * 1000).format('Do MMM YYYY h:mm:ss a') + '</span>';
|
||||
var swatch = '<span class="detail_swatch" style="background-color: ' +
|
||||
series.color + '"></span>';
|
||||
return swatch + series.name + ": " + parseInt(y) + '<br>' + date;
|
||||
}
|
||||
});
|
||||
|
||||
var shelving = new Rickshaw.Graph.Behavior.Series.Toggle({
|
||||
graph: graph,
|
||||
legend: legend
|
||||
});
|
||||
|
||||
var order = new Rickshaw.Graph.Behavior.Series.Order({
|
||||
graph: graph,
|
||||
legend: legend
|
||||
});
|
||||
|
||||
var highlighter = new Rickshaw.Graph.Behavior.Series.Highlight({
|
||||
graph: graph,
|
||||
legend: legend
|
||||
});
|
||||
}
|
||||
|
||||
function getData(data, type) {
|
||||
var columnData
|
||||
switch (type) {
|
||||
case "temperature" :
|
||||
columnData = data.values.temperature
|
||||
break;
|
||||
case "coffeelevel" :
|
||||
columnData = data.values.coffeelevel
|
||||
break;
|
||||
}
|
||||
|
||||
return columnData;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -18,7 +18,7 @@
|
||||
<div class="add-margin-top-4x">
|
||||
<div class="add-margin-top-4x">
|
||||
<div class="buttons">
|
||||
<a class="btn-operations" target="_blank" href="https://{{../device.ip}}:9443/connected-cup-agent/index.jsp?deviceOwner={{@user.username}}&deviceId={{../device.deviceIdentifier}}&token={{../device.accessToken}}" >Go To Device</a>
|
||||
<a class="btn-operations" target="_blank" href="https://{{../device.ip}}:9443/connected-cup-agent/index.jsp?deviceOwner={{@user.username}}&tenantDomain={{@user.domain}}&deviceId={{../device.deviceIdentifier}}&token={{../device.accessToken}}" >Go To Device</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -42,7 +42,7 @@
|
||||
<div class="panel panel-default tab-pane active"
|
||||
id="device_statistics" role="tabpanel" aria-labelledby="device_statistics">
|
||||
<div class="panel-heading">Device Statistics</div>
|
||||
{{unit "iot.unit.device.stats" device=device}}
|
||||
{{unit "cdmf.unit.device.type.connectedcup.realtime.analytics-view" device=device}}
|
||||
</div>
|
||||
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
|
||||
aria-labelledby="event_log">
|
||||
|
||||
@ -31,8 +31,13 @@ function onRequest(context) {
|
||||
|
||||
if (device && device.status != "error") {
|
||||
log.info(device);
|
||||
var deviceProperties = device.properties;
|
||||
device.accessToken = deviceProperties.accessToken;
|
||||
var constants = require("/app/modules/constants.js");
|
||||
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
||||
var token = "";
|
||||
if (tokenPair) {
|
||||
token = tokenPair.accessToken;
|
||||
}
|
||||
device.accessToken = token;
|
||||
device.ip = serverIp;
|
||||
return {"device": device};
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
{{#zone "topCss"}}
|
||||
{{css "css/graph.css"}}
|
||||
{{/zone}}
|
||||
<div id="div-chart" data-websocketurl="{{websocketEndpoint}}">
|
||||
<div class="chartWrapper" id="chartWrapper">
|
||||
<div id="y_axis" class="custom_y_axis">Temperature</div>
|
||||
<div class="legend_container">
|
||||
<div id="smoother" title="Smoothing"></div>
|
||||
<div id="legend"></div>
|
||||
</div>
|
||||
<div id="chart" class="custom_rickshaw_graph"></div>
|
||||
<div class="custom_x_axis">Time</div>
|
||||
</div>
|
||||
</div>
|
||||
<a class="padding-left"
|
||||
href="{{@app.context}}/device/{{device.type}}/analytics?deviceId={{device.deviceIdentifier}}&deviceName={{device.name}}">
|
||||
<span class="fw-stack">
|
||||
<i class="fw fw-ring fw-stack-2x"></i>
|
||||
<i class="fw fw-statistics fw-stack-1x"></i>
|
||||
</span> View Device Analytics
|
||||
</a>
|
||||
<!-- /statistics -->
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "js/d3.min.js"}}
|
||||
{{js "js/rickshaw.min.js"}}
|
||||
{{js "js/moment.min.js"}}
|
||||
{{js "js/socket.io.min.js"}}
|
||||
{{js "js/device-stats.js"}}
|
||||
{{/zone}}
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
function onRequest(context) {
|
||||
var log = new Log("stats.js");
|
||||
var device = context.unit.params.device;
|
||||
var devicemgtProps = require('/app/conf/devicemgt-props.js').config();
|
||||
var constants = require("/app/modules/constants.js");
|
||||
var websocketEndpoint = devicemgtProps["httpsURL"].replace("https", "wss");
|
||||
var tokenPair = session.get(constants.ACCESS_TOKEN_PAIR_IDENTIFIER);
|
||||
var token = "";
|
||||
if (tokenPair) {
|
||||
token = tokenPair.accessToken;
|
||||
}
|
||||
websocketEndpoint = websocketEndpoint + "/secured-outputui/org.wso2.iot.connectedcup/1.0.0?" +
|
||||
"token="+ token +"&deviceId=" + device.deviceIdentifier;
|
||||
return {"device": device, "websocketEndpoint" : websocketEndpoint};
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@ -0,0 +1,471 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* graph */
|
||||
|
||||
.rickshaw_graph {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.rickshaw_graph svg {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ticks */
|
||||
|
||||
.rickshaw_graph .x_tick {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 0;
|
||||
border-left: 1px dotted rgba(0, 0, 0, 0.2);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick .title {
|
||||
position: absolute;
|
||||
font-size: 12px;
|
||||
font-family: Arial, sans-serif;
|
||||
opacity: 0.5;
|
||||
white-space: nowrap;
|
||||
margin-left: 3px;
|
||||
bottom: -20px;
|
||||
height: auto;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* annotations */
|
||||
|
||||
.rickshaw_annotation_timeline {
|
||||
height: 1px;
|
||||
border-top: 1px solid #e0e0e0;
|
||||
margin-top: 10px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation {
|
||||
position: absolute;
|
||||
height: 6px;
|
||||
width: 6px;
|
||||
margin-left: -2px;
|
||||
top: -3px;
|
||||
border-radius: 5px;
|
||||
background-color: rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_line {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: -6px;
|
||||
width: 0;
|
||||
border-left: 2px solid rgba(0, 0, 0, 0.3);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_line.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: -6px;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_graph .annotation_range.active.offscreen {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content {
|
||||
background: white;
|
||||
color: black;
|
||||
opacity: 0.9;
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
z-index: 20;
|
||||
font-size: 12px;
|
||||
padding: 6px 8px 8px;
|
||||
top: 18px;
|
||||
left: -11px;
|
||||
width: 160px;
|
||||
display: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content:before {
|
||||
content: "\25b2";
|
||||
position: absolute;
|
||||
top: -11px;
|
||||
color: white;
|
||||
text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation.active,
|
||||
.rickshaw_annotation_timeline .annotation:hover {
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
cursor: none;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation .content:hover {
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation.active .content {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.rickshaw_annotation_timeline .annotation:hover .content {
|
||||
display: block;
|
||||
z-index: 50;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_axis,
|
||||
.rickshaw_graph .x_axis_d3 {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks .tick line,
|
||||
.rickshaw_graph .x_ticks_d3 .tick {
|
||||
stroke: rgba(0, 0, 0, 0.16);
|
||||
stroke-width: 2px;
|
||||
shape-rendering: crisp-edges;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid .tick,
|
||||
.rickshaw_graph .x_grid_d3 .tick {
|
||||
z-index: -1;
|
||||
stroke: rgba(0, 0, 0, 0.20);
|
||||
stroke-width: 1px;
|
||||
stroke-dasharray: 1 1;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid .tick[data-y-value="0"] {
|
||||
stroke-dasharray: 1 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_grid path,
|
||||
.rickshaw_graph .x_grid_d3 path {
|
||||
fill: none;
|
||||
stroke: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks path,
|
||||
.rickshaw_graph .x_ticks_d3 path {
|
||||
fill: none;
|
||||
stroke: #808080;
|
||||
}
|
||||
|
||||
.rickshaw_graph .y_ticks text,
|
||||
.rickshaw_graph .x_ticks_d3 text {
|
||||
opacity: 0.5;
|
||||
font-size: 12px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick.glow .title,
|
||||
.rickshaw_graph .y_ticks.glow text {
|
||||
fill: black;
|
||||
color: black;
|
||||
text-shadow: -1px 1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px -1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px 1px 0 rgba(255, 255, 255, 0.1),
|
||||
0 1px 0 rgba(255, 255, 255, 0.1),
|
||||
0 -1px 0 rgba(255, 255, 255, 0.1),
|
||||
1px 0 0 rgba(255, 255, 255, 0.1),
|
||||
-1px 0 0 rgba(255, 255, 255, 0.1),
|
||||
-1px -1px 0 rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.rickshaw_graph .x_tick.inverse .title,
|
||||
.rickshaw_graph .y_ticks.inverse text {
|
||||
fill: white;
|
||||
color: white;
|
||||
text-shadow: -1px 1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px -1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px 1px 0 rgba(0, 0, 0, 0.8),
|
||||
0 1px 0 rgba(0, 0, 0, 0.8),
|
||||
0 -1px 0 rgba(0, 0, 0, 0.8),
|
||||
1px 0 0 rgba(0, 0, 0, 0.8),
|
||||
-1px 0 0 rgba(0, 0, 0, 0.8),
|
||||
-1px -1px 0 rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.custom_rickshaw_graph {
|
||||
position: relative;
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.custom_y_axis {
|
||||
position: absolute;
|
||||
width: 40px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
|
||||
.custom_slider {
|
||||
left: 40px;
|
||||
}
|
||||
|
||||
.custom_x_axis {
|
||||
position: relative;
|
||||
left: 40px;
|
||||
height: 30px;
|
||||
width: 97%;
|
||||
top: 20px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.chartWrapper {
|
||||
padding-top: 50px;
|
||||
}
|
||||
|
||||
/*detail*/
|
||||
|
||||
.rickshaw_graph .detail {
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
bottom: 0;
|
||||
width: 1px;
|
||||
transition: opacity 0.25s linear;
|
||||
-moz-transition: opacity 0.25s linear;
|
||||
-o-transition: opacity 0.25s linear;
|
||||
-webkit-transition: opacity 0.25s linear;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail.inactive {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.active {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label {
|
||||
font-family: Arial, sans-serif;
|
||||
border-radius: 3px;
|
||||
padding: 6px;
|
||||
opacity: 0.5;
|
||||
border: 1px solid #e0e0e0;
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
background: white;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .x_label.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
border-radius: 3px;
|
||||
padding: 0.25em;
|
||||
font-size: 12px;
|
||||
font-family: Arial, sans-serif;
|
||||
opacity: 0;
|
||||
background: rgba(0, 0, 0, 0.4);
|
||||
color: white;
|
||||
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
margin-top: -1em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.left {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.right {
|
||||
right: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.active {
|
||||
opacity: 1;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item:after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: 0;
|
||||
height: 0;
|
||||
|
||||
content: "";
|
||||
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.left:after {
|
||||
top: 1em;
|
||||
left: -5px;
|
||||
margin-top: -5px;
|
||||
border-right-color: rgba(0, 0, 0, 0.8);
|
||||
border-left-width: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .item.right:after {
|
||||
top: 1em;
|
||||
right: -5px;
|
||||
margin-top: -5px;
|
||||
border-left-color: rgba(0, 0, 0, 0.8);
|
||||
border-right-width: 0;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .dot {
|
||||
width: 4px;
|
||||
height: 4px;
|
||||
margin-left: -3px;
|
||||
margin-top: -3.5px;
|
||||
border-radius: 5px;
|
||||
position: absolute;
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
|
||||
box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
background: white;
|
||||
border-width: 2px;
|
||||
border-style: solid;
|
||||
display: none;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.rickshaw_graph .detail .dot.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*legend*/
|
||||
.rickshaw_legend {
|
||||
font-family: Arial;
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
background: #404040;
|
||||
display: inline-block;
|
||||
padding: 12px 5px;
|
||||
border-radius: 2px;
|
||||
position: relative;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.rickshaw_legend:hover {
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.rickshaw_legend .swatch {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.rickshaw_legend .line {
|
||||
clear: both;
|
||||
line-height: 140%;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .line .swatch {
|
||||
display: inline-block;
|
||||
margin-right: 3px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .label {
|
||||
margin: 0;
|
||||
white-space: nowrap;
|
||||
display: inline;
|
||||
font-size: inherit;
|
||||
background-color: transparent;
|
||||
color: inherit;
|
||||
font-weight: normal;
|
||||
line-height: normal;
|
||||
padding: 0;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.rickshaw_legend .action:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.rickshaw_legend .action {
|
||||
margin-right: 0.2em;
|
||||
opacity: 0.2;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rickshaw_legend .line.disabled {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.rickshaw_legend ul {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 2px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.rickshaw_legend li {
|
||||
padding: 0 0 0 2px;
|
||||
min-width: 80px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.rickshaw_legend li:hover {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.rickshaw_legend li:active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.legend {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
left: 8px;
|
||||
}
|
||||
|
||||
.legend_container {
|
||||
float: right;
|
||||
padding-right: 10px;
|
||||
width: 0;
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.spaced {
|
||||
margin-top: 20px !important;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,132 @@
|
||||
/*
|
||||
* 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 ws;
|
||||
var graph;
|
||||
var temperatureData = [];
|
||||
var coffeeData = [];
|
||||
var temperature = 0;
|
||||
var coffeelevel = 0;
|
||||
var lastTime = 0;
|
||||
var palette = new Rickshaw.Color.Palette({scheme: "classic9"});
|
||||
|
||||
$(window).load(function () {
|
||||
var tNow = new Date().getTime() / 1000;
|
||||
for (var i = 0; i < 30; i++) {
|
||||
temperatureData.push({
|
||||
x: tNow - (30 - i) * 15,
|
||||
y: parseFloat(0)
|
||||
});
|
||||
coffeeData.push({
|
||||
x: tNow - (30 - i) * 15,
|
||||
y: parseFloat(0)
|
||||
});
|
||||
}
|
||||
|
||||
graph = new Rickshaw.Graph({
|
||||
element: document.getElementById("chart"),
|
||||
width: $("#div-chart").width() - 50,
|
||||
height: 300,
|
||||
renderer: "line",
|
||||
padding: {top: 0.2, left: 0.0, right: 0.0, bottom: 0.2},
|
||||
xScale: d3.time.scale(),
|
||||
series: [{
|
||||
'color': palette.color(),
|
||||
'data': coffeeData,
|
||||
'name': "Coffee Level"
|
||||
},{
|
||||
'color': palette.color(),
|
||||
'data': temperatureData,
|
||||
'name': "Temperature"
|
||||
}]
|
||||
});
|
||||
|
||||
graph.render();
|
||||
|
||||
var xAxis = new Rickshaw.Graph.Axis.Time({
|
||||
graph: graph
|
||||
});
|
||||
|
||||
xAxis.render();
|
||||
|
||||
new Rickshaw.Graph.Axis.Y({
|
||||
graph: graph,
|
||||
orientation: 'left',
|
||||
height: 300,
|
||||
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
|
||||
element: document.getElementById('y_axis')
|
||||
});
|
||||
|
||||
new Rickshaw.Graph.HoverDetail({
|
||||
graph: graph,
|
||||
formatter: function (series, x, y) {
|
||||
var date = '<span class="date">' + moment(x * 1000).format('Do MMM YYYY h:mm:ss a') + '</span>';
|
||||
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
|
||||
return swatch + series.name + ": " + parseInt(y) + '<br>' + date;
|
||||
}
|
||||
});
|
||||
|
||||
var websocketUrl = $("#div-chart").data("websocketurl");
|
||||
connect(websocketUrl)
|
||||
});
|
||||
|
||||
$(window).unload(function () {
|
||||
disconnect();
|
||||
});
|
||||
|
||||
//websocket connection
|
||||
function connect(target) {
|
||||
if ('WebSocket' in window) {
|
||||
ws = new WebSocket(target);
|
||||
} else if ('MozWebSocket' in window) {
|
||||
ws = new MozWebSocket(target);
|
||||
} else {
|
||||
console.log('WebSocket is not supported by this browser.');
|
||||
}
|
||||
if (ws) {
|
||||
ws.onmessage = function (event) {
|
||||
var dataPoint = JSON.parse(event.data);
|
||||
if (lastTime < parseInt(dataPoint[4]) / 1000) {
|
||||
lastTime = parseInt(dataPoint[4]) / 1000;
|
||||
if (dataPoint[3] == "temperature") {
|
||||
temperature = parseFloat(dataPoint[5]);
|
||||
} else if (dataPoint[3] == "coffeelevel") {
|
||||
coffeelevel = parseFloat(dataPoint[6]);
|
||||
}
|
||||
temperatureData.push({
|
||||
x: lastTime,
|
||||
y: temperature
|
||||
});
|
||||
temperatureData.shift();
|
||||
coffeeData.push({
|
||||
x: lastTime,
|
||||
y: coffeelevel
|
||||
});
|
||||
coffeeData.shift();
|
||||
graph.update();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function disconnect() {
|
||||
if (ws != null) {
|
||||
ws.close();
|
||||
ws = null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -145,7 +145,7 @@ function downloadAgent() {
|
||||
payload.name = $inputs[0].value;
|
||||
payload.owner = $inputs[1].value;
|
||||
|
||||
var connectedCupRegisterURL = "/connectedcup_mgt/manager/device?name=" + encodeURI(payload.name);
|
||||
var connectedCupRegisterURL = "/connectedcup/enrollment/devices?name=" + encodeURI(payload.name);
|
||||
|
||||
invokerUtil.post(
|
||||
connectedCupRegisterURL,
|
||||
|
||||
@ -195,28 +195,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="qr-code-modal" data-enrollment-url="{{deviceType.enrollmentURL}}" class="hidden">
|
||||
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-lg-5 col-md-6 col-centered">
|
||||
<h3>
|
||||
Scan QR code to start enrollment
|
||||
</h3>
|
||||
<h4>
|
||||
Please scan the QR code using your mobile device to retrieve enrollment URL.
|
||||
</h4>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body col-centered ">
|
||||
<div class="qr-code"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
.circle {
|
||||
background: none repeat scroll 0 0 #191919;
|
||||
|
||||
@ -23,36 +23,36 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>connected-cup-feature-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>org.coffeeking.connectedcup.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Feature</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup Feature</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<version>${wso2.iot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.api</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<version>${wso2.iot.version}</version>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.agent</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<version>${wso2.iot.version}</version>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -102,7 +102,7 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.analytics
|
||||
</artifactId>
|
||||
<version>${project.version}</version>
|
||||
@ -114,7 +114,7 @@
|
||||
<includes>**/*</includes>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.ui
|
||||
</artifactId>
|
||||
<version>${project.version}</version>
|
||||
@ -137,7 +137,7 @@
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.api</artifactId>
|
||||
<type>war</type>
|
||||
<overWrite>true</overWrite>
|
||||
@ -145,7 +145,7 @@
|
||||
<destFileName>connectedcup.war</destFileName>
|
||||
</artifactItem>
|
||||
<artifactItem>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.agent</artifactId>
|
||||
<type>war</type>
|
||||
<overWrite>true</overWrite>
|
||||
@ -219,7 +219,7 @@
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.wso2.carbon.devicemgt-plugins:org.coffeeking.connectedcup.plugin:${carbon.device.mgt.plugin.version}
|
||||
org.coffeeking:org.coffeeking.connectedcup.plugin:${wso2.iot.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
<importFeatures>
|
||||
|
||||
@ -5,8 +5,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `CONNECTED_CUP_DEVICE` (
|
||||
`CONNECTED_CUP_DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
|
||||
`ACCESS_TOKEN` VARCHAR(50) NOT NULL,
|
||||
`REFRESH_TOKEN` VARCHAR(50) NOT NULL,
|
||||
PRIMARY KEY (`CONNECTED_CUP_DEVICE_ID`) );
|
||||
|
||||
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
CREATE TABLE IF NOT EXISTS `CONNECTED_CUP_DEVICE` (
|
||||
`CONNECTED_CUP_DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
|
||||
`ACCESS_TOKEN` VARCHAR(50) NOT NULL,
|
||||
`REFRESH_TOKEN` VARCHAR(50) NOT NULL,
|
||||
PRIMARY KEY (`CONNECTED_CUP_DEVICE_ID`) )
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
@ -21,16 +21,16 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>connected-cup-feature-parent</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Feature Parent</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup Feature Parent</description>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
@ -29,9 +29,9 @@
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>device.mgt.iot.connectedcup-parent</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>WSO2 IoTS(Device Types) - Connected Cup Component</name>
|
||||
<description>WSO2 IoTS(Device Types) - Connected Cup Component</description>
|
||||
@ -56,26 +56,6 @@
|
||||
<version>${eclipse.equinox.common.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.beanshell</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
@ -155,95 +135,81 @@
|
||||
<version>4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.coffeeking</groupId>
|
||||
<artifactId>org.coffeeking.connectedcup.plugin</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<version>${wso2.iot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.webapp.publisher_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
<version>${carbon.kernel.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.ndatasource.core_${carbon.kernel.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.iot_${carbon.iot.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.core_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.common_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.certificate.mgt.core_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.annotations_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.analytics.data.publisher_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.api</artifactId>
|
||||
<version>${analytics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.datasource.commons</artifactId>
|
||||
<version>${analytics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.dataservice.commons</artifactId>
|
||||
<version>${analytics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.analytics</groupId>
|
||||
<artifactId>org.wso2.carbon.analytics.dataservice.core</artifactId>
|
||||
<version>${analytics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>${commons-httpclient.orbit.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/commons-httpclient_3.1.0.wso2v2.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
@ -307,64 +273,31 @@
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_${carbon.kernel.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>${smack.wso2.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/smack_3.0.4.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
<version>${smackx.wso2.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/smackx_3.0.4.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json.wso2</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>${commons-json.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/json_3.0.0.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4.0.wso2v1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/commons-codec_1.4.0.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.extensions_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.application.extension_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
@ -454,6 +387,8 @@
|
||||
<commons-httpclient.orbit.version>3.1.0.wso2v2</commons-httpclient.orbit.version>
|
||||
<commons-json.version>3.0.0.wso2v1</commons-json.version>
|
||||
<eclipse.equinox.common.version>3.6.100.v20120522-1841</eclipse.equinox.common.version>
|
||||
<analytics.version>1.0.6-ALPHA</analytics.version>
|
||||
<wso2.iot.version>1.0.0-SNAPSHOT</wso2.iot.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
||||
@ -25,9 +25,9 @@
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<groupId>org.wso2.iot.devicemgt-plugins</groupId>
|
||||
<artifactId>devicetype-feature-installation</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Creating custom distribution</name>
|
||||
<url>http://wso2.org</url>
|
||||
@ -35,11 +35,6 @@
|
||||
<modules>
|
||||
<!-- STEP#1 ADD THE LOCATION OF YOUR DEVICE-TYPE -->
|
||||
<module>samples/connectedcup</module>
|
||||
<module>samples/currentsensor</module>
|
||||
<module>samples/doormanager</module>
|
||||
<module>samples/firealarm</module>
|
||||
<!--<module>samples/digitaldisplay</module>-->
|
||||
<!--<module>samples/droneanalyzer</module>-->
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
@ -64,23 +59,8 @@
|
||||
<featureArtifacts>
|
||||
<featureArtifactDef>
|
||||
<!-- STEP#2. ADD YOUR DEVICE TYPE FEATURE HERE "< GROUP_ID:ARTIFACT_ID:VERSION >" -->
|
||||
org.wso2.carbon.devicemgt-plugins:org.coffeeking.connectedcup.feature:2.1.0-SNAPSHOT
|
||||
org.coffeeking:org.coffeeking.connectedcup.feature:1.0.0-SNAPSHOT
|
||||
</featureArtifactDef>
|
||||
<featureArtifactDef>
|
||||
org.homeautomation:org.homeautomation.currentsensor.feature:2.1.0-SNAPSHOT
|
||||
</featureArtifactDef>
|
||||
<featureArtifactDef>
|
||||
org.homeautomation:org.homeautomation.firealarm.feature:1.0.0-SNAPSHOT
|
||||
</featureArtifactDef>
|
||||
<featureArtifactDef>
|
||||
org.homeautomation:org.homeautomation.doormanager.feature:1.0.0-SNAPSHOT
|
||||
</featureArtifactDef>
|
||||
<!--<featureArtifactDef>-->
|
||||
<!--org.homeautomation:org.homeautomation.digitaldisplay.feature:2.1.0-SNAPSHOT-->
|
||||
<!--</featureArtifactDef>-->
|
||||
<!--<featureArtifactDef>-->
|
||||
<!--org.homeautomation:org.homeautomation.droneanalyzer.feature:2.1.0-SNAPSHOT-->
|
||||
<!--</featureArtifactDef>-->
|
||||
</featureArtifacts>
|
||||
</configuration>
|
||||
</execution>
|
||||
@ -108,28 +88,8 @@
|
||||
<!-- STEP#3. ADD YOUR DEVICE TYPE FEATURE GROUP HERE "<ARTIFACT_ID>.group" -->
|
||||
<feature>
|
||||
<id>org.coffeeking.connectedcup.feature.group</id>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</feature>
|
||||
<feature>
|
||||
<id>org.homeautomation.currentsensor.feature.group</id>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
</feature>
|
||||
<feature>
|
||||
<id>org.homeautomation.firealarm.feature.group</id>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</feature>
|
||||
<feature>
|
||||
<id>org.homeautomation.doormanager.feature.group</id>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</feature>
|
||||
<!--<feature>-->
|
||||
<!--<id>org.homeautomation.digitaldisplay.feature.group</id>-->
|
||||
<!--<version>2.1.0-SNAPSHOT</version>-->
|
||||
<!--</feature>-->
|
||||
<!--<feature>-->
|
||||
<!--<id>org.homeautomation.droneanalyzer.feature.group</id>-->
|
||||
<!--<version>2.1.0-SNAPSHOT</version>-->
|
||||
<!--</feature>-->
|
||||
</features>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user