Package com.projity.job

Examples of com.projity.job.Job


  protected long localSeed;
  public synchronized long getId(){
    return localSeed++;
  }
    public Job getCloseProjectsJob(final Collection projects){
      Job job=new Job(jobQueue,"closeProjects","Closing...",false);
      job.addRunnable(new JobRunnable("LocalAccess: closeProjects",0.1f){
        public Object run() throws Exception{
        setProgress(1.0f);
          return null;
        }
      });
      job.addExceptionRunnable(new JobRunnable("Local: exception"){
        public Object run() throws Exception{
          Alert.error(Messages.getString("Message.serverError"));
          return null;
        }
      });
View Full Code Here


   
   
   
    public Job getLoadProjectJob(final LoadOptions opt){
      final Job job=new Job(jobQueue,"loadProject","Loading...",true);
        job.setCancelMonitorClosure(new Closure(){
      public void execute(Object o) {
        System.out.println("Monitor Canceled");
        jobQueue.endCriticalSection(job);
      }
        });
    try {
      final FileImporter importer = (FileImporter) ClassUtils.forName(opt.getImporter()).newInstance();
        importer.setFileName(opt.getFileName());
        importer.setResourceMapping(opt.getResourceMapping());
        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);
            }
             setProgress(1.0f);
                  return null;
          }
          });
        job.addJob(importer.getImportFileJob());
          job.addRunnable(new JobRunnable("LocalAccess: loadProject.end",1.0f){
          public Object run() throws Exception{
              Project project=importer.getProject();
              project.setFileName(opt.getFileName()); //overrides project name
            if (MICROSOFT_PROJECT_IMPORTER.equals(opt.getImporter()))
              project.getResourcePool().setName(project.getName());
View Full Code Here

   
   
   
    public Job getSaveProjectJob(final List<Project> projs,final SaveOptions opt){
      final String title="Saving";
      final Job job=new Job(jobQueue,"saveProject",title+"...",true);
        job.setCancelMonitorClosure(new Closure(){
      public void execute(Object o) {
        System.out.println("Monitor Canceled");
        jobQueue.endCriticalSection(job);
      }
        });
    FileImporter importer=null;
    try {
      importer=(FileImporter) ClassUtils.forName(opt.getImporter()).newInstance();
    } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    importer.setJobQueue(jobQueue);
    importer.setProjectFactory(ProjectFactory.getInstance());//used?
    int count=projs.size();
    int i=0;
    for (final Project project : projs) {
      //if projs.size()>1 opt.getFileName() must be null
      String fileN=(opt.getFileName()==null)?project.getGuessedFileName():opt.getFileName();//+(count>1?("("+i+")"):""));
      if (!FileHelper.isFileNameAllowed(fileN, true)){
        fileN=SessionFactory.getInstance().getLocalSession().chooseFileName(true,FileHelper.changeFileExtension(fileN, /*project.getFileType()*/FileHelper.PROJITY_FILE_TYPE));
      }
      final String fileName=fileN;
      if (fileName==null) continue;
      importer.setFileName(fileName);
      importer.setProject(project);
      if (opt.getPreSaving() != null)
        opt.getPreSaving().execute(project);

      job.addJob(importer.getExportFileJob());
      job.addRunnable(new JobRunnable("Local: saveProject end"){
        public Object run() throws Exception{
          project.setFileName(fileName);
            project.setGroupDirty(false);
          if (opt.getPostSaving()!=null) opt.getPostSaving().execute(project);
              return null;
        }
      });


          //setProgress(((float)++i)/((float)count));
    }
       job.addExceptionRunnable(new JobRunnable("Local: exception"){
        public Object run() throws Exception{
          Alert.error(Messages.getString("Message.serverError"));
          return null;
        }
      });
View Full Code Here

      subprojects = new ArrayList();
      errorDescription = null;
      lastException = null;
      Session session=SessionFactory.getInstance().getSession(resourceMapping==null);
    Job job=new Job(session.getJobQueue(),"importFile",Messages.getString("MicrosoftImporter.Importing"),true); //$NON-NLS-1$ //$NON-NLS-2$
      job.addRunnable(new JobRunnable(Messages.getString("MicrosoftImporter.PrepareResources"),1.0f){ //$NON-NLS-1$

      public Object run() throws Exception{
        log.info("BEGIN: MicrosoftImporter.PrepareResources");
        MicrosoftImporter.this.jobRunnable = this;
        parse();
        log.info("END: MicrosoftImporter.PrepareResources");
        return null;
      }
      });
     
      job.addSwingRunnable(new JobRunnable("Import resources",1.0f){ //$NON-NLS-1$
      public Object run() throws Exception{
        log.info("BEGIN: Import resources");
        ResourceMappingForm form=getResourceMapping();
        if (form!=null&&form.isLocal()) //if form==null we are in a case were have no server access. popup not needed
          if (!job.okCancel(Messages.getString("Message.ServerUnreacheableReadOnlyProject"),true)){ //$NON-NLS-1$
            setProgress(1.0f);
            errorDescription = ABORT;
            Environment.setImporting(false); // will avoid certain popups
            throw new Exception(ABORT);
          }

// claur - Moved to convertToProjity after import Calendar because base calendar must be imported before resources
//      log.info("import resources");     //$NON-NLS-1$
//        if(!importResources()){
//          setProgress(1.0f);
//          errorDescription = ABORT;
//          Environment.setImporting(false); // will avoid certain popups
//          throw new Exception(ABORT);
//        }
        setProgress(1f);
        log.info("END: Import resources");
        return null;
        }
      });
      job.addRunnable(new JobRunnable("Finish import",1.0f){ //$NON-NLS-1$
      public Object run() throws Exception{
        log.info("BEGIN: Finish import");
        Object r=convertToProjity();
        log.info("END: Finish import");
        return r;
View Full Code Here

  /**
   * 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);
          return null;
View Full Code Here

    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){

                    }
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){

                }
View Full Code Here

  protected ProjectData projectData;

    public Job getImportFileJob(){
      final Serializer serializer=new Serializer();
      final FileImporter importer=this;
      final Job job=new Job(importer.getJobQueue(),"importFile",Messages.getString("LocalFileImporter.Importing"),true); //$NON-NLS-1$ //$NON-NLS-2$
        job.addRunnable(new JobRunnable("Import",1.0f){ //$NON-NLS-1$
        public Object run() throws Exception{
              //DataUtil serializer=new DataUtil();
              System.out.println("Loading "+importer.getFileName()+"..."); //$NON-NLS-1$ //$NON-NLS-2$

              long t1=System.currentTimeMillis();
              ObjectInputStream in=new ObjectInputStream(new FileInputStream(importer.getFileName()));
              Object obj=in.readObject();
              if (obj instanceof String) obj=in.readObject(); //check version in the future
              projectData=(ProjectData)obj;
              projectData.setMaster(false);
              projectData.setLocal(false);
              long t2=System.currentTimeMillis();
              System.out.println("Loading...Done in "+(t2-t1)+" ms"); //$NON-NLS-1$ //$NON-NLS-2$

              Collection<ResourceData> rs=(Collection<ResourceData>)projectData.getResources();
              List<EnterpriseResourceData> ers=new ArrayList<EnterpriseResourceData>(rs.size());
              for (ResourceData r: rs){
                ers.add(r.getEnterpriseResource());
              }

        ((ServerFileImporter)importer).prepareResources(ers,null,false);
        renumberProject();

              setProgress(1.0f);
                return null;
        }
        });

      job.addSwingRunnable(new JobRunnable("Import resources",1.0f){ //$NON-NLS-1$
      public Object run() throws Exception{
        ResourceMappingForm form=getResourceMapping();
        if (form!=null&&form.isLocal()) //if form==null we are in a case were have no server access. popup not needed
          if (!job.okCancel(Messages.getString("Message.ServerUnreacheableReadOnlyProject"),true)){ //$NON-NLS-1$
            setProgress(1.0f);
            throw new Exception(ABORT);
          }

        if(!importResources()){
          setProgress(1.0f);
          throw new JobCanceledException(ABORT);
        }
        setProgress(1f);
        return null;
        }
      });

        job.addRunnable(new JobRunnable("Import",1.0f){ //$NON-NLS-1$
        public Object run() throws Exception{
              System.out.println("Deserializing..."); //$NON-NLS-1$
              long t1=System.currentTimeMillis();
              ResourceMappingForm form=getResourceMapping();
//              project=serializer.deserializeProject(projectData,false,true,resourceMap);
View Full Code Here

                return null; //return not used anyway
          }
        };


        Job job=projectFactory.getPortfolio().getRemoveAllProjectsJob(exitRunnable,true,null);
        SessionFactory.getInstance().getLocalSession().schedule(job);

      }
    }).start();
  }
View Full Code Here

        }
            return null;
      }
    };
    final boolean[] closeStatus=new boolean[]{false};
    final Job job=projectFactory.getPortfolio().getRemoveAllProjectsJob(exitRunnable,false,closeStatus);
    SessionFactory.getInstance().getLocalSession().schedule(job);

    synchronized(lock){
      while (!lock[0]){
        try{
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.