예제 #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 convertObjectToEntry(OrganizerSuperClass obj) {
    TaskEntry entry = new TaskEntry();
    entry.setDate_created(obj.getDate_created().getTime());
    entry.setTitle(obj.getTitle());
    entry.setType(obj.getType());
    entry.setUser_id(Integer.toString(obj.getUser_id()));
    entry.setObj_id(obj.getId() + "");
    entry.setId(obj.getTitle() + obj.getId());

    // comment is missing date modified and description, this only runs for task and items
    if (null != obj.getDate_modified() && null != obj.getDescription()) {
      entry.setDate_modified(obj.getDate_modified().getTime());
      entry.setDescription(obj.getDescription());
    }
    taskEntryRepository.save(entry);
  }