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

The following examples show how to use org.activiti.engine.impl.interceptor.CommandContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SubmitStartFormCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
protected ProcessInstance execute(CommandContext commandContext, ProcessDefinition processDefinition) {
    ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition;
    ExecutionEntity processInstance = null;
    if (businessKey != null) {
        processInstance = processDefinitionEntity.createProcessInstance(businessKey);
    } else {
        processInstance = processDefinitionEntity.createProcessInstance();
    }

    commandContext.getHistoryManager()
            .reportFormPropertiesSubmitted(processInstance, properties, null);

    StartFormHandler startFormHandler = processDefinitionEntity.getStartFormHandler();
    startFormHandler.submitFormProperties(properties, processInstance);

    processInstance.start();

    return processInstance;
}
 
Example #2
Source File: MessageEventsAndNewVersionDeploymentsWithTenantIdTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
private List<String> getExecutionIdsForMessageEventSubscription(final String messageName) {
  return managementService.executeCommand(new Command<List<String>>() {
    public List<String> execute(CommandContext commandContext) {
      EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext);
      query.eventType("message");
      query.eventName(messageName);
      query.tenantId(TENANT_ID);
      query.orderByCreated().desc();
      List<EventSubscriptionEntity> eventSubscriptions = query.list();
      
      List<String> executionIds = new ArrayList<String>();
      for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
        executionIds.add(eventSubscription.getExecutionId());
      }
      return executionIds;
    }
  });
}
 
Example #3
Source File: GetTaskFormCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public TaskFormData execute(CommandContext commandContext) {
    TaskEntity task = commandContext
            .getTaskEntityManager()
            .findTaskById(taskId);
    if (task == null) {
        throw new ActivitiObjectNotFoundException("No task found for taskId '" + taskId + "'", Task.class);
    }

    if (task.getTaskDefinition() != null) {
        TaskFormHandler taskFormHandler = task.getTaskDefinition().getTaskFormHandler();
        if (taskFormHandler == null) {
            throw new ActivitiException("No taskFormHandler specified for task '" + taskId + "'");
        }

        return taskFormHandler.createTaskForm(task);
    } else {
        // Standalone task, no TaskFormData available
        return null;
    }
}
 
Example #4
Source File: Activiti5Util.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public static boolean isActiviti5ProcessDefinition(CommandContext commandContext, ProcessDefinition processDefinition) {
  
  if (!commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled()) {
    return false;
  }
  
  if (processDefinition.getEngineVersion() != null) {
    if (Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(processDefinition.getEngineVersion())) {
      if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled()) {
        return true;
      }
    } else {
      throw new ActivitiException("Invalid 'engine' for process definition " + processDefinition.getId() + " : " + processDefinition.getEngineVersion());
    }
  }
  return false;
}
 
Example #5
Source File: JobExecutorCmdHappyTest.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void testJobCommandsWithMessage() {
    ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration();
    CommandExecutor commandExecutor = activiti5ProcessEngineConfig.getCommandExecutor();

    String jobId = commandExecutor.execute(new Command<String>() {

        public String execute(CommandContext commandContext) {
            JobEntity message = createTweetMessage("i'm coding a test");
            commandContext.getJobEntityManager().send(message);
            return message.getId();
        }
    });

    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
    assertEquals(jobId, job.getId());

    assertEquals(0, tweetHandler.getMessages().size());

    activiti5ProcessEngineConfig.getManagementService().executeJob(job.getId());

    assertEquals("i'm coding a test", tweetHandler.getMessages().get(0));
    assertEquals(1, tweetHandler.getMessages().size());
}
 
Example #6
Source File: SubmitTaskFormCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected Void execute(CommandContext commandContext, TaskEntity task) {
  
  // Backwards compatibility
  if (task.getProcessDefinitionId() != null) {
    if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {
      Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); 
      activiti5CompatibilityHandler.submitTaskFormData(taskId, properties, completeTask);
      return null;
    }
  }
  
  commandContext.getHistoryManager().recordFormPropertiesSubmitted(task.getExecution(), properties, taskId);
  
  TaskFormHandler taskFormHandler = FormHandlerUtil.getTaskFormHandlder(task);

  if (taskFormHandler != null) {
    taskFormHandler.submitFormProperties(properties, task.getExecution());

    if (completeTask) {
      executeTaskComplete(commandContext, task, null, false);
    }

  }
  
  return null;
}
 
