Examples of WeatherReport


Examples of nl.topicus.onderwijs.dashboard.datatypes.WeatherReport

        is.setCharacterStream(new StringReader(response
            .getPageContent()));

        Document doc = db.parse(is);
        Element time = findTime(doc);
        WeatherReport report = new WeatherReport();
        report.setType(WeatherType.findType(Integer
            .parseInt(getTextForElement(time, "w"))));
        report.setRainfallProbability(Integer
            .parseInt(getTextForElement(time, "pc")));
        report.setMinTemperature(Double.parseDouble(getTextForElement(
            time, "tn")));
        report.setMaxTemperature(Double.parseDouble(getTextForElement(
            time, "tx")));
        report.setWindDirection(Integer.parseInt(getTextForElement(
            time, "wd")));
        report.setWindSpeed(Double.parseDouble(getTextForElement(time,
            "ws")));
        report.setSunrise(getSunrize(latitude, longitude));
        report.setSunset(getSunset(latitude, longitude));

        reports.put(curSettingEntry.getKey(), report);
      }
    } catch (Exception e) {
      log.error("Unable to refresh data from wetter.com: {} {}", e
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  private HiveSessionFactoryImpl hiveSessionFactory;

  @Test
  public void shouldSaveEntities() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = new ErrorCorrectingDataAccessObject<WeatherReport, Integer>(WeatherReport.class, getEntityHiveConfig().getEntityConfig(WeatherReport.class),getHive(), getSessionFactory());
    WeatherReport original = WeatherReportImpl.generate();
    dao.save(original);
    WeatherReport fetched = dao.get(original.getReportId());
    assertEquals(original, fetched);
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  }

  @Test
  public void shouldSaveAndReIndexIfAnEntityExistsOnTheDataNodeButNotTheDirectory() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = new ErrorCorrectingDataAccessObject<WeatherReport, Integer>(WeatherReport.class, getEntityHiveConfig().getEntityConfig(WeatherReport.class),getHive(), getSessionFactory());
    WeatherReport report = getPersistentInstance(dao);
    hive.directory().deleteResourceId("WeatherReport", report.getReportId());
    assertFalse(hive.directory().getNodeIdsOfResourceId("WeatherReport", report.getReportId()).size() > 0);
    report.setRegionCode(87654);
    dao.save(report);
    assertTrue(hive.directory().getNodeIdsOfResourceId("WeatherReport", report.getReportId()).size() > 0);
    WeatherReport thawed = dao.get(report.getReportId());
    assertEquals(report, thawed);
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  }

  @Test
  public void shouldSaveEntitiesWhenThePartitionKeyChanges() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = new ErrorCorrectingDataAccessObject<WeatherReport, Integer>(WeatherReport.class, getEntityHiveConfig().getEntityConfig(WeatherReport.class),getHive(), getSessionFactory());
    WeatherReport report = getPersistentInstance(dao);
    String oldContinent = report.getContinent();
    String newContinent = report.getContinent().equals("Asia") ? "Australia" : "Asia";
    report.setContinent(newContinent);
    dao.save(report);
    Session oldNodeSession = null;
    Session newNodeSession = null;

    try {
      oldNodeSession = hiveSessionFactory.openSession(oldContinent);
      newNodeSession = hiveSessionFactory.openSession(newContinent);
      if(!hive.directory().getNodeIdsOfPrimaryIndexKey(oldContinent).equals(hive.directory().getNodeIdsOfPrimaryIndexKey(newContinent)))
        assertNull(oldNodeSession.get(WeatherReport.class, report.getReportId()));
      WeatherReport fetched = (WeatherReport) newNodeSession.get(WeatherReport.class, report.getReportId());
      assertNotNull(fetched);
      assertEquals(newContinent, fetched.getContinent());
    } finally {
      if(oldNodeSession != null)
        oldNodeSession.close();
      if(newNodeSession != null)
        newNodeSession.close();
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  }

  @Test
  public void shouldDeleteRecords() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = new ErrorCorrectingDataAccessObject<WeatherReport, Integer>(WeatherReport.class, getEntityHiveConfig().getEntityConfig(WeatherReport.class),getHive(), getSessionFactory());
    WeatherReport report = getPersistentInstance(dao);
    assertTrue(dao.exists(report.getReportId()));
    dao.delete(report.getReportId());
    assertFalse(dao.exists(report.getReportId()));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

 
  @Test
  public void testOpenSessionByPrimaryKey() throws Exception {
    HiveSessionFactoryBuilderImpl factoryBuilder = getHiveSessionFactoryBuilder();
   
    final WeatherReport report = newInstance();
   
    save(factoryBuilder, report);
    assertNotNull(factoryBuilder.getSessionFactory());
    factoryBuilder.openSession(config.getEntityConfig(getGeneratedClass(WeatherReport.class)).getPrimaryIndexKey(report));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  @Test
  public void testOpenSessionByResourceId() throws Exception {
    HiveSessionFactoryBuilderImpl factoryBuilder = getHiveSessionFactoryBuilder();
    assertNotNull(factoryBuilder.getSessionFactory());
   
    final WeatherReport report = newInstance();
    save(factoryBuilder, report);
   
    factoryBuilder.openSession("WeatherReport", config.getEntityConfig(getGeneratedClass(WeatherReport.class)).getId(report));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

 
  @Test
  public void testOpenSessionBySecondaryIndex() throws Exception {
    HiveSessionFactoryBuilderImpl factoryBuilder = getHiveSessionFactoryBuilder();

    final WeatherReport report = newInstance();
    save(factoryBuilder, report);
   
    factoryBuilder.openSession("WeatherReport", "weatherEventEventId", Atom.getFirstOrThrow(report.getWeatherEvents()).getEventId());
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  }
 
  @Test
  public void testInsert() throws Exception {
    HiveSessionFactoryBuilderImpl factoryBuilder = getHiveSessionFactoryBuilder();
    final WeatherReport report = newInstance();
    for (Node node : getHive().getNodes()) {
      if (! Schemas.tableExists("WEATHER_REPORT", node.getUri())) {
        throw new RuntimeException("Can't find WEATHER_REPORT table on node " + node.getUri());
      }
    }
    save(factoryBuilder, report);
    Hive hive = getHive();
    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));   
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  }

  @Test
  public void shouldNotThrowAnExceptionWhenDeletingNonExistentRecords() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = new ErrorCorrectingDataAccessObject<WeatherReport, Integer>(WeatherReport.class, getEntityHiveConfig().getEntityConfig(WeatherReport.class),getHive(), getSessionFactory());
    WeatherReport report = WeatherReportImpl.generate();
    assertFalse(dao.exists(report.getReportId()));
    dao.delete(report.getReportId());
    assertFalse(dao.exists(report.getReportId()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.