@Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null) return false;
   if (getClass() != obj.getClass()) return false;
   Weather other = (Weather) obj;
   if (location == null) {
     if (other.location != null) return false;
   } else if (!location.equals(other.location)) return false;
   if (observationTime == null) {
     if (other.observationTime != null) return false;
   } else if (!observationTime.equals(other.observationTime)) return false;
   if (relativeHumidity == null) {
     if (other.relativeHumidity != null) return false;
   } else if (!relativeHumidity.equals(other.relativeHumidity)) return false;
   if (temperature == null) {
     if (other.temperature != null) return false;
   } else if (!temperature.equals(other.temperature)) return false;
   if (weatherDescription == null) {
     if (other.weatherDescription != null) return false;
   } else if (!weatherDescription.equals(other.weatherDescription)) return false;
   if (windDescription == null) {
     if (other.windDescription != null) return false;
   } else if (!windDescription.equals(other.windDescription)) return false;
   if (windDirection == null) {
     if (other.windDirection != null) return false;
   } else if (!windDirection.equals(other.windDirection)) return false;
   return true;
 }
  /**
   * Contract: get routes from shedule with StationInfo from filter; if in the filter exist date
   * then compare it with the date when train will be on the station for this route
   *
   * @param filter contains StationInfo fow which need SheduleItems info and date when train need on
   *     the station
   * @return SheduleItems that satisfy to conditions
   */
  @Transactional(readOnly = true)
  public List<SheduleItemEntity> searchByStation(SheduleFilter filter) {
    List<SheduleItemEntity> sheduleItemsList = new ArrayList<SheduleItemEntity>();

    List<StationInfoEntity> stationInfoList = new ArrayList<StationInfoEntity>();
    stationInfoList.add(filter.getStationInfo());
    for (SheduleItemEntity sheduleItem : this.sheduleDAO.getByStations(stationInfoList)) {

      StationEntity station = null;
      for (StationEntity stationInRoute : sheduleItem.getRoute().getStationsList()) {
        if (stationInRoute.getStationInfo().equals(filter.getStationInfo())) {
          station = stationInRoute;
        }
      }

      if (station != null) {
        GregorianCalendar dateCondition = null;
        if (filter.getDate() != null) {
          dateCondition = new GregorianCalendar();
          dateCondition.setTime(filter.getDate());
          dateCondition =
              new GregorianCalendar(
                  dateCondition.get(Calendar.YEAR),
                  dateCondition.get(Calendar.MONTH),
                  dateCondition.get(Calendar.DAY_OF_MONTH));
        }

        GregorianCalendar sheduleItemDate = null;
        if (dateCondition != null) {
          sheduleItemDate = new GregorianCalendar();
          sheduleItemDate.setTime(sheduleItem.getDepartureDate());
          sheduleItemDate.add(Calendar.MINUTE, station.getTimeOffset());
          sheduleItemDate =
              new GregorianCalendar(
                  sheduleItemDate.get(Calendar.YEAR),
                  sheduleItemDate.get(Calendar.MONTH),
                  sheduleItemDate.get(Calendar.DAY_OF_MONTH));
        }

        if ((dateCondition != null
                && sheduleItemDate != null
                && dateCondition.equals(sheduleItemDate))
            || dateCondition == null) {
          try {
            SheduleItemEntity cloneSheduleItem = (SheduleItemEntity) sheduleItem.clone();
            cloneSheduleItem.getRoute().getStationsList().clear();
            cloneSheduleItem.getRoute().getStationsList().add(station);
            sheduleItemsList.add(cloneSheduleItem);
          } catch (CloneNotSupportedException exc) {
            exc.printStackTrace();
            LOGGER.warn(exc);
          }
        }
      }
    }

    return sheduleItemsList;
  }
  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Event event = (Event) o;

    if (attenders != null ? !attenders.equals(event.attenders) : event.attenders != null)
      return false;
    if (description != null ? !description.equals(event.description) : event.description != null)
      return false;
    if (endTime != null ? !endTime.equals(event.endTime) : event.endTime != null) return false;
    if (name != null ? !name.equals(event.name) : event.name != null) return false;
    if (startTime != null ? !startTime.equals(event.startTime) : event.startTime != null)
      return false;

    return true;
  }
Beispiel #4
0
 /**
  * This method was created in VisualAge.
  *
  * @return boolean
  * @param g java.util.GregorianCalendar
  */
 private boolean dayHighlighted(GregorianCalendar g) {
   GregorianCalendar g2 = null;
   for (; _nextDay < _dayHighlights.size(); _nextDay++) {
     g2 = (GregorianCalendar) _dayHighlights.elementAt(_nextDay);
     if (g2.equals(g)) return true;
     else if (g2.after(g)) return false;
   }
   return false;
 }
