use of org.camunda.bpm.model.bpmn.instance.SequenceFlow in project camunda-bpmn-model by camunda.
the class SequenceFlowImpl method registerType.
public static void registerType(ModelBuilder modelBuilder) {
ModelElementTypeBuilder typeBuilder = modelBuilder.defineType(SequenceFlow.class, BPMN_ELEMENT_SEQUENCE_FLOW).namespaceUri(BPMN20_NS).extendsType(FlowElement.class).instanceProvider(new ModelTypeInstanceProvider<SequenceFlow>() {
public SequenceFlow newInstance(ModelTypeInstanceContext instanceContext) {
return new SequenceFlowImpl(instanceContext);
}
});
sourceRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_SOURCE_REF).required().idAttributeReference(FlowNode.class).build();
targetRefAttribute = typeBuilder.stringAttribute(BPMN_ATTRIBUTE_TARGET_REF).required().idAttributeReference(FlowNode.class).build();
isImmediateAttribute = typeBuilder.booleanAttribute(BPMN_ATTRIBUTE_IS_IMMEDIATE).build();
SequenceBuilder sequenceBuilder = typeBuilder.sequence();
conditionExpressionCollection = sequenceBuilder.element(ConditionExpression.class).build();
typeBuilder.build();
}
use of org.camunda.bpm.model.bpmn.instance.SequenceFlow in project camunda-bpmn-model by camunda.
the class FlowNodeImpl method updateAfterReplacement.
@SuppressWarnings("rawtypes")
public void updateAfterReplacement() {
super.updateAfterReplacement();
Collection<Reference> incomingReferences = getIncomingReferencesByType(SequenceFlow.class);
for (Reference<?> reference : incomingReferences) {
for (ModelElementInstance sourceElement : reference.findReferenceSourceElements(this)) {
String referenceIdentifier = reference.getReferenceIdentifier(sourceElement);
if (referenceIdentifier != null && referenceIdentifier.equals(getId()) && reference instanceof AttributeReference) {
String attributeName = ((AttributeReference) reference).getReferenceSourceAttribute().getAttributeName();
if (attributeName.equals(BPMN_ATTRIBUTE_SOURCE_REF)) {
getOutgoing().add((SequenceFlow) sourceElement);
} else if (attributeName.equals(BPMN_ATTRIBUTE_TARGET_REF)) {
getIncoming().add((SequenceFlow) sourceElement);
}
}
}
}
}
use of org.camunda.bpm.model.bpmn.instance.SequenceFlow in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testSetVariableInTakeListener.
@Test
public void testSetVariableInTakeListener() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).endEvent().done();
CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
listener.setCamundaExpression(EXPR_SET_VARIABLE);
modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, true);
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_BEFORE_CONDITION, task.getName());
// when task is completed
taskService.complete(task.getId());
// then take listener sets variable
// non interrupting boundary event is triggered with default evaluation behavior
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(TASK_AFTER_CONDITION, tasksAfterVariableIsSet.get(0).getName());
}
use of org.camunda.bpm.model.bpmn.instance.SequenceFlow in project camunda-bpm-platform by camunda.
the class BoundaryConditionalEventTest method testNonInterruptingSetVariableInTakeListener.
@Test
public void testNonInterruptingSetVariableInTakeListener() {
final BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent().userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).endEvent().done();
CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
listener.setCamundaExpression(EXPR_SET_VARIABLE);
modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
deployConditionalBoundaryEventProcess(modelInstance, TASK_WITH_CONDITION_ID, false);
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_BEFORE_CONDITION, task.getName());
// when task is completed
taskService.complete(task.getId());
// then take listener sets variable
// non interrupting boundary event is triggered with default evaluation behavior
tasksAfterVariableIsSet = taskQuery.list();
assertEquals(2, tasksAfterVariableIsSet.size());
}
use of org.camunda.bpm.model.bpmn.instance.SequenceFlow in project camunda-bpm-platform by camunda.
the class ConditionalEventTriggeredByExecutionListenerTest method testSetVariableInTakeListenerWithAsyncBefore.
@Test
public void testSetVariableInTakeListenerWithAsyncBefore() {
BpmnModelInstance modelInstance = Bpmn.createExecutableProcess(CONDITIONAL_EVENT_PROCESS_KEY).startEvent(START_EVENT_ID).userTask(TASK_BEFORE_CONDITION_ID).name(TASK_BEFORE_CONDITION).sequenceFlowId(FLOW_ID).userTask(TASK_WITH_CONDITION_ID).name(TASK_WITH_CONDITION).camundaAsyncBefore().endEvent(END_EVENT_ID).done();
CamundaExecutionListener listener = modelInstance.newInstance(CamundaExecutionListener.class);
listener.setCamundaEvent(ExecutionListener.EVENTNAME_TAKE);
listener.setCamundaExpression(EXPR_SET_VARIABLE);
modelInstance.<SequenceFlow>getModelElementById(FLOW_ID).builder().addExtensionElement(listener);
modelInstance = specifier.specifyConditionalProcess(modelInstance, true);
engine.manageDeployment(repositoryService.createDeployment().addModelInstance(CONDITIONAL_MODEL, modelInstance).deploy());
// given
ProcessInstance procInst = runtimeService.startProcessInstanceByKey(CONDITIONAL_EVENT_PROCESS_KEY);
TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(procInst.getId());
Task task = taskQuery.singleResult();
assertNotNull(task);
assertEquals(TASK_BEFORE_CONDITION, task.getName());
// when task is completed
taskService.complete(task.getId());
// then take listener sets variable
// conditional event is triggered
tasksAfterVariableIsSet = taskQuery.list();
specifier.assertTaskNames(tasksAfterVariableIsSet, true, false);
}
Aggregations