Exemple #1
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();
 }
Exemple #2
0
 @Override
 public boolean isCreatedDateDefined() {
   if (sitemapEntity.getCreatedDateProperty() == null) {
     return false;
   }
   return true;
 }
Exemple #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;
  }
Exemple #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;
  }
Exemple #5
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;
  }
Exemple #6
0
 @Override
 public void prepare() {
   Query q = new Query(sitemapEntity.getKind());
   PreparedQuery pq = ds.prepare(q);
   entityIterator = pq.asIterator();
 }
Exemple #7
0
 @Override
 public String getKind() {
   return sitemapEntity.getKind();
 }
Exemple #8
0
 @Override
 public String getRelativeUrl() {
   return sitemapEntity.buildRelativeUrl(
       (String) currentEntity.getProperty(sitemapEntity.getTitleProperty()),
       currentEntity.getKey().getId());
 }
Exemple #9
0
 @Override
 public Date getCreatedDate() {
   return (Date) currentEntity.getProperty(sitemapEntity.getCreatedDateProperty());
 }