Search in sources :

Example 1 with MultiInstanceActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior in project Activiti by Activiti.

the class AbstractActivityBpmnParseHandler method createMultiInstanceLoopCharacteristics.

protected void createMultiInstanceLoopCharacteristics(BpmnParse bpmnParse, Activity modelActivity) {
    MultiInstanceLoopCharacteristics loopCharacteristics = modelActivity.getLoopCharacteristics();
    // Activity Behavior
    MultiInstanceActivityBehavior miActivityBehavior = null;
    ActivityImpl activity = bpmnParse.getCurrentScope().findActivity(modelActivity.getId());
    if (activity == null) {
        throw new ActivitiException("Activity " + modelActivity.getId() + " needed for multi instance cannot bv found");
    }
    if (loopCharacteristics.isSequential()) {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createSequentialMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    } else {
        miActivityBehavior = bpmnParse.getActivityBehaviorFactory().createParallelMultiInstanceBehavior(activity, (AbstractBpmnActivityBehavior) activity.getActivityBehavior());
    }
    // ActivityImpl settings
    activity.setScope(true);
    activity.setProperty("multiInstance", loopCharacteristics.isSequential() ? "sequential" : "parallel");
    activity.setActivityBehavior(miActivityBehavior);
    ExpressionManager expressionManager = bpmnParse.getExpressionManager();
    BpmnModel bpmnModel = bpmnParse.getBpmnModel();
    // loopcardinality
    if (StringUtils.isNotEmpty(loopCharacteristics.getLoopCardinality())) {
        miActivityBehavior.setLoopCardinalityExpression(expressionManager.createExpression(loopCharacteristics.getLoopCardinality()));
    }
    // completion condition
    if (StringUtils.isNotEmpty(loopCharacteristics.getCompletionCondition())) {
        miActivityBehavior.setCompletionConditionExpression(expressionManager.createExpression(loopCharacteristics.getCompletionCondition()));
    }
    // activiti:collection
    if (StringUtils.isNotEmpty(loopCharacteristics.getInputDataItem())) {
        if (loopCharacteristics.getInputDataItem().contains("{")) {
            miActivityBehavior.setCollectionExpression(expressionManager.createExpression(loopCharacteristics.getInputDataItem()));
        } else {
            miActivityBehavior.setCollectionVariable(loopCharacteristics.getInputDataItem());
        }
    }
    // activiti:elementVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementVariable())) {
        miActivityBehavior.setCollectionElementVariable(loopCharacteristics.getElementVariable());
    }
    // activiti:elementIndexVariable
    if (StringUtils.isNotEmpty(loopCharacteristics.getElementIndexVariable())) {
        miActivityBehavior.setCollectionElementIndexVariable(loopCharacteristics.getElementIndexVariable());
    }
}
Also used : ExpressionManager(org.activiti.engine.impl.el.ExpressionManager) ActivitiException(org.activiti.engine.ActivitiException) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) MultiInstanceLoopCharacteristics(org.activiti.bpmn.model.MultiInstanceLoopCharacteristics) AbstractBpmnActivityBehavior(org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior) MultiInstanceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 2 with MultiInstanceActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior in project Activiti by Activiti.

the class ExecutionEntity method signal.

// methods that translate to operations /////////////////////////////////////
public void signal(String signalName, Object signalData) {
    ensureActivityInitialized();
    SignallableActivityBehavior activityBehavior = (SignallableActivityBehavior) activity.getActivityBehavior();
    try {
        String signalledActivityId = activity.getId();
        activityBehavior.signal(this, signalName, signalData);
        // If needed, dispatch an event indicating an activity was signalled
        boolean isUserTask = (activityBehavior instanceof UserTaskActivityBehavior) || ((activityBehavior instanceof MultiInstanceActivityBehavior) && ((MultiInstanceActivityBehavior) activityBehavior).getInnerActivityBehavior() instanceof UserTaskActivityBehavior);
        if (!isUserTask && Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
            Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createSignalEvent(ActivitiEventType.ACTIVITY_SIGNALED, signalledActivityId, signalName, signalData, this.id, this.processInstanceId, this.processDefinitionId));
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new PvmException("couldn't process signal '" + signalName + "' on activity '" + activity.getId() + "': " + e.getMessage(), e);
    }
}
Also used : UserTaskActivityBehavior(org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior) SignallableActivityBehavior(org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior) PvmException(org.activiti.engine.impl.pvm.PvmException) ActivitiException(org.activiti.engine.ActivitiException) PvmException(org.activiti.engine.impl.pvm.PvmException) MultiInstanceActivityBehavior(org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)

Aggregations

ActivitiException (org.activiti.engine.ActivitiException)2 MultiInstanceActivityBehavior (org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior)2 BpmnModel (org.activiti.bpmn.model.BpmnModel)1 MultiInstanceLoopCharacteristics (org.activiti.bpmn.model.MultiInstanceLoopCharacteristics)1 AbstractBpmnActivityBehavior (org.activiti.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior)1 UserTaskActivityBehavior (org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior)1 ExpressionManager (org.activiti.engine.impl.el.ExpressionManager)1 PvmException (org.activiti.engine.impl.pvm.PvmException)1 SignallableActivityBehavior (org.activiti.engine.impl.pvm.delegate.SignallableActivityBehavior)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1