Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Gitter chat badge to README.md #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Read me First
-------------

[![Gitter](https://badges.gitter.im/Join Chat.svg)](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.
Expand Down
5 changes: 1 addition & 4 deletions fluxtream-connectors/fluxtream-connectors.iml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="fluxtream-core" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.4" level="project" />
Expand Down
5 changes: 1 addition & 4 deletions fluxtream-core/fluxtream-core.iml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -44,52 +36,52 @@ public void setWeatherInfo(DayMetadataFacet info,
}

public List<WeatherInfo> 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<WeatherInfo> weather = new ArrayList<WeatherInfo>();
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<WeatherInfo> weather = new ArrayList<WeatherInfo>();
// 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;
}
}
12 changes: 3 additions & 9 deletions fluxtream-web/fluxtream-web.iml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
<webroots>
<root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
</webroots>
<sourceRoots>
<root url="file://$MODULE_DIR$/target/generated-sources/annotations" />
<root url="file://$MODULE_DIR$/src/main/java" />
<root url="file://$MODULE_DIR$/src/main/resources" />
</sourceRoots>
</configuration>
</facet>
<facet type="javaeeApplication" name="javaEEApplication">
Expand All @@ -41,7 +36,10 @@
<sourceFolder url="file://$MODULE_DIR$/target/generated-test-sources/test-annotations" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target/ROOT" />
<excludeFolder url="file://$MODULE_DIR$/target/classes" />
<excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
Expand All @@ -54,10 +52,6 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: javax.activation:activation:1.0.2" level="project" />
<orderEntry type="library" name="Maven: com.luckycatlabs.sotoo:SunriseSunsetCalculator:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.newrelic:newrelic-api:2.7.0" level="project" />
<orderEntry type="module" module-name="fluxtream-core" />
<orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.8" level="project" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 })
Expand Down Expand Up @@ -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<ApiKey> apiKeySelection = getApiKeySelection(guestId, filter, coachee);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down