refactoring code

merge-requests/1/head
GPrathap 9 years ago
parent 9b38eddd09
commit 24fe930727

@ -20,9 +20,9 @@
<property name="project-name" value="${ant.project.name}"/> <property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/> <property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/> <property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="sensor_dir" value="Sensor"/> <property name="sensor_dir" value="smartLock"/>
<target name="clean"> <target name="clean">
<delete dir="${target-dir}" /> <delete dir="${target-dir}"/>
</target> </target>
<target name="zip" depends="clean"> <target name="zip" depends="clean">
<mkdir dir="${target-dir}"/> <mkdir dir="${target-dir}"/>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--/* <!--/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
@ -15,19 +16,19 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/--> */-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>component</artifactId> <artifactId>doormanager-component</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>${groupId}.doormanager.analytics</artifactId> <artifactId>org.homeautomation.doormanager.analytics</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name> ${groupId}.doormanager.analytics </name> <name>org.homeautomation.doormanager.analytics</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<build> <build>
<plugins> <plugins>
@ -65,7 +66,7 @@
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version> <version>2.5.5</version>
<configuration> <configuration>
<finalName>${project.artifactId}-1.0.0-SNAPSHOT</finalName> <finalName>org.homeautomation.doormanager.analytics-1.0.0-SNAPSHOT</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptors> <descriptors>
<descriptor>src/assembly/src.xml</descriptor> <descriptor>src/assembly/src.xml</descriptor>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
@ -17,8 +18,8 @@
--> -->
<assembly <assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>src</id> <id>src</id>
<formats> <formats>

@ -27,8 +27,12 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DeviceJSON { public class DeviceJSON {
@XmlElement(required = true) public String owner; @XmlElement(required = true)
@XmlElement(required = true) public String deviceId; public String owner;
@XmlElement(required = true) public String UIDofUser; @XmlElement(required = true)
@XmlElement(required = true) public String serialNumber; public String deviceId;
@XmlElement(required = true)
public String UIDofUser;
@XmlElement(required = true)
public String serialNumber;
} }

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
package org.homeautomation.doormanager.manager.api.dto; package org.homeautomation.doormanager.controller.api.dto;
import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.annotate.JsonIgnoreProperties;
@ -27,8 +27,10 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class UserInfo { public class UserInfo {
@XmlElement(required = true) public String serialNumber; @XmlElement(required = true)
@XmlElement(required = true) public String deviceId; public String deviceId;
@XmlElement(required = true) public String cardNumber; @XmlElement(required = true)
@XmlElement(required = true) public String userName; public String cardNumber;
@XmlElement(required = true)
public String userName;
} }

