Package com.projity.pm.task

Examples of com.projity.pm.task.NormalTask


      resource=ResourceImpl.getUnassignedInstance();
    else resource = state.getOpenprojResource(assignment.getResource());
    if (resource==null)
      return null; //TODO handle error or log
   
    NormalTask task=state.getOpenprojTask(assignment.getTask());
   
   
    //create assignment
    com.projity.pm.assignment.Assignment openprojAssignment=AssignmentService.getInstance().newAssignment(task,resource
        ,(Double)assignment.get("units"),0,null);
View Full Code Here


   */
  public void adjustRemainingUnits(double newRemainingUnits, double oldRemainingUnits, boolean doChildren, boolean conserveTotalUnits) {
    if (!isTemporal()) // for absolute quantities, don't change
      return;
    oldRemainingUnits = getRemainingUnits();
    NormalTask task =(NormalTask)getTask();
  //  task.adjustUnitsDelta(newRemainingUnits - oldRemainingUnits);
    if (doChildren) {
      task.getSchedulingRule().adjustRemainingUnits(this, newRemainingUnits,
        oldRemainingUnits, false, false);
    } else { // just treat the assignment
      if (getPercentComplete() > 0.0D) // if actuals, then remaining may have different contour
        makeContourPersonal();

View Full Code Here

      taskLinker.addOutline(project.getTaskOutlineRoot());
      long projectId = project.getUniqueId();
        //dependencies
        //Count depCount=new Count("Dependencies");
        for (Iterator i=project.getTaskOutlineIterator();i.hasNext();){
            NormalTask task=(NormalTask)i.next(); //ResourceImpl to have the EnterpriseResource link
            if (task.getProjectId() != projectId||task.isExternal()) // skip if in another project, don't write externals to server
              continue;
          TaskData taskData=(TaskData)taskLinker.getTransformationMap().get(task);
          if (taskData == null)
            continue;

            Iterator j=task.getPredecessorList().iterator();
          if (j.hasNext()){
              List predecessors=new ArrayList();
              while (j.hasNext()){
                  Dependency dependency=(Dependency)j.next();
                  LinkData linkData;
View Full Code Here

      //tasks
      Collection tasks=projectData.getTasks();
      Map taskNodeMap=new HashMap();
      long projectId = project.getUniqueId();
      NormalTask task;

      if (tasks!=null){
        //order by position parents don't matter
        Collections.sort((List<TaskData>)tasks,new Comparator<TaskData>(){
          public int compare(TaskData task1, TaskData task2) {
            if (!task1.isExternal() && task2.isExternal()) return -1; //keep external tasks at the end
            else if (task1.isExternal() && !task2.isExternal()) return 1;
            else if (task1.getChildPosition()>task2.getChildPosition()) return 1;
            else return -1;
          }
        });

        //Set<Long> initialTaskIds=new HashSet<Long>();
        //project.setInitialTaskIds(initialTaskIds);
        for (Iterator i=tasks.iterator();i.hasNext();){
          task = null;
          TaskData taskData=(TaskData)i.next();
//        initialTaskIds.add(taskData.getUniqueId());
          if (taskData.isDirty()) fixCorruption=true; //recovers errors
//          if (Environment.isAddSummaryTask()&&taskData.getUniqueId()==Task.SUMMARY_UNIQUE_ID&&taskData.getSerialized()==null){ //claur
//          System.out.println("Fixing null binary summary task");
//          task = new NormalTask(project);
//          task.setName(taskData.getName());
//          task.setUniqueId(taskData.getUniqueId());
//          }else
          if (taskData.getSerialized()==null) {
            if (taskData.isTimesheetCreated()) {
              task = new NormalTask(project);
              task.setName(taskData.getName());
              System.out.println("made new task in serializer " + task + " parent " + taskData.getParentTask().getName());
            } else {
              continue; // void node
            }
          } else {
            try {
              task = (NormalTask)deserialize(taskData,reindex);
            } catch (Exception e) {
              if (taskData.isSubproject()){ //For migration
                try {
                  task = (NormalTask) Class.forName(Messages.getMetaString("Subproject")).getConstructor(new Class[]{Project.class,Long.class}).newInstance(project,taskData.getSubprojectId());
                } catch (Exception e1) {
                  e1.printStackTrace();
                }

//              task=new Subproject(project,taskData.getSubprojectId());
                task.setUniqueId(taskData.getUniqueId());
                task.setName(taskData.getName());
                ((SubProj)task).setSubprojectFieldValues(taskData.getSubprojectFieldValues());
              }
              else{
                e.printStackTrace();
                throw new IOException("Subproject:"+e);
              }
            }
          }
          taskNodeMap.put(taskData,NodeFactory.getInstance().createNode(task));
          task.setProject(project);
          project.initializeId(task);
          project.add(task);
          if (taskData.isExternal()) {
            task.setExternal(true);
            task.setProjectId(taskData.getProjectId());
            task.setAllSchedulesToCurrentDates();
            project.addExternalTask(task);
          } else {
            task.setOwningProject(project);
            task.setProjectId(projectId);
          }
          if (taskData.isSubproject()) {
            SubProj sub = (SubProj)task;
            sub.setSubprojectUniqueId(taskData.getSubprojectId());
            sub.setSubprojectFieldValues(taskData.getSubprojectFieldValues());
            sub.setSchedulesFromSubprojectFieldValues();
          }
//          if (task.isRoot()){ //claur
//            project.setSummaryTaskEnabled(true);
//          }

          WorkingCalendar cal=(WorkingCalendar) task.getWorkCalendar();
          if (cal!=null){ // use global one
            WorkingCalendar newCal = (WorkingCalendar) CalendarService.findBaseCalendar(cal.getName());
            if (newCal != null && newCal != cal)
              task.setWorkCalendar(newCal);
          }

          //project.addToDefaultOutline(null,);


          //assignments
          List assignments=new ArrayList();
//          if (Environment.isNoPodServer()&&task.getPersistedAssignments()!=null){ //claur
//            assignments.addAll(task.getPersistedAssignments());
//          }
          if (taskData.getAssignments()!=null) assignments.addAll(taskData.getAssignments());

          if (assignments.size()>0)
        for (Iterator j=assignments.iterator();j.hasNext();){
          Object obj=j.next();
          AssignmentData assignmentData=null;
//          if (loadResources!=null&&obj instanceof PersistedAssignment){ //claur
//          }else{
            assignmentData=(AssignmentData)obj;
            if (assignmentData.getSerialized() == null) { // timesheet created
                System.out.println("==== no cached start found " + task.getName());
                if (assignments.size()==1)
                  assignmentData.setResourceId(-1L);
                else j.remove();
            }
//          }
        }

          if (assignments.size()>0)
            for (Iterator j=assignments.iterator();j.hasNext();){
              Object obj=j.next();
              AssignmentData assignmentData=null;
              Assignment assignment=null;
              Resource resource;
              boolean assigned=true;
              int s;
//              if (loadResources!=null&&obj instanceof PersistedAssignment){ //claur
//                PersistedAssignment pa=(PersistedAssignment)obj;
//                assignment=pa.getAssignment();
//                s=pa.getSnapshot();
//
//                 long resId=pa.getResourceId();
//              Node node=(Node)resourceNodeMap.get(resId);
//              resource=node==null?ResourceImpl.getUnassignedInstance():(Resource)node.getImpl();
//
//              if (resource==null) assigned=false;
//              }else{
                assignmentData=(AssignmentData)obj;
                if (loadResources==null){
                  EnterpriseResourceData r=assignmentData.getResource();
                  if (r==null) assigned=false;
                  resource=(r==null)?ResourceImpl.getUnassignedInstance():(Resource)((Node)resourceNodeMap.get(r)).getImpl();
                }else{
                  long resId=assignmentData.getResourceId();
                  Node node=(Node)resourceNodeMap.get(resId);
                  resource=node==null?ResourceImpl.getUnassignedInstance():(Resource)node.getImpl();
                }
                if (assignmentData.getSerialized() != null){
                  try {
                    assignment=(Assignment)deserialize(assignmentData,reindex);
                  } catch (Exception e) {
                    e.printStackTrace();
                  }
                }
                if (assignmentData.getSerialized() == null||(assignmentData.getSerialized() != null&&assignment==null)) { // timesheet created
                  assignment = Assignment.getInstance(task,resource,  1.0, 0);
                  if (assignment.getCachedStart() == null) { //doesn't occur filtered above
                    System.out.println("==== no cached start found " + task.getName());

                  } else {
                    task.setActualStart(assignment.getCachedStart().getTime());
                    task.setActualFinish(assignment.getCachedEnd().getTime());
                  }
                }
                assignment.setCachedStart(assignmentData.getCachedStart());
                assignment.setCachedEnd(assignmentData.getCachedEnd());
                assignment.setTimesheetStatus(assignmentData.getTimesheetStatus());
                long lastUpdate = (assignmentData.getLastTimesheetUpdate() == null) ? 0 : assignmentData.getLastTimesheetUpdate().getTime();
                assignment.setLastTimesheetUpdate(lastUpdate);
                assignment.setWorkflowState(assignmentData.getWorkflowState());
                s=assignmentData.getSnapshotId();
//              }

              assignment.getDetail().setTask(task);
              assignment.getDetail().setResource(resource);
              Object snapshotId=new Integer(s);
              TaskSnapshot snapshot=(TaskSnapshot)task.getSnapshot(snapshotId);

              //TODO was commented but needed for loading  because task.getSnapshot(snapshotId)==null
              //for snapshots other than CURRENT
              if (snapshot==null){
                snapshot=new TaskSnapshot();
                snapshot.setCurrentSchedule(task.getCurrentSchedule());
                task.setSnapshot(snapshotId,snapshot);
              }
              if (Snapshottable.TIMESHEET.equals(snapshotId)) {
                assignment.setTimesheetAssignment(true);
              }
              //

              snapshot.addAssignment(assignment);

              if (assigned&&Snapshottable.CURRENT.equals(snapshotId)) resource.addAssignment(assignment);

              if (assignmentData!=null) assignmentData.emtpy();
              //incremental.addAssignment(assignmentData);
            }
//          task.setPersistedAssignments(null);
        }


        // the collection which holds a list of corresponding subproject tasks for projects which include this project
        // note that their task names have been transformed to hold the name of the project
        Collection referringSubprojectTaskData=projectData.getReferringSubprojectTasks();
        if (tasks!=null&&referringSubprojectTaskData!=null){
          ArrayList referringSubprojectTasks = new ArrayList(referringSubprojectTaskData.size());
          project.setReferringSubprojectTasks(referringSubprojectTasks);
          for (Iterator i=referringSubprojectTaskData.iterator();i.hasNext();){
            TaskData taskData=(TaskData)i.next();
            String projectName = taskData.getName(); // it was set to the referrig project name by synchronizer
            task = null;
            try {
              task = (NormalTask)deserialize(taskData,reindex);
            } catch (Exception e) {
              if (taskData.isSubproject()){ //For migration
                task=(NormalTask) project.getSubprojectHandler().createSubProj(taskData.getSubprojectId());
                task.setUniqueId(taskData.getUniqueId());
                task.setName(taskData.getName());
                ((SubProj)task).setSubprojectFieldValues(taskData.getSubprojectFieldValues());
              }
              else throw new IOException("Subproject:"+e);
            }
            task.setName(projectName);
            task.setProjectId(taskData.getProjectId());
            referringSubprojectTasks.add(task);
          }
        }

        //dependencies
View Full Code Here

      public void doClick(int row, int col) {
        Object obj = getCurrentRowImpl();
        if (obj!= null) {
        Field field = ((SpreadSheetModel)getModel()).getFieldInColumn(col+1);
        if (field == clickField) {
              NormalTask pred = (NormalTask) (predecessor ? ((Dependency)obj).getLeft() : ((Dependency)obj).getRight());
              dlg.setObject(pred);
              dlg.updateAll();
              pred.getDocument().getObjectSelectionEventManager().fire(this,pred);
        }
        }
      }
View Full Code Here

*
*/
public class OpenprojDependencyConverter {

  public com.projity.pm.dependency.Dependency to(Dependency dependency, OpenprojImportState state) {
    NormalTask predecessor=state.getOpenprojTask(dependency.getPredecessor());
    NormalTask successor=state.getOpenprojTask(dependency.getSuccessor());

    com.projity.pm.dependency.Dependency openprojDependency=null;
    try {
      OpenprojDurationConverter durationConverter=new OpenprojDurationConverter();
      Long openprojDuration=(Long)durationConverter.to(dependency.getLag());
View Full Code Here

        Task parentTask=null;
        if (!parentHierarchyNode.isRoot())
          parentTask=(Task)parentHierarchyNode.getNode();

        //openproj task conversion
        NormalTask openprojTask=project.newNormalTaskInstance(false);
        openprojTask.setOwningProject(project);
        openprojTask.setProjectId(project.getUniqueId());
        converter.to(openprojTask, task, state);
       
        //openproj task node conversion
        Node openprojTaskNode=NodeFactory.getInstance().createNode(openprojTask);
       
        //openproj node hierarchy
        NormalTask openprojParentTask=parentTask==null? null : state.getOpenprojTask(parentTask);
        Node openprojParentTaskNode=openprojParentTask==null? null : state.getOpenprojTaskNode(openprojParentTask);
        project.addToDefaultOutline(openprojParentTaskNode,openprojTaskNode);

       
        state.mapOpenprojTask(task, openprojTask);
View Full Code Here

   *
   */
  protected void importAssignments() {
    OpenprojAssignmentConverter converter=new OpenprojAssignmentConverter();
    for (Task task : plProject.getTasks()){
      NormalTask openprojTask=state.getOpenprojTask(task);
      for (com.projectlibre.pm.tasks.Assignment assignment : task.getAssignments()){
        Assignment openprojAssignment=converter.to(assignment, state);
        openprojTask.addAssignment(openprojAssignment);
      }
    }
  }
View Full Code Here

  public void newAssignments(Collection tasks, Collection resources, double units, long delay, Object eventSource,boolean undo) {
    if (tasks.size()==0||resources.size()==0) return;
    int transactionId = 0;
    Project transactionProject = null;
    for (Iterator i=tasks.iterator();i.hasNext();){
      NormalTask task = (NormalTask)i.next();
//      if (!task.isAssignable())
//        continue;
      if (transactionId == 0) {
        transactionProject = task.getProject();
        transactionProject.beginUndoUpdate();
        transactionId = transactionProject.fireMultipleTransaction(0,true);
       
        //backup before any assignment operation
        transactionProject.getUndoController().getEditSupport().postEdit(new ScheduleBackupEdit(tasks,this));
      }
      // if task currently has no assignments, then we should not change duration if adding several at once
      boolean taskHasNoAssignments = !task.hasRealAssignments() || !task.hasLaborAssignment();
      int oldSchedulingType = task.getSchedulingType();
      boolean oldEffortDriven = task.isEffortDriven();
      if (taskHasNoAssignments) {// if adding for first time
        task.setSchedulingType(SchedulingType.FIXED_DURATION);
        task.setEffortDriven(false);
      }

      Iterator r = resources.iterator();
      while (r.hasNext()) {
        Resource resource = (Resource) r.next();
        if (null == task.findAssignment(resource)) {
//          double units = 1.0D;
//TODO Bug 330: this is slow and uses tons of memory when assigning many at once. optimizing by doing just one update
//The result is that AssignmentNodeModel.objectChanged(ObjectEvent objectEvent) is called for each assignment
//This needs to be batched as its current memory usage is unacceptable and it takes very long
//Perhaps one solution would be to replace hierarchy search() with a hash table for mapping impls to nodes

//TODO It throws an event for assignment. A service for updating all the assignments at once should be added.
          Assignment assignment = newAssignment(task,resource,units,0,eventSource,true);
          if (!resource.isLabor()) // for assigning non temporal resources, use the value of 1
            assignment.setRateUnit(TimeUnit.NON_TEMPORAL);
        }
      }
      if (taskHasNoAssignments) {// if adding for first time, put back effort driven value
        task.setSchedulingType(oldSchedulingType);
        task.setEffortDriven(oldEffortDriven);
      }
    }
    if (transactionId != 0) {
      transactionProject.fireMultipleTransaction(transactionId,false);
      transactionProject.endUndoUpdate();
View Full Code Here

//      }
    }
  }

  public void remove(Assignment assignment, boolean cleanTaskLink, Object eventSource, NodeUndoInfo undo) {
      NormalTask task=(NormalTask)assignment.getTask();
      Resource resource=assignment.getResource();
                 
      if (task.findAssignment(resource) == null)
        return; // avoids endless loop 9/1/06 hk

     
      if (cleanTaskLink) task.removeAssignment(assignment);
      resource.removeAssignment(assignment);
     
//    //remove assignment snapshots too 18/7/2006 lc
//    //if (resource!=ResourceImpl.getUnassignedInstance())
//        for (int s=0;s<Settings.numBaselines();s++){
View Full Code Here

TOP

Related Classes of com.projity.pm.task.NormalTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.