Package com.openhouseautomation.model

Examples of com.openhouseautomation.model.Forecast


      XPathExpression exprmin =
          xpath.compile("/dwml/data/parameters/temperature[@type='minimum']/value[1]");
      String minimum = (String) exprmin.evaluate(doc, XPathConstants.STRING);
      // update datastore
      Forecast forecast = ofy().load().type(Forecast.class).id(zipcode).now();
      if (forecast == null) {
          forecast = new Forecast();
          forecast.setZipCode(zipcode);
      }
      forecast.setForecastLow(minimum);

      XPathExpression exprmax =
          xpath.compile("/dwml/data/parameters/temperature[@type='maximum']/value[1]");
      String maximum = (String) exprmax.evaluate(doc, XPathConstants.STRING);
      forecast.setForecastHigh(maximum);
     
      XPathExpression exprpop =
          xpath.compile("/dwml/data/parameters/probability-of-precipitation[@type='12 hour']/value[1]");
      String pop = (String) exprpop.evaluate(doc, XPathConstants.STRING);
      forecast.setForecastPop(pop);
      forecast.setLastUpdate(new Date());
     
      log.log(Level.INFO, "forecast cron took " + (System.currentTimeMillis() - curtime) + "ms");
      ofy().save().entity(forecast).now();
      out.println(forecast);
    } catch (Exception e) {
View Full Code Here


      String zipcode = request.getParameter("k");
      if (zipcode == null || "".equals(zipcode)) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Missing zipcode (k=?)");
        return;
      }
      Forecast forecast = ofy().load().type(Forecast.class).id(zipcode).now();
      if (forecast == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND,
            "I don't have information for that zip code");
        return;
      }
      String param = request.getParameter("v");
      if (null == param || "".equals(param)) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Use a param: {high,low,pop,all}");
        return;
      }
      if ("forecasthigh".equals(param)) {
        out.println(forecast.getForecastHigh());
      }
      if ("forecastlow".equals(param)) {
        out.println(forecast.getForecastLow());
      }
      if ("forecastpop".equals(param)) {
        out.println(forecast.getForecastPop());
      }
      if ("forecastall".equals(param)) {
        out.println("high=" + forecast.getForecastHigh());
        out.println("low=" + forecast.getForecastLow());
        out.println("pop=" + forecast.getForecastPop());
        out.println("last update=" + forecast.getLastUpdate().getTime() / 1000);
        out.println("last update(human)=" + forecast.getLastUpdate());
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.openhouseautomation.model.Forecast

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.