Package org.jbpm.pvm.internal.env

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


  public List<JobRef> getJobs()
  {
    List<JobRef> results = new ArrayList<JobRef>();

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

    try
    {
      ManagementService mgmtService = this.processEngine.getManagementService();

      // jobs
      JobQuery timerQuery = mgmtService.createJobQuery();
      timerQuery.timers();
      List<Job> timers = timerQuery.list();
      for(Job t : timers)
      {
        JobRef ref = ModelAdaptor.adoptJob(t);
        ref.setType("timer");
        results.add(ref);
      }

      // messages
      JobQuery msgQuery= mgmtService.createJobQuery();
      msgQuery.messages();
      List<Job> msgs = msgQuery.list();
      for(Job t : msgs)
      {
        JobRef ref = ModelAdaptor.adoptJob(t);
        ref.setType("message");
        results.add(ref);
      }
    }
    finally
    {
      env.close();
    }

    return results;
  }
View Full Code Here


  }


  public void executeJob(String jobId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      ManagementService mgmtService = this.processEngine.getManagementService();
      mgmtService.executeJob(jobId);
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

*/
public class TaskManagementImpl extends JBPMIntegration implements TaskManagement
{
  public List<TaskRef> getAssignedTasks(String idRef)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      List<TaskRef> results = new ArrayList<TaskRef>();

      List<Task> assignedTasks = taskService.findPersonalTasks(idRef);
      adoptTasks(assignedTasks, results);

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

    }
  }

  public List<TaskRef> getUnassignedTasks(String idRef, String participationType)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      List<TaskRef> results = new ArrayList<TaskRef>();

      if(null==participationType || participationType.equals(Participation.CANDIDATE))
      {
        List<Task> groupTasks = taskService.findGroupTasks(idRef);
        adoptTasks(groupTasks, results);
      }
      else
      {
        throw new IllegalArgumentException("Unknown participation type: " +participationType);
      }

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

    }
  }

  public TaskRef getTaskById(long taskId)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      Task t0 = taskService.getTask(Long.toString(taskId));
      return ModelAdaptor.adoptTask(t0);
    }
    finally{
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void assignTask(long taskId, String idRef, String performingUser)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      taskService.assignTask(Long.toString(taskId), idRef);
    }
    finally{
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void releaseTask(long taskId, String performingUser)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      taskService.assignTask(Long.toString(taskId), null);
    }
    finally{
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void completeTask(long taskId, Map data, String performingUser)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      if(data!=null)
        taskService.setVariables(Long.toString(taskId), data);

      taskService.completeTask(Long.toString(taskId));
    }
    finally{
      env.close();
    }
  }
View Full Code Here

    }
  }

  public void completeTask(long taskId, String outcome, Map data, String performingUser)
  {
    Environment env = ((EnvironmentFactory)processEngine).openEnvironment();

    try
    {
      TaskService taskService = this.processEngine.get(TaskService.class);
      if(data!=null)
        taskService.setVariables(Long.toString(taskId), data);

      taskService.completeTask(Long.toString(taskId), outcome);
    }
    finally
    {
      env.close();
    }
  }
View Full Code Here

class ProcessManagementImpl extends JBPMIntegration implements ProcessManagement
{

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

    try
    {
      List<ProcessDefinitionRef> results = new ArrayList<ProcessDefinitionRef>();

      RepositoryService repositoryService = this.processEngine.getRepositoryService();

      // active processes
      List<ProcessDefinition> activePds = repositoryService.createProcessDefinitionQuery()
          .notSuspended()
          .orderAsc(ProcessDefinitionQuery.PROPERTY_NAME)
          .list();
    
      for(ProcessDefinition processDefinition : activePds)
      {
        ProcessDefinitionRef ref = ModelAdaptor.adoptDefinition(processDefinition);
        results.add(ref);
      }

      // suspended  processes
      ProcessDefinitionQuery pdQuery2 = repositoryService.createProcessDefinitionQuery();
      pdQuery2.suspended();
      List<ProcessDefinition> suspendedPds = pdQuery2.list();

      for(ProcessDefinition p : suspendedPds)
      {
        ProcessDefinitionRef ref = ModelAdaptor.adoptDefinition(p);
        ref.setSuspended(true);       
        results.add(ref);
      }

      return results;
    }
    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.