コード例 #1
0
 @SuppressWarnings("unchecked")
 public List<T> getSelectedTrainings(final List<?> objects) {
   final List<T> trainings = new ArrayList<>();
   for (final Object obj : objects) {
     if (obj instanceof Integer) {
       final DateTime von = new DateTime((int) obj, 1, 1, 0, 0);
       final DateTime bis = new DateTime((int) obj, 12, 31, 23, 59);
       if (type.isAssignableFrom(ITraining.class)) {
         trainings.addAll(
             (Collection<? extends T>)
                 databaseAccess.getTrainingsByAthleteAndDate(athlete, von, bis));
       }
     }
     if (obj instanceof INavigationParent) {
       final INavigationParent parent = (INavigationParent) obj;
       final List<INavigationItem> childs = parent.getChilds();
       for (final INavigationItem child : childs) {
         if (type.isAssignableFrom(child.getClass())) {
           trainings.add(((T) child));
         }
       }
     }
     if (type.isAssignableFrom(obj.getClass())) {
       trainings.add((T) obj);
     }
   }
   return trainings;
 }
コード例 #2
0
 @Override
 public INavigationItem getImportedItem(final Date date) {
   final KalenderWoche kw = new KalenderWoche(date);
   final Map<Integer, INavigationParent> jahresWerte = map.get(kw.getJahr());
   if (jahresWerte != null) {
     final INavigationParent naviParent = jahresWerte.get(kw.getKw());
     for (final INavigationItem item : naviParent.getChilds()) {
       if (item instanceof ConcreteImported && item.getDate().compareTo(date) == 0) {
         return item;
       }
     }
   }
   return null;
 }
コード例 #3
0
  @Override
  public void removeItem(final INavigationItem item) {
    final Date date = item.getDate();
    final KalenderWoche kw = new KalenderWoche(date);

    if (map.containsKey(kw.getJahr())) {
      final Map<Integer, INavigationParent> jahr = map.get(kw.getJahr());
      if (jahr.containsKey(kw.getKw())) {
        final INavigationParent week = jahr.get(kw.getKw());
        week.remove(item);
        if (week.getChilds().isEmpty()) {
          jahr.remove(kw.getKw());
        }
        if (jahr.values().isEmpty()) {
          map.remove(kw.getJahr());
        }
      }
    }
  }
コード例 #4
0
  @Override
  public void addItem(final INavigationItem item) {
    final Date date = item.getDate();
    final KalenderWoche kw = new KalenderWoche(date);

    if (!map.containsKey(kw.getJahr())) {
      map.put(
          kw.getJahr(),
          new TreeMap<Integer, INavigationParent>(
              new Comparator<Integer>() {

                @Override
                public int compare(final Integer o1, final Integer o2) {
                  return o2.compareTo(o1);
                }
              }));
    }
    final Map<Integer, INavigationParent> jahr = map.get(kw.getJahr());
    if (!jahr.containsKey(kw.getKw())) {
      jahr.put(kw.getKw(), new NavigationParent());
    }
    jahr.get(kw.getKw()).add(item);
  }