use of org.activiti.bpmn.model.FlowElement in project Activiti by Activiti.
the class DefaultWorkflowDefinitionConversionListener method generateSequenceflowMappings.
protected SequenceFlowMapping generateSequenceflowMappings(Process process) {
HashMap<String, List<SequenceFlow>> incomingSequenceFlowMapping = new HashMap<String, List<SequenceFlow>>();
HashMap<String, List<SequenceFlow>> outgoingSequenceFlowMapping = new HashMap<String, List<SequenceFlow>>();
for (FlowElement flowElement : process.findFlowElementsOfType(SequenceFlow.class)) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
String srcId = sequenceFlow.getSourceRef();
String targetId = sequenceFlow.getTargetRef();
if (outgoingSequenceFlowMapping.get(srcId) == null) {
outgoingSequenceFlowMapping.put(srcId, new ArrayList<SequenceFlow>());
}
outgoingSequenceFlowMapping.get(srcId).add(sequenceFlow);
if (incomingSequenceFlowMapping.get(targetId) == null) {
incomingSequenceFlowMapping.put(targetId, new ArrayList<SequenceFlow>());
}
incomingSequenceFlowMapping.get(targetId).add(sequenceFlow);
}
SequenceFlowMapping mapping = new SequenceFlowMapping();
mapping.setIncomingSequenceFlowMapping(incomingSequenceFlowMapping);
mapping.setOutgoingSequenceFlowMapping(outgoingSequenceFlowMapping);
return mapping;
}
use of org.activiti.bpmn.model.FlowElement in project Activiti by Activiti.
the class SequenceFlowJsonConverter method convertToJson.
@Override
public void convertToJson(BaseElement baseElement, ActivityProcessor processor, BpmnModel model, FlowElementsContainer container, ArrayNode shapesArrayNode, double subProcessX, double subProcessY) {
SequenceFlow sequenceFlow = (SequenceFlow) baseElement;
ObjectNode flowNode = BpmnJsonConverterUtil.createChildShape(sequenceFlow.getId(), STENCIL_SEQUENCE_FLOW, 172, 212, 128, 212);
ArrayNode dockersArrayNode = objectMapper.createArrayNode();
ObjectNode dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getSourceRef()).getWidth() / 2.0);
dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getSourceRef()).getHeight() / 2.0);
dockersArrayNode.add(dockNode);
if (model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() > 2) {
for (int i = 1; i < model.getFlowLocationGraphicInfo(sequenceFlow.getId()).size() - 1; i++) {
GraphicInfo graphicInfo = model.getFlowLocationGraphicInfo(sequenceFlow.getId()).get(i);
dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, graphicInfo.getX());
dockNode.put(EDITOR_BOUNDS_Y, graphicInfo.getY());
dockersArrayNode.add(dockNode);
}
}
dockNode = objectMapper.createObjectNode();
dockNode.put(EDITOR_BOUNDS_X, model.getGraphicInfo(sequenceFlow.getTargetRef()).getWidth() / 2.0);
dockNode.put(EDITOR_BOUNDS_Y, model.getGraphicInfo(sequenceFlow.getTargetRef()).getHeight() / 2.0);
dockersArrayNode.add(dockNode);
flowNode.put("dockers", dockersArrayNode);
ArrayNode outgoingArrayNode = objectMapper.createArrayNode();
outgoingArrayNode.add(BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
flowNode.put("outgoing", outgoingArrayNode);
flowNode.put("target", BpmnJsonConverterUtil.createResourceNode(sequenceFlow.getTargetRef()));
ObjectNode propertiesNode = objectMapper.createObjectNode();
propertiesNode.put(PROPERTY_OVERRIDE_ID, sequenceFlow.getId());
if (StringUtils.isNotEmpty(sequenceFlow.getName())) {
propertiesNode.put(PROPERTY_NAME, sequenceFlow.getName());
}
if (StringUtils.isNotEmpty(sequenceFlow.getDocumentation())) {
propertiesNode.put(PROPERTY_DOCUMENTATION, sequenceFlow.getDocumentation());
}
if (StringUtils.isNotEmpty(sequenceFlow.getConditionExpression())) {
propertiesNode.put(PROPERTY_SEQUENCEFLOW_CONDITION, sequenceFlow.getConditionExpression());
}
if (StringUtils.isNotEmpty(sequenceFlow.getSourceRef())) {
FlowElement sourceFlowElement = container.getFlowElement(sequenceFlow.getSourceRef());
if (sourceFlowElement != null) {
String defaultFlowId = null;
if (sourceFlowElement instanceof ExclusiveGateway) {
ExclusiveGateway parentExclusiveGateway = (ExclusiveGateway) sourceFlowElement;
defaultFlowId = parentExclusiveGateway.getDefaultFlow();
} else if (sourceFlowElement instanceof Activity) {
Activity parentActivity = (Activity) sourceFlowElement;
defaultFlowId = parentActivity.getDefaultFlow();
}
if (defaultFlowId != null && defaultFlowId.equals(sequenceFlow.getId())) {
propertiesNode.put(PROPERTY_SEQUENCEFLOW_DEFAULT, true);
}
}
}
if (sequenceFlow.getExecutionListeners().size() > 0) {
BpmnJsonConverterUtil.convertListenersToJson(sequenceFlow.getExecutionListeners(), true, propertiesNode);
}
flowNode.put(EDITOR_SHAPE_PROPERTIES, propertiesNode);
shapesArrayNode.add(flowNode);
}
use of org.activiti.bpmn.model.FlowElement in project Activiti by Activiti.
the class ScopedConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("outerSubProcess");
assertNotNull(flowElement);
assertTrue(flowElement instanceof SubProcess);
assertEquals("outerSubProcess", flowElement.getId());
SubProcess outerSubProcess = (SubProcess) flowElement;
List<BoundaryEvent> eventList = outerSubProcess.getBoundaryEvents();
assertEquals(1, eventList.size());
BoundaryEvent boundaryEvent = eventList.get(0);
assertEquals("outerBoundaryEvent", boundaryEvent.getId());
FlowElement subElement = outerSubProcess.getFlowElement("innerSubProcess");
assertNotNull(subElement);
assertTrue(subElement instanceof SubProcess);
assertEquals("innerSubProcess", subElement.getId());
SubProcess innerSubProcess = (SubProcess) subElement;
eventList = innerSubProcess.getBoundaryEvents();
assertEquals(1, eventList.size());
boundaryEvent = eventList.get(0);
assertEquals("innerBoundaryEvent", boundaryEvent.getId());
FlowElement taskElement = innerSubProcess.getFlowElement("usertask");
assertNotNull(taskElement);
assertTrue(taskElement instanceof UserTask);
UserTask userTask = (UserTask) taskElement;
assertEquals("usertask", userTask.getId());
eventList = userTask.getBoundaryEvents();
assertEquals(1, eventList.size());
boundaryEvent = eventList.get(0);
assertEquals("taskBoundaryEvent", boundaryEvent.getId());
}
use of org.activiti.bpmn.model.FlowElement in project Activiti by Activiti.
the class ServiceTaskConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("servicetask");
assertNotNull(flowElement);
assertTrue(flowElement instanceof ServiceTask);
assertEquals("servicetask", flowElement.getId());
ServiceTask serviceTask = (ServiceTask) flowElement;
assertEquals("servicetask", serviceTask.getId());
assertEquals("Service task", serviceTask.getName());
List<FieldExtension> fields = serviceTask.getFieldExtensions();
assertEquals(2, fields.size());
FieldExtension field = (FieldExtension) fields.get(0);
assertEquals("testField", field.getFieldName());
assertEquals("test", field.getStringValue());
field = (FieldExtension) fields.get(1);
assertEquals("testField2", field.getFieldName());
assertEquals("${test}", field.getExpression());
List<ActivitiListener> listeners = serviceTask.getExecutionListeners();
assertEquals(3, listeners.size());
ActivitiListener listener = (ActivitiListener) listeners.get(0);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(listener.getImplementationType()));
assertEquals("org.test.TestClass", listener.getImplementation());
assertEquals("start", listener.getEvent());
listener = (ActivitiListener) listeners.get(1);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(listener.getImplementationType()));
assertEquals("${testExpression}", listener.getImplementation());
assertEquals("end", listener.getEvent());
listener = (ActivitiListener) listeners.get(2);
assertTrue(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(listener.getImplementationType()));
assertEquals("${delegateExpression}", listener.getImplementation());
assertEquals("start", listener.getEvent());
}
use of org.activiti.bpmn.model.FlowElement in project Activiti by Activiti.
the class StartEventConverterTest method validateModel.
private void validateModel(BpmnModel model) {
FlowElement flowElement = model.getMainProcess().getFlowElement("start");
assertTrue(flowElement instanceof StartEvent);
StartEvent startEvent = (StartEvent) flowElement;
assertEquals("start", startEvent.getId());
assertEquals("startName", startEvent.getName());
assertEquals("startFormKey", startEvent.getFormKey());
assertEquals("startInitiator", startEvent.getInitiator());
assertEquals("startDoc", startEvent.getDocumentation());
List<FormProperty> formProperties = startEvent.getFormProperties();
assertEquals(2, formProperties.size());
FormProperty formProperty = formProperties.get(0);
assertEquals("startFormProp1", formProperty.getId());
assertEquals("startFormProp1", formProperty.getName());
assertEquals("string", formProperty.getType());
formProperty = formProperties.get(1);
assertEquals("startFormProp2", formProperty.getId());
assertEquals("startFormProp2", formProperty.getName());
assertEquals("boolean", formProperty.getType());
}
Aggregations