Java Code Examples for org.flowable.engine.impl.persistence.entity.ExecutionEntity#getProcessDefinitionId()

The following examples show how to use org.flowable.engine.impl.persistence.entity.ExecutionEntity#getProcessDefinitionId() . 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: FlowableProcessStartedEventImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public FlowableProcessStartedEventImpl(final Object entity, final Map variables, final boolean localScope) {
    super(entity, variables, localScope, FlowableEngineEventType.PROCESS_STARTED);
    if (entity instanceof ExecutionEntity) {
        ExecutionEntity executionEntity = (ExecutionEntity) entity;
        if (!executionEntity.isProcessInstanceType()) {
            executionEntity = executionEntity.getParent();
        }

        final ExecutionEntity superExecution = executionEntity.getSuperExecution();
        if (superExecution != null) {
            this.nestedProcessDefinitionId = superExecution.getProcessDefinitionId();
            this.nestedProcessInstanceId = superExecution.getProcessInstanceId();
        } else {
            this.nestedProcessDefinitionId = null;
            this.nestedProcessInstanceId = null;
        }

    } else {
        this.nestedProcessDefinitionId = null;
        this.nestedProcessInstanceId = null;
    }
}
 
Example 2
Source File: AbstractHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected String getProcessDefinitionId(EntityLinkEntity entityLink) {
    String processDefinitionId = null;
    if (ScopeTypes.BPMN.equals(entityLink.getScopeType()) && entityLink.getScopeId() != null) {
        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager().findById(entityLink.getScopeId());
        if (execution != null) {
            processDefinitionId = execution.getProcessDefinitionId();
        }

    } else if (ScopeTypes.TASK.equals(entityLink.getScopeType()) && entityLink.getScopeId() != null) {
        TaskEntity task = CommandContextUtil.getTaskService().getTask(entityLink.getScopeId());
        if (task != null) {
            processDefinitionId = task.getProcessDefinitionId();
        }
    }
    return processDefinitionId;
}
 
Example 3
Source File: EventUtil.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public static FlowableVariableEvent createVariableDeleteEvent(VariableInstanceEntity variableInstance) {

        String processDefinitionId = null;
        if (variableInstance.getProcessInstanceId() != null) {
            ExecutionEntity executionEntity = CommandContextUtil.getExecutionEntityManager().findById(variableInstance.getProcessInstanceId());
            if (executionEntity != null) {
                processDefinitionId = executionEntity.getProcessDefinitionId();
            }
        }

        return FlowableEventBuilder.createVariableEvent(FlowableEngineEventType.VARIABLE_DELETED,
                variableInstance.getName(),
                null,
                variableInstance.getType(),
                variableInstance.getTaskId(),
                variableInstance.getExecutionId(),
                variableInstance.getProcessInstanceId(),
                processDefinitionId);
    }
 
Example 4
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void recordTaskCreated(TaskEntity task, ExecutionEntity execution) {
    String processDefinitionId = null;
    if (execution != null) {
        processDefinitionId = execution.getProcessDefinitionId();
    } else if (task != null) {
        processDefinitionId = task.getProcessDefinitionId();
    }
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT, processDefinitionId)) {
        if (execution != null) {
            task.setExecutionId(execution.getId());
            task.setProcessInstanceId(execution.getProcessInstanceId());
            task.setProcessDefinitionId(execution.getProcessDefinitionId());
            
            if (execution.getTenantId() != null) {
                task.setTenantId(execution.getTenantId());
            }
        }
        HistoricTaskInstanceEntity historicTaskInstance = CommandContextUtil.getHistoricTaskService().recordTaskCreated(task);
        historicTaskInstance.setLastUpdateTime(processEngineConfiguration.getClock().getCurrentTime());

        if (execution != null) {
            historicTaskInstance.setExecutionId(execution.getId());
        }
    }
}
 
Example 5
Source File: ExecutionQueryImpl.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected void localize(Execution execution, String activityId) {
    ExecutionEntity executionEntity = (ExecutionEntity) execution;
    executionEntity.setLocalizedName(null);
    executionEntity.setLocalizedDescription(null);

    String processDefinitionId = executionEntity.getProcessDefinitionId();
    if (locale != null && processDefinitionId != null) {
        ObjectNode languageNode = BpmnOverrideContext.getLocalizationElementProperties(locale, activityId, processDefinitionId, withLocalizationFallback);
        if (languageNode != null) {
            JsonNode languageNameNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_NAME);
            if (languageNameNode != null && !languageNameNode.isNull()) {
                executionEntity.setLocalizedName(languageNameNode.asText());
            }

            JsonNode languageDescriptionNode = languageNode.get(DynamicBpmnConstants.LOCALIZATION_DESCRIPTION);
            if (languageDescriptionNode != null && !languageDescriptionNode.isNull()) {
                executionEntity.setLocalizedDescription(languageDescriptionNode.asText());
            }
        }
    }
}
 
