コード例 #1
0
  public void updateSolrRepository() {
    System.out.println("scheduled task");
    if (taskEntryRepository.count() != 0) {
      System.out.println(latestUpdate);
      List<OrganizerSuperClass> tasks = OrganizerDAO.getRecentTasks(latestUpdate);
      System.out.print("new tasks: " + tasks.size() + " ");
      List<OrganizerSuperClass> items = OrganizerDAO.getRecentItems(latestUpdate);
      System.out.print("new items:" + items.size() + " ");
      List<OrganizerSuperClass> comments = OrganizerDAO.getRecentComments(latestUpdate);
      System.out.println("new comments:" + comments.size());

      for (OrganizerSuperClass task : tasks) {
        task.setType("task");
        convertObjectToEntry(task);
        setLatestUpdate(task.getDate_modified());
      }
      for (OrganizerSuperClass item : items) {
        item.setType("taskItem");
        convertObjectToEntry(item);
        setLatestUpdate(item.getDate_modified());
      }
      for (OrganizerSuperClass comment : comments) {
        comment.setType("comment");
        convertObjectToEntry(comment);
        setLatestUpdate(comment.getDate_created());
      }
    }
  }
コード例 #2
0
  private void loadSampleData() {
    if (taskEntryRepository.count() == 0) {

      System.out.println(latestUpdate);
      List<TaskItem> taskItems = OrganizerDAO.getAllTaskItems();
      List<Task> tasks = OrganizerDAO.getAllTasks();
      List<Comment> comments = OrganizerDAO.getAllComments();

      // finds the latest item updated in comments/tasks/taskitems using math.max(a, math.max(b, c))
      long templatestUpdate =
          Math.max(
              taskItems.get(0).getDate_modified().getTime(),
              Math.max(
                  tasks.get(0).getDate_modified().getTime(),
                  comments.get(0).getDate_created().getTime()));
      latestUpdate = new Timestamp(templatestUpdate);
      convertToEntries(taskItems, tasks, comments);
      System.out.println(latestUpdate);
    }
  }