org.flowable.engine.impl.util.CommandContextUtil Java Examples
The following examples show how to use
org.flowable.engine.impl.util.CommandContextUtil.
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: MultiInstanceActivityBehavior.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void executeCompensationBoundaryEvents(FlowElement flowElement, DelegateExecution execution) { // Execute compensation boundary events Collection<BoundaryEvent> boundaryEvents = findBoundaryEventsForFlowNode(execution.getProcessDefinitionId(), flowElement); if (CollectionUtil.isNotEmpty(boundaryEvents)) { // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions())) { continue; } if (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) { ExecutionEntity childExecutionEntity = CommandContextUtil.getExecutionEntityManager() .createChildExecution((ExecutionEntity) execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); ActivityBehavior boundaryEventBehavior = ((ActivityBehavior) boundaryEvent.getBehavior()); boundaryEventBehavior.execute(childExecutionEntity); } } } }
Example #2
Source File: ParallelMultiInstanceBehavior.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void lockFirstParentScope(DelegateExecution execution) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(); boolean found = false; ExecutionEntity parentScopeExecution = null; ExecutionEntity currentExecution = (ExecutionEntity) execution; while (!found && currentExecution != null && currentExecution.getParentId() != null) { parentScopeExecution = executionEntityManager.findById(currentExecution.getParentId()); if (parentScopeExecution != null && parentScopeExecution.isScope()) { found = true; } currentExecution = parentScopeExecution; } parentScopeExecution.forceUpdate(); }
Example #3
Source File: EndExecutionOperation.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void scheduleAsyncCompleteCallActivity(ExecutionEntity superExecutionEntity, ExecutionEntity childProcessInstanceExecutionEntity) { JobService jobService = CommandContextUtil.getJobService(commandContext); JobEntity job = jobService.createJob(); // Needs to be the parent process instance, as the parent needs to be locked to avoid concurrency when multiple call activities are ended job.setExecutionId(superExecutionEntity.getId()); // Child execution of subprocess is passed as configuration job.setJobHandlerConfiguration(childProcessInstanceExecutionEntity.getId()); String processInstanceId = superExecutionEntity.getProcessInstanceId() != null ? superExecutionEntity.getProcessInstanceId() : superExecutionEntity.getId(); job.setProcessInstanceId(processInstanceId); job.setProcessDefinitionId(childProcessInstanceExecutionEntity.getProcessDefinitionId()); job.setElementId(superExecutionEntity.getCurrentFlowElement().getId()); job.setElementName(superExecutionEntity.getCurrentFlowElement().getName()); job.setTenantId(childProcessInstanceExecutionEntity.getTenantId()); job.setJobHandlerType(AsyncCompleteCallActivityJobHandler.TYPE); superExecutionEntity.getJobs().add(job); jobService.createAsyncJob(job, true); // Always exclusive to avoid concurrency problems jobService.scheduleAsyncJob(job); }
Example #4
Source File: SetProcessDefinitionVersionCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected void validateAndSwitchVersionOfExecution(CommandContext commandContext, ExecutionEntity execution, ProcessDefinition newProcessDefinition) { // check that the new process definition version contains the current activity org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(newProcessDefinition.getId()); if (execution.getActivityId() != null && process.getFlowElement(execution.getActivityId(), true) == null) { throw new FlowableException("The new process definition " + "(key = '" + newProcessDefinition.getKey() + "') " + "does not contain the current activity " + "(id = '" + execution.getActivityId() + "') " + "of the process instance " + "(id = '" + processInstanceId + "')."); } // switch the process instance to the new process definition version execution.setProcessDefinitionId(newProcessDefinition.getId()); execution.setProcessDefinitionName(newProcessDefinition.getName()); execution.setProcessDefinitionKey(newProcessDefinition.getKey()); // and change possible existing tasks (as the process definition id is stored there too) List<TaskEntity> tasks = CommandContextUtil.getTaskService(commandContext).findTasksByExecutionId(execution.getId()); Clock clock = commandContext.getCurrentEngineConfiguration().getClock(); for (TaskEntity taskEntity : tasks) { taskEntity.setProcessDefinitionId(newProcessDefinition.getId()); CommandContextUtil.getActivityInstanceEntityManager(commandContext).recordTaskInfoChange(taskEntity, clock.getCurrentTime()); } }
Example #5
Source File: JobQueryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test public void testQueryByHandlerType() { final JobEntity job = (JobEntity) managementService.createJobQuery().singleResult(); job.setJobHandlerType("test"); managementService.executeCommand(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { CommandContextUtil.getJobService(commandContext).updateJob(job); return null; } }); Job handlerTypeJob = managementService.createJobQuery().handlerType("test").singleResult(); assertThat(handlerTypeJob).isNotNull(); }
Example #6
Source File: AbstractExternalWorkerJobCmd.java From flowable-engine with Apache License 2.0 | 6 votes |
protected ExternalWorkerJobEntity resolveJob(CommandContext commandContext) { if (StringUtils.isEmpty(externalJobId)) { throw new FlowableIllegalArgumentException("externalJobId must not be empty"); } if (StringUtils.isEmpty(workerId)) { throw new FlowableIllegalArgumentException("workerId must not be empty"); } JobServiceConfiguration jobServiceConfiguration = CommandContextUtil.getJobServiceConfiguration(commandContext); ExternalWorkerJobEntityManager externalWorkerJobEntityManager = jobServiceConfiguration.getExternalWorkerJobEntityManager(); ExternalWorkerJobEntity job = externalWorkerJobEntityManager.findById(externalJobId); if (job == null) { throw new FlowableObjectNotFoundException("No External Worker job found for id: " + externalJobId, ExternalWorkerJobEntity.class); } if (!Objects.equals(workerId, job.getLockOwner())) { throw new FlowableIllegalArgumentException(workerId + " does not hold a lock on the requested job"); } return job; }
Example #7
Source File: BoundaryEventRegistryEventActivityBehavior.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void trigger(DelegateExecution execution, String triggerName, Object triggerData) { ExecutionEntity executionEntity = (ExecutionEntity) execution; BoundaryEvent boundaryEvent = (BoundaryEvent) execution.getCurrentFlowElement(); Object eventInstance = execution.getTransientVariables().get(EventConstants.EVENT_INSTANCE); if (eventInstance instanceof EventInstance) { EventInstanceBpmnUtil.handleEventInstanceOutParameters(execution, boundaryEvent, (EventInstance) eventInstance); } if (boundaryEvent.isCancelActivity()) { EventSubscriptionService eventSubscriptionService = CommandContextUtil.getEventSubscriptionService(); List<EventSubscriptionEntity> eventSubscriptions = executionEntity.getEventSubscriptions(); CommandContext commandContext = Context.getCommandContext(); String eventDefinitionKey = getEventDefinitionKey(commandContext, executionEntity); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { if (Objects.equals(eventDefinitionKey, eventSubscription.getEventType())) { eventSubscriptionService.deleteEventSubscription(eventSubscription); CountingEntityUtil.handleDeleteEventSubscriptionEntityCount(eventSubscription); } } } super.trigger(executionEntity, triggerName, triggerData); }
Example #8
Source File: EventDefinitionExpressionUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
/** * Determines the signal name of the {@link SignalEventDefinition} that is passed: * - if a signal name is set, it has precedence * - otherwise, the signal ref is used * - unless a signalExpression is set */ public static String determineSignalName(CommandContext commandContext, SignalEventDefinition signalEventDefinition, BpmnModel bpmnModel, DelegateExecution execution) { String signalName = null; if (StringUtils.isNotEmpty(signalEventDefinition.getSignalRef())) { Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef()); if (signal != null) { signalName = signal.getName(); } else { signalName = signalEventDefinition.getSignalRef(); } } else { signalName = signalEventDefinition.getSignalExpression(); } if (StringUtils.isNotEmpty(signalName)) { Expression expression = CommandContextUtil.getProcessEngineConfiguration(commandContext).getExpressionManager().createExpression(signalName); return expression.getValue(execution != null ? execution : NoExecutionVariableScope.getSharedInstance()).toString(); } return signalName; }
Example #9
Source File: AppDeployer.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void deploy(EngineDeployment deployment, Map<String, Object> deploymentSettings) { LOGGER.debug("Processing app deployment {}", deployment.getName()); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); DeploymentManager deploymentManager = processEngineConfiguration.getDeploymentManager(); Object appResourceObject = null; DeploymentEntity deploymentEntity = (DeploymentEntity) deployment; Map<String, EngineResource> resources = deploymentEntity.getResources(); for (String resourceName : resources.keySet()) { if (resourceName.endsWith(".app")) { LOGGER.info("Processing app resource {}", resourceName); EngineResource resourceEntity = resources.get(resourceName); byte[] resourceBytes = resourceEntity.getBytes(); appResourceObject = processEngineConfiguration.getAppResourceConverter().convertAppResourceToModel(resourceBytes); } } if (appResourceObject != null) { deploymentManager.getAppResourceCache().add(deployment.getId(), appResourceObject); } }
Example #10
Source File: AsyncHistoryManager.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void recordVariableRemoved(VariableInstanceEntity variable) { String processDefinitionId = null; if (enableProcessDefinitionHistoryLevel && variable.getProcessInstanceId() != null) { ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(variable.getProcessInstanceId()); processDefinitionId = processInstanceExecution.getProcessDefinitionId(); } if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId)) { ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode(); putIfNotNull(data, HistoryJsonConstants.ID, variable.getId()); putIfNotNull(data, HistoryJsonConstants.REVISION, variable.getRevision()); getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_VARIABLE_REMOVED, data); } }
Example #11
Source File: RuntimeActivityInstanceTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = "org/flowable/engine/test/history/oneTaskProcess.bpmn20.xml") public void upgradeFromHistoryToRuntimeActivities_completeTask() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess"); assertThat(processInstance).isNotNull(); waitForHistoryJobExecutorToProcessAllJobs(7000, 100); managementService.executeCommand(commandContext -> { CommandContextUtil.getActivityInstanceEntityManager(commandContext).deleteActivityInstancesByProcessInstanceId(processInstance.getId()); return null; }); taskService.complete(taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId()); assertProcessEnded(processInstance.getId()); }
Example #12
Source File: SkipExpressionUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
public static boolean isSkipExpressionEnabled(String skipExpression, String activityId, DelegateExecution execution, CommandContext commandContext) { if (skipExpression == null) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); if (processEngineConfiguration.isEnableProcessDefinitionInfoCache()) { ObjectNode taskElementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(activityId, execution.getProcessDefinitionId()); String overrideSkipExpression = DynamicPropertyUtil.getActiveValue(null, DynamicBpmnConstants.TASK_SKIP_EXPRESSION, taskElementProperties); if (overrideSkipExpression == null) { return false; } } else { return false; } } return checkSkipExpressionVariable(activityId, execution, commandContext); }
Example #13
Source File: ConditionUtil.java From flowable-engine with Apache License 2.0 | 6 votes |
public static boolean hasTrueCondition(SequenceFlow sequenceFlow, DelegateExecution execution) { String conditionExpression = null; if (CommandContextUtil.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) { ObjectNode elementProperties = BpmnOverrideContext.getBpmnOverrideElementProperties(sequenceFlow.getId(), execution.getProcessDefinitionId()); conditionExpression = getActiveValue(sequenceFlow.getConditionExpression(), DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties); } else { conditionExpression = sequenceFlow.getConditionExpression(); } if (StringUtils.isNotEmpty(conditionExpression)) { Expression expression = CommandContextUtil.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression); Condition condition = new UelExpressionCondition(expression); return condition.evaluate(sequenceFlow.getId(), execution); } else { return true; } }
Example #14
Source File: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 6 votes |
protected List<ExecutionEntity> createBoundaryEvents(List<BoundaryEvent> boundaryEvents, ExecutionEntity execution, CommandContext commandContext) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); List<ExecutionEntity> boundaryEventExecutions = new ArrayList<>(boundaryEvents.size()); // The parent execution becomes a scope, and a child execution is created for each of the boundary events for (BoundaryEvent boundaryEvent : boundaryEvents) { if (CollectionUtil.isEmpty(boundaryEvent.getEventDefinitions()) || (boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition)) { continue; } // A Child execution of the current execution is created to represent the boundary event being active ExecutionEntity childExecutionEntity = executionEntityManager.createChildExecution(execution); childExecutionEntity.setParentId(execution.getId()); childExecutionEntity.setCurrentFlowElement(boundaryEvent); childExecutionEntity.setScope(false); boundaryEventExecutions.add(childExecutionEntity); } return boundaryEventExecutions; }
Example #15
Source File: ExternalWorkerTaskCompleteJobHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void execute(JobEntity job, String configuration, VariableScope variableScope, CommandContext commandContext) { ExecutionEntity executionEntity = (ExecutionEntity) variableScope; VariableService variableService = CommandContextUtil.getVariableService(commandContext); List<VariableInstanceEntity> jobVariables = variableService.findVariableInstanceBySubScopeIdAndScopeType(executionEntity.getId(), ScopeTypes.BPMN_EXTERNAL_WORKER); for (VariableInstanceEntity jobVariable : jobVariables) { executionEntity.setVariable(jobVariable.getName(), jobVariable.getValue()); CountingEntityUtil.handleDeleteVariableInstanceEntityCount(jobVariable, false); variableService.deleteVariableInstance(jobVariable); } if (configuration != null && configuration.startsWith("error:")) { String errorCode; if (configuration.length() > 6) { errorCode = configuration.substring(6); } else { errorCode = null; } ErrorPropagation.propagateError(errorCode, executionEntity); } else { CommandContextUtil.getAgenda(commandContext).planTriggerExecutionOperation(executionEntity); } }
Example #16
Source File: DatabaseEventFlusher.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void closing(CommandContext commandContext) { if (commandContext.getException() != null) { return; // Not interested in events about exceptions } EventLogEntryEntityManager eventLogEntryEntityManager = CommandContextUtil.getEventLogEntryEntityManager(commandContext); for (EventLoggerEventHandler eventHandler : eventHandlers) { try { eventLogEntryEntityManager.insert(eventHandler.generateEventLogEntry(commandContext), false); } catch (Exception e) { LOGGER.warn("Could not create event log", e); } } }
Example #17
Source File: BoundaryTimerEventActivityBehavior.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(DelegateExecution execution) { ExecutionEntity executionEntity = (ExecutionEntity) execution; if (!(execution.getCurrentFlowElement() instanceof BoundaryEvent)) { throw new FlowableException("Programmatic error: " + this.getClass() + " should not be used for anything else than a boundary event"); } TimerJobEntity timerJob = TimerUtil.createTimerEntityForTimerEventDefinition(timerEventDefinition, execution.getCurrentFlowElement(), interrupting, executionEntity, TriggerTimerEventJobHandler.TYPE, TimerEventHandler.createConfiguration(execution.getCurrentActivityId(), timerEventDefinition.getEndDate(), timerEventDefinition.getCalendarName())); if (timerJob != null) { CommandContextUtil.getTimerJobService().scheduleTimerJob(timerJob); } }
Example #18
Source File: JsonTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test @Deployment(resources = "org/flowable/engine/test/api/oneTaskProcess.bpmn20.xml") void testSetInstantInJsonNode() { ProcessInstance processInstance = runtimeService.createProcessInstanceBuilder() .processDefinitionKey("oneTaskProcess") .variable("customer", objectMapper.createObjectNode()) .start(); assertThatJson(runtimeService.getVariable(processInstance.getId(), "customer")) .isEqualTo("{}"); if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { assertThatJson(historyService.createHistoricVariableInstanceQuery().variableName("customer").singleResult().getValue()) .isEqualTo("{}"); } managementService.executeCommand(commandContext -> { Expression expression = processEngineConfiguration.getExpressionManager().createExpression("${customer.creationDate}"); expression.setValue(Instant.parse("2020-02-16T14:24:45.583Z"), CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstance.getId())); return null; }); assertThatJson(runtimeService.getVariable(processInstance.getId(), "customer")) .isEqualTo("{ creationDate: '2020-02-16T14:24:45.583Z' }"); if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { assertThatJson(historyService.createHistoricVariableInstanceQuery().variableName("customer").singleResult().getValue()) .isEqualTo("{ creationDate: '2020-02-16T14:24:45.583Z' }"); } }
Example #19
Source File: GetProcessDefinitionHistoryLevelModelCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public HistoryLevel execute(CommandContext commandContext) { if (processDefinitionId == null) { throw new FlowableIllegalArgumentException("processDefinitionId is null"); } HistoryLevel historyLevel = null; ProcessDefinition processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId); BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId); Process process = bpmnModel.getProcessById(processDefinition.getKey()); if (process.getExtensionElements().containsKey("historyLevel")) { ExtensionElement historyLevelElement = process.getExtensionElements().get("historyLevel").iterator().next(); String historyLevelValue = historyLevelElement.getElementText(); if (StringUtils.isNotEmpty(historyLevelValue)) { try { historyLevel = HistoryLevel.getHistoryLevelForKey(historyLevelValue); } catch (Exception e) { } } } if (historyLevel == null) { historyLevel = CommandContextUtil.getProcessEngineConfiguration(commandContext).getHistoryLevel(); } return historyLevel; }
Example #20
Source File: AbstractDynamicInjectionCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
protected BpmnModel createBpmnModel(CommandContext commandContext, ProcessDefinitionEntity originalProcessDefinitionEntity, DeploymentEntity newDeploymentEntity) { ResourceEntity originalBpmnResource = CommandContextUtil.getResourceEntityManager(commandContext) .findResourceByDeploymentIdAndResourceName(originalProcessDefinitionEntity.getDeploymentId(), originalProcessDefinitionEntity.getResourceName()); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(new BytesStreamSource(originalBpmnResource.getBytes()), false, false); org.flowable.bpmn.model.Process process = bpmnModel.getProcessById(originalProcessDefinitionEntity.getKey()); updateBpmnProcess(commandContext, process, bpmnModel, originalProcessDefinitionEntity, newDeploymentEntity); return bpmnModel; }
Example #21
Source File: BpmnDeployer.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void dispatchProcessDefinitionEntityInitializedEvent(ParsedDeployment parsedDeployment) { CommandContext commandContext = Context.getCommandContext(); for (ProcessDefinitionEntity processDefinitionEntity : parsedDeployment.getAllProcessDefinitions()) { FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher(); if (eventDispatcher != null && eventDispatcher.isEnabled()) { eventDispatcher.dispatchEvent( FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, processDefinitionEntity)); } } }
Example #22
Source File: EventSubscriptionManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void removeObsoleteEventSubscriptionsImpl(ProcessDefinitionEntity processDefinition, String eventHandlerType) { // remove all subscriptions for the previous version EventSubscriptionService eventSubscriptionService = CommandContextUtil.getEventSubscriptionService(); List<EventSubscriptionEntity> subscriptionsToDelete = eventSubscriptionService .findEventSubscriptionsByTypeAndProcessDefinitionId(eventHandlerType, processDefinition.getId(), processDefinition.getTenantId()); for (EventSubscriptionEntity eventSubscriptionEntity : subscriptionsToDelete) { eventSubscriptionService.deleteEventSubscription(eventSubscriptionEntity); CountingEntityUtil.handleDeleteEventSubscriptionEntityCount(eventSubscriptionEntity); } }
Example #23
Source File: HistoricProcessInstanceQueryImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public List<HistoricProcessInstance> executeList(CommandContext commandContext) { ensureVariablesInitialized(); List<HistoricProcessInstance> results = null; ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext); if (processEngineConfiguration.getHistoricProcessInstanceQueryInterceptor() != null) { processEngineConfiguration.getHistoricProcessInstanceQueryInterceptor().beforeHistoricProcessInstanceQueryExecute(this); } if (includeProcessVariables) { results = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext).findHistoricProcessInstancesAndVariablesByQueryCriteria(this); if (processInstanceId != null) { addCachedVariableForQueryById(commandContext, results); } } else { results = CommandContextUtil.getHistoricProcessInstanceEntityManager(commandContext).findHistoricProcessInstancesByQueryCriteria(this); } if (processEngineConfiguration.getPerformanceSettings().isEnableLocalization() && processEngineConfiguration.getInternalProcessLocalizationManager() != null) { for (HistoricProcessInstance processInstance : results) { processEngineConfiguration.getInternalProcessLocalizationManager().localize(processInstance, locale, withLocalizationFallback); } } if (processEngineConfiguration.getHistoricProcessInstanceQueryInterceptor() != null) { processEngineConfiguration.getHistoricProcessInstanceQueryInterceptor().afterHistoricProcessInstanceQueryExecute(this, results); } return results; }
Example #24
Source File: ProcessDefinitionInfoCache.java From flowable-engine with Apache License 2.0 | 5 votes |
protected ProcessDefinitionInfoCacheObject retrieveProcessDefinitionInfoCacheObject(String processDefinitionId, CommandContext commandContext) { ProcessDefinitionInfoEntityManager infoEntityManager = CommandContextUtil.getProcessDefinitionInfoEntityManager(commandContext); ObjectMapper objectMapper = CommandContextUtil.getProcessEngineConfiguration(commandContext).getObjectMapper(); ProcessDefinitionInfoCacheObject cacheObject = null; if (cache.containsKey(processDefinitionId)) { cacheObject = cache.get(processDefinitionId); } else { cacheObject = new ProcessDefinitionInfoCacheObject(); cacheObject.setRevision(0); cacheObject.setInfoNode(objectMapper.createObjectNode()); } ProcessDefinitionInfoEntity infoEntity = infoEntityManager.findProcessDefinitionInfoByProcessDefinitionId(processDefinitionId); if (infoEntity != null && infoEntity.getRevision() != cacheObject.getRevision()) { cacheObject.setRevision(infoEntity.getRevision()); if (infoEntity.getInfoJsonId() != null) { byte[] infoBytes = infoEntityManager.findInfoJsonById(infoEntity.getInfoJsonId()); try { ObjectNode infoNode = (ObjectNode) objectMapper.readTree(infoBytes); cacheObject.setInfoNode(infoNode); } catch (Exception e) { throw new FlowableException("Error reading json info node for process definition " + processDefinitionId, e); } } } else if (infoEntity == null) { cacheObject.setRevision(0); cacheObject.setInfoNode(objectMapper.createObjectNode()); } return cacheObject; }
Example #25
Source File: BoundaryEventRegistryEventActivityBehavior.java From flowable-engine with Apache License 2.0 | 5 votes |
protected String getEventDefinitionKey(CommandContext commandContext, ExecutionEntity executionEntity) { Object key = null; if (StringUtils.isNotEmpty(eventDefinitionKey)) { Expression expression = CommandContextUtil.getProcessEngineConfiguration(commandContext).getExpressionManager() .createExpression(eventDefinitionKey); key = expression.getValue(executionEntity); } if (key == null) { throw new FlowableException("Could not resolve key for: " + eventDefinitionKey); } return key.toString(); }
Example #26
Source File: ServiceTaskDelegateExpressionActivityBehavior.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void trigger(DelegateExecution execution, String signalName, Object signalData) { Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, execution, fieldDeclarations); ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); boolean loggingSessionEnabled = processEngineConfiguration.isLoggingSessionEnabled(); if (triggerable && delegate instanceof TriggerableActivityBehavior) { if (loggingSessionEnabled) { BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_BEFORE_TRIGGER, "Triggering service task with delegate " + delegate, execution); } ((TriggerableActivityBehavior) delegate).trigger(execution, signalName, signalData); if (loggingSessionEnabled) { BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_AFTER_TRIGGER, "Triggered service task with delegate " + delegate, execution); } } else if (loggingSessionEnabled) { if (!triggerable) { BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_WRONG_TRIGGER, "Service task with delegate expression triggered but not triggerable " + delegate, execution); } else { BpmnLoggingSessionUtil.addLoggingData(LoggingSessionConstants.TYPE_SERVICE_TASK_WRONG_TRIGGER, "Service task with delegate expression triggered but not implementing TriggerableActivityBehavior " + delegate, execution); } } leave(execution); }
Example #27
Source File: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void safeDeleteSubProcessInstance(String processInstanceId, List<ExecutionEntity> executionsPool, String deleteReason, CommandContext commandContext) { ExecutionEntityManager executionEntityManager = CommandContextUtil.getExecutionEntityManager(commandContext); //Confirm that all the subProcessExecutions are in the executionsPool List<ExecutionEntity> subProcessExecutions = executionEntityManager.findChildExecutionsByProcessInstanceId(processInstanceId); HashSet<String> executionIdsToMove = executionsPool.stream().map(ExecutionEntity::getId).collect(Collectors.toCollection(HashSet::new)); Optional<ExecutionEntity> notIncludedExecution = subProcessExecutions.stream().filter(e -> !executionIdsToMove.contains(e.getId())).findAny(); if (notIncludedExecution.isPresent()) { throw new FlowableException("Execution of sub process instance is not moved " + notIncludedExecution.get().getId()); } // delete the sub process instance executionEntityManager.deleteProcessInstance(processInstanceId, deleteReason, true); }
Example #28
Source File: AbstractDynamicStateManager.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void handleUserTaskNewAssignee(ExecutionEntity taskExecution, String newAssigneeId, CommandContext commandContext) { TaskService taskService = CommandContextUtil.getTaskService(commandContext); TaskEntityImpl task = (TaskEntityImpl) taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult(); if (task != null) { TaskHelper.changeTaskAssignee(task, newAssigneeId); } }
Example #29
Source File: FormPropertiesSubmittedHistoryJsonTransformer.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void transformJson(HistoryJobEntity job, ObjectNode historicalData, CommandContext commandContext) { HistoricDetailDataManager historicDetailDataManager = CommandContextUtil.getProcessEngineConfiguration(commandContext).getHistoricDetailDataManager(); int counter = 1; while (true) { String propertyId = getStringFromJson(historicalData, HistoryJsonConstants.FORM_PROPERTY_ID + counter); if (StringUtils.isEmpty(propertyId)) { break; } HistoricFormPropertyEntity historicFormPropertyEntity = historicDetailDataManager.createHistoricFormProperty(); historicFormPropertyEntity.setProcessInstanceId(getStringFromJson(historicalData, HistoryJsonConstants.PROCESS_INSTANCE_ID)); historicFormPropertyEntity.setExecutionId(getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID)); historicFormPropertyEntity.setTaskId(getStringFromJson(historicalData, HistoryJsonConstants.TASK_ID)); historicFormPropertyEntity.setPropertyId(propertyId); historicFormPropertyEntity.setPropertyValue(getStringFromJson(historicalData, HistoryJsonConstants.FORM_PROPERTY_VALUE + counter)); historicFormPropertyEntity.setTime(getDateFromJson(historicalData, HistoryJsonConstants.CREATE_TIME)); String activityId = getStringFromJson(historicalData, HistoryJsonConstants.ACTIVITY_ID); if (StringUtils.isNotEmpty(activityId)) { HistoricActivityInstance activityInstance = findHistoricActivityInstance(commandContext, getStringFromJson(historicalData, HistoryJsonConstants.EXECUTION_ID), activityId); historicFormPropertyEntity.setActivityInstanceId(activityInstance.getId()); } HistoricDetailEntityManager historicDetailEntityManager = CommandContextUtil.getProcessEngineConfiguration(commandContext).getHistoricDetailEntityManager(); historicDetailEntityManager.insert(historicFormPropertyEntity); counter++; } }
Example #30
Source File: GetPotentialStarterGroupsCmd.java From flowable-engine with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public List<Group> execute(CommandContext commandContext) { ProcessDefinitionEntity processDefinition = CommandContextUtil.getProcessDefinitionEntityManager(commandContext).findById(processDefinitionId); if (processDefinition == null) { throw new FlowableObjectNotFoundException("Cannot find process definition with id " + processDefinitionId, ProcessDefinition.class); } IdentityService identityService = CommandContextUtil.getProcessEngineConfiguration(commandContext).getIdentityService(); List<String> groupIds = new ArrayList<>(); List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks(); for (IdentityLink identityLink : identityLinks) { if (identityLink.getGroupId() != null && identityLink.getGroupId().length() > 0) { if (!groupIds.contains(identityLink.getGroupId())) { groupIds.add(identityLink.getGroupId()); } } } if (groupIds.size() > 0) { return identityService.createGroupQuery().groupIds(groupIds).list(); } else { return new ArrayList<>(); } }