Example 6
Source File: AbstractHistoryManager.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected String getProcessDefinitionId(VariableInstanceEntity variable, ExecutionEntity sourceActivityExecution) {
    String processDefinitionId = null;
    if (sourceActivityExecution != null) {
        processDefinitionId = sourceActivityExecution.getProcessDefinitionId();
    } else if (variable.getProcessInstanceId() != null) {
        ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(variable.getProcessInstanceId());
        if (processInstanceExecution != null) {
            processDefinitionId = processInstanceExecution.getProcessDefinitionId();
        }
    } else if (variable.getTaskId() != null) {
        TaskEntity taskEntity = CommandContextUtil.getTaskService().getTask(variable.getTaskId());
        if (taskEntity != null) {
            processDefinitionId = taskEntity.getProcessDefinitionId();
        }
    }
    return processDefinitionId;
}
 
Example 7
Source File: AbstractHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void createAttachmentComment(TaskEntity task, ExecutionEntity processInstance, String attachmentName, boolean create) {
    String processDefinitionId = null;
    if (processInstance != null) {
        processDefinitionId = processInstance.getProcessDefinitionId();
    } else if (task != null) {
        processDefinitionId = task.getProcessDefinitionId();
    }
    if (isHistoryEnabled(processDefinitionId)) {
        String userId = Authentication.getAuthenticatedUserId();
        CommentEntity comment = getCommentEntityManager().create();
        comment.setUserId(userId);
        comment.setType(CommentEntity.TYPE_EVENT);
        comment.setTime(getClock().getCurrentTime());
        if (task != null) {
            comment.setTaskId(task.getId());
        }
        if (processInstance != null) {
            comment.setProcessInstanceId(processInstance.getId());
        }
        if (create) {
            comment.setAction(Event.ACTION_ADD_ATTACHMENT);
        } else {
            comment.setAction(Event.ACTION_DELETE_ATTACHMENT);
        }
        comment.setMessage(attachmentName);
        getCommentEntityManager().insert(comment);
    }
}
 
Example 8
Source File: LogMDC.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public static void putMDCExecution(ExecutionEntity e) {
    if (e.getId() != null)
        MDC.put(LOG_MDC_EXECUTION_ID, e.getId());
    if (e.getProcessDefinitionId() != null)
        MDC.put(LOG_MDC_PROCESSDEFINITION_ID, e.getProcessDefinitionId());
    if (e.getProcessInstanceId() != null)
        MDC.put(LOG_MDC_PROCESSINSTANCE_ID, e.getProcessInstanceId());
    if (e.getProcessInstanceBusinessKey() != null)
        MDC.put(LOG_MDC_BUSINESS_KEY, e.getProcessInstanceBusinessKey());

}
 
Example 9
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordVariableRemoved(VariableInstanceEntity variableInstanceEntity) {
    String processDefinitionId = null;
    if (enableProcessDefinitionHistoryLevel && variableInstanceEntity.getProcessInstanceId() != null) {
        ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(variableInstanceEntity.getProcessInstanceId());
        processDefinitionId = processInstanceExecution.getProcessDefinitionId();
    }
    
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId)) {
        CommandContextUtil.getHistoricVariableService().recordVariableRemoved(variableInstanceEntity);
    }
}
 
Example 10
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordVariableUpdate(VariableInstanceEntity variableInstanceEntity, Date updateTime) {
    String processDefinitionId = null;
    if (enableProcessDefinitionHistoryLevel && variableInstanceEntity.getProcessInstanceId() != null) {
        ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(variableInstanceEntity.getProcessInstanceId());
        processDefinitionId = processInstanceExecution.getProcessDefinitionId();
    }
    
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId)) {
        CommandContextUtil.getHistoricVariableService().recordVariableUpdate(variableInstanceEntity, updateTime);
    }
}
 
Example 11
Source File: DefaultHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordVariableCreate(VariableInstanceEntity variable, Date createTime) {
    String processDefinitionId = null;
    if (enableProcessDefinitionHistoryLevel && variable.getProcessInstanceId() != null) {
        ExecutionEntity processInstanceExecution = CommandContextUtil.getExecutionEntityManager().findById(variable.getProcessInstanceId());
        processDefinitionId = processInstanceExecution.getProcessDefinitionId();
    }
    
    if (isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processDefinitionId)) {
        CommandContextUtil.getHistoricVariableService().createAndInsert(variable, createTime);
    }
}
 
