Пример #1
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;
 }
Пример #2
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);
   }
 }