Package org.jbpm.pvm.internal.session

Examples of org.jbpm.pvm.internal.session.DbSession


  public TaskActivityStart(TaskImpl task) {
    this.task = task;
  }
 
  public void process() {
    DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);

    ExecutionImpl processInstance = execution.getProcessInstance();
    long processInstanceDbid = processInstance.getDbid();

    HistoryProcessInstance historyProcessInstance =
        dbSession.get(HistoryProcessInstanceImpl.class, processInstanceDbid);
   
    HistoryTaskImpl historyTask = new HistoryTaskImpl(task);
    historyTask.setExecutionId(execution.getId());
   
    HistoryActivityInstanceImpl historyActivityInstance =
        new HistoryTaskInstanceImpl(historyProcessInstance, execution, historyTask);
   
    String activityType = execution.getActivity().getType();
    historyActivityInstance.setType(activityType);
   
    dbSession.save(historyActivityInstance);
   
    execution.setHistoryActivityInstanceDbid(historyActivityInstance.getDbid());
  }
View Full Code Here


  public void setVariables(Map<String, ?> variables) {
    this.variables = variables;
  }

  protected ClientExecution getExecution(Environment environment, String executionId) {
    DbSession dbSession = environment.get(DbSession.class);
    ClientExecution execution = dbSession.findExecutionById(executionId);
    if (execution == null) {
      throw new JbpmException("execution " + executionId + " doesn't exist");
    }
    return execution;
  }
View Full Code Here

  public void process() {
   
    if (processDefinition == null || processInstance == null || !(processInstance instanceof ExecutionImpl)) return;
   
    DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);

    HistoryProcessInstanceImpl historyProcessInstance = null;
    long processInstanceDbid = ((ExecutionImpl)processInstance).getDbid();
    historyProcessInstance = (HistoryProcessInstanceImpl)dbSession.get(HistoryProcessInstanceImpl.class, processInstanceDbid);
    if (historyProcessInstance == null) return;
   
    String oldVersion = historyProcessInstance.getProcessDefinitionId();
    String newVersion = processDefinition.getId();
   
    historyProcessInstance.setProcessDefinitionId(newVersion);
    HistoryProcessInstanceMigrationImpl historyProcessInstanceMigration =
        new HistoryProcessInstanceMigrationImpl(oldVersion, newVersion);
    historyProcessInstance.addDetail(historyProcessInstanceMigration);
   
   
    dbSession.save(historyProcessInstanceMigration);
  }
View Full Code Here

    Collection<Long> acquiredJobDbids = new ArrayList<Long>();

    try {
      Collection<JobImpl<?>> acquiredJobs = new ArrayList<JobImpl<?>>();
     
      DbSession dbSession = environment.get(DbSession.class);
      if (log.isTraceEnabled()) log.trace("start querying first acquirable job...");

      JobImpl<?> job = dbSession.findFirstAcquirableJob();

      if (job!=null) {
        if (job.isExclusive()) {
          if (log.isTraceEnabled()) log.trace("exclusive acquirable job found ("+job+"). querying for other exclusive jobs to lock them all in one tx...");
          List<JobImpl<?>> otherExclusiveJobs = dbSession.findExclusiveJobs(job.getProcessInstance());
          acquiredJobs.addAll(otherExclusiveJobs);
        } else {
          acquiredJobs.add(job);
        }
View Full Code Here

  public TaskCreated(TaskImpl task) {
    this.task = task;
  }

  public void process() {
    DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class);
    HistoryTaskImpl historyTask = new HistoryTaskImpl(task);
    dbSession.save(historyTask);
   
    if (task.getSuperTask()!=null) {
      HistoryTaskImpl superHistoryTask = dbSession.get(HistoryTaskImpl.class, task.getSuperTask().getDbid());
      superHistoryTask.addSubTask(historyTask);
    }
  }
View Full Code Here

    return lob.extractBytes();
  }

  public void setObject(Object value) {
    if (this.lob!=null) {
      DbSession dbSession = EnvironmentImpl.getFromCurrent(DbSession.class, false);
      if (dbSession!=null) {
        dbSession.delete(this.lob);
      }
    }
    this.lob = new Lob((byte[])value, true);
  }
View Full Code Here

  public Object execute(Environment environment) throws Exception {
    Command<?> command = (Command<?>) getConfiguration();
    command.execute(environment);
   
    DbSession dbSession = environment.get(DbSession.class);
    dbSession.delete(this);

    return null;
  }
View Full Code Here

    this.taskId = taskId;
    this.outcomeSpecified = false;
  }

  public Void execute(Environment environment) throws Exception {
    DbSession dbSession = environment.get(DbSession.class);
   
    if (taskId == null || "".equals(taskId)) {
      throw new JbpmException("Cannot complete a task with a null or empty taskId");
    }
   
    TaskImpl task = dbSession.get(TaskImpl.class, Long.parseLong(taskId));
   
    if (task == null) {
      throw new JbpmException("No task with id " + taskId + " was found");
    }
   
    if (outcomeSpecified) {
      task.complete(outcome);
    } else {
      task.complete();
    }
    dbSession.delete(task);
    return null;
  }
View Full Code Here

    this.deleteProcessInstances = deleteProcessInstances;
    this.deleteHistory = deleteHistory;
  }

  public Void execute(Environment environment) {
    DbSession dbSession = environment.get(DbSession.class);
    if (dbSession==null) {
      throw new JbpmException("no "+DbSessionBinding.TAG+" configured");
    }
    dbSession.deleteProcessDefinition(processDefinitionId, deleteProcessInstances, deleteHistory);
    return null;
  }
View Full Code Here

    boolean deleteThisJob = true;
    // if there is no repeat on this timer
    if (repeat==null) {
      // delete the job
      if (log.isDebugEnabled()) log.debug("deleting " + this);
      DbSession dbSession = environment.get(DbSession.class);
      if (dbSession==null) {
        throw new JbpmException("no "+DbSession.class.getName()+" in environment");
      }
      dbSession.delete(this);

    } else { // there is a repeat on this timer
      deleteThisJob = false;
      // suppose that it took the timer runner thread a very long time to execute the timers
      // then the repeat action duedate could already have passed
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.session.DbSession

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.