Example 12
Source File: SaveAttachmentCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
    AttachmentEntity updateAttachment = CommandContextUtil.getAttachmentEntityManager().findById(attachment.getId());

    String processInstanceId = updateAttachment.getProcessInstanceId();
    String processDefinitionId = null;
    if (updateAttachment.getProcessInstanceId() != null) {
        ExecutionEntity process = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);
        if (process != null) {
            processDefinitionId = process.getProcessDefinitionId();
            if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, process.getProcessDefinitionId())) {
                Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
                compatibilityHandler.saveAttachment(attachment);
                return null;
            }
        }
    }

    updateAttachment.setName(attachment.getName());
    updateAttachment.setDescription(attachment.getDescription());

    FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher();
    if (eventDispatcher != null && eventDispatcher.isEnabled()) {
        eventDispatcher
                .dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_UPDATED, attachment, processInstanceId, processInstanceId, processDefinitionId));
    }

    return null;
}
 
Example 13
Source File: AsyncHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void recordTaskCreated(TaskEntity task, ExecutionEntity execution) {
    String processDefinitionId = null;
    if (execution != null) {
        processDefinitionId = execution.getProcessDefinitionId();
    } else {
        processDefinitionId = task.getProcessDefinitionId();
    }
    if (isHistoryLevelAtLeast(HistoryLevel.AUDIT, processDefinitionId)) {
        ObjectNode data = processEngineConfiguration.getObjectMapper().createObjectNode();
        addCommonTaskFields(task, execution, data);

        getAsyncHistorySession().addHistoricData(getJobServiceConfiguration(), HistoryJsonConstants.TYPE_TASK_CREATED, data, task.getTenantId());
    }
}
 
Example 14
Source File: AbstractOperation.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to match the activityId of an execution with a FlowElement of the process definition referenced by the execution.
 */
protected FlowElement getCurrentFlowElement(final ExecutionEntity execution) {
    if (execution.getCurrentFlowElement() != null) {
        return execution.getCurrentFlowElement();
    } else if (execution.getCurrentActivityId() != null) {
        String processDefinitionId = execution.getProcessDefinitionId();
        org.flowable.bpmn.model.Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
        String activityId = execution.getCurrentActivityId();
        FlowElement currentFlowElement = process.getFlowElement(activityId, true);
        return currentFlowElement;
    }
    return null;
}
 
Example 15
Source File: AbstractHistoryManager.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected String getProcessDefinitionId(IdentityLinkEntity identityLink) {
    String processDefinitionId = null;
    if (identityLink.getProcessInstanceId() != null) {
        ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager().findById(identityLink.getProcessInstanceId());
        if (execution != null) {
            processDefinitionId = execution.getProcessDefinitionId();
        }
    } else if (identityLink.getTaskId() != null) {
        TaskEntity task = CommandContextUtil.getTaskService().getTask(identityLink.getTaskId());
        if (task != null) {
            processDefinitionId = task.getProcessDefinitionId();
        }
    }
    return processDefinitionId;
}
 