@ -1,4 +1,3 @@
package org.homeautomation.doormanager.controller.api.exception;
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
@ -16,20 +15,16 @@ package org.homeautomation.doormanager.controller.api.exception;
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.homeautomation.doormanager.controller.api.exception;
public class DoorManagerException extends Exception { public class DoorManagerException extends Exception {
private static final long serialVersionUID = 2736466230451105441L; private static final long serialVersionUID = 2736466230451105441L;
private String errorMessage; private String errorMessage;
public String getErrorMessage() { @SuppressWarnings("unused")
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public DoorManagerException(String msg, DoorManagerException nestedEx) { public DoorManagerException(String msg, DoorManagerException nestedEx) {
super(msg, nestedEx); super(msg, nestedEx);
setErrorMessage(msg); setErrorMessage(msg);
@ -40,18 +35,30 @@ public class DoorManagerException extends Exception {
setErrorMessage(message); setErrorMessage(message);
} }
@SuppressWarnings("unused")
public DoorManagerException(String msg) { public DoorManagerException(String msg) {
super(msg); super(msg);
setErrorMessage(msg); setErrorMessage(msg);
} }
@SuppressWarnings("unused")
public DoorManagerException() { public DoorManagerException() {
super(); super();
} }
@SuppressWarnings("unused")
public DoorManagerException(Throwable cause) { public DoorManagerException(Throwable cause) {
super(cause); super(cause);
} }
@SuppressWarnings("unused")
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
} }

@ -1,37 +1,65 @@
package org.homeautomation.doormanager.controller.api.util; /*
* 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.homeautomation.doormanager.controller.api.transport;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.homeautomation.doormanager.controller.api.exception.DoorManagerException; import org.homeautomation.doormanager.controller.api.exception.DoorManagerException;
import org.homeautomation.doormanager.controller.api.util.DoorManagerServiceUtils;
import org.homeautomation.doormanager.plugin.constants.DoorManagerConstants; import org.homeautomation.doormanager.plugin.constants.DoorManagerConstants;
import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttConfig; import org.wso2.carbon.device.mgt.iot.controlqueue.mqtt.MqttConfig;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager;
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
import org.wso2.carbon.device.mgt.iot.transport.mqtt.MQTTTransportHandler; import org.wso2.carbon.device.mgt.iot.transport.mqtt.MQTTTransportHandler;
import javax.ws.rs.core.Response;
import java.io.File; import java.io.File;
import java.util.Calendar; import java.util.Calendar;
import java.util.UUID; import java.util.UUID;
/**
* MQTT is used as transport protocol. So this will provide basic functional requirement in order to communicate over
* MQTT
*/
@SuppressWarnings("no JAX-WS annotation") @SuppressWarnings("no JAX-WS annotation")
public class DoorManagerMQTTConnector extends MQTTTransportHandler { public class DoorManagerMQTTConnector extends MQTTTransportHandler {
private static Log log = LogFactory.getLog(DoorManagerMQTTConnector.class); private static Log log = LogFactory.getLog(DoorManagerMQTTConnector.class);
private static final String subscribeTopic = private static String PUBLISHER_CONTEXT = "publisher";
"wso2" + File.separator + "iot" + File.separator + "+" + File.separator + private static String SUBSCRIBER_CONTEXT = "subscriber";
DoorManagerConstants.DEVICE_TYPE + File.separator + "+" + File.separator + private static String SUBCRIBER_TOPIC = "wso2" + File.separator + "iot" + File.separator + "+" + File.separator +
"lockStatusPublisher"+ File.separator; DoorManagerConstants.DEVICE_TYPE + File.separator + "+" + File.separator + PUBLISHER_CONTEXT;
private static String iotServerSubscriber = UUID.randomUUID().toString().substring(0, 5); private static String PUBLISHER_TOPIC = "wso2/iot/%s/" + DoorManagerConstants.DEVICE_TYPE + "/%s/"
+ SUBSCRIBER_CONTEXT;
private static String SUBSCRIBER = UUID.randomUUID().toString().substring(0, 5);
private DoorManagerMQTTConnector() { private DoorManagerMQTTConnector() {
super(iotServerSubscriber, DoorManagerConstants.DEVICE_TYPE, super(SUBSCRIBER, DoorManagerConstants.DEVICE_TYPE,
MqttConfig.getInstance().getMqttQueueEndpoint(), subscribeTopic); MqttConfig.getInstance().getMqttQueueEndpoint(), SUBCRIBER_TOPIC);
} }
/**
* This method will initialize connection with message broker
*/
@Override @Override
public void connect() { public void connect() {
Runnable connector = new Runnable() { Runnable connector = new Runnable() {
@ -63,79 +91,103 @@ public class DoorManagerMQTTConnector extends MQTTTransportHandler {
connectorThread.start(); connectorThread.start();
} }
/**
* This callback function will be called by message broker when some messages available to subscribed topic
*
* @param message mqtt message which is coming form agent side
* @param messageParams metadata of mqtt message
*/
@Override @Override
public void processIncomingMessage(MqttMessage message, String... messageParams) { public void processIncomingMessage(MqttMessage message, String... messageParams) {
String topic = messageParams[0]; String topic = messageParams[0];
String ownerAndId = topic.replace("wso2" + File.separator + "iot" + File.separator, ""); String ownerAndId = topic.replace("wso2" + File.separator + "iot" + File.separator, "");
ownerAndId = ownerAndId.replace(File.separator + DoorManagerConstants.DEVICE_TYPE ownerAndId = ownerAndId.replace(File.separator + DoorManagerConstants.DEVICE_TYPE
+ File.separator, ":"); + File.separator, ":");
ownerAndId = ownerAndId.replace(File.separator + "lockStatusPublisher", ""); ownerAndId = ownerAndId.replace(File.separator + PUBLISHER_CONTEXT, "");
String owner = ownerAndId.split(":")[0]; String owner = ownerAndId.split(":")[0];
String deviceId = ownerAndId.split(":")[1]; String deviceId = ownerAndId.split(":")[1];
log.warn(deviceId); log.warn(deviceId);
String[] messageData = message.toString().split(":"); String[] messageData = message.toString().split(":");
if (log.isDebugEnabled()) {
if (log.isDebugEnabled()){
log.debug("Received MQTT message for: [OWNER-" + owner + "] & [DEVICE.ID-" + deviceId + "]"); log.debug("Received MQTT message for: [OWNER-" + owner + "] & [DEVICE.ID-" + deviceId + "]");
} }
if (messageData.length == 2) { if (messageData.length == 2) {
log.warn("-------------------------------------------");
log.warn(messageData[0]);
log.warn(messageData[1]);
String lockerCurrentState = messageData[1]; String lockerCurrentState = messageData[1];
float lockerStatus;
if (lockerCurrentState.equals("LOCKED")) {
lockerStatus = 0;
} else {
lockerStatus = 1;
}
try { try {
SensorDataManager.getInstance().setSensorRecord(deviceId, "door_locker_state", SensorDataManager.getInstance().setSensorRecord(deviceId, "doorLockerCurrentStatus",
String.valueOf(1), Calendar.getInstance().getTimeInMillis()); String.valueOf(lockerStatus), Calendar.getInstance().getTimeInMillis());
if (!DoorManagerServiceUtils.publishToDASCurrent(owner, deviceId, 1)) { if (!DoorManagerServiceUtils.publishToDASLockerStatus(owner, deviceId, lockerStatus)) {
log.warn("An error occured whilst trying to publish with ID [" + deviceId + log.warn("An error occurred while trying to publish with ID [" + deviceId + "] of owner ["
"] of owner [" + owner + "]"); + owner + "]");
} }
} catch(Exception e){ } catch (Exception e) {
log.error(e); log.error(e);
}
if(log.isDebugEnabled()){
//log.debug("Return result " + result + " for Request " + requestMessage);
} }
} }
} }
/**
* Publish a MQTT message to device through message broker
*
* @param topic mqtt topic which will be used to uniquely identify who are the subscribers to this topic
* @param payLoad message is to be published
* @param qos level of qos(quality of service):1,2,3
* @param retained klkkl
* @throws TransportHandlerException
*/
private void publishToAutomaticDoorLocker(String topic, String payLoad, int qos, boolean retained) private void publishToAutomaticDoorLocker(String topic, String payLoad, int qos, boolean retained)
throws TransportHandlerException { throws TransportHandlerException {
if(log.isDebugEnabled()){ if (log.isDebugEnabled()) {
log.debug("Publishing message [" + payLoad + "to topic [" + topic + "]."); log.debug("Publishing message [" + payLoad + "to topic [" + topic + "].");
} }
publishToQueue(topic, payLoad, qos, retained); publishToQueue(topic, payLoad, qos, retained);
} }
/**
* Publish a MQTT message to device through message broker
*
* @param deviceOwner person who own the device
* @param deviceId unique identifier for each device
* @param operation command is to executed at agent side e.g: off, on
* @param param additional payload
* @throws DeviceManagementException
* @throws DoorManagerException
*/
public void sendCommandViaMQTT(String deviceOwner, String deviceId, String operation, String param) public void sendCommandViaMQTT(String deviceOwner, String deviceId, String operation, String param)
throws DeviceManagementException, DoorManagerException { throws DeviceManagementException, DoorManagerException {
String PUBLISH_TOPIC = "wso2/iot/%s/doormanager/%s/lockController"; String topic = String.format(PUBLISHER_TOPIC, deviceOwner, deviceId);
String topic = String.format(PUBLISH_TOPIC, deviceOwner, deviceId);
String payload = operation + param; String payload = operation + param;
try { try {
publishToAutomaticDoorLocker(topic, payload, 2, false); publishToAutomaticDoorLocker(topic, payload, 2, false);
if(param.equals("LOCK")){ if (param.equals("LOCK")) {
if (!DoorManagerServiceUtils.publishToDASCurrent(deviceOwner, deviceId, 0)) { if (!DoorManagerServiceUtils.publishToDASLockerStatus(deviceOwner, deviceId, 0)) {
log.warn("An error occured whilst trying to publish with ID [" + deviceId + log.warn("An error occurred whilst trying to publish with ID [" + deviceId + "] of owner [" +
"] of owner [" + deviceOwner + "]"); deviceOwner + "]");
} }
}else{ } else {
if (!DoorManagerServiceUtils.publishToDASCurrent(deviceOwner, deviceId, 1)) { if (!DoorManagerServiceUtils.publishToDASLockerStatus(deviceOwner, deviceId, 1)) {
log.warn("An error occured whilst trying to publish with ID [" + deviceId + log.warn("An error occurred whilst trying to publish with ID [" + deviceId + "] of owner [" +
"] of owner [" + deviceOwner + "]"); deviceOwner + "]");
} }
} }
if (!DoorManagerServiceUtils.publishToDASCurrent(deviceOwner, deviceId, 1)) {
log.warn("An error occured whilst trying to publish with ID [" + deviceId +
"] of owner [" + deviceOwner + "]");
}
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
String errorMessage = "Error publishing data to device with ID " + deviceId; String errorMessage = "Error publishing data to device with ID " + deviceId;
throw new DoorManagerException(errorMessage, e); throw new DoorManagerException(errorMessage, e);
} catch (DataPublisherConfigurationException e) {
String errorMessage = "Error publishing data to DAS with ID " + deviceId;
throw new DoorManagerException(errorMessage, e);
} }
} }
/**
* Connection with message broker can be terminated
*/
@Override @Override
public void disconnect() { public void disconnect() {
Runnable stopConnection = new Runnable() { Runnable stopConnection = new Runnable() {
@ -143,8 +195,7 @@ public class DoorManagerMQTTConnector extends MQTTTransportHandler {
while (isConnected()) { while (isConnected()) {
try { try {
closeConnection(); closeConnection();
} } catch (MqttException e) {
catch (MqttException e) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.warn("Unable to 'STOP' MQTT connection at broker at: " + mqttBrokerEndPoint); log.warn("Unable to 'STOP' MQTT connection at broker at: " + mqttBrokerEndPoint);
} }

@ -16,9 +16,9 @@
~ limitations under the License. ~ limitations under the License.
--> -->
<beans xmlns="http://www.springframework.org/schema/beans" <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation=" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
@ -30,12 +30,12 @@
</bean> </bean>
</jaxrs:serviceBeans> </jaxrs:serviceBeans>
<jaxrs:providers> <jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" /> <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<bean id="communicationHandler" <bean id="communicationHandler"
class="org.homeautomation.doormanager.controller.api.util.DoorManagerMQTTConnector" > class="org.homeautomation.doormanager.controller.api.transport.DoorManagerMQTTConnector">
</bean> </bean>
</beans> </beans>

@ -19,15 +19,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>component</artifactId> <artifactId>doormanager-component</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>${groupId}.doormanager.manager</artifactId> <artifactId>org.homeautomation.doormanager.manager</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<name>${groupId}.doormanager.manager </name> <name>org.homeautomation.doormanager.manager </name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<build> <build>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
@ -46,7 +46,7 @@
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version> <version>${maven-war-plugin.version}</version>
<configuration> <configuration>
<warName>${groupId}.doormanager.manager_mgt</warName> <warName>org.homeautomation.doormanager.manager_mgt</warName>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
@ -54,7 +54,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>${project-base-package}.plugin</artifactId> <artifactId>org.homeautomation.doormanager.plugin</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>

@ -15,7 +15,9 @@
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> */-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>doormanager</artifactId> <artifactId>doormanager</artifactId>
@ -24,7 +26,7 @@
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<artifactId>component</artifactId> <artifactId>doormanager-component</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<build> <build>
<pluginManagement> <pluginManagement>
@ -271,12 +273,11 @@
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<modules> <modules>
<module>plugin</module> <module>plugin</module>
<module>controller</module> <module>controller</module>
<module>manager</module> <module>manager</module>
<module>agent</module> <module>analytics</module>
<module>analytics</module> <module>ui</module>
<module>ui</module> </modules>
</modules>
</project> </project>

@ -16,18 +16,18 @@
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>component</artifactId> <artifactId>doormanager-component</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>${groupId}.doormanager.ui</artifactId> <artifactId>org.homeautomation.doormanager.ui</artifactId>
<name>${groupId}.doormanager.ui</name> <name>org.homeautomation.doormanager.ui</name>
<packaging>pom</packaging> <packaging>pom</packaging>
<build> <build>
<plugins> <plugins>
@ -35,7 +35,7 @@
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version> <version>2.5.5</version>
<configuration> <configuration>
<finalName>${project.artifactId}-1.0.0-SNAPSHOT</finalName> <finalName>org.homeautomation.doormanager.ui-1.0.0-SNAPSHOT</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptors> <descriptors>
<descriptor>src/assembly/src.xml</descriptor> <descriptor>src/assembly/src.xml</descriptor>

@ -17,8 +17,8 @@
--> -->
<assembly <assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>src</id> <id>src</id>
<formats> <formats>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
@ -15,20 +16,20 @@
~ specific language governing permissions and limitations ~ specific language governing permissions and limitations
~ under the License. ~ under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
<artifactId>feature</artifactId> <artifactId>doormanager-feature</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<artifactId>${groupId}.doormanager.feature</artifactId> <artifactId>org.homeautomation.doormanager.feature</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name> ${project.artifactId} </name> <name>${project.artifactId}</name>
<url>http://wso2.org</url> <url>http://wso2.org</url>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.homeautomation</groupId> <groupId>org.homeautomation</groupId>
@ -47,12 +48,6 @@
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<type>war</type> <type>war</type>
</dependency> </dependency>
<dependency>
<groupId>org.homeautomation</groupId>
<artifactId>${project-base-package}.agent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>war</type>
</dependency>
<dependency> <dependency>
<groupId>com.h2database.wso2</groupId> <groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId> <artifactId>h2-database-engine</artifactId>
@ -63,6 +58,7 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions> <executions>
<execution> <execution>
<id>copy-resources</id> <id>copy-resources</id>
@ -104,7 +100,7 @@
<type>zip</type> <type>zip</type>
<overWrite>true</overWrite> <overWrite>true</overWrite>
<outputDirectory> <outputDirectory>
${basedir}/src/main/resources/carbonapps ${project.build.directory}/maven-shared-archive-resources/carbonapps
</outputDirectory> </outputDirectory>
<includes>**/*</includes> <includes>**/*</includes>
</artifactItem> </artifactItem>
@ -115,7 +111,9 @@
<version>${project.version}</version> <version>${project.version}</version>
<type>zip</type> <type>zip</type>
<overWrite>true</overWrite> <overWrite>true</overWrite>
<outputDirectory>${basedir}/src/main/resources/jaggeryapps/</outputDirectory> <outputDirectory>
${project.build.directory}/maven-shared-archive-resources/jaggeryapps
</outputDirectory>
<includes>**/*</includes> <includes>**/*</includes>
</artifactItem> </artifactItem>
</artifactItems> </artifactItems>
@ -134,7 +132,9 @@
<artifactId>${project-base-package}.manager</artifactId> <artifactId>${project-base-package}.manager</artifactId>
<type>war</type> <type>war</type>
<overWrite>true</overWrite> <overWrite>true</overWrite>
<outputDirectory>${basedir}/src/main/resources/webapps/</outputDirectory> <outputDirectory>
${project.build.directory}/maven-shared-archive-resources/webapps/
</outputDirectory>
<destFileName>doormanager_mgt.war</destFileName> <destFileName>doormanager_mgt.war</destFileName>
</artifactItem> </artifactItem>
</artifactItems> </artifactItems>
@ -153,31 +153,14 @@
<artifactId>${project-base-package}.controller</artifactId> <artifactId>${project-base-package}.controller</artifactId>
<type>war</type> <type>war</type>
<overWrite>true</overWrite> <overWrite>true</overWrite>
<outputDirectory>${basedir}/src/main/resources/webapps/</outputDirectory> <outputDirectory>
${project.build.directory}/maven-shared-archive-resources/webapps/
</outputDirectory>
<destFileName>doormanager.war</destFileName> <destFileName>doormanager.war</destFileName>
</artifactItem> </artifactItem>
</artifactItems> </artifactItems>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>copy-jaxrs-agent-war</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.homeautomation</groupId>
<artifactId>${project-base-package}.agent</artifactId>
<type>war</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/src/main/resources/webapps/</outputDirectory>
<destFileName>doormanager_agent.war</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
@ -198,7 +181,7 @@
<property name="userid" value="wso2carbon"/> <property name="userid" value="wso2carbon"/>
<property name="password" value="wso2carbon"/> <property name="password" value="wso2carbon"/>
<property name="dbURL" <property name="dbURL"
value="jdbc:h2:file:${basedir}/${db.dir}/doormanagerDM_DB;DB_CLOSE_ON_EXIT=FALSE"/> value="jdbc:h2:file:${basedir}/${db.dir}/doormanagerDM_DB;DB_CLOSE_ON_EXIT=FALSE"/>
<mkdir dir="${basedir}/${db.dir}"/> <mkdir dir="${basedir}/${db.dir}"/>
<sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}" <sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}"
password="${password}" password="${password}"
@ -216,6 +199,7 @@
<plugin> <plugin>
<groupId>org.wso2.maven</groupId> <groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId> <artifactId>carbon-p2-plugin</artifactId>
<version>${carbon-p2-plugin.version}</version>
<executions> <executions>
<execution> <execution>
<id>p2-feature-generation</id> <id>p2-feature-generation</id>

@ -5,13 +5,25 @@
}, },
"analyticStreams": [ "analyticStreams": [
{ {
"name": "sensorValue", "name": "smartLock",
"table": "DEVICE_SENSOR_DATA_SUMMARY", "table": "DEVICE_smartLock_SUMMARY",
"ui_unit": { "ui_unit": {
"name": "cdmf.unit.analytics.line-chart", "name": "cdmf.unit.analytics.line-chart",
"data":[ "data": [
{"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, {
{"column": {"name":"sensorValue", "label":"sensorValue", "ui-mapping":"y-axis"}} "column": {
"name": "TIME",
"label": "time",
"ui-mapping": "x-axis"
}
},
{
"column": {
"name": "smartLock",
"label": "smartLock",
"ui-mapping": "y-axis"
}
}
] ]
} }
} }

@ -18,7 +18,7 @@
--> -->
<DeviceTypeConfigurations> <DeviceTypeConfigurations>
<DeviceTypeConfig type="doormanager"> <DeviceTypeConfig type="doormanager">
<DatasourceName>jdbc/doormanagerDM_DB</DatasourceName> <DatasourceName>jdbc/doormanagerDM_DB</DatasourceName>
</DeviceTypeConfig> </DeviceTypeConfig>
</DeviceTypeConfigurations> </DeviceTypeConfigurations>

@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
@ -16,14 +17,14 @@
~ under the License. ~ under the License.
--> -->
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration"> <datasources-configuration>
<providers> <providers>
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider> <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
</providers> </providers>
<datasources> <datasources>
<datasource> <datasource>
<name>doormanagerDM_DB</name> <name>doormanagerDM_DB</name>
<description>The datasource used for the this device type </description> <description>The datasource used for the this device type</description>
<jndiConfig> <jndiConfig>
<name>jdbc/doormanagerDM_DB</name> <name>jdbc/doormanagerDM_DB</name>
</jndiConfig> </jndiConfig>

Loading…
Cancel
Save