Package com.projity.pm.resource

Examples of com.projity.pm.resource.ResourcePool


    System.out.println("doNewProjectNoDialog1 end");
    return form;
  }
  public boolean doNewProjectDialog2(ProjectDialog.Form form) {
    showWaitCursor(true);
    ResourcePool resourcePool=form.getResourcePool();
    boolean local=form.isLocal();
    if (resourcePool!=null) resourcePool.setLocal(local);
    CreateOptions opt=new CreateOptions();
    opt.setResourcePool(form.getResourcePool());
    opt.setLocal(local);
    opt.setName(form.getName());
    opt.setAddResources(!local);
View Full Code Here


      project.postDeserialization();


      //resources
      final Map resourceNodeMap=new HashMap();
      ResourcePool resourcePool = ResourcePoolFactory.getInstance().createResourcePool(project.getName(),undoController);
      resourcePool.setMaster(project.isMaster());
      resourcePool.setLocal(project.isLocal());
      resourcePool.updateOutlineTypes();
      Collection resources=projectData.getResources();
      if (resources!=null)
        //order by position parents don't matter
        Collections.sort((List<ResourceData>)resources,new Comparator<ResourceData>(){
          public int compare(ResourceData resource1, ResourceData resource2) {
View Full Code Here

        importer.setProjectFactory(ProjectFactory.getInstance());//used?
        importer.setJobQueue(jobQueue);
         
          job.addSwingRunnable(new JobRunnable("LocalAccess: loadProject.begin",1.0f){
          public Object run() throws Exception{
            ResourcePool resourcePool=null;
            if (MICROSOFT_PROJECT_IMPORTER.equals(opt.getImporter())){
              DataFactoryUndoController undoController=new DataFactoryUndoController();
              resourcePool = ResourcePoolFactory.getInstance().createResourcePool("",undoController);
              resourcePool.setLocal(importer.getResourceMapping()==null);
              Project project = Project.createProject(resourcePool,undoController);
             
              ((DefaultNodeModel)project.getTaskOutline()).setDataFactory(project);   
              importer.setProject(project);
            }
View Full Code Here

   *
   * @param file
   *            MPX file
   */
  protected void importLocalResources(){
    ResourcePool resourcePool = project.getResourcePool();
    project.setLocal(true);
    resourcePool.setLocal(true);
    resourcePool.setMaster(false);
        resourcePool.updateOutlineTypes();
    ResourceImpl openprojResource;
    OpenprojResourceConverter converter=new OpenprojResourceConverter();
    for (com.projectlibre.pm.resources.Resource plResource : plProject.getResourcePool().getResources()){
      openprojResource = resourcePool.newResourceInstance();
      converter.to(openprojResource,plResource,state);
      state.mapOpenprojResource(plResource, openprojResource);
      // Add to resource hierarchy.  MSProject does not actually have a hierarchy
      Node openprojResourceNode = NodeFactory.getInstance().createNode(openprojResource); // get a node for this resource
      resourcePool.addToDefaultOutline(null,openprojResourceNode);     
      state.mapOpenprojResourceNode(openprojResource, openprojResourceNode);

    }
    //insertResourceVoids();
  }
View Full Code Here

        return true;
      }

      com.projity.pm.resource.Resource projityResource=null;
      int projityResourceCount=0;
      ResourcePool resourcePool = project.getResourcePool();
      project.setTemporaryLocal(true);
      Object srcResource;
      EnterpriseResourceData data;
      Map enterpriseResourceDataMap=new HashMap();
      for (Iterator i=form.getResources().iterator();i.hasNext();){
        data=(EnterpriseResourceData)i.next();
        if (data.isLocal()) {
          projityResource=ResourceImpl.getUnassignedInstance();
        } else {
//          try {
            projityResource=Serializer.deserializeResourceAndAddToPool(data,resourcePool,null);

            //Handles only flat outlines
            Node node=NodeFactory.getInstance().createNode(projityResource);
            resourcePool.addToDefaultOutline(null,node,projityResourceCount++,false);
                    ((ResourceImpl)projityResource).getGlobalResource().setResourcePool(resourcePool);
//          } catch (Exception e) {}
        }
        enterpriseResourceDataMap.put(data,projityResource);

      }
      Iterator ir = form.getImportedResources().iterator();
      Iterator sr = form.getSelectedResources().iterator();
      while (ir.hasNext()) {
        srcResource = ir.next();
        data=(EnterpriseResourceData)sr.next();
        projityResource=(com.projity.pm.resource.Resource)enterpriseResourceDataMap.get(data);
        mapResource((long)projityResource.getUniqueId(),projityResource );
      }

      resourcePool.setMaster(false);
      resourcePool.updateOutlineTypes();

      project.setAccessControlPolicy(form.getAccessControlType());
      project.resetRoles(form.getAccessControlType()==0);

View Full Code Here

    public void paste(Node parent,List children,int position,NodeModel model,int actionType){
      Node p=(parent==null)?root:parent;

      Project project=null;
      ResourcePool resourcePool=null;
      if (model.getDataFactory() instanceof Project)
          project=(Project)model.getDataFactory();
      else if(model.getDataFactory() instanceof ResourcePool)
          resourcePool=(ResourcePool)model.getDataFactory();

      int subprojectLevel=getChildrenSubprojectLevel(parent);


//      ArrayList trees=new ArrayList();
//      HierarchyUtils.extractParents(children,trees);

      int childCount=p.getChildCount();
      if (position>childCount){
        NodeFactory nodeFactory=NodeFactory.getInstance();
        Node node=nodeFactory.createVoidNode();
        for (int i=childCount;i<position;i++){
          setSubprojectLevel(node,subprojectLevel);
          p.add(node);
        }
      }



      int j=position;
         for (Iterator i=/*trees*/children.iterator();i.hasNext();){
           Node node=(Node)i.next();
           if ((project!=null && node.getImpl() instanceof Task)||
               (resourcePool!=null && node.getImpl() instanceof Resource)||
               node.isVoid()){
            //if (node.getImpl() instanceof Task) System.out.println("PASTE parent="+parent+":"+(parent==null?"X":parent.isInSubproject())+", node="+node+":"+node.isInSubproject());
          setSubprojectLevel(node,subprojectLevel);
        //if (node.getImpl() instanceof Task) System.out.println("PASTE node in sub="+node.isInSubproject());
          if (position==-1) p.add(node);
      else p.insert(node,j++);
           }
         }
         Node[] descendants=addDescendants(/*trees*/children);


         ArrayList<Dependency> dependencies=new ArrayList<Dependency>();

      boolean doTransaction = model.getDocument() != null && descendants.length > 0;
      int transactionId = 0;
      if (doTransaction)
        transactionId = model.getDocument().fireMultipleTransaction(0,true);


      ArrayList<Node> insertedNodes=new ArrayList<Node>(descendants.length);

      if (project!=null){
        HashMap<Long,Resource> resourceMap=new HashMap<Long,Resource>();
        for (Resource r: (Collection<Resource>)project.getResourcePool().getResourceList())
          resourceMap.put(r.getUniqueId(),r);

        HashMap<Long,Task> taskMap=null;
        if (Environment.isKeepExternalLinks()){
          taskMap=new HashMap<Long,Task>();
          for (Task t: (Collection<Task>)project.getTasks()) //use model instead?
            taskMap.put(t.getUniqueId(),t);
        }

        Project owningProject;
        if (parent!=null && parent.getImpl() instanceof Task){
          Task task=(Task)parent.getImpl();
          if (task.isSubproject()) owningProject=((SubProj)task).getSubproject();
          else owningProject=task.getOwningProject();
        }else owningProject=(Project)model.getDataFactory();

          for (int i=0;i<descendants.length;i++){
            if (descendants[i].getImpl() instanceof Task){
              Task task=(Task)descendants[i].getImpl();

              Node parentSubproject=getParentSubproject((Node)descendants[i].getParent());
              if (parentSubproject!=null) owningProject=((SubProj)parentSubproject.getImpl()).getSubproject();
              if (!task.isExternal()) // fixes  subproject bug with external links
                task.setProjectId(owningProject.getUniqueId()); //useful?
              owningProject.validateObject(task,model,this,null,false);

              Set<Dependency> depsSet=new HashSet<Dependency>();
            List pdeps=task.getDependencyList(true);
            if (pdeps!=null&&pdeps.size()>0){
              if (Environment.isKeepExternalLinks()){
                for (Iterator k=pdeps.iterator();k.hasNext();){
                  Dependency d=(Dependency)k.next();
                  if (!(d.getPredecessor() instanceof Task)){
                    TaskLinkReference ref=(TaskLinkReference)d.getPredecessor();
                    Task t=taskMap.get(ref.getUniqueId());
                    if (t==null){
                      k.remove();
                      continue;
                    } else{
                      d.setPredecessor(t);
                      t.getSuccessorList().add(d);
                      //DependencyService.getInstance().updateSentinels(d);
                      //DependencyService.getInstance().connect(d, this);
                    }
                  }
                  depsSet.add(d);
                }
               }
            }
            List sdeps=task.getDependencyList(false);
            if (sdeps!=null&&sdeps.size()>0){
              if (Environment.isKeepExternalLinks()){
                for (Iterator k=sdeps.iterator();k.hasNext();){
                  Dependency d=(Dependency)k.next();
                  if (!(d.getSuccessor() instanceof Task)){
                    TaskLinkReference ref=(TaskLinkReference)d.getSuccessor();
                    Task t=taskMap.get(ref.getUniqueId());
                    if (t==null){
                      k.remove();
                      continue;
                    } else{
                      d.setSuccessor(t);
                      t.getPredecessorList().add(d);
                      //DependencyService.getInstance().updateSentinels(d);
                      //DependencyService.getInstance().connect(d, this);
                    }
                  }
                  depsSet.add(d);
                }
               }
            }
          dependencies.addAll(depsSet);

              //check assignments, if resource not present change it to unassigned

              for (int s=0;s<Settings.numBaselines();s++){
                TaskSnapshot snapshot=(TaskSnapshot)task.getSnapshot(new Integer(s));
                    if (snapshot==null) continue;
                  AssociationList snapshotAssignments=snapshot.getHasAssignments().getAssignments();
                  if (snapshotAssignments.size()>0){
//                    ArrayList<Assignment> assignmentsToLink=new ArrayList<Assignment>();
                      for (Iterator a=snapshotAssignments.listIterator();a.hasNext();){
                          Assignment assignment=(Assignment)a.next();
                          Resource resource=assignment.getResource();
                      if (resource==ResourceImpl.getUnassignedInstance()) continue;
                      Resource destResource=resourceMap.get(resource.getUniqueId());
                      if (destResource!=null){
                          if (Snapshottable.CURRENT.equals(s)){
                            if (destResource!=resource){ // use destination resource
                              resource=destResource;
                              assignment.getDetail().setResource(resource);
                            }
//                            assignmentsToLink.add(assignment);
                            resource.addAssignment(assignment);
                            NodeUndoInfo undo=new NodeUndoInfo(false);
                            ((ResourcePool)assignment.getResource().getDocument()).getObjectEventManager().fireCreateEvent(this,assignment,undo);
                          }
                      }else{
                        assignment.getDetail().setResource(ResourceImpl.getUnassignedInstance());
                      }
                      }
//                      for (Assignment assignment: assignmentsToLink){
//                        AssignmentService.getInstance().remove(assignmentsToLink, this,false);
//                        AssignmentService.getInstance().connect(assignment, this);
//                      }


                  }
              }

              project.initializeId(task);
              project.addPastedTask(task);

              insertedNodes.add(descendants[i]);
            }
          }
      }else if (resourcePool!=null){
          for (int i=0;i<descendants.length;i++){
            if (descendants[i].getImpl() instanceof Resource){
              Resource resource=(Resource)descendants[i].getImpl();
              model.getDataFactory().validateObject(resource,model,this,null,false);
              resourcePool.initializeId(resource);
              insertedNodes.add(descendants[i]);
            }
          }
      }

View Full Code Here

    System.out.println("doNewProjectNoDialog1 end");
    return form;
  }
  public boolean doNewProjectDialog2(ProjectDialog.Form form) {
    showWaitCursor(true);
    ResourcePool resourcePool=form.getResourcePool();
    boolean local=form.isLocal();
    if (resourcePool!=null) resourcePool.setLocal(local);
    CreateOptions opt=new CreateOptions();
    opt.setResourcePool(form.getResourcePool());
    opt.setLocal(local);
    opt.setName(form.getName());
    opt.setAddResources(!local);
View Full Code Here

            : "Spreadsheet.AssignmentEntry.assignResources"));
  }
  public void init() {
    if (project == null)
      return;
    ResourcePool pool = project.getResourcePool();
   
//    if (assignmentModel==null){
      pool.getResourceOutline().getHierarchy().removeHierarchyListener(this);
      pool.getResourceOutline().getHierarchy().addHierarchyListener(this);
 
      assignmentModel = NodeModelFactory.getInstance().replicate(pool.getResourceOutline(),new NodeFactoryTransformer());
      assignmentModel.getHierarchy().setNbEndVoidNodes(0); // don't allow blank lines
//    }
    if (spreadSheet==null){
      spreadSheet = new AssignmentSpreadSheet(resourceAssigner);
      spreadSheet.setSpreadSheetCategory(spreadsheetCategory)// for columns.  Must do first
View Full Code Here

//    return createProject(resourcePool,local,name,!local,true);
//  }
//  public Project createProject(ResourcePool resourcePool, boolean local, String name, boolean addResources,boolean verify) {
  private Project createProjectAsync(CreateOptions opt) {
    DataFactoryUndoController undoController=new DataFactoryUndoController();
    ResourcePool resourcePool=opt.getResourcePool();
    if (resourcePool == null){
      resourcePool = ResourcePoolFactory.getInstance().createResourcePool(opt.getName(),undoController);
      resourcePool.setLocal(opt.isLocal());
    }
    Project project = Project.createProject(resourcePool,undoController);
    undoController.setDataFactory(project);
    project.setName(opt.getName());
    if (opt.isLocal()) project.setMaster(true);
View Full Code Here

TOP

Related Classes of com.projity.pm.resource.ResourcePool

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.