@Before
 public void setUp() {
   aggregator_0 =
       new UserActivityAggregatorImpl(
           Arrays.asList(UserProfileConstants.DEFAULT_CMD_TYPES), Period.parse("PT1m"), "test", 0);
   aggregator_1 =
       new UserActivityAggregatorImpl(
           Arrays.asList(UserProfileConstants.DEFAULT_CMD_TYPES),
           Period.parse("PT1m"),
           "test",
           5000);
 }
 private void checkAgainstTimespanRestriction(String timespan) {
   Duration duration = Period.parse(requestIntervalRestriction).toDurationFrom(new DateTime());
   if (duration.getMillis() < Interval.parse(timespan).toDurationMillis()) {
     throw new BadRequestException(
         "Requested timespan is to long, please use a period shorter than '"
             + requestIntervalRestriction
             + "'");
   }
 }
Esempio n. 3
0
  public Timer(Element timer) {
    this();

    setTitle(timer.getChildTextNormalize("title"));
    String started = timer.getChildTextNormalize("started");
    this.started = started.isEmpty() ? null : DateTime.parse(started);
    if (this.started != null) {
      this.timer.start();
    }
    period = Period.parse(timer.getChildTextNormalize("total"));

    update_speed = Integer.parseInt(timer.getChildTextNormalize("speed"), 10);
    this.timer.setDelay(update_speed);
    if (this.started != null) {
      this.timer.start();
    }

    setLocation(
        Integer.parseInt(timer.getChildTextNormalize("x"), 10),
        Integer.parseInt(timer.getChildTextNormalize("y"), 10));
    setSize(
        Integer.parseInt(timer.getChildTextNormalize("width"), 10),
        Integer.parseInt(timer.getChildTextNormalize("height"), 10));

    Color foreground =
        new Color((int) Long.parseLong(timer.getChildTextNormalize("foreground"), 16), true);
    total.setForeground(foreground);
    time.setForeground(foreground);
    Color background =
        new Color((int) Long.parseLong(timer.getChildTextNormalize("background"), 16), true);
    panel.setBackground(background);

    Element times = timer.getChild("times");
    for (Element ts : times.getChildren()) {
      this.times.add(new TimeSpan(ts));
    }

    updateTimes();
    setVisible(Boolean.parseBoolean(timer.getChildText("visible")));
  }
Esempio n. 4
0
 private static Object parseDateOrPeriod(Class<?> toClass, String str) {
   if (DateTime.class.isAssignableFrom(toClass)) {
     return DTF.parseDateTime(str);
   } else if (Date.class.isAssignableFrom(toClass)) {
     return DTF.parseDateTime(str).toDate();
   } else if (Period.class.isAssignableFrom(toClass)) {
     return Period.parse(str);
   } else if (LocalDate.class.isAssignableFrom(toClass)) {
     String val = str;
     int tIndex = str.indexOf('T');
     if (tIndex >= 0) {
       val = str.substring(0, tIndex);
     }
     return LocalDate.parse(val);
   } else if (java.time.LocalDate.class.isAssignableFrom(toClass)) {
     return java.time.LocalDate.parse(str);
   } else if (java.time.LocalDateTime.class.isAssignableFrom(toClass)) {
     return str.contains("T") ? parseJavaLocalDateTimeBackend(str) : parseJavaLocalDateTimeUI(str);
   } else {
     return null;
   }
 }
 public void setRequestIntervalRestriction(String requestIntervalRestriction) {
   // validate requestIntervalRestriction, if it's no period an exception occured
   Period.parse(requestIntervalRestriction);
   this.requestIntervalRestriction = requestIntervalRestriction;
 }