use of org.activiti.bpmn.model.EndEvent in project Activiti by Activiti.
the class AsyncEndEventConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("endEvent");
assertNotNull(flowElement);
assertTrue(flowElement instanceof EndEvent);
assertEquals("endEvent", flowElement.getId());
EndEvent endEvent = (EndEvent) flowElement;
assertEquals("endEvent", endEvent.getId());
assertTrue(endEvent.isAsynchronous());
List<ActivitiListener> listeners = endEvent.getExecutionListeners();
assertEquals(1, listeners.size());
ActivitiListener listener = listeners.get(0);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
assertEquals("org.test.TestClass", listener.getImplementation());
assertEquals("start", listener.getEvent());
}
use of org.activiti.bpmn.model.EndEvent in project Activiti by Activiti.
the class AlfrescoEndProcessStepConverter method createProcessArtifact.
@Override
protected EndEvent createProcessArtifact(AlfrescoEndProcessStepDefinition stepDefinition, WorkflowDefinitionConversion conversion) {
EndEvent endEvent = new EndEvent();
endEvent.setId(conversion.getUniqueNumberedId(ConversionConstants.EVENT_ID_PREFIX));
addFlowElement(conversion, endEvent, true);
return endEvent;
}
use of org.activiti.bpmn.model.EndEvent in project Activiti by Activiti.
the class DefaultWorkflowDefinitionConversionListener method afterStepsConversion.
public void afterStepsConversion(WorkflowDefinitionConversion conversion) {
// Add end-event to process
Process process = conversion.getProcess();
EndEvent endEvent = new EndEvent();
endEvent.setId(END_EVENT_ID);
process.addFlowElement(endEvent);
// Sequence flow from last created activity to end
SequenceFlow sequenceFlow = new SequenceFlow();
sequenceFlow.setId(conversion.getUniqueNumberedId(ConversionConstants.DEFAULT_SEQUENCEFLOW_PREFIX));
sequenceFlow.setSourceRef(conversion.getLastActivityId());
sequenceFlow.setTargetRef(END_EVENT_ID);
process.addFlowElement(sequenceFlow);
// To make the generated workflow compatible with some tools (eg the
// Modeler, but also others),
// We must add the ingoing and outgoing sequence flow to each of the flow
// nodes
SequenceFlowMapping sequenceFlowMapping = generateSequenceflowMappings(process);
for (FlowNode flowNode : process.findFlowElementsOfType(FlowNode.class)) {
List<SequenceFlow> incomingSequenceFlow = sequenceFlowMapping.getIncomingSequenceFlowMapping().get(flowNode.getId());
if (incomingSequenceFlow != null) {
flowNode.setIncomingFlows(incomingSequenceFlow);
}
List<SequenceFlow> outgoingSequenceFlow = sequenceFlowMapping.getOutgoingSequenceFlowMapping().get(flowNode.getId());
if (outgoingSequenceFlow != null) {
flowNode.setOutgoingFlows(outgoingSequenceFlow);
}
}
}
use of org.activiti.bpmn.model.EndEvent in project Activiti by Activiti.
the class ChoiceStepsDefinitionConverter method createProcessArtifact.
protected ExclusiveGateway createProcessArtifact(ChoiceStepsDefinition choiceStepsDefinition, WorkflowDefinitionConversion conversion) {
// First choice gateway
ExclusiveGateway forkGateway = createExclusiveGateway(conversion);
// Sequence flow from last activity to first gateway
addSequenceFlow(conversion, conversion.getLastActivityId(), forkGateway.getId());
conversion.setLastActivityId(forkGateway.getId());
// Convert all other steps, disabling activity id updates which makes all
// generated steps have a sequence flow to the first gateway
WorkflowDefinitionConversionFactory conversionFactory = conversion.getConversionFactory();
List<FlowElement> endElements = new ArrayList<FlowElement>();
List<SequenceFlow> bypassingFlows = new ArrayList<SequenceFlow>();
for (ListConditionStepDefinition<ChoiceStepsDefinition> stepListDefinition : choiceStepsDefinition.getStepList()) {
StringBuilder conditionBuilder = new StringBuilder();
for (ConditionDefinition conditionDefintion : stepListDefinition.getConditions()) {
if (conditionBuilder.length() > 0) {
conditionBuilder.append(" && ");
} else {
conditionBuilder.append("${");
}
conditionBuilder.append(conditionDefintion.getLeftOperand());
conditionBuilder.append(" ");
conditionBuilder.append(conditionDefintion.getOperator());
conditionBuilder.append(" ");
conditionBuilder.append(conditionDefintion.getRightOperand());
}
for (int i = 0; i < stepListDefinition.getSteps().size(); i++) {
if (i == 0) {
conversion.setSequenceflowGenerationEnabled(false);
} else {
conversion.setSequenceflowGenerationEnabled(true);
}
StepDefinition step = stepListDefinition.getSteps().get(i);
FlowElement flowElement = (FlowElement) conversionFactory.getStepConverterFor(step).convertStepDefinition(step, conversion);
if (i == 0) {
if (conditionBuilder.length() > 0) {
conditionBuilder.append("}");
SequenceFlow mainFlow = addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId(), conditionBuilder.toString());
if (stepListDefinition.getName() != null) {
mainFlow.setName(stepListDefinition.getName());
}
} else {
addSequenceFlow(conversion, forkGateway.getId(), flowElement.getId());
}
}
if ((i + 1) == stepListDefinition.getSteps().size()) {
endElements.add(flowElement);
}
}
if (stepListDefinition.getSteps().isEmpty()) {
// Special case for a "stepless" stepListDefinition, which should just create a sequence-flow from the fork to the join
SequenceFlow created = null;
if (conditionBuilder.length() > 0) {
conditionBuilder.append("}");
created = addSequenceFlow(conversion, forkGateway.getId(), null, conditionBuilder.toString());
} else {
created = addSequenceFlow(conversion, forkGateway.getId(), null);
}
if (stepListDefinition.getName() != null) {
created.setName(stepListDefinition.getName());
}
bypassingFlows.add(created);
}
}
conversion.setSequenceflowGenerationEnabled(false);
// Second choice gateway
ExclusiveGateway joinGateway = createExclusiveGateway(conversion);
conversion.setLastActivityId(joinGateway.getId());
conversion.setSequenceflowGenerationEnabled(true);
// Create sequenceflow from all generated steps to the second gateway
for (FlowElement endElement : endElements) {
if (!(endElement instanceof EndEvent)) {
addSequenceFlow(conversion, endElement.getId(), joinGateway.getId());
}
}
for (SequenceFlow bypassingFlow : bypassingFlows) {
bypassingFlow.setTargetRef(joinGateway.getId());
}
return forkGateway;
}
use of org.activiti.bpmn.model.EndEvent in project herd by FINRAOS.
the class JobDefinitionServiceTest method testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync.
/**
* Asserts that update job definition proceeds without exceptions when first task is set to async
*
* @throws Exception
*/
@Test
public void testUpdateJobDefinitionAssertSuccessWhenFirstTaskAsync() throws Exception {
String namespace = NAMESPACE;
String jobName = JOB_NAME;
BpmnModel bpmnModel = new BpmnModel();
Process process = new Process();
process.setId(namespace + '.' + jobName);
{
StartEvent element = new StartEvent();
element.setId("start");
process.addFlowElement(element);
}
{
ScriptTask element = new ScriptTask();
element.setId("script");
element.setScriptFormat("js");
element.setScript("// do nothing");
element.setAsynchronous(true);
process.addFlowElement(element);
}
{
EndEvent element = new EndEvent();
element.setId("end");
process.addFlowElement(element);
}
process.addFlowElement(new SequenceFlow("start", "script"));
process.addFlowElement(new SequenceFlow("script", "end"));
bpmnModel.addProcess(process);
String activitiJobXml = getActivitiXmlFromBpmnModel(bpmnModel);
namespaceDaoTestHelper.createNamespaceEntity(namespace);
jobDefinitionService.createJobDefinition(new JobDefinitionCreateRequest(namespace, jobName, null, activitiJobXml, null, null), true);
jobDefinitionService.updateJobDefinition(namespace, jobName, new JobDefinitionUpdateRequest(null, activitiJobXml, null, null), true);
// Assert no exceptions
}
Aggregations