Example #7
Source File: ActivitySignaledEventHandler.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public EventLogEntryEntity generateEventLogEntry(CommandContext commandContext) {
  ActivitiSignalEvent signalEvent = (ActivitiSignalEvent) event;

  Map<String, Object> data = new HashMap<String, Object>();
  putInMapIfNotNull(data, Fields.ACTIVITY_ID, signalEvent.getActivityId());
  putInMapIfNotNull(data, Fields.ACTIVITY_NAME, signalEvent.getActivityName());
  putInMapIfNotNull(data, Fields.PROCESS_DEFINITION_ID, signalEvent.getProcessDefinitionId());
  putInMapIfNotNull(data, Fields.PROCESS_INSTANCE_ID, signalEvent.getProcessInstanceId());
  putInMapIfNotNull(data, Fields.EXECUTION_ID, signalEvent.getExecutionId());
  putInMapIfNotNull(data, Fields.ACTIVITY_TYPE, signalEvent.getActivityType());
  
  putInMapIfNotNull(data, Fields.SIGNAL_NAME, signalEvent.getSignalName());
  putInMapIfNotNull(data, Fields.SIGNAL_DATA, signalEvent.getSignalData());

  return createEventLogEntry(signalEvent.getProcessDefinitionId(), signalEvent.getProcessInstanceId(), signalEvent.getExecutionId(), null, data);
}
 
Example #8
Source File: HistoricTaskInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public List<HistoricTaskInstance> executeList(CommandContext commandContext, Page page) {
  ensureVariablesInitialized();
  checkQueryOk();
  List<HistoricTaskInstance> tasks = null;
  if (includeTaskLocalVariables || includeProcessVariables) {
    tasks = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesAndVariablesByQueryCriteria(this);
  } else {
    tasks = commandContext.getHistoricTaskInstanceEntityManager().findHistoricTaskInstancesByQueryCriteria(this);
  }
  
  if (tasks != null && Context.getProcessEngineConfiguration().getPerformanceSettings().isEnableLocalization()) {
    for (HistoricTaskInstance task : tasks) {
      localize(task);
    }
  }
  
  return tasks;
}
 
Example #9
Source File: AbstractEventHandler.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void dispatchExecutionCancelled(EventSubscriptionEntity eventSubscription, ExecutionEntity execution, CommandContext commandContext) {
    // subprocesses
    for (ExecutionEntity subExecution : execution.getExecutions()) {
        dispatchExecutionCancelled(eventSubscription, subExecution, commandContext);
    }

    // call activities
    ExecutionEntity subProcessInstance = commandContext.getExecutionEntityManager().findSubProcessInstanceBySuperExecutionId(execution.getId());
    if (subProcessInstance != null) {
        dispatchExecutionCancelled(eventSubscription, subProcessInstance, commandContext);
    }

    // activity with message/signal boundary events
    ActivityImpl activity = execution.getActivity();
    if (activity != null && activity.getActivityBehavior() != null) {
        dispatchActivityCancelled(eventSubscription, execution, activity, commandContext);
    }
}
 
Example #10
Source File: GetExecutionsVariablesCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public List<VariableInstance> execute(CommandContext commandContext) {
  // Verify existence of executions
  if (executionIds == null) {
    throw new ActivitiIllegalArgumentException("executionIds is null");
  }
  if (executionIds.isEmpty()){
    throw new ActivitiIllegalArgumentException("Set of executionIds is empty");
  }
  
  List<VariableInstance> instances = new ArrayList<VariableInstance>();
  List<VariableInstanceEntity> entities = commandContext.getVariableInstanceEntityManager().findVariableInstancesByExecutionIds(executionIds);
  for (VariableInstanceEntity entity : entities){
      entity.getValue();
      instances.add(entity);
  }
  return instances;
}
 
Example #11
Source File: GetJobExceptionStacktraceCmd.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public String execute(CommandContext commandContext) {
    if (jobId == null) {
        throw new ActivitiIllegalArgumentException("jobId is null");
    }

    JobEntity job = commandContext
            .getJobEntityManager()
            .findJobById(jobId);

    if (job == null) {
        throw new ActivitiObjectNotFoundException("No job found with id " + jobId, Job.class);
    }

    return job.getExceptionStacktrace();
}
 
