Exemplo n.º 1
0
 /** Returns all open Projects. */
 public ArrayList<Project> getOpenProjects() {
   ArrayList<Project> result = new ArrayList<Project>(P_PROJS.getItemCount(this));
   for (Project task : P_PROJS.getList(this)) {
     if (!task.get(Project.P_FINISHED)) {
       result.add(task);
     }
   }
   return result;
 }
Exemplo n.º 2
0
 /** Returns the first "default" TaskType, null. */
 public Project findDefaultProject() {
   for (Project proj : P_PROJS.getList(this)) {
     if (proj.get(Project.P_DEFAULT) && !proj.get(Project.P_FINISHED)) {
       return proj;
     }
   }
   return null;
 }
Exemplo n.º 3
0
 /** Find a workDay. */
 public Project findProject(Integer id) {
   for (Project project : P_PROJS.getList(this)) {
     if (Project.P_ID.equals(project, id)) {
       return project;
     }
   }
   return null;
 }
Exemplo n.º 4
0
  /** Find a workDay or create new. */
  public WorkDay findWorkDay(YearMonthDay dayId) {
    for (WorkDay workDay : P_DAYS.getList(this)) {
      if (WorkDay.P_DATE.equals(workDay, dayId)) {
        return workDay;
      }
    }

    WorkDay result = new WorkDay();
    WorkDay.P_DATE.setValue(result, dayId.cloneDay());
    WorkSpace.P_DAYS.addItem(this, result);
    return result;
  }
Exemplo n.º 5
0
 /** Sync projects with other WorkSpace. */
 public void syncProjects(WorkSpace otherSpace) {
   ArrayList<Project> newProjects = new ArrayList<Project>();
   for (Project otherProject : P_PROJS.getList(otherSpace)) {
     boolean found = false;
     for (Project thisProject : P_PROJS.getList(this)) {
       if (Project.P_ID.equals(otherProject, thisProject.get(Project.P_ID))) {
         if (Project.P_DESCR.equals(otherProject, thisProject.get(Project.P_DESCR))) {
           // only update projects with same description, otherwise
           // old non-synced projects may change description
           thisProject.copyFrom(otherProject);
           thisProject.syncTasks(otherProject);
         }
         found = true;
         break;
       }
     }
     if (!found) {
       newProjects.add(otherProject);
     }
   }
   for (Project thisProject : P_PROJS.getList(this)) {
     boolean found = false;
     for (Project otherProject : P_PROJS.getList(otherSpace)) {
       if (Project.P_ID.equals(otherProject, thisProject.get(Project.P_ID))) {
         found = true;
         break;
       }
     }
     if (!found) {
       thisProject.set(Project.P_FINISHED, true);
     }
   }
   for (Project otherProject : newProjects) {
     Project project = new Project();
     project.copyFrom(otherProject);
     project.syncTasks(otherProject);
     WorkSpace.P_PROJS.addItem(this, project);
   }
 }
Exemplo n.º 6
0
 /** Assing tasks and projects. Call the method after a data loading. */
 public void assingTasks() {
   for (WorkDay day : P_DAYS.getList(this)) {
     for (Event event : WorkDay.P_EVENTS.getList(day)) {
       Integer projectId = event.get(Event.P_PROJID);
       Integer taskId = event.get(Event.P_TASKID);
       //
       Project project = this.findProject(projectId);
       TaskType task = project != null ? project.findTaskType(taskId) : null;
       //
       Event.P_PROJ.setValue(event, project);
       Event.P_PROJID.setValue(event, null);
       Event.P_TASK.setValue(event, task);
       Event.P_TASKID.setValue(event, null);
     }
   }
 }
Exemplo n.º 7
0
 /** Sort Days by a YearMonthDay */
 @SuppressWarnings("unchecked")
 public void sortDays() {
   ((ListProperty) P_DAYS).sort(this, WorkDay.P_DATE);
 }