Search in sources :

Example 1 with UelExpressionCondition

use of org.activiti.engine.impl.el.UelExpressionCondition in project Activiti by Activiti.

the class SequenceFlowParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, SequenceFlow sequenceFlow) {
    ScopeImpl scope = bpmnParse.getCurrentScope();
    ActivityImpl sourceActivity = scope.findActivity(sequenceFlow.getSourceRef());
    ActivityImpl destinationActivity = scope.findActivity(sequenceFlow.getTargetRef());
    Expression skipExpression;
    if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
        ExpressionManager expressionManager = bpmnParse.getExpressionManager();
        skipExpression = expressionManager.createExpression(sequenceFlow.getSkipExpression());
    } else {
        skipExpression = null;
    }
    TransitionImpl transition = sourceActivity.createOutgoingTransition(sequenceFlow.getId(), skipExpression);
    bpmnParse.getSequenceFlows().put(sequenceFlow.getId(), transition);
    transition.setProperty("name", sequenceFlow.getName());
    transition.setProperty("documentation", sequenceFlow.getDocumentation());
    transition.setDestination(destinationActivity);
    if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
        Condition expressionCondition = new UelExpressionCondition(sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION_TEXT, sequenceFlow.getConditionExpression());
        transition.setProperty(PROPERTYNAME_CONDITION, expressionCondition);
    }
    createExecutionListenersOnTransition(bpmnParse, sequenceFlow.getExecutionListeners(), transition);
}
Also used : UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition) Condition(org.activiti.engine.impl.Condition) ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) TransitionImpl(org.activiti.engine.impl.pvm.process.TransitionImpl) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) Expression(org.activiti.engine.delegate.Expression) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition)

Example 2 with UelExpressionCondition

use of org.activiti.engine.impl.el.UelExpressionCondition in project Activiti by Activiti.

the class TakeOutgoingSequenceFlowsOperation method handleAdhocSubProcess.

protected void handleAdhocSubProcess(FlowNode flowNode) {
    boolean completeAdhocSubProcess = false;
    AdhocSubProcess adhocSubProcess = (AdhocSubProcess) flowNode.getParentContainer();
    if (adhocSubProcess.getCompletionCondition() != null) {
        Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(adhocSubProcess.getCompletionCondition());
        Condition condition = new UelExpressionCondition(expression);
        if (condition.evaluate(adhocSubProcess.getId(), execution)) {
            completeAdhocSubProcess = true;
        }
    }
    if (flowNode.getOutgoingFlows().size() > 0) {
        leaveFlowNode(flowNode);
    } else {
        commandContext.getExecutionEntityManager().deleteExecutionAndRelatedData(execution, null);
    }
    if (completeAdhocSubProcess) {
        boolean endAdhocSubProcess = true;
        if (!adhocSubProcess.isCancelRemainingInstances()) {
            List<ExecutionEntity> childExecutions = commandContext.getExecutionEntityManager().findChildExecutionsByParentExecutionId(execution.getParentId());
            for (ExecutionEntity executionEntity : childExecutions) {
                if (!executionEntity.getId().equals(execution.getId())) {
                    endAdhocSubProcess = false;
                    break;
                }
            }
        }
        if (endAdhocSubProcess) {
            Context.getAgenda().planEndExecutionOperation(execution.getParent());
        }
    }
}
Also used : Condition(org.activiti.engine.impl.Condition) UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition) AdhocSubProcess(org.activiti.bpmn.model.AdhocSubProcess) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) Expression(org.activiti.engine.delegate.Expression) UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition)

Example 3 with UelExpressionCondition

use of org.activiti.engine.impl.el.UelExpressionCondition in project Activiti by Activiti.

the class ConditionUtil method hasTrueCondition.

public static boolean hasTrueCondition(SequenceFlow sequenceFlow, DelegateExecution execution) {
    String conditionExpression = null;
    if (Context.getProcessEngineConfiguration().isEnableProcessDefinitionInfoCache()) {
        ObjectNode elementProperties = Context.getBpmnOverrideElementProperties(sequenceFlow.getId(), execution.getProcessDefinitionId());
        conditionExpression = getActiveValue(sequenceFlow.getConditionExpression(), DynamicBpmnConstants.SEQUENCE_FLOW_CONDITION, elementProperties);
    } else {
        conditionExpression = sequenceFlow.getConditionExpression();
    }
    if (StringUtils.isNotEmpty(conditionExpression)) {
        Expression expression = Context.getProcessEngineConfiguration().getExpressionManager().createExpression(conditionExpression);
        Condition condition = new UelExpressionCondition(expression);
        if (condition.evaluate(sequenceFlow.getId(), execution)) {
            return true;
        }
        return false;
    } else {
        return true;
    }
}
Also used : UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition) Condition(org.activiti.engine.impl.Condition) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Expression(org.activiti.engine.delegate.Expression) UelExpressionCondition(org.activiti.engine.impl.el.UelExpressionCondition)

Aggregations

Expression (org.activiti.engine.delegate.Expression)3 Condition (org.activiti.engine.impl.Condition)3 UelExpressionCondition (org.activiti.engine.impl.el.UelExpressionCondition)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 AdhocSubProcess (org.activiti.bpmn.model.AdhocSubProcess)1 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)1 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)1 TransitionImpl (org.activiti.engine.impl.pvm.process.TransitionImpl)1