Package nl.topicus.onderwijs.dashboard.datatypes

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


        return random.nextInt(1000);
      }

      private WeatherReport createRandomWeather() {
        Random random = new Random();
        WeatherReport ret = new WeatherReport();
        ret.setMaxTemperature(Math.round(random.nextDouble() * 500.0 - 150.0) / 10.0);
        ret.setMinTemperature(Math.round(ret.getMaxTemperature() * 10.0
            - random.nextDouble() * 100.0) / 10.0);
        ret.setRainfallProbability(random.nextInt(100));
        ret.setType(WeatherType.values()[random.nextInt(WeatherType
            .values().length)]);
        ret.setWindDirection(random.nextInt(360));
        ret.setWindSpeed(Math.round(random.nextDouble() * 1000.0) / 10.0);
        double lat = 52.25;
        double lon = 6.2;
        ret.setSunrise(WetterComService.getSunrize(lat, lon));
        ret.setSunset(WetterComService.getSunset(lat, lon));

        return ret;
      }

      private BuienRadar createRandomBuien() {
        Random random = new Random();
        BuienRadar ret = new BuienRadar();

        Integer[] rainForecast = new Integer[12];
        for (int i = 0; i < rainForecast.length; i++) {
          rainForecast[i] = 500 * random.nextInt(2);
        }
        ret.setRainForecast(rainForecast);

        return ret;
      }

      private List<Train> createRandomTrains() {
        Random random = new Random();
        List<Train> ret = new ArrayList<Train>();
        for (int count = 0; count < 10; count++) {
          Train train = new Train();
          train.setType(TrainType.values()[random.nextInt(TrainType
              .values().length)]);
          train.setDestination("random random random centraal");
          int minute = random.nextInt(60);
          train.setDepartureTime(random.nextInt(24) + ":"
              + (minute < 10 ? "0" : "") + minute);
          train.setDelay(random.nextInt(10));
          train.setPlatform(Integer.toString(random.nextInt(10)));
          ret.add(train);
        }
        Collections.sort(ret, new Comparator<Train>() {
          @Override
          public int compare(Train o1, Train o2) {
            return o1.getKey().compareTo(o2.getKey());
          }
        });
        return ret;
      }

      private List<Alert> createRandomAlerts(Key key) {
        if (!(key instanceof Project))
          return null;

        Random random = new Random();
        List<Alert> ret = new ArrayList<Alert>();
        for (int count = 0; count < random.nextInt(3); count++) {
          Alert alert = new Alert();
          alert.setProject(key);
          alert.setOverlayVisible(false);
          alert.setColor(DotColor.values()[random.nextInt(3)]);
          int minute = random.nextInt(60);
          alert.setTime(random.nextInt(24) + ":"
              + (minute < 10 ? "0" : "") + minute);
          alert.setMessage("random exception with long message");
          ret.add(alert);
        }
        Collections.sort(ret, new Comparator<Alert>() {
          @Override
          public int compare(Alert o1, Alert o2) {
            return o1.getKey().compareTo(o2.getKey());
          }
        });
        return ret;
      }

      private List<Commit> createRandomCommits(Key key) {
        Random random = new Random();
        List<Commit> ret = new ArrayList<Commit>();
        for (int count = 0; count < 5; count++) {
          Commit commit = new Commit();
          commit.setProject(key);
          long rev = Math.abs(random.nextLong());
          if (rev < HEX_10_DIGITS)
            rev += HEX_10_DIGITS + 1;
          commit.setRevision(Long.toString(rev, 16).substring(0, 8));
          commit.setDateTime(new Date(System.currentTimeMillis()
              - random.nextInt(3600000)));
          commit.setMessage("random commit with long message");
          commit.setAuthor("random");
          ret.add(commit);
        }
        return ret;
      }

      private List<Issue> createRandomIssues(Key key) {
        Random random = new Random();
        List<Issue> ret = new ArrayList<Issue>();
        for (int count = 0; count < 5; count++) {
          Issue issue = new Issue();
          issue.setProject(key);
          issue.setId(random.nextInt(100000));
          issue.setDateTime(new Date(System.currentTimeMillis()
              - random.nextInt(3600000)));
          issue.setSummary("random issue with long message");
          issue.setStatus(IssueStatus.NEW);
          issue.setSeverity(IssueSeverity.values()[random
              .nextInt(IssueSeverity.values().length)]);
          issue.setPriority(IssuePriority.values()[random
              .nextInt(IssuePriority.values().length)]);
          ret.add(issue);
        }
        return ret;
      }

      private synchronized List<Event> createRandomEvents(Key key) {

        List<Event> ret = eventCache.get(key);
        if (ret != null)
          return ret;

        Random random = new Random();
        ret = new ArrayList<Event>();
        for (int count = 0; count < 2; count++) {
          Event event = new Event();
          event.setKey(key);
          event.setTitle("random");
          Calendar cal = Calendar.getInstance();
          cal.add(Calendar.DAY_OF_YEAR, random.nextInt(30));
          event.setDateTime(cal.getTime());
          event.setMajor(random.nextInt(5) == 0);
          if (event.isMajor())
            event.getTags().add("#major");
          event.setColor(Integer.toHexString(random
              .nextInt(256 * 256 * 256)));
          while (event.getColor().length() < 0)
            event.setColor("0" + event.getColor());
          event.setColor("#" + event.getColor());
          ret.add(event);
        }
        Collections.sort(ret, new Comparator<Event>() {
          @Override
          public int compare(Event o1, Event o2) {
            return o1.getDateTime().compareTo(o2.getDateTime());
          }
        });
        eventCache.put(key, ret);
        return ret;
      }

      private List<TwitterStatus> createRandomTweets(Key key) {
        Random random = new Random();
        List<TwitterStatus> ret = new ArrayList<TwitterStatus>();
        for (int count = 0; count < 10; count++) {
          TwitterStatus status = new TwitterStatus(key);
          status.setDate(new Date(System.currentTimeMillis()
              - random.nextInt(24 * 3600 * 1000)));
          status.setTags(Collections.<String> emptyList());
          status.setUser("random");
          status.setText("random tweet at " + count);
          ret.add(status);
        }
        return ret;
      }
    };
    return (T) Proxy.newProxyInstance(getClass().getClassLoader(),
View Full Code Here

TOP

Related Classes of nl.topicus.onderwijs.dashboard.datatypes.WeatherReport

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.