Ejemplo n.º 1
0
  @Override
  public List<Integer> years() {
    List<Integer> years = new ArrayList<Integer>();

    Query q = new Query(sitemapEntity.getKind());
    q.addSort(sitemapEntity.getCreatedDateProperty(), SortDirection.ASCENDING);
    List<Entity> e = ds.prepare(q).asList(FetchOptions.Builder.withLimit(1));
    int start;
    if (e.size() == 1) {
      start =
          DateUtils.getYear((Date) e.get(0).getProperty(sitemapEntity.getCreatedDateProperty()));
    } else {
      return years;
    }

    q = new Query(sitemapEntity.getKind());
    q.addSort(sitemapEntity.getCreatedDateProperty(), SortDirection.DESCENDING);
    e = ds.prepare(q).asList(FetchOptions.Builder.withLimit(1));

    int end =
        DateUtils.getYear((Date) e.get(0).getProperty(sitemapEntity.getCreatedDateProperty()));

    for (int i = start; i <= end; i++) {
      years.add(i);
    }
    return years;
  }
Ejemplo n.º 2
0
 @Override
 public void prepare(int year, int month, int day) {
   Query q = new Query(sitemapEntity.getKind());
   addBetweenFilter(
       q,
       sitemapEntity.getCreatedDateProperty(),
       DateUtils.getBeginningOfDay(year, month, day),
       DateUtils.getEndOfDay(year, month, day));
   PreparedQuery pq = ds.prepare(q);
   entityIterator = pq.asIterator();
 }
Ejemplo n.º 3
0
  @Override
  public List<Integer> months(int year) {
    List<Integer> months = new ArrayList<Integer>();

    for (int i = 1; i <= 12; i++) {
      Query q = new Query(sitemapEntity.getKind());
      addBetweenFilter(
          q,
          sitemapEntity.getCreatedDateProperty(),
          DateUtils.getBeginningOfMonth(year, i),
          DateUtils.getEndOfMonth(year, i));
      List<Entity> e = ds.prepare(q).asList(FetchOptions.Builder.withLimit(1));
      if (e.size() == 1) {
        months.add(Integer.valueOf(i));
      }
    }

    return months;
  }
Ejemplo n.º 4
0
  @Override
  public List<Integer> days(int year, int month) {
    List<Integer> days = new ArrayList<Integer>();

    for (int i = 1; i <= DateUtils.getLastDayOf(year, month); i++) {
      Query q = new Query(sitemapEntity.getKind());
      addBetweenFilter(
          q,
          sitemapEntity.getCreatedDateProperty(),
          DateUtils.getBeginningOfDay(year, month, i),
          DateUtils.getEndOfDay(year, month, i));
      PreparedQuery pq = ds.prepare(q);
      List<Entity> e = pq.asList(FetchOptions.Builder.withLimit(1));
      if (e.size() == 1) {
        days.add(Integer.valueOf(i));
      }
    }

    return days;
  }
Ejemplo n.º 5
0
 @Override
 public void prepare() {
   Query q = new Query(sitemapEntity.getKind());
   PreparedQuery pq = ds.prepare(q);
   entityIterator = pq.asIterator();
 }
Ejemplo n.º 6
0
 @Override
 public String getKind() {
   return sitemapEntity.getKind();
 }