Package org.activiti.engine.impl.interceptor

Examples of org.activiti.engine.impl.interceptor.CommandContext


 
  public void deleteHistoricTaskInstanceById(String taskId) {
    if (getHistoryManager().isHistoryEnabled()) {
      HistoricTaskInstanceEntity historicTaskInstance = findHistoricTaskInstanceById(taskId);
      if(historicTaskInstance!=null) {
        CommandContext commandContext = Context.getCommandContext();
       
        commandContext
          .getHistoricDetailManager()
          .deleteHistoricDetailsByTaskId(taskId);

        commandContext
          .getHistoricVariableInstanceManager()
          .deleteHistoricVariableInstancesByTaskId(taskId);

        commandContext
          .getCommentManager()
          .deleteCommentsByTaskId(taskId);
       
        commandContext
          .getAttachmentManager()
          .deleteAttachmentsByTaskId(taskId);
     
        getDbSqlSession().delete(historicTaskInstance);
      }
View Full Code Here


  @SuppressWarnings({ "unchecked", "rawtypes" })
  public void setReplacedBy(InterpretableExecution replacedBy) {
    this.replacedBy = (ExecutionEntity) replacedBy;
   
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();

    // update the related tasks
    for (TaskEntity task: getTasks()) {
      task.setExecutionId(replacedBy.getId());
      task.setExecution(this.replacedBy);
      this.replacedBy.addTask(task);
    }
   
    // All tasks have been moved to 'replacedBy', safe to clear the list
    this.tasks.clear();
   
    tasks = dbSqlSession.findInCache(TaskEntity.class);
    for (TaskEntity task: tasks) {
      if (id.equals(task.getExecutionId())) {
        task.setExecutionId(replacedBy.getId());
      }
    }
   
    // update the related jobs
    List<JobEntity> jobs = getJobs();
    for (JobEntity job: jobs) {
      job.setExecution((ExecutionEntity) replacedBy);
    }
   
    // update the related event subscriptions
    List<EventSubscriptionEntity> eventSubscriptions = getEventSubscriptions();
    for (EventSubscriptionEntity subscriptionEntity: eventSubscriptions) {
      subscriptionEntity.setExecution((ExecutionEntity) replacedBy);
    }
   
    // update the related process variables
    List<VariableInstanceEntity> variables = (List) commandContext
      .getVariableInstanceManager()
      .findVariableInstancesByExecutionId(id);
   
    for (VariableInstanceEntity variable: variables) {
      variable.setExecutionId(replacedBy.getId());
    }
    variables = dbSqlSession.findInCache(VariableInstanceEntity.class);
    for (VariableInstanceEntity variable: variables) {
      if (id.equals(variable.getExecutionId())) {
        variable.setExecutionId(replacedBy.getId());
      }
    }
   
    commandContext.getHistoryManager()
      .recordExecutionReplacedBy(this, replacedBy);
  }
View Full Code Here

    ((ModelEntity) model).setCreateTime(new Date());
    getDbSqlSession().insert((PersistentObject) model);
  }

  public void updateModel(ModelEntity updatedModel) {
    CommandContext commandContext = Context.getCommandContext();
    DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
    dbSqlSession.update(updatedModel);
  }
View Full Code Here

  public void deleteTask(TaskEntity task, String deleteReason, boolean cascade) {
    if (!task.isDeleted()) {
      task.setDeleted(true);
     
      CommandContext commandContext = Context.getCommandContext();
      String taskId = task.getId();
     
      List<Task> subTasks = findTasksByParentTaskId(taskId);
      for (Task subTask: subTasks) {
        deleteTask((TaskEntity) subTask, deleteReason, cascade);
      }
     
      commandContext
        .getIdentityLinkManager()
        .deleteIdentityLinksByTaskId(taskId);

      commandContext
        .getVariableInstanceManager()
        .deleteVariableInstanceByTask(task);

      if (cascade) {
        commandContext
          .getHistoricTaskInstanceManager()
          .deleteHistoricTaskInstanceById(taskId);
      } else {
        commandContext
          .getHistoryManager()
          .recordTaskEnd(taskId, deleteReason);
      }
       
      getDbSqlSession().delete(task);
View Full Code Here

    eventHandler.handleEvent(this, payload, Context.getCommandContext());
  }
 
  protected void scheduleEventAsync(Serializable payload) {
   
    final CommandContext commandContext = Context.getCommandContext();

    MessageEntity message = new MessageEntity();
    message.setJobHandlerType(ProcessEventJobHandler.TYPE);
    message.setJobHandlerConfiguration(id);

    // TODO: support payload
//    if(payload != null) {
//      message.setEventPayload(payload);
//    }
   
    commandContext.getJobManager().send(message);
  }
View Full Code Here

    params.put("tenantId", newTenantId);
    getDbSqlSession().update("updateExecutionTenantIdForDeployment", params);
  }
 
  public void updateProcessInstanceLockTime(String processInstanceId) {
    CommandContext commandContext = Context.getCommandContext();
    Date lockTime = commandContext.getProcessEngineConfiguration().getClock().getCurrentTime();
   
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("id", processInstanceId);
    params.put("lockTime", lockTime);
   
View Full Code Here

  public void deleteTask(TaskEntity task, String deleteReason, boolean cascade) {
    if (!task.isDeleted()) {
       task.fireEvent(TaskListener.EVENTNAME_DELETE);
      task.setDeleted(true);
     
      CommandContext commandContext = Context.getCommandContext();
      String taskId = task.getId();
     
      List<Task> subTasks = findTasksByParentTaskId(taskId);
      for (Task subTask: subTasks) {
        deleteTask((TaskEntity) subTask, deleteReason, cascade);
      }
     
      commandContext
        .getIdentityLinkEntityManager()
        .deleteIdentityLinksByTaskId(taskId);

      commandContext
        .getVariableInstanceEntityManager()
        .deleteVariableInstanceByTask(task);

      if (cascade) {
        commandContext
          .getHistoricTaskInstanceEntityManager()
          .deleteHistoricTaskInstanceById(taskId);
      } else {
        commandContext
          .getHistoryManager()
          .recordTaskEnd(taskId, deleteReason);
      }
       
      getDbSqlSession().delete(task);
     
      if(commandContext.getEventDispatcher().isEnabled()) {
        commandContext.getEventDispatcher().dispatchEvent(
            ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, task));
      }
    }
  }
View Full Code Here

    this.job = job;
    this.commandExecutor = commandExecutor;
  }

  public void run() {
    CommandContext commandContext = Context.getCommandContext();
   
    try {
      if (job.isExclusive()) {
        commandExecutor.execute(new LockExclusiveJobCmd(job));
      }
     
    } catch (ActivitiOptimisticLockingException optimisticLockingException) {
      if (log.isDebugEnabled()) {
        log.debug("Optimistic locking exception during exclusive job acquisition. If you have multiple job executors running against the same database, " +
            "this exception means that this thread tried to acquire an exclusive job, which already was changed by another async executor thread." +
            "This is expected behavior in a clustered environment. " +
            "You can ignore this message if you indeed have multiple job executor acquisition threads running against the same database. " +
            "Exception message: {}", optimisticLockingException.getMessage());
      }
     
      commandContext.getJobEntityManager().retryAsyncJob(job);
      return;
   
    } catch (Throwable t) {
      log.error("Error while locking exclusive job " + job.getId(), t);
      return;
View Full Code Here

      if (event.getProcessInstanceId() == null && processInstanceScope) {
        throw new ActivitiIllegalArgumentException(
            "Cannot throw process-instance scoped signal, since the dispatched event is not part of an ongoing process instance");
      }

      CommandContext commandContext = Context.getCommandContext();
      List<SignalEventSubscriptionEntity> subscriptionEntities = null;
      if (processInstanceScope) {
        subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
            .findSignalEventSubscriptionsByProcessInstanceAndEventName(event.getProcessInstanceId(), signalName);
      } else {
        String tenantId = null;
        if (event.getProcessDefinitionId() != null) {
          ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessEngineConfiguration()
              .getDeploymentManager().findDeployedProcessDefinitionById(event.getProcessDefinitionId());
          tenantId = processDefinitionEntity.getTenantId();
        }
        subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
            .findSignalEventSubscriptionsByEventName(signalName, tenantId);
      }

      for (SignalEventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) {
        signalEventSubscriptionEntity.eventReceived(null, false);
View Full Code Here

      if (event.getProcessInstanceId() == null) {
        throw new ActivitiIllegalArgumentException(
            "Cannot throw process-instance scoped message, since the dispatched event is not part of an ongoing process instance");
      }
 
      CommandContext commandContext = Context.getCommandContext();
      List<EventSubscriptionEntity> subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
            .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, event.getExecutionId());
 
      // Revert to messaging the process instance
      if(subscriptionEntities.isEmpty() && event.getProcessInstanceId() != null && !event.getExecutionId().equals(event.getProcessInstanceId())) {
        subscriptionEntities = commandContext.getEventSubscriptionEntityManager()
            .findEventSubscriptionsByNameAndExecution(MessageEventHandler.EVENT_HANDLER_TYPE, messageName, event.getProcessInstanceId());
      }
     
      for (EventSubscriptionEntity signalEventSubscriptionEntity : subscriptionEntities) {
        signalEventSubscriptionEntity.eventReceived(null, false);
View Full Code Here

TOP

Related Classes of org.activiti.engine.impl.interceptor.CommandContext

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.