Example #12
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the version on each process definition entity, and the identifier.  If the map contains
 * an older version for a process definition, then the version is set to that older entity's
 * version plus one; otherwise it is set to 1.  Also dispatches an ENTITY_CREATED event.
 */
protected void setProcessDefinitionVersionsAndIds(ParsedDeployment parsedDeployment,
    Map<ProcessDefinitionEntity, ProcessDefinitionEntity> mapNewToOldProcessDefinitions) {
  CommandContext commandContext = Context.getCommandContext();

  for (ProcessDefinitionEntity processDefinition : parsedDeployment.getAllProcessDefinitions()) {
    int version = 1;
    
    ProcessDefinitionEntity latest = mapNewToOldProcessDefinitions.get(processDefinition);
    if (latest != null) {
      version = latest.getVersion() + 1;
    }
    
    processDefinition.setVersion(version);
    processDefinition.setId(getIdForNewProcessDefinition(processDefinition));
    
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, processDefinition));
    }
  }
}
 
Example #13
Source File: BpmnDeploymentTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testDiagramCreationDisabled() {
  // disable diagram generation
  org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti5.engine.impl.cfg.ProcessEngineConfigurationImpl)
      processEngineConfiguration.getActiviti5CompatibilityHandler().getRawProcessConfiguration();
  activiti5ProcessEngineConfig.setCreateDiagramOnDeploy(false);

  try {
    repositoryService.createDeployment()
      .addClasspathResource("org/activiti5/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml")
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();

    // Graphical information is not yet exposed publicly, so we need to do some plumbing
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    ProcessDefinition processDefinition = commandExecutor.execute(new Command<ProcessDefinition>() {
      public ProcessDefinition execute(CommandContext commandContext) {
        return Context.getProcessEngineConfiguration()
                      .getDeploymentManager()
                      .findDeployedLatestProcessDefinitionByKey("myProcess");
      }
    });

    assertNotNull(processDefinition);
    
    // Check that no diagram has been created
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinition.getDeploymentId());
    assertEquals(1, resourceNames.size());

    repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
  } finally {
    activiti5ProcessEngineConfig.setCreateDiagramOnDeploy(true);
  }
}
 
Example #14
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 获得当前任务.
 */
public TaskEntity findTask(CommandContext commandContext) {
    TaskEntity taskEntity = commandContext.getTaskEntityManager()
            .findTaskById(taskId);

    return taskEntity;
}
 
Example #15
Source File: AbstractQuery.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public U executeSingleResult(CommandContext commandContext) {
    List<U> results = executeList(commandContext, null);
    if (results.size() == 1) {
        return results.get(0);
    } else if (results.size() > 1) {
        throw new ActivitiException("Query return " + results.size() + " results instead of max 1");
    }
    return null;
}
 
Example #16
Source File: GetModelEditorSourceCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public byte[] execute(CommandContext commandContext) {
  if (modelId == null) {
    throw new ActivitiIllegalArgumentException("modelId is null");
  }

  byte[] bytes = commandContext.getModelEntityManager().findEditorSourceByModelId(modelId);

  return bytes;
}
 
Example #17
Source File: ContinueProcessOperation.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public ContinueProcessOperation(CommandContext commandContext, ExecutionEntity execution,
    boolean forceSynchronousOperation, boolean inCompensation) {

  super(commandContext, execution);
  this.forceSynchronousOperation = forceSynchronousOperation;
  this.inCompensation = inCompensation;
}
 
Example #18
Source File: BoundaryEventActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void trigger(DelegateExecution execution, String triggerName, Object triggerData) {

  ExecutionEntity executionEntity = (ExecutionEntity) execution;

  CommandContext commandContext = Context.getCommandContext();

  if (interrupting) {
    executeInterruptingBehavior(executionEntity, commandContext);
  } else {
    executeNonInterruptingBehavior(executionEntity, commandContext);
  }
}
 