Example 16
Source File: AbstractDynamicInjectionCmd.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
protected void updateExecutions(CommandContext commandContext, ProcessDefinitionEntity processDefinitionEntity, ExecutionEntity processInstance, BpmnModel bpmnModel) {
    String previousProcessDefinitionId = processInstance.getProcessDefinitionId();
    processInstance.setProcessDefinitionId(processDefinitionEntity.getId());
    processInstance.setProcessDefinitionVersion(processDefinitionEntity.getVersion());
    
    List<TaskEntity> currentTasks = CommandContextUtil.getTaskService(commandContext).findTasksByProcessInstanceId(processInstance.getId());
    for (TaskEntity currentTask : currentTasks) {
        currentTask.setProcessDefinitionId(processDefinitionEntity.getId());
    }
    
    List<JobEntity> currentJobs = CommandContextUtil.getJobService(commandContext).findJobsByProcessInstanceId(processInstance.getId());
    for (JobEntity currentJob : currentJobs) {
        currentJob.setProcessDefinitionId(processDefinitionEntity.getId());
    }
    
    List<TimerJobEntity> currentTimerJobs = CommandContextUtil.getTimerJobService(commandContext).findTimerJobsByProcessInstanceId(processInstance.getId());
    for (TimerJobEntity currentTimerJob : currentTimerJobs) {
        currentTimerJob.setProcessDefinitionId(processDefinitionEntity.getId());
    }
    
    List<SuspendedJobEntity> currentSuspendedJobs = CommandContextUtil.getJobService(commandContext).findSuspendedJobsByProcessInstanceId(processInstance.getId());
    for (SuspendedJobEntity currentSuspendedJob : currentSuspendedJobs) {
        currentSuspendedJob.setProcessDefinitionId(processDefinitionEntity.getId());
    }
    
    List<DeadLetterJobEntity> currentDeadLetterJobs = CommandContextUtil.getJobService(commandContext).findDeadLetterJobsByProcessInstanceId(processInstance.getId());
    for (DeadLetterJobEntity currentDeadLetterJob : currentDeadLetterJobs) {
        currentDeadLetterJob.setProcessDefinitionId(processDefinitionEntity.getId());
    }
    
    List<IdentityLinkEntity> identityLinks = CommandContextUtil.getIdentityLinkService().findIdentityLinksByProcessDefinitionId(previousProcessDefinitionId);
    for (IdentityLinkEntity identityLinkEntity : identityLinks) {
        if (identityLinkEntity.getTaskId() != null || identityLinkEntity.getProcessInstanceId() != null || identityLinkEntity.getScopeId() != null) {
            identityLinkEntity.setProcessDefId(processDefinitionEntity.getId());
        }
    }

    CommandContextUtil.getActivityInstanceEntityManager(commandContext).updateActivityInstancesProcessDefinitionId(processDefinitionEntity.getId(), processInstance.getId());
    CommandContextUtil.getHistoryManager(commandContext).updateProcessDefinitionIdInHistory(processDefinitionEntity, processInstance);
    
    List<ExecutionEntity> childExecutions = CommandContextUtil.getExecutionEntityManager(commandContext).findChildExecutionsByProcessInstanceId(processInstance.getId());
    for (ExecutionEntity childExecution : childExecutions) {
        childExecution.setProcessDefinitionId(processDefinitionEntity.getId());
        childExecution.setProcessDefinitionVersion(processDefinitionEntity.getVersion());
    }

    updateExecutions(commandContext, processDefinitionEntity, processInstance, childExecutions);
}
 
Example 17
Source File: DeleteAttachmentCmd.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Object execute(CommandContext commandContext) {
    AttachmentEntity attachment = CommandContextUtil.getAttachmentEntityManager().findById(attachmentId);

    String processInstanceId = attachment.getProcessInstanceId();
    String processDefinitionId = null;
    ExecutionEntity processInstance = null;
    if (attachment.getProcessInstanceId() != null) {
        processInstance = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);
        if (processInstance != null) {
            processDefinitionId = processInstance.getProcessDefinitionId();
            if (Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processInstance.getProcessDefinitionId())) {
                Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
                compatibilityHandler.deleteAttachment(attachmentId);
                return null;
            }
        }
    }

    CommandContextUtil.getAttachmentEntityManager().delete(attachment, false);

    if (attachment.getContentId() != null) {
        CommandContextUtil.getByteArrayEntityManager().deleteByteArrayById(attachment.getContentId());
    }
    
    TaskEntity task = null;
    if (attachment.getTaskId() != null) {
        task = CommandContextUtil.getTaskService().getTask(attachment.getTaskId());
    }

    if (attachment.getTaskId() != null) {
        CommandContextUtil.getHistoryManager(commandContext).createAttachmentComment(task, processInstance, attachment.getName(), false);
    }

    FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher();
    if (eventDispatcher != null && eventDispatcher.isEnabled()) {
        eventDispatcher
                .dispatchEvent(FlowableEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, attachment, processInstanceId, processInstanceId, processDefinitionId));
    }
    return null;
}
 