Beispiel #5
0
  /** This method adds a new day to highlight to the calendar. */
  public void addDayHighlight(GregorianCalendar g) {
    int max = _dayHighlights.size();
    GregorianCalendar g2 = null;
    for (int i = 0; i < max; i++) {
      g2 = (GregorianCalendar) _dayHighlights.elementAt(i);
      if (g.equals(g2)) return;
      else if (g2.after(g)) {
        _dayHighlights.insertElementAt(g, i);
        return;
      }
    }

    _dayHighlights.addElement(g);
  }
 private File generarFicheroFaltas(
     GregorianCalendar fechaMin, GregorianCalendar fechaMax, ArrayList<String> cursos)
     throws TransformerConfigurationException, IllegalArgumentException,
         TransformerFactoryConfigurationError, TransformerException {
   setFicherosGenerados(true);
   String contenido = docToString(getDocumento());
   String nombre = "";
   if (fechaMin.equals(fechaMax)) {
     nombre = "Faltas " + Fechas.format(fechaMin, "dd-MM-yyyy");
   } else {
     nombre =
         "Faltas desde "
             + Fechas.format(fechaMin, "dd-MM-yyyy")
             + " hasta "
             + Fechas.format(fechaMax, "dd-MM-yyyy");
   }
   StringBuilder sbCursos = new StringBuilder();
   boolean primero = true;
   for (String c : cursos) {
     if (primero) {
       primero = false;
     } else {
       sbCursos.append("-");
     }
     sbCursos.append(c);
   }
   nombre = nombre + " " + sbCursos.toString();
   sbCursos = null;
   File f = new File(getCarpetaSalida(), nombre + ".xml");
   Archivo.setContenido(contenido, "latin1", f, false);
   contenido = null;
   setDocumento(null);
   trans = null;
   System.gc();
   setFicherosGenerados(true);
   return f;
 }
Beispiel #7
0
 /** toString データベースに含まれる情報を一つの文字列として出力 */
 public String toString() {
   if (mStart.get(Calendar.HOUR_OF_DAY) == 0 && mStart.get(Calendar.MINUTE) == 0) {
     GregorianCalendar startCal = (GregorianCalendar) mStart.clone();
     startCal.add(Calendar.DAY_OF_MONTH, 1);
     if (startCal.equals(mEnd)) {
       // 開始時刻が00:00で終了日時が翌日の00:00の場合
       // 終日の予定と判断して開始日のみ表示する
       return getTitle() + "\n" + getStartDateString() + "\n" + getWhere() + "\n" + getContent();
     }
   }
   return getTitle()
       + "\n"
       + getStartDateString()
       + " "
       + getStartTimeString()
       + "\n"
       + getEndDateString()
       + " "
       + getEndTimeString()
       + "\n"
       + getWhere()
       + "\n"
       + getContent();
 }