Example #19
Source File: ExecutionEntityManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
private void deleteProcessInstanceCascade(ExecutionEntity execution, String deleteReason, boolean deleteHistory) {
    CommandContext commandContext = Context.getCommandContext();

    ProcessInstanceQueryImpl processInstanceQuery = new ProcessInstanceQueryImpl(commandContext);
    List<ProcessInstance> subProcesses = processInstanceQuery.superProcessInstanceId(execution.getProcessInstanceId()).list();
    for (ProcessInstance subProcess : subProcesses) {
        deleteProcessInstanceCascade((ExecutionEntity) subProcess, deleteReason, deleteHistory);
    }

    commandContext
            .getTaskEntityManager()
            .deleteTasksByProcessInstanceId(execution.getId(), deleteReason, deleteHistory);

    // fill default reason if none provided
    if (deleteReason == null) {
        deleteReason = "ACTIVITY_DELETED";
    }

    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                ActivitiEventBuilder.createCancelledEvent(execution.getProcessInstanceId(),
                        execution.getProcessInstanceId(), execution.getProcessDefinitionId(), deleteReason));
    }

    // delete the execution BEFORE we delete the history, otherwise we will produce orphan HistoricVariableInstance instances
    execution.deleteCascade(deleteReason);

    if (deleteHistory) {
        commandContext
                .getHistoricProcessInstanceEntityManager()
                .deleteHistoricProcessInstanceById(execution.getId());
    }
}
 
Example #20
Source File: CancelJobsCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Void execute(CommandContext commandContext) {
    JobEntity jobToDelete = null;
    for (String jobId : jobIds) {
        jobToDelete = commandContext
                .getJobEntityManager()
                .findJobById(jobId);

        if (jobToDelete != null) {
            if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
                commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                        ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.JOB_CANCELED, jobToDelete));
            }

            jobToDelete.delete();

        } else {
            TimerJobEntity timerJobToDelete = commandContext.getTimerJobEntityManager().findJobById(jobId);

            if (timerJobToDelete != null) {
                if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
                    commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
                            ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.JOB_CANCELED, timerJobToDelete));
                }

                timerJobToDelete.delete();
            }
        }
    }
    return null;
}
 
Example #21
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public long executeCount(CommandContext commandContext) {
    checkQueryOk();
    ensureVariablesInitialized();
    return commandContext
            .getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstanceCountByQueryCriteria(this);
}
 
Example #22
Source File: EventSubscriptionQueryTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void testQueryByEventType() {

        CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor();
        commandExecutor.execute(new Command<Void>() {
            public Void execute(CommandContext commandContext) {

                MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity();
                messageEventSubscriptionEntity1.setEventName("messageName");
                messageEventSubscriptionEntity1.insert();

                MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity();
                messageEventSubscriptionEntity2.setEventName("messageName");
                messageEventSubscriptionEntity2.insert();

                SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity();
                signalEventSubscriptionEntity3.setEventName("messageName2");
                signalEventSubscriptionEntity3.insert();

                return null;
            }
        });

        List<EventSubscriptionEntity> list = newEventSubscriptionQuery()
                .eventType("signal")
                .list();
        assertEquals(1, list.size());

        list = newEventSubscriptionQuery()
                .eventType("message")
                .list();
        assertEquals(2, list.size());

        cleanDb();

    }
 
Example #23
Source File: MessageEventsAndNewVersionDeploymentsTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
private List<EventSubscriptionEntity> getAllEventSubscriptions() {
  return managementService.executeCommand(new Command<List<EventSubscriptionEntity>>() {
    public List<EventSubscriptionEntity> execute(CommandContext commandContext) {
      EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext);
      query.orderByCreated().desc();
      
      List<EventSubscriptionEntity> eventSubscriptionEntities = query.list();
      for (EventSubscriptionEntity entity : eventSubscriptionEntities) {
        assertEquals("message", entity.getEventType());
        assertNotNull(entity.getProcessDefinitionId());
      }
      return eventSubscriptionEntities;
    }
  });
}
 
Example #24
Source File: ProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public long executeCount(CommandContext commandContext) {
    checkQueryOk();
    ensureVariablesInitialized();
    return commandContext
            .getExecutionEntityManager()
            .findProcessInstanceCountByQueryCriteria(this);
}
 