Example 18
Source File: AddCommentCmd.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Comment execute(CommandContext commandContext) {

    TaskEntity task = null;
    // Validate task
    if (taskId != null) {
        task = CommandContextUtil.getTaskService().getTask(taskId);

        if (task == null) {
            throw new FlowableObjectNotFoundException("Cannot find task with id " + taskId, Task.class);
        }

        if (task.isSuspended()) {
            throw new FlowableException(getSuspendedTaskException());
        }
    }

    ExecutionEntity execution = null;
    if (processInstanceId != null) {
        execution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(processInstanceId);

        if (execution == null) {
            throw new FlowableObjectNotFoundException("execution " + processInstanceId + " doesn't exist", Execution.class);
        }

        if (execution.isSuspended()) {
            throw new FlowableException(getSuspendedExceptionMessage());
        }
    }

    String processDefinitionId = null;
    if (execution != null) {
        processDefinitionId = execution.getProcessDefinitionId();
    } else if (task != null) {
        processDefinitionId = task.getProcessDefinitionId();
    }

    if (processDefinitionId != null && Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, processDefinitionId)) {
        Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();
        return compatibilityHandler.addComment(taskId, processInstanceId, type, message);
    }

    String userId = Authentication.getAuthenticatedUserId();
    CommentEntity comment = CommandContextUtil.getCommentEntityManager(commandContext).create();
    comment.setUserId(userId);
    comment.setType((type == null) ? CommentEntity.TYPE_COMMENT : type);
    comment.setTime(CommandContextUtil.getProcessEngineConfiguration(commandContext).getClock().getCurrentTime());
    comment.setTaskId(taskId);
    comment.setProcessInstanceId(processInstanceId);
    comment.setAction(Event.ACTION_ADD_COMMENT);

    String eventMessage = message.replaceAll("\\s+", " ");
    if (eventMessage.length() > 163) {
        eventMessage = eventMessage.substring(0, 160) + "...";
    }
    comment.setMessage(eventMessage);

    comment.setFullMessage(message);

    CommandContextUtil.getCommentEntityManager(commandContext).insert(comment);

    return comment;
}
 
Example 19
Source File: CompensationEventHandler.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {

    String configuration = eventSubscription.getConfiguration();
    if (configuration == null) {
        throw new FlowableException("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId());
    }

    ExecutionEntity compensatingExecution = CommandContextUtil.getExecutionEntityManager(commandContext).findById(configuration);

    String processDefinitionId = compensatingExecution.getProcessDefinitionId();
    Process process = ProcessDefinitionUtil.getProcess(processDefinitionId);
    if (process == null) {
        throw new FlowableException("Cannot start process instance. Process model (id = " + processDefinitionId + ") could not be found");
    }

    FlowElement flowElement = process.getFlowElement(eventSubscription.getActivityId(), true);

    if (flowElement instanceof SubProcess && !((SubProcess) flowElement).isForCompensation()) {

        // descend into scope:
        compensatingExecution.setScope(true);
        List<CompensateEventSubscriptionEntity> eventsForThisScope = CommandContextUtil.getEventSubscriptionService(commandContext).findCompensateEventSubscriptionsByExecutionId(compensatingExecution.getId());
        ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);

    } else {

        try {

            FlowableEventDispatcher eventDispatcher = CommandContextUtil.getProcessEngineConfiguration(commandContext).getEventDispatcher();
            if (eventDispatcher != null && eventDispatcher.isEnabled()) {
                eventDispatcher.dispatchEvent(
                        FlowableEventBuilder.createActivityEvent(FlowableEngineEventType.ACTIVITY_COMPENSATE, flowElement.getId(), flowElement.getName(),
                                compensatingExecution.getId(), compensatingExecution.getProcessInstanceId(), compensatingExecution.getProcessDefinitionId(), flowElement));
            }
            
            Activity compensationActivity = null;
            Activity activity = (Activity) flowElement;
            if (!activity.isForCompensation() && activity.getBoundaryEvents().size() > 0) {
                for (BoundaryEvent boundaryEvent : activity.getBoundaryEvents()) {
                    if (boundaryEvent.getEventDefinitions().size() > 0 && boundaryEvent.getEventDefinitions().get(0) instanceof CompensateEventDefinition) {
                        List<Association> associations = process.findAssociationsWithSourceRefRecursive(boundaryEvent.getId());
                        for (Association association : associations) {
                            FlowElement targetElement = process.getFlowElement(association.getTargetRef(), true);
                            if (targetElement instanceof Activity) {
                                Activity targetActivity = (Activity) targetElement;
                                if (targetActivity.isForCompensation()) {
                                    compensationActivity = targetActivity;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            
            if (compensationActivity != null) {
                flowElement = compensationActivity;
            }
            
            compensatingExecution.setCurrentFlowElement(flowElement);
            CommandContextUtil.getAgenda().planContinueProcessInCompensation(compensatingExecution);

        } catch (Exception e) {
            throw new FlowableException("Error while handling compensation event " + eventSubscription, e);
        }

    }
}
 
Example 20
Source File: ProcessInstancesByProcessDefinitionMatcher.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRetained(ExecutionEntity entity, Object parameter) {
    return entity.getParentId() == null && entity.getProcessDefinitionId() != null && entity.getProcessDefinitionId().equals(parameter);
}