Beispiel #8
0
  public static void main(String[] args) throws Throwable {

    int N = 10000;
    long t1970 = new java.util.Date(70, 0, 01).getTime();
    Random r = new Random();
    for (int i = 0; i < N; i++) {
      int days = r.nextInt(50) * 365 + r.nextInt(365);
      long secs = t1970 + days * 86400 + r.nextInt(86400);
      int nanos = r.nextInt(NANOS_PER_SECOND);
      int nanos_ms = nanos / 1000000 * 1000000; // millis precision
      long millis = secs * 1000 + r.nextInt(1000);
      LocalDateTime ldt = LocalDateTime.ofEpochSecond(secs, nanos, ZoneOffset.UTC);
      LocalDateTime ldt_ms = LocalDateTime.ofEpochSecond(secs, nanos_ms, ZoneOffset.UTC);
      Instant inst = Instant.ofEpochSecond(secs, nanos);
      Instant inst_ms = Instant.ofEpochSecond(secs, nanos_ms);
      ///////////// java.util.Date /////////////////////////
      Date jud = new java.util.Date(millis);
      Instant inst0 = jud.toInstant();
      if (jud.getTime() != inst0.toEpochMilli() || !jud.equals(Date.from(inst0))) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: j.u.d -> instant -> j.u.d");
      }
      // roundtrip only with millis precision
      Date jud0 = Date.from(inst_ms);
      if (jud0.getTime() != inst_ms.toEpochMilli() || !inst_ms.equals(jud0.toInstant())) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: instant -> j.u.d -> instant");
      }
      //////////// java.util.GregorianCalendar /////////////
      GregorianCalendar cal = new GregorianCalendar();
      // non-roundtrip of tz name between j.u.tz and j.t.zid
      cal.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
      cal.setGregorianChange(new java.util.Date(Long.MIN_VALUE));
      cal.setFirstDayOfWeek(Calendar.MONDAY);
      cal.setMinimalDaysInFirstWeek(4);
      cal.setTimeInMillis(millis);
      ZonedDateTime zdt0 = cal.toZonedDateTime();
      if (cal.getTimeInMillis() != zdt0.toInstant().toEpochMilli()
          || !cal.equals(GregorianCalendar.from(zdt0))) {
        System.out.println("cal:" + cal);
        System.out.println("zdt:" + zdt0);
        System.out.println("calNew:" + GregorianCalendar.from(zdt0));
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: gcal -> zdt -> gcal");
      }
      inst0 = cal.toInstant();
      if (cal.getTimeInMillis() != inst0.toEpochMilli()) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: gcal -> zdt");
      }
      ZonedDateTime zdt = ZonedDateTime.of(ldt_ms, ZoneId.systemDefault());
      GregorianCalendar cal0 = GregorianCalendar.from(zdt);
      if (zdt.toInstant().toEpochMilli() != cal0.getTimeInMillis()
          || !zdt.equals(GregorianCalendar.from(zdt).toZonedDateTime())) {
        System.out.printf("ms: %16d  ns: %10d  ldt:[%s]%n", millis, nanos, ldt);
        throw new RuntimeException("FAILED: zdt -> gcal -> zdt");
      }
    }

    ///////////// java.util.TimeZone /////////////////////////
    for (String zidStr : TimeZone.getAvailableIDs()) {
      // TBD: tzdt intergration
      if (zidStr.startsWith("SystemV")
          || zidStr.contains("Riyadh8")
          || zidStr.equals("US/Pacific-New")
          || zidStr.equals("EST")
          || zidStr.equals("HST")
          || zidStr.equals("MST")) {
        continue;
      }
      ZoneId zid = ZoneId.of(zidStr, ZoneId.SHORT_IDS);
      if (!zid.equals(TimeZone.getTimeZone(zid).toZoneId())) {
        throw new RuntimeException("FAILED: zid -> tz -> zid :" + zidStr);
      }
      TimeZone tz = TimeZone.getTimeZone(zidStr);
      // no round-trip for alias and "GMT"
      if (!tz.equals(TimeZone.getTimeZone(tz.toZoneId()))
          && !ZoneId.SHORT_IDS.containsKey(zidStr)
          && !zidStr.startsWith("GMT")) {
        throw new RuntimeException("FAILED: tz -> zid -> tz :" + zidStr);
      }
    }
    System.out.println("Passed!");
  }
  @Override
  protected Object doInBackground() throws Exception {
    ReleaseNotifierDialog.ovaReleased.clear();
    ReleaseNotifierDialog.filmReleased.clear();
    String oggi = MAMUtil.today();
    GregorianCalendar today = MAMUtil.getDate(oggi);
    GregorianCalendar lastControlDate = null;
    if (!AnimeIndex.appProp.getProperty("Date_Release").equalsIgnoreCase("none"))
      lastControlDate = MAMUtil.getDate(AnimeIndex.appProp.getProperty("Date_Release"));
    GregorianCalendar animeDate = null;
    Object[] ovaArray = AnimeIndex.ovaModel.toArray();
    for (int i = 0; i < ovaArray.length; i++) {
      String name = (String) ovaArray[i];
      AnimeData data = AnimeIndex.ovaMap.get(name);
      String releaseDate = data.getFinishDate();
      String secondaryReleaseDate = data.getReleaseDate();

      if (releaseDate.contains("?") || today.before(MAMUtil.getDate(releaseDate))) {
        if (!secondaryReleaseDate.contains("?")) animeDate = MAMUtil.getDate(secondaryReleaseDate);
      } else animeDate = MAMUtil.getDate(releaseDate);
      if (animeDate != null) {
        if (AnimeIndex.openReleaseDialog == true)
          if (AnimeIndex.exitDateMap.containsKey(name))
            if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).equals(today))
              if (animeDate.before(today) || animeDate.equals(today)) {
                ReleaseNotifierDialog.ovaReleased.addElement(name);
                if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                  AnimeData newData =
                      new AnimeData(
                          data.getCurrentEpisode(),
                          data.getTotalEpisode(),
                          data.getFansub(),
                          data.getNote(),
                          data.getImageName(),
                          "Rilasciato",
                          data.getId(),
                          data.getLinkName(),
                          data.getLink(),
                          data.getAnimeType(),
                          data.getReleaseDate(),
                          data.getFinishDate(),
                          data.getDurationEp(),
                          data.getBd());
                  AnimeIndex.ovaMap.put(name, newData);
                }
              }

        if (lastControlDate != null) {
          if (animeDate.after(lastControlDate)) {
            if (AnimeIndex.exitDateMap.containsKey(name)) {
              if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).before(animeDate)) {
                if (animeDate.before(today) || animeDate.equals(today)) {
                  ReleaseNotifierDialog.ovaReleased.addElement(name);
                  AnimeIndex.exitDateMap.put(name, oggi);
                  if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                    AnimeData newData =
                        new AnimeData(
                            data.getCurrentEpisode(),
                            data.getTotalEpisode(),
                            data.getFansub(),
                            data.getNote(),
                            data.getImageName(),
                            "Rilasciato",
                            data.getId(),
                            data.getLinkName(),
                            data.getLink(),
                            data.getAnimeType(),
                            data.getReleaseDate(),
                            data.getFinishDate(),
                            data.getDurationEp(),
                            data.getBd());
                    AnimeIndex.ovaMap.put(name, newData);
                  }
                }
              }
            } else if (animeDate.before(today) || animeDate.equals(today)) {
              ReleaseNotifierDialog.ovaReleased.addElement(name);
              AnimeIndex.exitDateMap.put(name, oggi);
              if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                AnimeData newData =
                    new AnimeData(
                        data.getCurrentEpisode(),
                        data.getTotalEpisode(),
                        data.getFansub(),
                        data.getNote(),
                        data.getImageName(),
                        "Rilasciato",
                        data.getId(),
                        data.getLinkName(),
                        data.getLink(),
                        data.getAnimeType(),
                        data.getReleaseDate(),
                        data.getFinishDate(),
                        data.getDurationEp(),
                        data.getBd());
                AnimeIndex.ovaMap.put(name, newData);
              }
            }
          }
        } else if (AnimeIndex.exitDateMap.containsKey(name)) {
          if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).before(animeDate)) {
            if (animeDate.before(today) || animeDate.equals(today)) {
              ReleaseNotifierDialog.ovaReleased.addElement(name);
              AnimeIndex.exitDateMap.put(name, oggi);
              if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                AnimeData newData =
                    new AnimeData(
                        data.getCurrentEpisode(),
                        data.getTotalEpisode(),
                        data.getFansub(),
                        data.getNote(),
                        data.getImageName(),
                        "Rilasciato",
                        data.getId(),
                        data.getLinkName(),
                        data.getLink(),
                        data.getAnimeType(),
                        data.getReleaseDate(),
                        data.getFinishDate(),
                        data.getDurationEp(),
                        data.getBd());
                AnimeIndex.ovaMap.put(name, newData);
              }
            }
          }
        } else if (animeDate.before(today) || animeDate.equals(today)) {
          ReleaseNotifierDialog.ovaReleased.addElement(name);
          AnimeIndex.exitDateMap.put(name, oggi);
          if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
            AnimeData newData =
                new AnimeData(
                    data.getCurrentEpisode(),
                    data.getTotalEpisode(),
                    data.getFansub(),
                    data.getNote(),
                    data.getImageName(),
                    "Rilasciato",
                    data.getId(),
                    data.getLinkName(),
                    data.getLink(),
                    data.getAnimeType(),
                    data.getReleaseDate(),
                    data.getFinishDate(),
                    data.getDurationEp(),
                    data.getBd());
            AnimeIndex.ovaMap.put(name, newData);
          }
        }
      }
    }

    animeDate = null;
    Object[] filmArray = AnimeIndex.filmModel.toArray();
    for (int i = 0; i < filmArray.length; i++) {
      String name = (String) filmArray[i];
      AnimeData data = AnimeIndex.filmMap.get(name);
      String releaseDate = data.getFinishDate();
      String secondaryReleaseDate = data.getReleaseDate();

      if (releaseDate.contains("?") || today.before(MAMUtil.getDate(releaseDate))) {
        if (!secondaryReleaseDate.contains("?")) animeDate = MAMUtil.getDate(secondaryReleaseDate);
      } else animeDate = MAMUtil.getDate(releaseDate);
      if (animeDate != null) {
        if (AnimeIndex.openReleaseDialog == true)
          if (AnimeIndex.exitDateMap.containsKey(name))
            if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).equals(today))
              if (animeDate.before(today) || animeDate.equals(today)) {
                ReleaseNotifierDialog.filmReleased.addElement(name);
                if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                  AnimeData newData =
                      new AnimeData(
                          data.getCurrentEpisode(),
                          data.getTotalEpisode(),
                          data.getFansub(),
                          data.getNote(),
                          data.getImageName(),
                          "Rilasciato",
                          data.getId(),
                          data.getLinkName(),
                          data.getLink(),
                          data.getAnimeType(),
                          data.getReleaseDate(),
                          data.getFinishDate(),
                          data.getDurationEp(),
                          data.getBd());
                  AnimeIndex.filmMap.put(name, newData);
                }
              }

        if (lastControlDate != null) {
          if (animeDate.after(lastControlDate)) {
            if (AnimeIndex.exitDateMap.containsKey(name)) {
              if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).before(animeDate)) {
                if (animeDate.before(today) || animeDate.equals(today)) {
                  ReleaseNotifierDialog.filmReleased.addElement(name);
                  AnimeIndex.exitDateMap.put(name, oggi);
                  if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                    AnimeData newData =
                        new AnimeData(
                            data.getCurrentEpisode(),
                            data.getTotalEpisode(),
                            data.getFansub(),
                            data.getNote(),
                            data.getImageName(),
                            "Rilasciato",
                            data.getId(),
                            data.getLinkName(),
                            data.getLink(),
                            data.getAnimeType(),
                            data.getReleaseDate(),
                            data.getFinishDate(),
                            data.getDurationEp(),
                            data.getBd());
                    AnimeIndex.filmMap.put(name, newData);
                  }
                }
              }
            } else if (animeDate.before(today) || animeDate.equals(today)) {
              ReleaseNotifierDialog.filmReleased.addElement(name);
              AnimeIndex.exitDateMap.put(name, oggi);
              if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                AnimeData newData =
                    new AnimeData(
                        data.getCurrentEpisode(),
                        data.getTotalEpisode(),
                        data.getFansub(),
                        data.getNote(),
                        data.getImageName(),
                        "Rilasciato",
                        data.getId(),
                        data.getLinkName(),
                        data.getLink(),
                        data.getAnimeType(),
                        data.getReleaseDate(),
                        data.getFinishDate(),
                        data.getDurationEp(),
                        data.getBd());
                AnimeIndex.filmMap.put(name, newData);
              }
            }
          }
        } else if (AnimeIndex.exitDateMap.containsKey(name)) {
          if (MAMUtil.getDate(AnimeIndex.exitDateMap.get(name)).before(animeDate)) {
            if (animeDate.before(today) || animeDate.equals(today)) {
              ReleaseNotifierDialog.filmReleased.addElement(name);
              AnimeIndex.exitDateMap.put(name, oggi);
              if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
                AnimeData newData =
                    new AnimeData(
                        data.getCurrentEpisode(),
                        data.getTotalEpisode(),
                        data.getFansub(),
                        data.getNote(),
                        data.getImageName(),
                        "Rilasciato",
                        data.getId(),
                        data.getLinkName(),
                        data.getLink(),
                        data.getAnimeType(),
                        data.getReleaseDate(),
                        data.getFinishDate(),
                        data.getDurationEp(),
                        data.getBd());
                AnimeIndex.filmMap.put(name, newData);
              }
            }
          }
        } else if (animeDate.before(today) || animeDate.equals(today)) {
          ReleaseNotifierDialog.filmReleased.addElement(name);
          AnimeIndex.exitDateMap.put(name, oggi);
          if (!data.getDay().equalsIgnoreCase("Rilasciato")) {
            AnimeData newData =
                new AnimeData(
                    data.getCurrentEpisode(),
                    data.getTotalEpisode(),
                    data.getFansub(),
                    data.getNote(),
                    data.getImageName(),
                    "Rilasciato",
                    data.getId(),
                    data.getLinkName(),
                    data.getLink(),
                    data.getAnimeType(),
                    data.getReleaseDate(),
                    data.getFinishDate(),
                    data.getDurationEp(),
                    data.getBd());
            AnimeIndex.filmMap.put(name, newData);
          }
        }
      }
    }
    if (ReleaseNotifierDialog.ovaReleased.isEmpty()) {
      ReleaseNotifierDialog.ovaReleased.addElement("Nessun Anime Rilasciato");
      enableOav = false;
    } else enableOav = true;
    if (ReleaseNotifierDialog.filmReleased.isEmpty()) {
      ReleaseNotifierDialog.filmReleased.addElement("Nessun Anime Rilasciato");
      enableFilm = false;
    } else enableFilm = true;
    return null;
  }