You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by am...@apache.org on 2017/08/08 12:48:01 UTC
[04/12] incubator-unomi git commit: Integrate weather update
extension to unomi
Integrate weather update extension to unomi
Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/774e8010
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/774e8010
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/774e8010
Branch: refs/heads/master
Commit: 774e8010ed4bf2d8452f8eaa86582c35e0f90d02
Parents: bc06486
Author: dinesh1996 <Dragonball21>
Authored: Wed Jul 26 14:29:54 2017 +0200
Committer: dinesh1996 <Dragonball21>
Committed: Thu Aug 3 14:27:18 2017 +0200
----------------------------------------------------------------------
extensions/pom.xml | 1 +
extensions/weather-update/.gitignore | 8 +
extensions/weather-update/README.md | 30 +++
extensions/weather-update/core/pom.xml | 100 ++++++++
.../actions/WeatherUpdateAction.java | 251 +++++++++++++++++++
.../cxs/actions/UpdateWeatherAction.json | 15 ++
.../sessions/weather/weatherLike.json | 13 +
.../sessions/weather/weatherTemp.json | 13 +
.../sessions/weather/weatherWindDirection.json | 13 +
.../sessions/weather/weatherWindSpeed.json | 13 +
.../META-INF/cxs/rules/UpdateWeather.json | 40 +++
.../sessions/weatherSessionProperties.json | 5 +
.../resources/OSGI-INF/blueprint/blueprint.xml | 44 ++++
.../src/main/resources/messages_en.properties | 18 ++
.../org.apache.unomi.weatherUpdate.cfg | 20 ++
extensions/weather-update/karaf-kar/pom.xml | 82 ++++++
.../karaf-kar/src/main/feature/feature.xml | 28 +++
extensions/weather-update/pom.xml | 37 +++
...g.apache.unomi.persistence.elasticsearch.cfg | 4 +-
19 files changed, 733 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 07608b3..29437be 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -36,6 +36,7 @@
<module>geonames</module>
<module>router</module>
<module>salesforce-connector</module>
+ <module>weather-update</module>
</modules>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/.gitignore
----------------------------------------------------------------------
diff --git a/extensions/weather-update/.gitignore b/extensions/weather-update/.gitignore
new file mode 100644
index 0000000..851a31c
--- /dev/null
+++ b/extensions/weather-update/.gitignore
@@ -0,0 +1,8 @@
+/.classpath
+/.project
+/.settings
+.idea
+*.iml
+*.ipr
+target
+repository.xml.generated
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/README.md
----------------------------------------------------------------------
diff --git a/extensions/weather-update/README.md b/extensions/weather-update/README.md
new file mode 100644
index 0000000..0763929
--- /dev/null
+++ b/extensions/weather-update/README.md
@@ -0,0 +1,30 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF 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.
+ -->
+
+
+# UnomiWeatherUpdate
+A simple plugin to send Unomi events when a member is logged
+
+
+In the etc/org.apache.unomi.weatherupdate.cfg file change the following settings:
+
+ weatherUpdate.apiKey=YOUR_WEATHER_APIKEY
+
+
+ <configfile finalname="/etc/org.apache.unomi.weatherupdate.cfg">mvn:org.apache.unomi
+ .samples/weather-update-karaf-kar/${project.version}/cfg/weatherupdatecfg</configfile>
+
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/pom.xml b/extensions/weather-update/core/pom.xml
new file mode 100755
index 0000000..06aa2ee
--- /dev/null
+++ b/extensions/weather-update/core/pom.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-weather-update</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>unomi-weather-update-core</artifactId>
+ <name>Apache Unomi :: Extension :: Weather Update :: Core</name>
+ <description>This is a simple Apache Unomi plugin.</description>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>${project.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient-osgi</artifactId>
+ <version>4.5.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-osgi</artifactId>
+ <version>4.4.6</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
+ <Import-Package>
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>
+ src/main/resources/org.apache.unomi.weatherupdate.cfg
+ </file>
+ <type>cfg</type>
+ <classifier>weatherupdatecfg</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/java/org/apache/unomi/weatherupdate/actions/WeatherUpdateAction.java
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/java/org/apache/unomi/weatherupdate/actions/WeatherUpdateAction.java b/extensions/weather-update/core/src/main/java/org/apache/unomi/weatherupdate/actions/WeatherUpdateAction.java
new file mode 100644
index 0000000..e37895e
--- /dev/null
+++ b/extensions/weather-update/core/src/main/java/org/apache/unomi/weatherupdate/actions/WeatherUpdateAction.java
@@ -0,0 +1,251 @@
+/*
+
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF 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.apache.unomi.weatherupdate.actions;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.apache.unomi.api.Event;
+import org.apache.unomi.api.Session;
+import org.apache.unomi.api.actions.Action;
+import org.apache.unomi.api.actions.ActionExecutor;
+import org.apache.unomi.api.services.EventService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Get the weather location of the users by an API
+ *
+ * @author dsalhotra
+ */
+public class WeatherUpdateAction implements ActionExecutor {
+ private static Logger logger = LoggerFactory.getLogger(WeatherUpdateAction.class);
+ private CloseableHttpClient httpClient;
+
+ private String weatherApiKey;
+ private String weatherUrlBase;
+ private String weatherUrlAttributes;
+
+ @Override
+ public int execute(Action action, Event event) {
+ if (httpClient == null) {
+ httpClient = HttpClients.createDefault();
+ }
+
+ Session session = event.getSession();
+
+ if (!(weatherApiKey == null || weatherUrlBase == null || weatherUrlAttributes == null)) {
+ Map<String, Object> sessionProperties = session.getProperties();
+ if (sessionProperties.containsKey("location")) {
+ Map<String, Double> location = (Map<String, Double>) session.getProperty("location");
+ HttpGet httpGet = new HttpGet(weatherUrlBase + "/" + weatherUrlAttributes + "?lat=" +
+ location.get("lat") + "&lon=" + location.get("lon") + "&appid=" + weatherApiKey
+ );
+
+ JsonNode jsonNode = null;
+ CloseableHttpResponse response = null;
+ try {
+ response = httpClient.execute(httpGet);
+ if (response != null) {
+ HttpEntity entity = response.getEntity();
+ String responseString;
+ if (entity != null) {
+ try {
+ responseString = EntityUtils.toString(entity);
+ ObjectMapper objectMapper = new ObjectMapper();
+ jsonNode = objectMapper.readTree(responseString);
+ } catch (IOException e) {
+ logger.error("Error : With the API json response.", e.getMessage());
+ }
+ }
+ }
+ } catch (IOException e) {
+ logger.error("Error : With the Http Request execution. Wrong parameters given", e.getMessage());
+ } finally {
+ if (response != null) {
+ EntityUtils.consumeQuietly(response.getEntity());
+ }
+ }
+
+ if (jsonNode.has("cod")) {
+ if (jsonNode.get("cod").asText().equals("200")) {
+ String temperature = extractTemperature(jsonNode);
+ String weatherLike = extractWeatherLike(jsonNode);
+ String windDirection = extractWindDirection(jsonNode);
+ String windSpeed = extractWindSpeed(jsonNode);
+ if (temperature != null) {
+ fillPropreties(session, "weatherTemperature", temperature);
+ }
+ if (weatherLike != null) {
+ fillPropreties(session, "weatherLike", weatherLike);
+ }
+ if (windDirection != null) {
+ fillPropreties(session, "weatherWindDirection", windDirection);
+ }
+ if (windSpeed != null) {
+ fillPropreties(session, "weatherWindSpeed", windSpeed);
+ }
+ return EventService.SESSION_UPDATED;
+ }
+ }
+ }
+ }
+ return EventService.NO_CHANGE;
+ }
+
+ private String extractTemperature(JsonNode jsonNode) {
+ float temperature;
+ if (jsonNode.has("main") && jsonNode.get("main").has("temp")) {
+ String responseString = jsonNode.get("main").get("temp").asText();
+ temperature = Float.parseFloat(responseString);
+ temperature -= 273.15;
+ int temperatureTreated = (int) temperature;
+ if (temperature - temperatureTreated > 0.5) {
+ temperatureTreated++;
+ }
+ logger.debug("Temperature: " + temperatureTreated);
+ return temperatureTreated + "";
+ }
+ logger.info("API Response doesn't contains the temperature");
+ return null;
+ }
+
+ private String extractWindSpeed(JsonNode jsonNode) {
+ JsonNode WindInfoSpeed;
+ if (jsonNode.has("wind") && jsonNode.get("wind").has("speed")) {
+ WindInfoSpeed = jsonNode.get("wind").get("speed");
+ float speed = Float.parseFloat(WindInfoSpeed.toString());
+ speed *= 3.6;
+ int speedTreated = (int) speed;
+ logger.debug("Wind speed: " + speedTreated);
+ return speedTreated + "";
+ }
+ logger.info("API Response doesn't contains the wind speed");
+ return null;
+
+ }
+
+ private String extractWindDirection(JsonNode jsonNode) {
+ JsonNode WindInfoDirection;
+ if (jsonNode.has("wind")) {
+ WindInfoDirection = jsonNode.get("wind").get("deg");
+ String direction = "";
+ float deg = Float.parseFloat(WindInfoDirection.toString());
+ if (11.25 < deg && deg < 348.75) {
+ direction = ("N");
+ } else if (11.25 < deg && deg < 33.75) {
+ direction = ("NNE");
+ } else if (33.75 < deg && deg < 56.25) {
+ direction = ("NE");
+ } else if (56.25 < deg && deg < 78.75) {
+ direction = ("ENE");
+ } else if (78.75 < deg && deg < 101.25) {
+ direction = ("E");
+ } else if (101.25 < deg && deg < 123.75) {
+ direction = ("ESE");
+ } else if (123.75 < deg && deg < 146.25) {
+ direction = ("SE");
+ } else if (146.25 < deg && deg < 168.75) {
+ direction = ("SSE");
+ } else if (168.75 < deg && deg < 191.25) {
+ direction = ("S");
+ } else if (191.25 < deg && deg < 213.75) {
+ direction = ("SSW");
+ } else if (213.75 < deg && deg < 236.25) {
+ direction = ("SW");
+ } else if (236.25 < deg && deg < 258.75) {
+ direction = ("WSW");
+ } else if (258.75 < deg && deg < 281.25) {
+ direction = ("W");
+ } else if (281.25 < deg && deg < 303.75) {
+ direction = ("WNW");
+ } else if (303.75 < deg && deg < 326.25) {
+ direction = ("NW");
+ } else if (326.25 < deg && deg < 348.75) {
+ direction = ("NNW");
+ }
+ logger.debug("Wind direction: " + direction);
+ return direction;
+ }
+ logger.info("API Response doesn't contains the wind direction");
+ return null;
+ }
+
+ /**
+ *
+ * @param jsonNode
+ * @return
+ */
+ private String extractWeatherLike(JsonNode jsonNode) {
+ JsonNode weatherLike;
+ if (jsonNode.has("weather")) {
+ weatherLike = jsonNode.get("weather");
+ if (weatherLike.size() > 0) {
+ weatherLike = weatherLike.get(0).get("main");
+ logger.debug("Weather like: " + weatherLike);
+ return weatherLike.asText();
+ }
+ }
+ logger.info("API Response doesn't contains the weather description");
+ return null;
+ }
+
+ /**
+ *
+ * @param session
+ * @param property
+ * @param value
+ */
+ private void fillPropreties(Session session, String property, String value) {
+ session.setProperty(property, value);
+ }
+
+ //Setters
+
+ /**
+ * @param weatherApiKey
+ */
+ public void setWeatherApiKey(String weatherApiKey) {
+ this.weatherApiKey = weatherApiKey;
+ }
+
+ /**
+ * @param weatherUrlBase
+ */
+ public void setWeatherUrlBase(String weatherUrlBase) {
+ this.weatherUrlBase = weatherUrlBase;
+ }
+
+ /**
+ * @param weatherUrlAttributes
+ */
+ public void setWeatherUrlAttributes(String weatherUrlAttributes) {
+ this.weatherUrlAttributes = weatherUrlAttributes;
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/actions/UpdateWeatherAction.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/actions/UpdateWeatherAction.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/actions/UpdateWeatherAction.json
new file mode 100755
index 0000000..339291b
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/actions/UpdateWeatherAction.json
@@ -0,0 +1,15 @@
+{
+ "metadata": {
+ "id": "weatherUpdateAction",
+ "name": "Update session with local weather information",
+ "description": "This action will retrieve the weather associated with the resolved location of the user (from his IP address)",
+ "tags": [
+ "event",
+ "hidden.availableToEndUser",
+ "hidden.hasNoTemplate"
+ ],
+ "readOnly": true
+ },
+ "actionExecutor": "weatherUpdate",
+ "parameters": []
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherLike.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherLike.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherLike.json
new file mode 100755
index 0000000..ade7495
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherLike.json
@@ -0,0 +1,13 @@
+{
+ "metadata": {
+ "id": "weatherLike",
+ "name": "Weather Description"
+ },
+ "type": "string",
+ "tags": [
+ "sessionProperties"
+ ],
+ "defaultValue": "",
+ "automaticMappingsFrom": [],
+ "rank": "302.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherTemp.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherTemp.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherTemp.json
new file mode 100755
index 0000000..d3aebe5
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherTemp.json
@@ -0,0 +1,13 @@
+{
+ "metadata": {
+ "id": "weatherTemperature",
+ "name": "Weather Temperature"
+ },
+ "type": "integer",
+ "tags": [
+ "sessionProperties"
+ ],
+ "defaultValue": "",
+ "automaticMappingsFrom": [],
+ "rank": "302.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindDirection.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindDirection.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindDirection.json
new file mode 100755
index 0000000..c9fc3e6
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindDirection.json
@@ -0,0 +1,13 @@
+{
+ "metadata": {
+ "id": "weatherWindDirection",
+ "name": "Weather Wind Direction"
+ },
+ "type": "string",
+ "tags": [
+ "sessionProperties"
+ ],
+ "defaultValue": "",
+ "automaticMappingsFrom": [],
+ "rank": "302.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindSpeed.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindSpeed.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindSpeed.json
new file mode 100755
index 0000000..5077f1e
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/properties/sessions/weather/weatherWindSpeed.json
@@ -0,0 +1,13 @@
+{
+ "metadata": {
+ "id": "weatherWindSpeed",
+ "name": "Weather Wind Speed"
+ },
+ "type": "integer",
+ "tags": [
+ "sessionProperties"
+ ],
+ "defaultValue": "",
+ "automaticMappingsFrom": [],
+ "rank": "302.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/rules/UpdateWeather.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/rules/UpdateWeather.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/rules/UpdateWeather.json
new file mode 100755
index 0000000..ec25145
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/rules/UpdateWeather.json
@@ -0,0 +1,40 @@
+{
+ "metadata": {
+ "id": "weatherUpdate",
+ "name": "Add weather information to session",
+ "description": "Get the weather from a city"
+ },
+ "raiseEventOnlyOnceForSession": false,
+ "condition": {
+
+ "parameterValues": {
+ "subConditions": [
+ {
+ "type": "eventTypeCondition",
+ "parameterValues": {
+ "eventTypeId": "weatherEvent"
+ }
+ },
+ {
+ "type": "eventTypeCondition",
+ "parameterValues": {
+ "eventTypeId": "login"
+ }
+ }
+ ],
+ "operator" : "or"
+ },
+ "type": "booleanCondition"
+ },
+ "actions": [
+ {
+ "type": "weatherUpdateAction",
+ "parameterValues": {}
+ }
+ ]
+}
+
+
+
+
+
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/META-INF/cxs/tags/properties/sessions/weatherSessionProperties.json
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/META-INF/cxs/tags/properties/sessions/weatherSessionProperties.json b/extensions/weather-update/core/src/main/resources/META-INF/cxs/tags/properties/sessions/weatherSessionProperties.json
new file mode 100755
index 0000000..d634f69
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/META-INF/cxs/tags/properties/sessions/weatherSessionProperties.json
@@ -0,0 +1,5 @@
+{
+ "id": "weatherSessionProperties",
+ "parent": "sessionProperties",
+ "rank": "1.0"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/extensions/weather-update/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
new file mode 100755
index 0000000..0339ce8
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF 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.
+ -->
+<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+ xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
+
+ <!-- cfg configuration -->
+ <cm:property-placeholder persistent-id="org.apache.unomi.weatherupdate"
+ update-strategy="reload">
+ <cm:default-properties>
+ <cm:property name="weatherUpdate.apiKey" value=""/>
+ <cm:property name="weatherUpdate.url.base" value=""/>
+ <cm:property name="weatherUpdate.url.attributes" value=""/>
+ </cm:default-properties>
+ </cm:property-placeholder>
+
+ <!-- Action executor -->
+ <service auto-export="interfaces">
+ <service-properties>
+ <entry key="actionExecutorId" value="weatherUpdate"/>
+ </service-properties>
+ <bean class="org.apache.unomi.weatherupdate.actions.WeatherUpdateAction">
+ <property name="weatherApiKey" value="${weatherUpdate.apiKey}"/>
+ <property name="weatherUrlBase" value="${weatherUpdate.url.base}"/>
+ <property name="weatherUrlAttributes" value="${weatherUpdate.url.attributes}"/>
+ </bean>
+ </service>
+</blueprint>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/messages_en.properties
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/messages_en.properties b/extensions/weather-update/core/src/main/resources/messages_en.properties
new file mode 100755
index 0000000..ef653d6
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/messages_en.properties
@@ -0,0 +1,18 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF 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.
+#
+action.incrementTweetNumberAction.description=This action will retrieve the weather associated with the resolved location of the user (from his IP address)
+action.incrementTweetNumberAction.name=Update session with local weather information
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/core/src/main/resources/org.apache.unomi.weatherUpdate.cfg
----------------------------------------------------------------------
diff --git a/extensions/weather-update/core/src/main/resources/org.apache.unomi.weatherUpdate.cfg b/extensions/weather-update/core/src/main/resources/org.apache.unomi.weatherUpdate.cfg
new file mode 100644
index 0000000..475b631
--- /dev/null
+++ b/extensions/weather-update/core/src/main/resources/org.apache.unomi.weatherUpdate.cfg
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF 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.
+#
+
+weatherUpdate.apiKey=3e66ec6001684dad10724dbddaf547e6
+weatherUpdate.url.base=http://api.openweathermap.org
+weatherUpdate.url.attributes=data/2.5/weather
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/karaf-kar/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/weather-update/karaf-kar/pom.xml b/extensions/weather-update/karaf-kar/pom.xml
new file mode 100644
index 0000000..ffe164e
--- /dev/null
+++ b/extensions/weather-update/karaf-kar/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-weather-update</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>unomi-weather-update-karaf-kar</artifactId>
+ <name>Apache Unomi :: Extension :: Weather Update :: Apache Karaf Feature and KAR archive</name>
+ <description>This is a simple Apache Unomi plugin.</description>
+ <packaging>kar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-api</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-osgi</artifactId>
+ <version>4.4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient-osgi</artifactId>
+ <version>4.5.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-weather-update-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <includeTransitiveDependency>false</includeTransitiveDependency>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.tooling</groupId>
+ <artifactId>karaf-maven-plugin</artifactId>
+ <configuration>
+ <startLevel>85</startLevel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/karaf-kar/src/main/feature/feature.xml
----------------------------------------------------------------------
diff --git a/extensions/weather-update/karaf-kar/src/main/feature/feature.xml b/extensions/weather-update/karaf-kar/src/main/feature/feature.xml
new file mode 100644
index 0000000..73ebcb6
--- /dev/null
+++ b/extensions/weather-update/karaf-kar/src/main/feature/feature.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="unomi-weather-update-karaf-feature">
+ <feature name="unomi-weather-update-karaf-kar" version="1.0-SNAPSHOT"
+ description="Apache Unomi :: Extensions :: Weather update :: Apache Karaf Feature">
+ <details>Apache Karaf feature for the Apache Unomi Context Server extension that integrates Weather
+ update</details>
+ <configfile finalname="/etc/org.apache.unomi.weatherupdate.cfg">mvn:org.apache.unomi/unomi-weather-update-core/1.2.0-incubating-SNAPSHOT/cfg/weatherupdatecfg</configfile>
+ <bundle start-level="85">mvn:org.apache.httpcomponents/httpcore-osgi/4.4.6</bundle>
+ <bundle start-level="85">mvn:org.apache.httpcomponents/httpclient-osgi/4.5.1</bundle>
+ <bundle start-level="85">mvn:org.apache.unomi/unomi-weather-update-core/1.2.0-incubating-SNAPSHOT</bundle>
+ </feature>
+</features>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/extensions/weather-update/pom.xml
----------------------------------------------------------------------
diff --git a/extensions/weather-update/pom.xml b/extensions/weather-update/pom.xml
new file mode 100644
index 0000000..36c53fb
--- /dev/null
+++ b/extensions/weather-update/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.unomi</groupId>
+ <artifactId>unomi-extensions</artifactId>
+ <version>1.2.0-incubating-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>unomi-weather-update</artifactId>
+ <name>Apache Unomi :: Extension :: Weather Update</name>
+ <description>Apache Unomi Context Server that get the visitor weather based on his location</description>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>core</module>
+ <module>karaf-kar</module>
+ </modules>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/774e8010/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
----------------------------------------------------------------------
diff --git a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
index 77eb091..57127fd 100644
--- a/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
+++ b/persistence-elasticsearch/core/src/main/resources/org.apache.unomi.persistence.elasticsearch.cfg
@@ -15,7 +15,7 @@
# limitations under the License.
#
-cluster.name=contextElasticSearch
+cluster.name=dineshElasticSearch
# The elasticSearchAddresses may be a comma seperated list of host names and ports such as
# hostA:9300,hostB:9300
# Note: the port number must be repeated for each host.
@@ -42,4 +42,4 @@ bulkProcessor.backoffPolicy=exponential
# for each node in the ElasticSearch cluster:
# minimalElasticSearchVersion <= ElasticSearch node version < maximalElasticSearchVersion
minimalElasticSearchVersion=5.0.0
-maximalElasticSearchVersion=5.3.0
\ No newline at end of file
+maximalElasticSearchVersion=5.3.0