Package com.projity.job

Examples of com.projity.job.Job


      _addProject(project);
      return;
    }
//    if (Environment.getStandAlone())
//      createJob = false;
    Job job=null;
    if (creating)
      return;
    Node oldNode=nodeModel.search(project,comparator);
    if (oldNode!=null){
      if (Alert.confirm(Messages.getString("Message.projectAlreadyExists"))==1){
        //TODO be sure all references are removed
        return;
      }else{
          //removeProject((Project)oldNode.getImpl());
        job=getRemoveProjectJob((Project)oldNode.getImpl(),true);
        if (job!=null&&!createJob){
          //job.addSync(); //sync leads to a lock
            SessionFactory.getInstance().getSession(project.isLocal()).schedule(job);
        }
      }
    }

    if (!createJob){
      _addProject(project);
      return;
    }

       Job addProjectJob=new Job(SessionFactory.getInstance().getSession(project.isLocal()).getJobQueue(),"addProject","Adding project...",false);
       addProjectJob.addSwingRunnable(new JobRunnable("Local: addProject",1.0f){
        public Object run() throws Exception{
          _addProject(project);
          setProgress(1.0f);
          return null;
        }
View Full Code Here


  }

  public Job getRemoveAllProjectsJob(JobRunnable exitRunnable,boolean calledFromSwing,boolean[] closeStatus){
    boolean exitOnClose=true;
    if (closeStatus!=null&&closeStatus.length>0) closeStatus[0]=true;
      final Job job=new Job(SessionFactory.getInstance().getLocalSession().getJobQueue(),"removeAllProjects","Removing projects...",true);
    ArrayList toRemove=new ArrayList();
    for (Iterator i=nodeModel.iterator();i.hasNext();){
      Node node=(Node)i.next();
      if (!node.isRoot()) toRemove.add(node);
    }
    Project p;
    for (Iterator i=toRemove.iterator();i.hasNext();){
      p = (Project)((Node)i.next()).getImpl();
      if (p.isOpenedAsSubproject()) // subprojects are saved with their parents
        continue;
      Job rJob=getRemoveProjectJob(p,calledFromSwing);
      if (rJob==null) {
        if (calledFromSwing) exitOnClose=false; //close cancelled.
        if (closeStatus!=null&&closeStatus.length>0){
          System.out.println("Close cancelled");
          closeStatus[0]=false;
View Full Code Here

        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) {
View Full Code Here

      public Object run() throws Exception{
        return createProjectAsync(opt);
      }
    };
    if (opt.isSync()){
        Job job=new Job(SessionFactory.getInstance().getJobQueue(),"createProject","Creating project...",false);
        job.addRunnable(runnable);
      job.addSync();
      SessionFactory.getInstance().schedule(job);
      try {
        Project project=(Project)job.waitResult();
        System.out.println("Project returned end lock");
        return project;
      } catch (Exception e) {//Forward exception + Alert
        e.printStackTrace();
        return null;
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

    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
View Full Code Here

  //SAVE PROJECTS



  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

          p.validateNewDistributionMap();
          portfolio.handleExternalTasks(p,false, true);     // external link handling
          if (opt.getPostSaving()!=null) opt.getPostSaving().execute(obj); //id, combobox update
        }
      });
      Job job=session.getSaveProjectJob(projects,o);
      return job;
    }
    return null;
  }
View Full Code Here

        }
      }
    });
    if (projects.size()>0){
      Session session=SessionFactory.getInstance().getSession(project.isLocal()); //assume same type for subprojets
      Job job=session.getCloseProjectsJob(projects);
      return job;
    }
    return null;
  }
View Full Code Here

    for (Project project : (Collection<Project>)projects) {
      if (project.isReadOnly()) continue;
      if (project.isLocal()) localProjects.add(project);
      else serverProjects.add(project);
    }
    Job job=null;
    if (localProjects.size()>0) job=SessionFactory.getInstance().getLocalSession().getCloseProjectsJob(projects);
    if (serverProjects.size()>0){
      Job j=SessionFactory.getInstance().getSession(false).getCloseProjectsJob(projects);
      if (job==null) job=j;
      else job.addJob(j);
    }
    return job;
  }
View Full Code Here

TOP

Related Classes of com.projity.job.Job

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.