Skip to content

Commit

Permalink
added weekly forecasting
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhampgonsalves committed Dec 14, 2011
1 parent 03c4ab1 commit 02572cd
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 213 deletions.
42 changes: 0 additions & 42 deletions src/com/hourlyweather/web/ForecastSymbolUtil.java

This file was deleted.

38 changes: 0 additions & 38 deletions src/com/hourlyweather/web/HourlyWeatherByCity.java

This file was deleted.

11 changes: 10 additions & 1 deletion src/com/hourlyweather/web/HourlyWeatherByCityForward.java
Expand Up @@ -20,8 +20,17 @@ protected void doGet(HttpServletRequest request,
city = city.replaceAll("%20", " ");
request.setAttribute("city", city);

Location location = CityLocationUtil.getLocation(city);

if (location == null)
throw new LocationException(city + " wasn't found.");

request.setAttribute("lat", location.getLat());
request.setAttribute("lon", location.getLon());
request.setAttribute("timeOffset", location.getTimeZone());

RequestDispatcher dispatcher = getServletContext()
.getRequestDispatcher("/hourlyWeatherByCity.jsp");
.getRequestDispatcher("/");
dispatcher.forward(request, response);
}
}
4 changes: 2 additions & 2 deletions src/com/hourlyweather/web/HourlyWeatherByLocationServlet.java
Expand Up @@ -36,9 +36,9 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
return;
}

// get the forecast
// get the forecast for a full week
HourlyForecast forecast = new HourlyForecast(lat,
lon, new DateTime(), 36, timezoneOffset);
lon, new DateTime(), 168, timezoneOffset);

// get the forecast
ForecastFetcher.getHourlyForecast(forecast);
Expand Down
2 changes: 2 additions & 0 deletions src/com/hourlyweather/web/LocationException.java
Expand Up @@ -4,4 +4,6 @@

public class LocationException extends ServletException {
private static final long serialVersionUID = 1L;

public LocationException(String msg) {super(msg);}
}
17 changes: 9 additions & 8 deletions war/WEB-INF/web.xml
Expand Up @@ -4,23 +4,24 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<servlet>
<servlet-name>HourlyWeatherByCity</servlet-name>
<servlet-class>com.hourlyweather.web.HourlyWeatherByCityForward</servlet-class>
</servlet>
<servlet>
<servlet-name>HourlyWeatherByLocation</servlet-name>
<servlet-class>com.hourlyweather.web.HourlyWeatherByLocationServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>HourlyWeatherByCity</servlet-name>
<servlet-class>com.hourlyweather.web.HourlyWeatherByCityForward</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>HourlyWeatherByLocation</servlet-name>
<url-pattern>/HourlyWeatherByLocation</url-pattern>
<servlet-name>HourlyWeatherByCity</servlet-name>
<url-pattern>/forecast/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>HourlyWeatherByCity</servlet-name>
<url-pattern>/city/*</url-pattern>
<servlet-name>HourlyWeatherByLocation</servlet-name>
<url-pattern>/HourlyWeatherByLocation</url-pattern>
</servlet-mapping>

<welcome-file-list>
Expand Down
51 changes: 0 additions & 51 deletions war/hourlyWeatherByCity.jsp

This file was deleted.

0 comments on commit 02572cd

Please sign in to comment.