From bd856c0b75d5047911eeb03a198aae800edfdac4 Mon Sep 17 00:00:00 2001 From: GPrathap Date: Sun, 13 Mar 2016 21:28:12 +0530 Subject: [PATCH] refactoring code --- .../tools/cdmf-devicetype-archetype/README.md | 118 +++++++++++------- .../component/analytics/src/assembly/src.xml | 2 +- ...iot.devices.__nameOfTheSensor___1.0.0.json | 4 +- .../__nameOfTheSensor___Script.xml | 2 +- .../controller/api/ControllerService.java | 100 +++++++++++---- .../controller/api/dto/DeviceJSON.java | 3 +- .../api/exception/DeviceTypeException.java | 3 +- .../api/transport/MQTTConnector.java | 10 +- .../component/manager/pom.xml | 9 +- .../plugin/constants/DeviceTypeConstants.java | 6 +- .../archetype-resources/component/pom.xml | 3 +- .../archetype-resources/component/ui/pom.xml | 4 +- .../public/images/current-sensor.png | Bin 38879 -> 0 bytes .../public/images/deviceType.png | Bin 0 -> 10418 bytes .../public/images/deviceType.png | Bin 38879 -> 10418 bytes .../public/images/myDevices_analytics.png | Bin 6693 -> 0 bytes .../public/images/thumb.png | Bin 38879 -> 10418 bytes .../feature/feature/pom.xml | 7 +- .../src/main/resources/agent/src/agent.py | 9 +- .../agent/src/deviceConfig.properties | 31 ----- .../__deviceType__-datasources.xml | 1 + .../archetype-resources/feature/pom.xml | 1 + .../resources/archetype-resources/pom.xml | 17 +-- 23 files changed, 195 insertions(+), 135 deletions(-) delete mode 100644 modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.__deviceType__.device-view/public/images/current-sensor.png create mode 100644 modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.__deviceType__.device-view/public/images/deviceType.png delete mode 100644 modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.__deviceType__.type-view/public/images/myDevices_analytics.png delete mode 100644 modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/feature/feature/src/main/resources/agent/src/deviceConfig.properties diff --git a/modules/tools/cdmf-devicetype-archetype/README.md b/modules/tools/cdmf-devicetype-archetype/README.md index 8ee77d26..926825ed 100644 --- a/modules/tools/cdmf-devicetype-archetype/README.md +++ b/modules/tools/cdmf-devicetype-archetype/README.md @@ -1,59 +1,89 @@ -# cdmf-devicetype-archetype +# Install cdmf-devicetype-archetype -To install this maven archetype - -go to this folder `cdmf-devicetype-archetype` - - mvn clean install +First you need to download this maven archetype. To download -To create new project + git clone https://github.com/GPrathap/cdmf-devicetype-archetype.git -go to this folder `/wso2iots-1.0.0-SNAPSHOT/samples` - - mvn archetype:generate -DarchetypeCatalog=local - -Then select the `cdmf.devicetype:cdmf-devicetype-archetype` as new archetype. Then you need to provide groupId, artifactId, -version, packaging, name of your device type and name for sensor as shown bellow. +To install this maven archetype into your local system, inside the cdmf-devicetype-archetype - Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 3 + mvn clean install + +# Create sample device type plugin using cdmf-devicetype-archetype + +First download WOS2 IoT Server and copy the downloaded file to a preferred location and unzip it. The unzipped folder rename as IOTS_HOME. +To create new project go to this folder: IOTS_HOME/samples + + mvn archetype:generate -DarchetypeCatalog=local + +Then select the cdmf.devicetype:cdmf-devicetype-archetype as new archetype. + + jobs@jobs-ThinkPad-T530:~/wso2/IoT/m3/product/IOTS_HOME/samples$ + mvn archetype:generate -DarchetypeCatalog=local + [INFO] Scanning for projects... + [INFO] + [INFO] ------------------------------------------------------------------------ + [INFO] Building Maven Stub Project (No POM) 1 + [INFO] ------------------------------------------------------------------------ + [INFO] + [INFO] >>> maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom >>> + [INFO] + [INFO] <<< maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom <<< + [INFO] + [INFO] --- maven-archetype-plugin:2.4:generate (default-cli) @ standalone-pom --- + [INFO] Generating project in Interactive mode + [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0) + Choose archetype: + 1: local -> org.apache.synapse:synapse-package-archetype (This archetype can be used to create Maven projects that bundle a mediation + into a standalone distribution ready to be executed) + 2: local -> org.wso2.mdm:mdm-android-agent-archetype (Creates a MDM-Android agent project) + 3: local -> org.wso2.cdmf.devicetype:cdmf-devicetype-archetype (WSO2 CDMF Device Type Archetype) + Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 3 + + + Then you need to provide groupId, artifactId, version, packaging, name of your device type and name for sensor as shown below. + Define value for property 'groupId': : org.homeautomation - Define value for property 'artifactId': : safeLocker + Define value for property 'artifactId': : currentsensor Define value for property 'version': 1.0-SNAPSHOT: : 1.0.0-SNAPSHOT Define value for property 'package': org.homeautomation: : - Define value for property 'deviceType': : safeLocker - Define value for property 'nameOfTheSensor': : lock + Define value for property 'deviceType': : currentsensor + Define value for property 'nameOfTheSensor': : current Confirm properties configuration: groupId: org.homeautomation - artifactId: safeLocker + artifactId: currentsensor version: 1.0.0-SNAPSHOT package: org.homeautomation - deviceType: safeLocker - nameOfTheSensor: lock - - -To install sample app into IOTS - open `device-deployer.xml` which is located in wso2iots-1.0.0-SNAPSHOT directory - -Under modules tag add name of sample which you created as module - - samples/safeLocker - -Under featureArtifacts tag add feature artifact definition as below - - - org.homeautomation:org.homeautomation.safeLocker.feature:1.0.0-SNAPSHOT - - -Under features tag add feature group definition as below + deviceType: currentsensor + nameOfTheSensor: current + + + +# Configure the device-deployer.xml file that is in the IoTS_HOME directory. + +Add the new module under the tag. + + + samples/currentsensor + + +Add the device type feature under the `` tag. + + org.homeautomation:org.homeautomation.currentsensor.feature:1.0.0-SNAPSHOT + + + +Add the device type feature group under the tag. + - org.homeautomation.safeLocker.feature.group - 1.0.0-SNAPSHOT + org.homeautomation.currentsensor.feature.group + 1.0.0-SNAPSHOT - -Finally to deploy sample device type into IoT Server - - mvn clean install -f device-deployer.xml - -Note: This command should be executed place where `device-deployer.xml` is located + + + +To deploy sample device type into IoT Server + mvn clean install -f device-deployer.xml + +Note: This command should be executed place where `device-deployer.xml` is located diff --git a/modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/analytics/src/assembly/src.xml b/modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/analytics/src/assembly/src.xml index a5a37501..22733722 100644 --- a/modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/analytics/src/assembly/src.xml +++ b/modules/tools/cdmf-devicetype-archetype/src/main/resources/archetype-resources/component/analytics/src/assembly/src.xml @@ -1,3 +1,4 @@ + - - IoTServer_Sensor_Script + IoTServer_${nameOfTheSensor}_Script