Example #25
Source File: HistoryProcessInstanceDiagramCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public InputStream execute(CommandContext commandContext) {
    try {
        CustomProcessDiagramGenerator customProcessDiagramGenerator = new CustomProcessDiagramGenerator();

        return customProcessDiagramGenerator
                .generateDiagram(historyProcessInstanceId);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example #26
Source File: BpmnDeploymentTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testDiagramCreationDisabled() {
  // disable diagram generation
  processEngineConfiguration.setCreateDiagramOnDeploy(false);

  try {
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy();

    // Graphical information is not yet exposed publicly, so we need to
    // do some plumbing
    CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
    ProcessDefinition processDefinition = commandExecutor.execute(new Command<ProcessDefinition>() {
      public ProcessDefinition execute(CommandContext commandContext) {
        return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("myProcess");
      }
    });

    assertNotNull(processDefinition);
    BpmnModel processModel = repositoryService.getBpmnModel(processDefinition.getId());
    assertEquals(14, processModel.getMainProcess().getFlowElements().size());
    assertEquals(7, processModel.getMainProcess().findFlowElementsOfType(SequenceFlow.class).size());

    // Check that no diagram has been created
    List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinition.getDeploymentId());
    assertEquals(1, resourceNames.size());

    repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true);
  } finally {
    processEngineConfiguration.setCreateDiagramOnDeploy(true);
  }
}
 
Example #27
Source File: GetIdentityLinksForProcessInstanceCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
  ExecutionEntity processInstance = commandContext.getExecutionEntityManager().findById(processInstanceId);

  if (processInstance == null) {
    throw new ActivitiObjectNotFoundException("Cannot find process definition with id " + processInstanceId, ExecutionEntity.class);
  }

  return (List) processInstance.getIdentityLinks();
}
 
Example #28
Source File: SetDeploymentKeyCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {

    if (deploymentId == null) {
      throw new ActivitiIllegalArgumentException("Deployment id is null");
    }

    DeploymentEntity deployment = commandContext.getDeploymentEntityManager().findById(deploymentId);

    if (deployment == null) {
      throw new ActivitiObjectNotFoundException("No deployment found for id = '" + deploymentId + "'", Deployment.class);
    }
    
    if (commandContext.getProcessEngineConfiguration().isActiviti5CompatibilityEnabled() && 
        Activiti5CompatibilityHandler.ACTIVITI_5_ENGINE_TAG.equals(deployment.getEngineVersion())) {
      
      return null;
    }

    // Update category
    deployment.setKey(key);

    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
      commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, deployment));
    }

    return null;
  }
 
Example #29
Source File: SetJobRetriesCmd.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public Void execute(CommandContext commandContext) {
  JobEntity job = commandContext.getJobEntityManager().findById(jobId);
  if (job != null) {
    
    job.setRetries(retries);

    if (commandContext.getEventDispatcher().isEnabled()) {
      commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_UPDATED, job));
    }
  } else {
    throw new ActivitiObjectNotFoundException("No job found with id '" + jobId + "'.", Job.class);
  }
  return null;
}
 
Example #30
Source File: BpmnDeployer.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
protected boolean localizeDataObjectElements(List<ValuedDataObject> dataObjects, ObjectNode infoNode) {
  boolean localizationValuesChanged = false;
  CommandContext commandContext = Context.getCommandContext();
  DynamicBpmnService dynamicBpmnService = commandContext.getProcessEngineConfiguration().getDynamicBpmnService();

  for(ValuedDataObject dataObject : dataObjects) {
    List<ExtensionElement> localizationElements = dataObject.getExtensionElements().get("localization");
    if (localizationElements != null) {
      for (ExtensionElement localizationElement : localizationElements) {
        if (BpmnXMLConstants.ACTIVITI_EXTENSIONS_PREFIX.equals(localizationElement.getNamespacePrefix())) {
          String locale = localizationElement.getAttributeValue(null, "locale");
          String name = localizationElement.getAttributeValue(null, "name");
          String documentation = null;

          List<ExtensionElement> documentationElements = localizationElement.getChildElements().get("documentation");
          if (documentationElements != null) {
            for (ExtensionElement documentationElement : documentationElements) {
              documentation = StringUtils.trimToNull(documentationElement.getElementText());
              break;
            }
          }
          
          if (name != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), DynamicBpmnConstants.LOCALIZATION_NAME, name, infoNode) == false) {
            dynamicBpmnService.changeLocalizationName(locale, dataObject.getId(), name, infoNode);
            localizationValuesChanged = true;
          }
          
          if (documentation != null && isEqualToCurrentLocalizationValue(locale, dataObject.getId(), 
              DynamicBpmnConstants.LOCALIZATION_DESCRIPTION, documentation, infoNode) == false) {
            
            dynamicBpmnService.changeLocalizationDescription(locale, dataObject.getId(), documentation, infoNode);
            localizationValuesChanged = true;
          }
        }
      }
    }
  }
  
  return localizationValuesChanged;
}