Package com.projity.session

Examples of com.projity.session.Session


  /**
   * Currently not implemented
   */
  public Job getExportFileJob(){
      Session session=SessionFactory.getInstance().getLocalSession();
    Job job=new Job(session.getJobQueue(),"exportFile","Exporting...",true); //$NON-NLS-1$ //$NON-NLS-2$
      job.addRunnable(new JobRunnable("Local: export",1.0f){ //$NON-NLS-1$
        public Object run() throws Exception{
           MSPDISerializer serializer = new MSPDISerializer();
          serializer.setJob(this);
          serializer.saveProject(project,fileName);
View Full Code Here


    form.setResources(projityResources);
  }


  protected void renumberProject() throws Exception{
    Session session=SessionFactory.getInstance().getSession(false);
    //renumber tasks
    Map<Long,Long> idMap=new HashMap<Long,Long>();
    for (TaskData task:(Collection<TaskData>)projectData.getTasks()){
      long oldUniqueId=task.getUniqueId();
      long uniqueId=session.getId();
      task.setUniqueId(uniqueId);
      idMap.put(oldUniqueId, uniqueId);
      if (task.getAssignments()!=null)
      for (AssignmentData assignment:(Collection<AssignmentData>)task.getAssignments()){
        assignment.setTaskId(uniqueId);
      }
    }

    Collection<DistributionData> dists=(Collection<DistributionData>)projectData.getDistributions();
    if (dists!=null)
    for (Iterator<DistributionData> i=dists.iterator();i.hasNext();){
      DistributionData dist=i.next();
      dist.setTaskId(idMap.get(dist.getTaskId()));
    }

    //renumber project
    projectData.setUniqueId(session.getId());
  }
View Full Code Here

    unassigned.setUniqueId(EnterpriseResource.UNASSIGNED_ID);
    unassigned.setName(Messages.getString("Text.Unassigned")); //$NON-NLS-1$
    form.setUnassignedResource(unassigned);
    projityResources.add(unassigned);
    try{
      Session session=SessionFactory.getInstance().getSession(false);
      projityResources.addAll((Collection)SessionFactory.call(session,resourceDescriptorsOnly?"retrieveResourceDescriptors":"retrieveResourceHierarchy",null,null));
      if (projityResources!=null&&projityResources.size()>0) form.setUnassignedResource(projityResources.get(0));
    }catch (Exception e){
      form.setLocal(true);
      return;
View Full Code Here

    match.setToolTipText(Messages.getString("LookupDialog.EnterPartOfTheName")); //$NON-NLS-1$
    find = new JButton(Messages.getString("LookupDialog.Find")); //$NON-NLS-1$
    find.addActionListener(new ActionListener() {

      public void actionPerformed(ActionEvent e) {
        Session session = SessionFactory.getInstance().getSession(false);
        if (session != null)
          try {
            resultMap = (LinkedHashMap)SessionFactory.call(session,"queryLike",new Class[]{String.class,String.class},new Object[]{ types.getSelectedItem(), match.getText()});
            results= new ActionJList(resultMap.values().toArray());
            ((ActionJList)results).addActionListener(new ActionListener(){
View Full Code Here

    doingOpenDialog = true;
    finishAnyOperations();

    final ArrayList descriptors=new ArrayList();

      Session session=SessionFactory.getInstance().getSession(false);
    Job job=(Job)SessionFactory.callNoEx(session,"getLoadProjectDescriptorsJob",new Class[]{boolean.class,java.util.List.class,boolean.class},new Object[]{true,descriptors,!Environment.isAdministrator()});
      job.addSwingRunnable(new JobRunnable("Local: loadDocument"){ //$NON-NLS-1$
        public Object run() throws Exception{
                 final Closure setter=new Closure(){
                    public void execute(Object obj){

                    }
                };
                final Closure getter=new Closure(){
                    public void execute(Object obj){
                      final Object[] r=(Object[])obj;
                      if (r!=null){
                        DocumentData data=(DocumentData)r[0];
                        boolean openAs=(Boolean)r[1];
                        loadDocument(data.getUniqueId(),false,openAs);
                      }

                    }
                };
                try {
                  boolean allowMaster = getCurrentFrame() == null && Environment.isAdministrator();
                  OpenProjectDialog.getInstance(getFrame(),descriptors,Messages.getString("Text.openProject"),allowMaster, true, null).execute(setter,getter); //$NON-NLS-1$
                } finally {
                doingOpenDialog = false;
                }

                return null;
        }
    });
    session.schedule(job);
  }
View Full Code Here

//      }
//    }

    final ArrayList descriptors=new ArrayList();

      Session session=SessionFactory.getInstance().getSession(false);
    Job job=(Job)SessionFactory.callNoEx(session,"getLoadProjectDescriptorsJob",new Class[]{boolean.class,java.util.List.class,boolean.class},new Object[]{true,descriptors,true});
      job.addSwingRunnable(new JobRunnable("Local: add"){ //$NON-NLS-1$
        public Object run() throws Exception{
            Closure setter=new Closure(){
                public void execute(Object obj){

                }
            };
            Closure getter=new Closure(){
                public void execute(Object obj){
                  final Object[] r=(Object[])obj;
                  if (r!=null){
                     final DocumentData data=(DocumentData)r[0];
                    if (data.isMaster())
                      return;
                    insertSubproject(project, data.getUniqueId(), true);
//                    Project openedAlready = ProjectFactory.getInstance().findFromId(data.getUniqueId());
//
//              if (!project.canInsertProject(data.getUniqueId())) {
//                Alert.error("The selected project is already a subproject in this consolidated project.");
//                return;
//              }
//              if (openedAlready != null && openedAlready.isOpenedAsSubproject()) {
//                Alert.error("The selected project is already opened as a subproject in another consolidated project.");
//                return;
//              }
//              Subproject subprojectTask = new Subproject(project,data.getUniqueId());
//              Node subprojectNode = getCurrentFrame().addNodeForImpl(subprojectTask,NodeModel.EVENT);
//              ProjectFactory.getInstance().openSubproject(project, subprojectNode, true);
                  }
                }
            };

          try {
              OpenProjectDialog dlg = OpenProjectDialog.getInstance(getFrame(),descriptors,Messages.getString("Text.insertProject"),false, false, project); //$NON-NLS-1$
              dlg.execute(setter,getter);
          } catch (Exception e) {
            Alert.error(Messages.getString("Message.serverUnreachable"),getContainer()); //$NON-NLS-1$
            //TODO need more precise exception
            e.printStackTrace();
          } finally {
            doingOpenDialog = false;
          }
          return null;
        }
    });
    session.schedule(job);
  }
View Full Code Here

    if (opt.isLocal()) project.setMaster(true);

    //Don't forget to modify Serializer.deserialize too
    if (opt.isAddResources() &&!project.isLocal()){
      try {
        Session session=SessionFactory.getInstance().getSession(false);
        List resources;
        if (((Boolean)SessionFactory.callNoEx(session,"isLocalAccess",null,null)).booleanValue())
          resources=(List)SessionFactory.call(session,"retrieveResourceHierarchy",null,null);
        else{
          resources=new ArrayList();

          Job job=(Job)SessionFactory.callNoEx(session,"getLoadResourceHierarchyJob", new Class[]{boolean.class,List.class},new Object[]{true,resources});
          job.addSync();
          session.schedule(job);
          //job.waitResult();
        }
        DataUtil.setEnterpriseResources(resources,resourcePool);
      } catch (Exception e) {
        // TODO Auto-generated catch block
View Full Code Here

  //OPEN PROJECTS


  public Project openProject(final LoadOptions opt) {
    Session session=SessionFactory.getInstance().getSession(opt.isLocal());
    Job job=null;
    final boolean recover;
    if (opt.getId()>0){
      Project p = findFromId(opt.getId());
      if (p != null && !opt.isOpenAs()){
        job=session.getEmptyJob("Recover project",p);
        recover=true;
      }else{
        addLoadingProject(opt.getId());
        recover=false;
      }
    }else recover=false;

    if (job==null) job=session.getLoadProjectJob(opt);
    job.addSwingRunnable(new JobRunnable("Local: addProject"){
      public Object run() throws Exception{
        Project project=(Project)getPreviousResult();
        if (!recover){
          if (project!=null) addProject(project,false,true);
          if (opt.getId()>0) removeLoadingProject(opt.getId());
        }
        if (opt.getEndSwingClosure()!=null) opt.getEndSwingClosure().execute(project);


        if (project != null && opt.isOpenAs() && project.isMaster())
          project.setReadOnly(true); // don't allow copy of master

        if (project != null && opt.isOpenAs()) {
          project.setReadOnly(true);
          project.setLocal(true);
        }
        return project;
      }
    },false);
    if (opt.isSync()) job.addSync();
    session.schedule(job);
    try {
      return (opt.isSync())?(Project)job.waitResult():null;
    } catch (Exception e) {//Forward exception + Alert
      return null;
    }
View Full Code Here

      parent.getSubprojectHandler().addSubproject(openSubproject, subprojectNode,creating, true);
      portfolio.handleExternalTasks(openSubproject,true, false)// resolve external links if any
      return openSubproject;
    }

    final Session session=SessionFactory.getInstance().getSession(false); // never local
    if (!session.projectExists(id)) {
      Alert.error(Messages.getString("Error.projectDoesNotExist"));
      return null;
    }

    addLoadingProject(id);

    LoadOptions opt=new LoadOptions();
    opt.setSubproject(true);
    opt.setId(id);
    Job job=session.getLoadProjectJob(opt);
    subprojectTask.setFetching(true);

    job.addSwingRunnable(new JobRunnable("Local: insertProject"){
      public Object run() throws Exception{
        try {
          Project subproject = (Project)getPreviousResult();

          //add assignments in the outline, paste uses only assignments present in the nodeModel
          AssignmentNodeModel parentModel = (AssignmentNodeModel)subproject.getTaskOutline();
          parentModel.addAssignments(parentModel.iterator()); // assignments

          if (subproject != null) {// is it possible it can be null?
            parent.getSubprojectHandler().addSubproject(subproject, subprojectNode,creating, false);
            if (subproject.isReadOnly()){
              Alert.warn(MessageFormat.format(Messages.getString("Message.readOnlySubproject"),new Object[]{subproject.getName()}));
            }
//
//            subproject.setGroupDirty(true);
//            //TODO something more precise here
          }
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          throw e;
        } finally {
          subprojectTask.setFetching(false);
          removeLoadingProject(id);

        }
            return null; //return not used anyway
      }
    },false);

    session.schedule(job);
    return ((Task)subprojectTask).getProject();
  }
View Full Code Here



  public void saveProject(final Project project, final SaveOptions opt) {
    Job job=getSaveProjectJob(project,opt);
    Session session=SessionFactory.getInstance().getSession(opt.isLocal());
    if (job!=null){
      if (opt.isSync()) job.addSync();
      session.schedule(job);
      try {
        if (opt.isSync()) job.waitResult();
      } catch (Exception e) {}
    }
  }
View Full Code Here

TOP

Related Classes of com.projity.session.Session

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.