diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index b75d38770..84ad81d86 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -1,5 +1,22 @@
-
+
+
+ #@
+ `
+ com.mysql.jdbc.Driver
+ jdbc:mysql://localhost:3306/flx
+ root
+ dfdadfd8dfc5dfdfdfdedf9cdf93df80
+ flx.*
+ flx.*
+ MySQL
+
+
+ jar://$MAVEN_REPOSITORY$/mysql/mysql-connector-java/5.1.13/mysql-connector-java-5.1.13.jar!/
+
+
+
+
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index 1f92ea28d..3ac95b419 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -1,6 +1,7 @@
+
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
index fe282adbc..8dcb7fcbb 100644
--- a/.idea/jsLibraryMappings.xml
+++ b/.idea/jsLibraryMappings.xml
@@ -1,16 +1,3 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/README.md b/README.md
index b82d9609f..19168b062 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
Read me First
-------------
+[](https://gitter.im/fluxtream/fluxtream-app?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
Fluxtream is based on Spring(-MVC) 3.1, Spring Security 3.1 and JPA for the persistence. We use Jersey (JAX-WS) for exposing the REST API
This is a maven project with 5 sub-modules.
diff --git a/fluxtream-connectors/fluxtream-connectors.iml b/fluxtream-connectors/fluxtream-connectors.iml
index dfdc21327..bafb79f6c 100644
--- a/fluxtream-connectors/fluxtream-connectors.iml
+++ b/fluxtream-connectors/fluxtream-connectors.iml
@@ -14,13 +14,10 @@
+
-
-
-
-
diff --git a/fluxtream-core/fluxtream-core.iml b/fluxtream-core/fluxtream-core.iml
index 257bfa406..2aba37503 100644
--- a/fluxtream-core/fluxtream-core.iml
+++ b/fluxtream-core/fluxtream-core.iml
@@ -17,14 +17,11 @@
+
-
-
-
-
diff --git a/fluxtream-core/src/main/java/com/fluxtream/thirdparty/helpers/WWOHelper.java b/fluxtream-core/src/main/java/com/fluxtream/thirdparty/helpers/WWOHelper.java
index 68ccc7cbd..701cd4703 100644
--- a/fluxtream-core/src/main/java/com/fluxtream/thirdparty/helpers/WWOHelper.java
+++ b/fluxtream-core/src/main/java/com/fluxtream/thirdparty/helpers/WWOHelper.java
@@ -1,23 +1,15 @@
package com.fluxtream.thirdparty.helpers;
-import static com.fluxtream.utils.HttpUtils.fetch;
-
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
-
+import com.fluxtream.Configuration;
import com.fluxtream.domain.metadata.DayMetadataFacet;
-import net.sf.json.JSONArray;
-import net.sf.json.JSONObject;
-
+import com.fluxtream.domain.metadata.WeatherInfo;
import org.apache.commons.httpclient.HttpException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import com.fluxtream.Configuration;
-import com.fluxtream.domain.metadata.WeatherInfo;
-
@Component
public class WWOHelper {
@@ -44,52 +36,52 @@ public void setWeatherInfo(DayMetadataFacet info,
}
public List getWeatherInfo(double latitude, double longitude, String fdate) throws HttpException, IOException {
- String wwoUrl = "http://www.worldweatheronline.com/feed/premium-weather-v2.ashx?" +
-"key=" + env.get("wwo.key") + "&feedkey=" + env.get("wwo.feedkey") + "&format=json&q=" + latitude + "," + longitude + "&date=" + fdate;
- String wwoJson = fetch(wwoUrl);
-
- JSONObject wwoInfo = JSONObject.fromObject(wwoJson);
- List weather = new ArrayList();
- if (wwoInfo!=null) {
- JSONObject data = wwoInfo.getJSONObject("data");
- if (data==null) return weather;
- JSONArray weatherDataArray = data.getJSONArray("weather");
- if (weatherDataArray==null) return weather;
- JSONObject weatherData = weatherDataArray.getJSONObject(0);
- if (weatherData==null) return weather;
- JSONArray hourly = weatherData.getJSONArray("hourly");
- if (hourly!=null) {
- @SuppressWarnings("rawtypes")
- Iterator iterator = hourly.iterator();
- while (iterator.hasNext()) {
- JSONObject hourlyRecord = (JSONObject) iterator.next();
- WeatherInfo weatherInfo = new WeatherInfo();
- weatherInfo.cloudcover = Integer.valueOf(hourlyRecord.getString("cloudcover"));
- weatherInfo.humidity = Integer.valueOf(hourlyRecord.getString("humidity"));
- weatherInfo.precipMM = Float.valueOf(hourlyRecord.getString("precipMM"));
- weatherInfo.pressure = Integer.valueOf(hourlyRecord.getString("pressure"));
- weatherInfo.tempC = Integer.valueOf(hourlyRecord.getString("tempC"));
- weatherInfo.tempF = Integer.valueOf(hourlyRecord.getString("tempF"));
- weatherInfo.minuteOfDay = Integer.valueOf(hourlyRecord.getString("time"));
-
- weatherInfo.visibility = Integer.valueOf(hourlyRecord.getString("visibility"));
- weatherInfo.weatherCode = Integer.valueOf(hourlyRecord.getString("weatherCode"));
- JSONArray weatherDesc = hourlyRecord.getJSONArray("weatherDesc");
- JSONArray weatherIconUrl = hourlyRecord.getJSONArray("weatherIconUrl");
- weatherInfo.weatherDesc = weatherDesc.getJSONObject(0).getString("value");
- weatherInfo.weatherIconUrl = null;
- weatherInfo.weatherIconUrlDay = null;
- weatherInfo.weatherIconUrlNight = null;
- weatherInfo.weatherIconUrl = weatherIconUrl.getJSONObject(0).getString("value");
- weatherInfo.winddirDegree = Integer.valueOf(hourlyRecord.getString("winddirDegree"));
- weatherInfo.windspeedMiles = Integer.valueOf(hourlyRecord.getString("windspeedMiles"));
- weatherInfo.windspeedKmph = Integer.valueOf(hourlyRecord.getString("windspeedKmph"));
- weatherInfo.winddir16Point = hourlyRecord.getString("winddir16Point");
-
- weather.add(weatherInfo);
- }
- }
- }
+ List weather = new ArrayList();
+// String wwoUrl = "http://www.worldweatheronline.com/feed/premium-weather-v2.ashx?" +
+//"key=" + env.get("wwo.key") + "&feedkey=" + env.get("wwo.feedkey") + "&format=json&q=" + latitude + "," + longitude + "&date=" + fdate;
+// String wwoJson = fetch(wwoUrl);
+//
+// JSONObject wwoInfo = JSONObject.fromObject(wwoJson);
+// if (wwoInfo!=null) {
+// JSONObject data = wwoInfo.getJSONObject("data");
+// if (data==null) return weather;
+// JSONArray weatherDataArray = data.getJSONArray("weather");
+// if (weatherDataArray==null) return weather;
+// JSONObject weatherData = weatherDataArray.getJSONObject(0);
+// if (weatherData==null) return weather;
+// JSONArray hourly = weatherData.getJSONArray("hourly");
+// if (hourly!=null) {
+// @SuppressWarnings("rawtypes")
+// Iterator iterator = hourly.iterator();
+// while (iterator.hasNext()) {
+// JSONObject hourlyRecord = (JSONObject) iterator.next();
+// WeatherInfo weatherInfo = new WeatherInfo();
+// weatherInfo.cloudcover = Integer.valueOf(hourlyRecord.getString("cloudcover"));
+// weatherInfo.humidity = Integer.valueOf(hourlyRecord.getString("humidity"));
+// weatherInfo.precipMM = Float.valueOf(hourlyRecord.getString("precipMM"));
+// weatherInfo.pressure = Integer.valueOf(hourlyRecord.getString("pressure"));
+// weatherInfo.tempC = Integer.valueOf(hourlyRecord.getString("tempC"));
+// weatherInfo.tempF = Integer.valueOf(hourlyRecord.getString("tempF"));
+// weatherInfo.minuteOfDay = Integer.valueOf(hourlyRecord.getString("time"));
+//
+// weatherInfo.visibility = Integer.valueOf(hourlyRecord.getString("visibility"));
+// weatherInfo.weatherCode = Integer.valueOf(hourlyRecord.getString("weatherCode"));
+// JSONArray weatherDesc = hourlyRecord.getJSONArray("weatherDesc");
+// JSONArray weatherIconUrl = hourlyRecord.getJSONArray("weatherIconUrl");
+// weatherInfo.weatherDesc = weatherDesc.getJSONObject(0).getString("value");
+// weatherInfo.weatherIconUrl = null;
+// weatherInfo.weatherIconUrlDay = null;
+// weatherInfo.weatherIconUrlNight = null;
+// weatherInfo.weatherIconUrl = weatherIconUrl.getJSONObject(0).getString("value");
+// weatherInfo.winddirDegree = Integer.valueOf(hourlyRecord.getString("winddirDegree"));
+// weatherInfo.windspeedMiles = Integer.valueOf(hourlyRecord.getString("windspeedMiles"));
+// weatherInfo.windspeedKmph = Integer.valueOf(hourlyRecord.getString("windspeedKmph"));
+// weatherInfo.winddir16Point = hourlyRecord.getString("winddir16Point");
+//
+// weather.add(weatherInfo);
+// }
+// }
+// }
return weather;
}
}
diff --git a/fluxtream-web/fluxtream-web.iml b/fluxtream-web/fluxtream-web.iml
index ff9f46c5d..e3c2cf12c 100644
--- a/fluxtream-web/fluxtream-web.iml
+++ b/fluxtream-web/fluxtream-web.iml
@@ -18,11 +18,6 @@
-
-
-
-
-
@@ -41,7 +36,10 @@
+
+
+
@@ -54,10 +52,6 @@
-
-
-
-
diff --git a/fluxtream-web/src/main/java/com/fluxtream/api/CalendarDataStore.java b/fluxtream-web/src/main/java/com/fluxtream/api/CalendarDataStore.java
index c546b2ca8..34c22eac6 100644
--- a/fluxtream-web/src/main/java/com/fluxtream/api/CalendarDataStore.java
+++ b/fluxtream-web/src/main/java/com/fluxtream/api/CalendarDataStore.java
@@ -58,7 +58,6 @@
import com.luckycatlabs.sunrisesunset.SunriseSunsetCalculator;
import com.luckycatlabs.sunrisesunset.dto.Location;
import org.apache.log4j.Logger;
-import org.joda.time.DateTimeConstants;
import org.joda.time.DateTimeZone;
import org.joda.time.LocalDate;
import org.joda.time.format.DateTimeFormat;
@@ -393,6 +392,28 @@ public String getAllConnectorsYearData(@PathParam("year") int year,
}
}
+ @GET
+ @Path("/weather/date/{date}")
+ @Produces({ MediaType.APPLICATION_JSON })
+ public String getWeatherDataForADay(@PathParam("date") String date) {
+
+ Guest guest = AuthHelper.getGuest();
+ long guestId = guest.getId();
+
+ DigestModel digest = new DigestModel();
+ DayMetadataFacet dayMetadata = metadataService.getDayMetadata(guestId, date, true);
+ digest.tbounds = getStartEndResponseBoundaries(dayMetadata.start, dayMetadata.end);
+ digest.timeZoneOffset = TimeZone.getTimeZone(dayMetadata.timeZone).getOffset((digest.tbounds.start + digest.tbounds.end)/2);
+
+ City city = metadataService.getMainCity(guestId, dayMetadata);
+ if (city != null){
+ digest.hourlyWeatherData = metadataService.getWeatherInfo(city.geo_latitude,city.geo_longitude, date, 0, 24 * 60);
+ Collections.sort(digest.hourlyWeatherData);
+ }
+
+ return gson.toJson(digest);
+ }
+
@GET
@Path("/all/date/{date}")
@Produces({ MediaType.APPLICATION_JSON })
@@ -429,11 +450,6 @@ public String getAllConnectorsDayData(@PathParam("date") String date,
City city = metadataService.getMainCity(guestId, dayMetadata);
- if (city != null){
- digest.hourlyWeatherData = metadataService.getWeatherInfo(city.geo_latitude,city.geo_longitude, date, 0, 24 * 60);
- Collections.sort(digest.hourlyWeatherData);
- }
-
setSolarInfo(digest, city, guestId, dayMetadata);
List apiKeySelection = getApiKeySelection(guestId, filter, coachee);
diff --git a/fluxtream-web/src/main/webapp/js/applications/calendar/tabs/clock/ClockTab.js b/fluxtream-web/src/main/webapp/js/applications/calendar/tabs/clock/ClockTab.js
index e113bb675..5ad817113 100644
--- a/fluxtream-web/src/main/webapp/js/applications/calendar/tabs/clock/ClockTab.js
+++ b/fluxtream-web/src/main/webapp/js/applications/calendar/tabs/clock/ClockTab.js
@@ -25,14 +25,24 @@ define(["applications/calendar/tabs/clock/ClockDrawingUtils",
hideEventInfo();
this.getTemplate("text!applications/calendar/tabs/clock/clock.html", "clock", function() {
setup(params.digest, params.timeUnit, params.connectorEnabled);
+ fetchWeatherData();
});
}
+
+ function fetchWeatherData() {
+ $.ajax({ url: "/api/calendar/weather/"+Log.tabState, dataType: "json",
+ success: function(digest) {
+ if (!outsideTimeBoundaries(digest)) {
+ hourlyWeatherData = digest.hourlyWeatherData;
+ }
+ }
+ });
+ }
function setup(digest, timeUnit, cEn) {
dgst = digest;
selectedConnectors = digest.selectedConnectors;
connectorEnabled = cEn;
- hourlyWeatherData = digest.hourlyWeatherData;
solarInfo = digest.solarInfo;
tempratureUnit = digest.settings.temperatureUnit;
distanceUnit = digest.settings.distanceUnit;