diff --git a/modules/samples/connectedcup/feature/connectedcup-feature/pom.xml b/modules/samples/connectedcup/feature/connectedcup-feature/pom.xml index 9181eb7e..175f29ef 100644 --- a/modules/samples/connectedcup/feature/connectedcup-feature/pom.xml +++ b/modules/samples/connectedcup/feature/connectedcup-feature/pom.xml @@ -17,6 +17,7 @@ ~ specific language governing permissions and limitations ~ under the License. --> + @@ -69,7 +70,6 @@ h2-database-engine 1.2.140.wso2v3 - @@ -173,12 +173,9 @@ - - - org.apache.maven.plugins maven-antrun-plugin @@ -219,7 +216,6 @@ - org.wso2.maven carbon-p2-plugin diff --git a/modules/samples/connectedcup/pom.xml b/modules/samples/connectedcup/pom.xml index 09a31b4e..760b2668 100644 --- a/modules/samples/connectedcup/pom.xml +++ b/modules/samples/connectedcup/pom.xml @@ -17,8 +17,9 @@ ~ under the License. --> - + org.wso2 @@ -26,81 +27,81 @@ 1 - 4.0.0 - - org.wso2.carbon.devicemgt-plugins - device.mgt.iot.connectedcup-parent - 1.9.2-SNAPSHOT - pom - WSO2 IoTS(Device Types) - Connected Cup - WSO2 IoTS(Device Types) - Connected Cup - http://wso2.org + 4.0.0 + + org.wso2.carbon.devicemgt-plugins + device.mgt.iot.connectedcup-parent + 1.9.2-SNAPSHOT + pom + WSO2 IoTS(Device Types) - Connected Cup Component + WSO2 IoTS(Device Types) - Connected Cup Component + http://wso2.org component feature - - - - org.eclipse.osgi - org.eclipse.osgi - ${eclipse.osgi.version} - provided - - - org.eclipse.equinox - org.eclipse.equinox.common - ${eclipse.equinox.common.version} - provided - - - org.testng - testng - ${testng.version} - - - junit - junit - - - org.beanshell - bsh - - - org.yaml - snakeyaml - - - provided - - - org.eclipse.osgi - org.eclipse.osgi.services - 3.3.100.v20120522-1822 - provided - - - org.wso2.carbon - org.wso2.carbon.logging - ${carbon.kernel.version} - - - org.apache.log4j.wso2 - log4j - - - commons-logging - commons-logging - - - org.wso2.carbon - org.wso2.carbon.bootstrap - - - provided - + + + + org.eclipse.osgi + org.eclipse.osgi + ${eclipse.osgi.version} + provided + + + org.eclipse.equinox + org.eclipse.equinox.common + ${eclipse.equinox.common.version} + provided + + + org.testng + testng + ${testng.version} + + + junit + junit + + + org.beanshell + bsh + + + org.yaml + snakeyaml + + + provided + + + org.eclipse.osgi + org.eclipse.osgi.services + 3.3.100.v20120522-1822 + provided + + + org.wso2.carbon + org.wso2.carbon.logging + ${carbon.kernel.version} + + + org.apache.log4j.wso2 + log4j + + + commons-logging + commons-logging + + + org.wso2.carbon + org.wso2.carbon.bootstrap + + + provided + org.apache.cxf @@ -122,7 +123,7 @@ org.eclipse.paho - org.eclipse.paho.client.mqttv3 + org.eclipse.paho.client.mqttv3 ${paho.mqtt.version} provided @@ -154,44 +155,44 @@ 4.1 provided - - + + - - - wso2.releases - WSO2 internal Repository - http://maven.wso2.org/nexus/content/repositories/releases/ - - true - daily - ignore - - + + + wso2.releases + WSO2 internal Repository + http://maven.wso2.org/nexus/content/repositories/releases/ + + true + daily + ignore + + - - wso2.snapshots - Apache Snapshot Repository - http://maven.wso2.org/nexus/content/repositories/snapshots/ - - true - daily - - - false - - - - wso2-nexus - WSO2 internal Repository - http://maven.wso2.org/nexus/content/groups/wso2-public/ - - true - daily - ignore - - - + + wso2.snapshots + Apache Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + daily + + + false + + + + wso2-nexus + WSO2 internal Repository + http://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + daily + ignore + + + + 3.0.4.wso2v1 3.0.4.wso2v1 2.6.1 @@ -241,6 +242,6 @@ 3.1.0.wso2v2 3.0.0.wso2v1 3.6.100.v20120522-1841 - + diff --git a/modules/samples/currentsensor/component/agent/pom.xml b/modules/samples/currentsensor/component/agent/pom.xml index 004da2eb..9b167186 100644 --- a/modules/samples/currentsensor/component/agent/pom.xml +++ b/modules/samples/currentsensor/component/agent/pom.xml @@ -1,33 +1,37 @@ - - + + org.homeautomation - component + ${project-base-package}-component 1.9.2-SNAPSHOT ../pom.xml + 4.0.0 ${groupId}.currentsensor.agent 1.9.2-SNAPSHOT ${groupId}.currentsensor.agent war + junit @@ -51,7 +55,7 @@ maven-war-plugin ${maven-war-plugin.version} - ${groupId}.currentsensor.agent_agent + ${groupId}.currentsensor.agent diff --git a/modules/samples/currentsensor/component/analytics/build.xml b/modules/samples/currentsensor/component/analytics/build.xml new file mode 100644 index 00000000..797d7cf9 --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/build.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/samples/currentsensor/component/analytics/pom.xml b/modules/samples/currentsensor/component/analytics/pom.xml new file mode 100644 index 00000000..f4039a3b --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/pom.xml @@ -0,0 +1,92 @@ + + + + + + + + org.homeautomation + ${project-base-package}-component + 1.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + ${groupId}.currentsensor.analytics + ${groupId}.currentsensor.analytics + pom + + + + + maven-clean-plugin + 2.4.1 + + + auto-clean + initialize + + clean + + + + + + maven-antrun-plugin + 1.7 + + + process-resources + + + + + + + run + + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.device.mgt.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/analytics/src/assembly/src.xml b/modules/samples/currentsensor/component/analytics/src/assembly/src.xml new file mode 100644 index 00000000..a5a37501 --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/assembly/src.xml @@ -0,0 +1,36 @@ + + + + src + + zip + + false + ${basedir}/src + + + ${basedir}/target/carbonapps + / + true + + + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml new file mode 100644 index 00000000..edce6435 --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml @@ -0,0 +1,26 @@ + + + + + + false + + + + diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/artifact.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/artifact.xml new file mode 100644 index 00000000..a708891d --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventreceiver_current_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + EventReceiver_current.xml + diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/artifact.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/artifact.xml new file mode 100644 index 00000000..13f9ee71 --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + org_wso2_iot_devices_current.xml + diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml similarity index 66% rename from modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml rename to modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml index 866ca925..6a394266 100644 --- a/modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstore_current_1.0.0/org_wso2_iot_devices_current.xml @@ -1,4 +1,22 @@ + + org.wso2.iot.devices.current:1.0.0 diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstream_current_1.0.0/artifact.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstream_current_1.0.0/artifact.xml new file mode 100644 index 00000000..c1d92387 --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstream_current_1.0.0/artifact.xml @@ -0,0 +1,23 @@ + + + + + org.wso2.iot.devices.current_1.0.0.json + + diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventstream_current_1.0.0/org.wso2.iot.devices.current_1.0.0.json b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstream_current_1.0.0/org.wso2.iot.devices.current_1.0.0.json similarity index 100% rename from modules/samples/currentsensor/feature/analytics/Current/Eventstream_current_1.0.0/org.wso2.iot.devices.current_1.0.0.json rename to modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Eventstream_current_1.0.0/org.wso2.iot.devices.current_1.0.0.json diff --git a/modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml similarity index 56% rename from modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml rename to modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml index d17d9c99..f3106036 100644 --- a/modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Current/Sparkscripts_1.0.0/Current_Sensor_Script.xml @@ -1,4 +1,22 @@ + + IoTServer_Sensor_Script + 0 * * * * ? + diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/Sparkscripts_1.0.0/artifact.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/Sparkscripts_1.0.0/artifact.xml new file mode 100644 index 00000000..a892ddbf --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/Sparkscripts_1.0.0/artifact.xml @@ -0,0 +1,22 @@ + + + + + Power_Sensor_Script.xml + diff --git a/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/artifacts.xml b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/artifacts.xml new file mode 100644 index 00000000..170af67a --- /dev/null +++ b/modules/samples/currentsensor/component/analytics/src/main/resources/carbonapps/Power_Sensor/artifacts.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/modules/samples/currentsensor/component/controller/pom.xml b/modules/samples/currentsensor/component/controller/pom.xml index 67fb79f3..98a35230 100644 --- a/modules/samples/currentsensor/component/controller/pom.xml +++ b/modules/samples/currentsensor/component/controller/pom.xml @@ -1,34 +1,38 @@ - - + + org.homeautomation - component + ${project-base-package}-component 1.9.2-SNAPSHOT ../pom.xml + 4.0.0 ${groupId}.currentsensor.controller 1.9.2-SNAPSHOT war ${groupId}.currentsensor.controller API http://wso2.com + @@ -50,10 +54,171 @@ + org.homeautomation ${project-base-package}.plugin + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + org.apache.axis2.wso2 + axis2-client + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics + + + org.apache.axis2.wso2 + axis2-client + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.certificate.mgt.core + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + org.apache.cxf + cxf-rt-transports-http + + + + + org.apache.httpcomponents + httpasyncclient + 4.1 + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + + + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-jaxrs + + + javax + javaee-web-api + + + javax.ws.rs + jsr311-api + + + commons-httpclient.wso2 + commons-httpclient + + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.queuing + + + org.wso2.carbon + org.wso2.carbon.base + + + org.apache.axis2.wso2 + axis2 + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + jaxen + jaxen + + + commons-fileupload.wso2 + commons-fileupload + + + org.apache.ant.wso2 + ant + + + org.apache.ant.wso2 + ant + + + commons-httpclient.wso2 + commons-httpclient + + + org.eclipse.equinox + javax.servlet + + + org.wso2.carbon + org.wso2.carbon.registry.api + + + + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + + + org.json.wso2 + json + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/CurrentSensorControllerService.java b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorControllerService.java similarity index 67% rename from modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/CurrentSensorControllerService.java rename to modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorControllerService.java index 567cb301..d7ef9044 100644 --- a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/CurrentSensorControllerService.java +++ b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorControllerService.java @@ -16,17 +16,17 @@ * under the License. */ -package org.homeautomation; +package org.homeautomation.currentsensor.manager.api; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.homeautomation.currentsensor.manager.api.dto.DeviceJSON; +import org.homeautomation.currentsensor.manager.api.util.CurrentSensorServiceUtils; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.device.DeviceType; import org.wso2.carbon.apimgt.annotations.device.feature.Feature; import org.wso2.carbon.device.mgt.iot.DeviceManagement; -import org.wso2.carbon.device.mgt.iot.currentsensor.controller.api.dto.DeviceJSON; -import org.wso2.carbon.device.mgt.iot.currentsensor.controller.api.util.CurrentSensorServiceUtils; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; @@ -77,7 +77,37 @@ public class CurrentSensorControllerService { try { sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, - CurrentSensorConstants.SENSOR_CURRENT); + CurrentSensorConstants.SENSOR_CURRENT); + } catch ( DeviceControllerException e) { + response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); + } + + response.setStatus(Response.Status.OK.getStatusCode()); + return sensorRecord; + } + + /** + * @param owner + * @param deviceId + * @param protocol + * @param response + * @return + */ + @Path("controller/read-power") + @GET + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Feature( code="read-power", name="Power x100", type="monitor", + description="Request power reading from Arduino agent") + public SensorRecord requestPower(@HeaderParam("owner") String owner, + @HeaderParam("deviceId") String deviceId, + @HeaderParam("protocol") String protocol, + @Context HttpServletResponse response) { + SensorRecord sensorRecord = null; + + try { + sensorRecord = SensorDataManager.getInstance().getSensorRecord(deviceId, + CurrentSensorConstants.SENSOR_POWER); } catch ( DeviceControllerException e) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); } @@ -104,20 +134,19 @@ public class CurrentSensorControllerService { Calendar.getInstance().getTimeInMillis()); SensorDataManager.getInstance().setSensorRecord(deviceId, CurrentSensorConstants.SENSOR_POWER, - String.valueOf(pinData * 230), + String.valueOf(pinData * 230 / 100), Calendar.getInstance().getTimeInMillis()); - - if (!CurrentSensorServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value)) { + if (!CurrentSensorServiceUtils.publishToDASCurrent(dataMsg.owner, dataMsg.deviceId, pinData)) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); log.warn("An error occured whilst trying to publish pin data of Current Sensor Data with ID [" + deviceId + "] of owner [" + owner + "]"); } - if (!CurrentSensorServiceUtils.publishToDAS(dataMsg.owner, dataMsg.deviceId, dataMsg.value * 230)) { + if (!CurrentSensorServiceUtils.publishToDASPower(dataMsg.owner, dataMsg.deviceId, pinData * 230 / 100)) { response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); - log.warn("An error occured whilst trying to publish pin data of Current Sensor Data with ID [" + deviceId + - "] of owner [" + owner + "]"); + log.warn("An error occured whilst trying to publish pin data of Power Sensor Data with ID [" + deviceId + + "] of owner [" + owner + "]"); } } diff --git a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/dto/DeviceJSON.java b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/dto/DeviceJSON.java similarity index 85% rename from modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/dto/DeviceJSON.java rename to modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/dto/DeviceJSON.java index 41a04e90..519bdbac 100644 --- a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/dto/DeviceJSON.java +++ b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/dto/DeviceJSON.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -11,12 +11,12 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -package org.homeautomation.dto; +package org.homeautomation.currentsensor.manager.api.dto; import org.codehaus.jackson.annotate.JsonIgnoreProperties; diff --git a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/util/CurrentSensorServiceUtils.java b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/util/CurrentSensorServiceUtils.java similarity index 56% rename from modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/util/CurrentSensorServiceUtils.java rename to modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/util/CurrentSensorServiceUtils.java index e2546420..33920045 100644 --- a/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/util/CurrentSensorServiceUtils.java +++ b/modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/util/CurrentSensorServiceUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 @@ -11,19 +11,19 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -package org.homeautomation.util; +package org.homeautomation.currentsensor.manager.api.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException; import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; public class CurrentSensorServiceUtils { private static final Log log = LogFactory.getLog(CurrentSensorServiceUtils.class); @@ -31,18 +31,38 @@ public class CurrentSensorServiceUtils { //TODO; replace this tenant domain private static final String SUPER_TENANT = "carbon.super"; private static final String CURRENT_STREAM_DEFINITION = "org.wso2.iot.devices.current"; + private static final String POWER_STREAM_DEFINITION = "org.wso2.iot.devices.power"; - public static boolean publishToDAS(String owner, String deviceId, float current) { + public static boolean publishToDASCurrent(String owner, String deviceId, float current) { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); ctx.setTenantDomain(SUPER_TENANT, true); DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx.getOSGiService( DeviceAnalyticsService.class, null); Object metdaData[] = {owner, CurrentSensorConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()}; - Object payloadData[] = {current}; + Object payloadCurrent[] = {current}; try { - deviceAnalyticsService.publishEvent(CURRENT_STREAM_DEFINITION, "1.0.0", metdaData, new Object[0], payloadData); + deviceAnalyticsService.publishEvent(CURRENT_STREAM_DEFINITION, "1.0.0", metdaData, new Object[0], payloadCurrent); + } catch (DataPublisherConfigurationException e) { + return false; + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + return true; + } + + public static boolean publishToDASPower(String owner, String deviceId, float power) { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ctx.setTenantDomain(SUPER_TENANT, true); + DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx.getOSGiService( + DeviceAnalyticsService.class, null); + Object metdaData[] = {owner, CurrentSensorConstants.DEVICE_TYPE, deviceId, System.currentTimeMillis()}; + Object payloadPower[] = {power}; + + try { + deviceAnalyticsService.publishEvent(POWER_STREAM_DEFINITION, "1.0.0", metdaData, new Object[0], payloadPower); } catch (DataPublisherConfigurationException e) { return false; } finally { diff --git a/modules/samples/currentsensor/component/controller/src/main/webapp/WEB-INF/cxf-servlet.xml b/modules/samples/currentsensor/component/controller/src/main/webapp/WEB-INF/cxf-servlet.xml index a8dbfe8a..671a0293 100644 --- a/modules/samples/currentsensor/component/controller/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/modules/samples/currentsensor/component/controller/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,19 +1,21 @@ + class="org.homeautomation.currentsensor.manager.api.CurrentSensorControllerService"> diff --git a/modules/samples/currentsensor/component/manager/pom.xml b/modules/samples/currentsensor/component/manager/pom.xml index a0e3a1bb..17301d63 100644 --- a/modules/samples/currentsensor/component/manager/pom.xml +++ b/modules/samples/currentsensor/component/manager/pom.xml @@ -1,34 +1,38 @@ - - + + org.homeautomation - component + ${project-base-package}-component 1.9.2-SNAPSHOT ../pom.xml + 4.0.0 ${groupId}.currentsensor.manager war 1.9.2-SNAPSHOT - ${groupId}.currentsensor.manager + ${groupId}.currentsensor.manager http://wso2.org + ${basedir}/src/main/java @@ -46,7 +50,7 @@ maven-war-plugin ${maven-war-plugin.version} - ${groupId}.currentsensor.manager_mgt + ${groupId}.currentsensor.manager @@ -56,5 +60,180 @@ org.homeautomation ${project-base-package}.plugin + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + org.apache.axis2.wso2 + axis2-client + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.analytics + + + org.apache.axis2.wso2 + axis2-client + + + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.certificate.mgt.core + + + commons-codec.wso2 + commons-codec + + + + + + + org.apache.cxf + cxf-rt-frontend-jaxws + + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + org.apache.cxf + cxf-rt-transports-http + + + + + org.apache.httpcomponents + httpasyncclient + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + + + + + org.codehaus.jackson + jackson-core-asl + + + org.codehaus.jackson + jackson-jaxrs + + + javax + javaee-web-api + + + javax.ws.rs + jsr311-api + + + commons-httpclient.wso2 + commons-httpclient + + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.bouncycastle.wso2 + bcprov-jdk15on + + + org.wso2.carbon + org.wso2.carbon.user.api + + + org.wso2.carbon + org.wso2.carbon.queuing + + + org.wso2.carbon + org.wso2.carbon.base + + + org.apache.axis2.wso2 + axis2 + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + jaxen + jaxen + + + commons-fileupload.wso2 + commons-fileupload + + + org.apache.ant.wso2 + ant + + + org.apache.ant.wso2 + ant + + + commons-httpclient.wso2 + commons-httpclient + + + org.eclipse.equinox + javax.servlet + + + org.wso2.carbon + org.wso2.carbon.registry.api + + + + + + commons-codec + commons-codec + + + + commons-io + commons-io + + + + org.igniterealtime.smack.wso2 + smack + + + org.igniterealtime.smack.wso2 + smackx + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.annotations + + + + org.wso2.carbon.devicemgt + org.wso2.carbon.apimgt.webapp.publisher + + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/CurrentSensorManagerService.java b/modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorManagerService.java similarity index 97% rename from modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/CurrentSensorManagerService.java rename to modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorManagerService.java index 5519aafe..28e4eee4 100644 --- a/modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/CurrentSensorManagerService.java +++ b/modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorManagerService.java @@ -11,16 +11,17 @@ * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -package org.homeautomation; +package org.homeautomation.currentsensor.manager.api; import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.apimgt.annotations.device.DeviceType; import org.wso2.carbon.apimgt.webapp.publisher.KeyGenerationUtil; import org.wso2.carbon.device.mgt.common.Device; @@ -30,7 +31,6 @@ import org.wso2.carbon.device.mgt.common.EnrolmentInfo; import org.wso2.carbon.device.mgt.iot.DeviceManagement; import org.wso2.carbon.device.mgt.iot.apimgt.AccessTokenInfo; import org.wso2.carbon.device.mgt.iot.apimgt.TokenClient; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.device.mgt.iot.exception.AccessTokenException; import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException; import org.wso2.carbon.device.mgt.iot.util.ZipArchive; diff --git a/modules/samples/currentsensor/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml b/modules/samples/currentsensor/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml index 08041520..17ead072 100644 --- a/modules/samples/currentsensor/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml +++ b/modules/samples/currentsensor/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml @@ -1,19 +1,21 @@ + class="org.homeautomation.currentsensor.manager.api.CurrentSensorManagerService"> diff --git a/modules/samples/currentsensor/component/plugin/pom.xml b/modules/samples/currentsensor/component/plugin/pom.xml index 2b094a3b..35d8e0b5 100644 --- a/modules/samples/currentsensor/component/plugin/pom.xml +++ b/modules/samples/currentsensor/component/plugin/pom.xml @@ -1,34 +1,37 @@ - + + org.homeautomation - component + ${project-base-package}-component 1.9.2-SNAPSHOT ../pom.xml + 4.0.0 1.9.2-SNAPSHOT ${groupId}.currentsensor.plugin bundle ${groupId}.currentsensor.plugin for CDMF http://wso2.org + @@ -58,6 +61,22 @@ IoT Server Impl Bundle org.homeautomation.currentsensor.plugin.internal + 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, + 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.*, !org.homeautomation.currentsensor.plugin.internal, @@ -69,5 +88,31 @@ + + + org.eclipse.osgi + org.eclipse.osgi + + + org.eclipse.osgi + org.eclipse.osgi.services + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.common + + + org.wso2.carbon + org.wso2.carbon.ndatasource.core + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.iot + + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java index e0225bd7..890bdb23 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java @@ -1,18 +1,20 @@ /* -* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * 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.currentsensor.plugin.constants; @@ -23,4 +25,5 @@ public class CurrentSensorConstants { public final static String DEVICE_PLUGIN_DEVICE_ID = "CURRENT_SENSOR_DEVICE_ID"; public final static String SENSOR_CURRENT = "current"; public final static String SENSOR_POWER = "power"; + public static final String DATA_SOURCE_NAME = "jdbc/currentsensorDM_DB"; } diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java index d1676369..6d702f67 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java @@ -1,17 +1,17 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -21,11 +21,11 @@ package org.homeautomation.currentsensor.plugin.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.homeautomation.currentsensor.plugin.impl.dao.CurrentSensorDAO; import org.wso2.carbon.device.mgt.common.*; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.impl.dao.CurrentSensorDAO; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice; diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java index 09fc22f0..b2b7db3f 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java @@ -1,5 +1,24 @@ +/* + * 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.currentsensor.plugin.impl; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManager; @@ -8,12 +27,9 @@ 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.spi.DeviceManagementService; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; import java.util.List; -; - public class CurrentSensorManagerService implements DeviceManagementService{ private DeviceManager deviceManager; @Override diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAO.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAO.java index 35b6797d..1aac11b8 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAO.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAO.java @@ -1,32 +1,35 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. -*/ + */ package org.homeautomation.currentsensor.plugin.impl.dao; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.impl.dao.impl.CurrentSensorDeviceDAOImpl; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; +import org.homeautomation.currentsensor.plugin.impl.dao.impl.CurrentSensorDeviceDAOImpl; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface; +import javax.naming.Context; +import javax.naming.InitialContext; +import javax.naming.NamingException; import javax.sql.DataSource; import java.sql.Connection; import java.sql.SQLException; @@ -48,7 +51,13 @@ public class CurrentSensorDAO extends IotDeviceManagementDAOFactory } public static void initCurrentSensorDAO(){ - dataSource = getDataSourceMap().get(CurrentSensorConstants.DEVICE_TYPE); + try { + Context ctx = new InitialContext(); + dataSource = (DataSource) ctx.lookup(CurrentSensorConstants.DATA_SOURCE_NAME); + } catch (NamingException e) { + log.error("Error while looking up the data source: " + + CurrentSensorConstants.DATA_SOURCE_NAME); + } } public static void beginTransaction() throws IotDeviceManagementDAOException { diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java index d732d8a9..1b30aa63 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java @@ -1,27 +1,27 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 + * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -package org.homeautomation.currentsensor.impl.dao.impl; +package org.homeautomation.currentsensor.plugin.impl.dao.impl; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.constants.CurrentSensorConstants; -import org.wso2.carbon.device.mgt.iot.currentsensor.plugin.impl.dao.CurrentSensorDAO; +import org.homeautomation.currentsensor.plugin.constants.CurrentSensorConstants; +import org.homeautomation.currentsensor.plugin.impl.dao.CurrentSensorDAO; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException; import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil; diff --git a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java index d0cfe5d9..d9c8336e 100644 --- a/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java +++ b/modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java @@ -1,4 +1,3 @@ -package org.homeautomation.currentsensor.plugin.internal; /* * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -12,10 +11,98 @@ package org.homeautomation.currentsensor.plugin.internal; * 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 + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ -public class ServiceComponent{ + +package org.homeautomation.currentsensor.plugin.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.homeautomation.currentsensor.plugin.impl.CurrentSensorManagerService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; +import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService; + +/** + * @scr.component name="org.wso2.carbon.device.mgt.iot.currentsensor.plugin.internal.CurrentSensorManagementServiceComponent" + * immediate="true" + * @scr.reference name="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService" + * interface="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService" + * cardinality="1..1" + * policy="dynamic" + * bind="setDeviceTypeService" + * unbind="unsetDeviceTypeService" + */ + +public class ServiceComponent { + + + private ServiceRegistration currentSensorServiceRegRef; + + + + private static final Log log = LogFactory.getLog(ServiceComponent.class); + + protected void activate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Activating Current Sensor Management Service Component"); + } + try { + BundleContext bundleContext = ctx.getBundleContext(); + + + currentSensorServiceRegRef = + bundleContext.registerService(DeviceManagementService.class.getName(), new + CurrentSensorManagerService(), + null); + + + + if (log.isDebugEnabled()) { + log.debug("Current Sensor Management Service Component has been successfully activated"); + } + } catch (Throwable e) { + log.error("Error occurred while activating Current Sensor Management Service Component", e); + } + } + + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("De-activating Current Sensor Management Service Component"); + } + try { + if (currentSensorServiceRegRef != null) { + currentSensorServiceRegRef.unregister(); + } + + if (log.isDebugEnabled()) { + log.debug( + "Current Sensor Management Service Component has been successfully de-activated"); + } + } catch (Throwable e) { + log.error("Error occurred while de-activating Iot Device Management bundle", e); + } + } + + + protected void setDeviceTypeService(DeviceTypeService deviceTypeService) { + /* This is to avoid this component getting initialized before the + common registered */ + if (log.isDebugEnabled()) { + log.debug("Data source service set to mobile service component"); + } + } + + protected void unsetDeviceTypeService(DeviceTypeService deviceTypeService) { + //do nothing + } + + + } \ No newline at end of file diff --git a/modules/samples/currentsensor/component/pom.xml b/modules/samples/currentsensor/component/pom.xml index 4e3ddebe..6ba42621 100644 --- a/modules/samples/currentsensor/component/pom.xml +++ b/modules/samples/currentsensor/component/pom.xml @@ -1,4 +1,22 @@ + + @@ -9,7 +27,8 @@ 4.0.0 1.9.2-SNAPSHOT - component + ${project-base-package}-component + WSO2 IoTS(Device Types) - Current Sensor Component pom @@ -32,10 +51,12 @@ + analytics plugin controller manager agent + ui @@ -46,12 +67,6 @@ 1.9.2-SNAPSHOT provided - - org.wso2.carbon.devicemgt-plugins - org.coffeeking.connectedcup.plugin - 1.9.2-SNAPSHOT - provided - org.wso2.carbon.devicemgt @@ -59,7 +74,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.webapp.publisher_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.webapp.publisher_${carbon.device.mgt.jar.version}.jar @@ -78,7 +93,7 @@ ${carbon.iot.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.iot_1.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.iot_${carbon.iot.device.mgt.jar.version}.jar @@ -87,7 +102,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.core_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.core_${carbon.device.mgt.jar.version}.jar @@ -96,7 +111,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.common_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.common_${carbon.device.mgt.jar.version}.jar @@ -105,7 +120,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.certificate.mgt.core_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.certificate.mgt.core_${carbon.device.mgt.jar.version}.jar @@ -114,7 +129,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.annotations_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.annotations_${carbon.device.mgt.jar.version}.jar @@ -123,7 +138,7 @@ ${carbon.device.mgt.version} system - ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.analytics_0.9.2.SNAPSHOT.jar + ${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.analytics_${carbon.device.mgt.jar.version}.jar @@ -238,6 +253,11 @@ ${basedir}/../../../../repository/components/plugins/commons-codec_1.4.0.wso2v1.jar + + commons-io + commons-io + ${commons-io.version} + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/ui/pom.xml b/modules/samples/currentsensor/component/ui/pom.xml new file mode 100644 index 00000000..1632b3c5 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/pom.xml @@ -0,0 +1,64 @@ + + + + + + + + org.homeautomation + ${project-base-package}-component + 1.9.2-SNAPSHOT + ../pom.xml + + + 4.0.0 + 1.9.2-SNAPSHOT + ${groupId}.currentsensor.ui + ${groupId}.currentsensor.ui + pom + http://wso2.org + + + + + maven-assembly-plugin + 2.5.5 + + ${project.artifactId}-${carbon.device.mgt.version} + false + + src/assembly/src.xml + + + + + create-archive + package + + single + + + + + + + + \ No newline at end of file diff --git a/modules/samples/currentsensor/component/ui/src/assembly/src.xml b/modules/samples/currentsensor/component/ui/src/assembly/src.xml new file mode 100644 index 00000000..2797034e --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/assembly/src.xml @@ -0,0 +1,36 @@ + + + + src + + zip + + false + ${basedir}/src + + + ${basedir}/src/main/resources/jaggeryapps/devicemgt + / + true + + + \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.hbs b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.hbs similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.hbs rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.hbs diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js similarity index 95% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js index 75648e23..a50f5305 100644 --- a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * 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 diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.json b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.json similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.json rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/device-view.json diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/public/images/current-sensor.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/public/images/current-sensor.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/public/images/current-sensor.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.device-view/public/images/current-sensor.png diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-edit/policy-edit.hbs b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-edit/policy-edit.hbs new file mode 100644 index 00000000..63835834 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-edit/policy-edit.hbs @@ -0,0 +1 @@ +{{unit "iot.unit.policy.edit"}} \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.json b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-edit/policy-edit.json similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.json rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-edit/policy-edit.json diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.hbs b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.hbs new file mode 100644 index 00000000..00e27f7c --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.hbs @@ -0,0 +1 @@ +{{unit "iot.unit.policy.view"}} \ No newline at end of file diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.json b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.json new file mode 100644 index 00000000..9eecd8f5 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-view/policy-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.hbs b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.hbs new file mode 100644 index 00000000..3a0c0687 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.hbs @@ -0,0 +1 @@ +{{unit "iot.unit.policy.wizard"}} \ No newline at end of file diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.json b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.json new file mode 100644 index 00000000..9eecd8f5 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.policy-wizard/policy-wizard.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/current-sensor.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/current-sensor.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/current-sensor.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/current-sensor.png diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/display-icon.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/display-icon.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/display-icon.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/display-icon.png diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/myDevices_analytics.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/myDevices_analytics.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/myDevices_analytics.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/myDevices_analytics.png diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/schematicsGuide.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/schematicsGuide.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/schematicsGuide.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/schematicsGuide.png diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/thumb.png b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/thumb.png similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/thumb.png rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/images/thumb.png diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js similarity index 89% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js index b1afd412..7bc53e58 100644 --- a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/download.js @@ -1,19 +1,19 @@ /* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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 modalPopup = ".wr-modalpopup"; diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js similarity index 98% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js index 3c1ebb04..fe7ecf07 100644 --- a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/public/js/jquery.validate.js @@ -1,12 +1,19 @@ -/** - * jQuery Validation Plugin 1.11.0pre +/* + * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * - * http://bassistance.de/jquery-plugins/jquery-plugin-validation/ - * http://docs.jquery.com/Plugins/Validation + * 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 * - * Copyright 2013 Jörn Zaefferer - * Released under the MIT license: - * http://www.opensource.org/licenses/mit-license.php + * 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($) { diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.hbs b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.hbs similarity index 100% rename from modules/samples/currentsensor/feature/feature/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.hbs rename to modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.hbs diff --git a/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.json b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.json new file mode 100644 index 00000000..9eecd8f5 --- /dev/null +++ b/modules/samples/currentsensor/component/ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.currentsensor.type-view/type-view.json @@ -0,0 +1,3 @@ +{ + "version": "1.0.0" +} \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml b/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml deleted file mode 100644 index 8003949f..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/EventReceiver_current.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - false - - - - diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/artifact.xml b/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/artifact.xml deleted file mode 100644 index e18a54a9..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/Eventreceiver_current_1.0.0/artifact.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - EventReceiver_current.xml - diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/artifact.xml b/modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/artifact.xml deleted file mode 100644 index 8fa86f5f..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/Eventstore_current_1.0.0/artifact.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - org_wso2_iot_devices_current.xml - diff --git a/modules/samples/currentsensor/feature/analytics/Current/Eventstream_current_1.0.0/artifact.xml b/modules/samples/currentsensor/feature/analytics/Current/Eventstream_current_1.0.0/artifact.xml deleted file mode 100644 index 7be7a0ad..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/Eventstream_current_1.0.0/artifact.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - org.wso2.iot.devices.current_1.0.0.json - - diff --git a/modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/artifact.xml b/modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/artifact.xml deleted file mode 100644 index 02d3d73f..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/Sparkscripts_1.0.0/artifact.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - Current_Sensor_Script.xml - diff --git a/modules/samples/currentsensor/feature/analytics/Current/artifacts.xml b/modules/samples/currentsensor/feature/analytics/Current/artifacts.xml deleted file mode 100644 index 082b84ed..00000000 --- a/modules/samples/currentsensor/feature/analytics/Current/artifacts.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/modules/samples/currentsensor/feature/analytics/build.xml b/modules/samples/currentsensor/feature/analytics/build.xml deleted file mode 100644 index e34285ec..00000000 --- a/modules/samples/currentsensor/feature/analytics/build.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/modules/samples/currentsensor/feature/analytics/pom.xml b/modules/samples/currentsensor/feature/analytics/pom.xml deleted file mode 100644 index 739d65b3..00000000 --- a/modules/samples/currentsensor/feature/analytics/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - org.homeautomation - feature - 1.9.2-SNAPSHOT - ../pom.xml - - 4.0.0 - ${groupId}.currentsensor.analytics - 1.9.2-SNAPSHOT - pom - ${groupId}.currentsensor.analytics - http://wso2.org - - - - maven-clean-plugin - ${maven-clean-plugin.version} - - - auto-clean - initialize - - clean - - - - - - maven-antrun-plugin - ${wso2.maven.compiler.source} - - - process-resources - - - - - - - run - - - - - - - \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/feature/pom.xml b/modules/samples/currentsensor/feature/feature/pom.xml index e36046f6..16465679 100644 --- a/modules/samples/currentsensor/feature/feature/pom.xml +++ b/modules/samples/currentsensor/feature/feature/pom.xml @@ -15,20 +15,25 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + org.homeautomation feature 1.9.2-SNAPSHOT ../pom.xml + 4.0.0 1.9.2-SNAPSHOT ${groupId}.currentsensor.feature pom - ${project.artifactId} - http://wso2.org + ${project.artifactId} + http://wso2.org + org.homeautomation @@ -59,6 +64,7 @@ 1.2.140.wso2v3 + @@ -90,7 +96,40 @@ maven-dependency-plugin - copy-jaxrs-manager-war + unpack + package + + unpack + + + + + org.homeautomation + ${project-base-package}.analytics + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/carbonapps + + **/* + + + org.homeautomation + ${project-base-package}.ui + ${project.version} + zip + true + + ${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt + + **/* + + + + + + copy-jaxrs-war package copy @@ -102,45 +141,29 @@ ${project-base-package}.manager war true - ${basedir}/src/main/resources/webapps/ + + ${project.build.directory}/maven-shared-archive-resources/webapps/ + currentsensor_mgt.war - - - - - copy-jaxrs-controller-war - package - - copy - - - org.homeautomation ${project-base-package}.controller war true - ${basedir}/src/main/resources/webapps/ + + ${project.build.directory}/maven-shared-archive-resources/webapps/ + currentsensor.war - - - - - copy-jaxrs-agent-war - package - - copy - - - org.homeautomation ${project-base-package}.agent war true - ${basedir}/src/main/resources/webapps/ + + ${project.build.directory}/maven-shared-archive-resources/webapps/ + currentsensor_agent.war @@ -162,7 +185,7 @@ + value="target/maven-shared-archive-resources/database"/> +# +# 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. +# + custom = true diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json b/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json index dbdc7258..cdc1fdf5 100644 --- a/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json +++ b/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json @@ -1,24 +1,7 @@ -/* - * 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. - */ { "deviceType": { - "label": "", - "category": "virtual", + "label": "Current Sensor", + "category": "virtual" }, "analyticStreams": [ { @@ -31,6 +14,17 @@ {"column": {"name":"CURRENT", "label":"current", "ui-mapping":"y-axis"}} ] } + }, + { + "name": "Power x100", + "table": "DEVICE_POWER_SUMMARY", + "ui_unit": { + "name": "cdmf.unit.analytics.line-chart", + "data":[ + {"column": {"name":"TIME", "label":"time", "ui-mapping":"x-axis"}}, + {"column": {"name":"POWER", "label":"power", "ui-mapping":"y-axis"}} + ] + } } ] } \ No newline at end of file diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/dbscripts/h2.sql b/modules/samples/currentsensor/feature/feature/src/main/resources/dbscripts/h2.sql index 6b3be839..2bbb379e 100644 --- a/modules/samples/currentsensor/feature/feature/src/main/resources/dbscripts/h2.sql +++ b/modules/samples/currentsensor/feature/feature/src/main/resources/dbscripts/h2.sql @@ -1,11 +1,9 @@ -- ----------------------------------------------------- --- Agent Database +-- Table `CURRENT_SENSOR_DEVICE` -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS `currentsensor_DEVICE` ( - `currentsensor_DEVICE_ID` VARCHAR(45) NOT NULL , +CREATE TABLE IF NOT EXISTS `CURRENT_SENSOR_DEVICE` ( + `CURRENT_SENSOR_DEVICE_ID` VARCHAR(45) NOT NULL , `DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL, - PRIMARY KEY (`currentsensor_DEVICE_ID`) ); - - + PRIMARY KEY (`CURRENT_SENSOR_DEVICE_ID`) ); diff --git a/modules/samples/currentsensor/feature/pom.xml b/modules/samples/currentsensor/feature/pom.xml index b5995473..71292345 100644 --- a/modules/samples/currentsensor/feature/pom.xml +++ b/modules/samples/currentsensor/feature/pom.xml @@ -1,4 +1,5 @@ + + --> + org.homeautomation currentsensor 1.9.2-SNAPSHOT ../pom.xml + feature 4.0.0 pom - 1.9.2-SNAPSHOT - - analytics - feature - + + + + feature + \ No newline at end of file diff --git a/modules/samples/currentsensor/pom.xml b/modules/samples/currentsensor/pom.xml index fa0fd506..d8876f0a 100644 --- a/modules/samples/currentsensor/pom.xml +++ b/modules/samples/currentsensor/pom.xml @@ -15,14 +15,24 @@ ~ specific language governing permissions and limitations ~ under the License. --> - + + + org.wso2 + wso2 + 1 + + org.homeautomation currentsensor 1.9.2-SNAPSHOT pom 4.0.0 http://wso2.com + component feature @@ -145,13 +155,29 @@ + 4.4.3 + 1.1.0-SNAPSHOT + 1.1.0.SNAPSHOT + 1.0.2 + 3.0.0.wso2v1 + 3.8.1.v20120830-144521 + 1.9.2-SNAPSHOT + 1.9.2.SNAPSHOT + 1.1.1 + 2.4 + + + 3.0.4.wso2v1 + 3.0.4.wso2v1 + 2.6.1 + 1.9.0 + 3.1.0.wso2v2 + 3.6.100.v20120522-1841 + 1.7 1.7 org.homeautomation.currentsensor 3.8.1 - 1.0.0 - 4.4.2 - 0.9.2-SNAPSHOT 1.4.0 2.4.1 2.3.2 @@ -159,6 +185,7 @@ 1.8 1.7.2 + wso2.releases @@ -247,4 +274,4 @@ - \ No newline at end of file + diff --git a/modules/samples/installer/device-deployer.xml b/modules/samples/installer/device-deployer.xml index ebec035a..e9fd67be 100644 --- a/modules/samples/installer/device-deployer.xml +++ b/modules/samples/installer/device-deployer.xml @@ -34,6 +34,7 @@ samples/connectedcup + samples/currentsensor @@ -61,6 +62,9 @@ org.wso2.carbon.devicemgt-plugins:org.coffeeking.connectedcup.feature:1.9.2-SNAPSHOT + + org.homeautomation:org.homeautomation.currentsensor.feature:1.9.2-SNAPSHOT + @@ -90,6 +94,10 @@ org.coffeeking.connectedcup.feature.group 1.9.2-SNAPSHOT + + org.homeautomation.currentsensor.feature.group + 1.9.2-SNAPSHOT +