Package org.jbpm.pvm.internal.env

Examples of org.jbpm.pvm.internal.env.Environment


  }

  public ProcessDefinitionRef getProcessDefinition(String procDefId)
  {

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
          .processDefinitionId(procDefId)
          .uniqueResult();
      return ModelAdaptor.adoptDefinition(processDefinition);

    }
    finally
    {
      env.close();
    }
  }
View Full Code Here


    }
  }

  public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {

      RepositoryService repositoryService = this.processEngine.getRepositoryService();
      ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
          .processDefinitionId(procDefId)
          .uniqueResult();
      if (processDefinition!=null) {
        repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentId());
      }
      return getProcessDefinitions();
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

    }
  }

  public List<ProcessInstanceRef> getProcessInstances(String procDefId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {

      ExecutionService execService = this.processEngine.getExecutionService();
      ProcessInstanceQuery query = execService.createProcessInstanceQuery();
      query.processDefinitionId(String.valueOf(procDefId));

      List<ProcessInstance> processInstances = query.list();

      List<ProcessInstanceRef> results = adoptProcessInstances(processInstances);

      // add history info
      // TODO: optimize w. batch query
      HistoryService histService = this.processEngine.getHistoryService();
      for(ProcessInstanceRef inst : results)
      {
        HistoryProcessInstanceQuery hQuery = histService.createHistoryProcessInstanceQuery();
        hQuery.processInstanceId(inst.getId());
        HistoryProcessInstance entry = hQuery.uniqueResult();
        inst.setStartDate(entry.getStartTime());
      }

      return results;
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

    }
  }

  private List<ProcessInstanceRef> adoptProcessInstances(List<ProcessInstance> processInstances)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {

      List<ProcessInstanceRef> results = new ArrayList<ProcessInstanceRef>();
      for(Execution processInstance : processInstances)
      {
        if(processInstance.isEnded())
        {
          //JBPM-2055: Execution is already ended. Should not show up in query
          continue;
        }

        if(processInstance.isProcessInstance()) // parent execution
        {
          results.add( ModelAdaptor.adoptExecution((ExecutionImpl)processInstance) );
        }
      }
      return results;
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

    }
  }

  public ProcessInstanceRef getProcessInstance(String instanceId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      ProcessInstanceQuery query = execService.createProcessInstanceQuery();
      query.processInstanceId(instanceId);
      ProcessInstance processInstance = query.uniqueResult();
      return ModelAdaptor.adoptExecution( (ExecutionImpl)processInstance);
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

  public Map<String, Object> getInstanceData(String instanceId)
  {
    Map<String, Object> data = new HashMap<String, Object>();

    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      Set<String> keys = execService.getVariableNames(instanceId);
      data = execService.getVariables(instanceId, keys);
    }
    finally
    {
      env.close();
    }

    return data;
  }
View Full Code Here

    throw new RuntimeException("Not implemented");
  }

  public ProcessInstanceRef newInstance(String definitionId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.startProcessInstanceById(definitionId);
      return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
    }
    finally{
      env.close();
    }
  }
View Full Code Here

  }


  public ProcessInstanceRef newInstance(String definitionId, Map<String, Object> processVars)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.startProcessInstanceById(definitionId);
      execService.setVariables(exec.getId(), processVars);
     
      return ModelAdaptor.adoptExecution((ExecutionImpl)exec);
    }
    finally{
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void endInstance(String instanceId, ProcessInstanceRef.RESULT result)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {

      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.findExecutionById(instanceId);
      if(null==exec)
        throw new IllegalArgumentException("No such execution with id "+ instanceId);

      ProcessInstanceRef.RESULT actualResult = result!=null ? result : ProcessInstanceRef.RESULT.COMPLETED;
      execService.endProcessInstance(instanceId, actualResult.toString());
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void deleteInstance(String instanceId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {

      ExecutionService execService = this.processEngine.getExecutionService();
      Execution exec = execService.findExecutionById(instanceId);
      if(null==exec)
        throw new IllegalArgumentException("No such execution with id "+ instanceId);

      execService.deleteProcessInstance(instanceId);
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.env.Environment

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.