예제 #1
0
 public List<Task> doTaskSearch(String query, int user_id) {
   List<TaskEntry> list = taskEntryRepository.findByTitleOrDescription(query, query);
   List<Task> ret = new ArrayList<>();
   for (TaskEntry entry : list) {
     System.out.println(
         "entry userID = "
             + entry.getUser_id()
             + " required UserID = "
             + Integer.toString(user_id));
     System.out.println(entry.getType());
     String type = entry.getType();
     if ((type.equals("task") || type.equals("taskItem"))
         && entry.getUser_id().equals(Integer.toString(user_id))) {
       if (type.equals("task")) {
         Task task = OrganizerDAO.getTaskByTitle(user_id, entry.getTitle());
         ret.add(task);
       }
       if (type.equals("taskItem")) {
         TaskItem item = OrganizerDAO.getTaskId(Integer.parseInt(entry.getObj_id()));
         Task task = OrganizerDAO.getTaskById(item.getTask_id());
         List<TaskItem> taskList = OrganizerDAO.getTaskItems(task.getId());
         if (taskList != null) {
           task.setTaskList(taskList);
           task.setTaskListSize(taskList.size());
         }
         ret.add(task);
       }
     }
   }
   return ret;
 }
예제 #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);
  }