Beispiel #1
0
 /** Create a DemoData */
 public void createDemoData() {
   TaskType task = new TaskType();
   TaskType.P_DESCR.setValue(task, "Task of the 1st Project");
   Project project = new Project();
   Project.P_DESCR.setValue(project, "1st Project");
   Project.P_TASKS.addItem(project, task);
   WorkSpace.P_PROJS.addItem(this, project);
 }
Beispiel #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);
   }
 }