use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnAutoLayout method handleSequenceFlow.
protected void handleSequenceFlow() {
Hashtable<String, Object> edgeStyle = new Hashtable<String, Object>();
edgeStyle.put(mxConstants.STYLE_ORTHOGONAL, true);
edgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.ElbowConnector);
edgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.0);
edgeStyle.put(mxConstants.STYLE_ENTRY_Y, 0.5);
graph.getStylesheet().putCellStyle(STYLE_SEQUENCEFLOW, edgeStyle);
Hashtable<String, Object> boundaryEdgeStyle = new Hashtable<String, Object>();
boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_X, 0.5);
boundaryEdgeStyle.put(mxConstants.STYLE_EXIT_Y, 1.0);
boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_X, 0.5);
boundaryEdgeStyle.put(mxConstants.STYLE_ENTRY_Y, 1.0);
boundaryEdgeStyle.put(mxConstants.STYLE_EDGE, mxEdgeStyle.OrthConnector);
graph.getStylesheet().putCellStyle(STYLE_BOUNDARY_SEQUENCEFLOW, boundaryEdgeStyle);
for (SequenceFlow sequenceFlow : sequenceFlows.values()) {
Object sourceVertex = generatedVertices.get(sequenceFlow.getSourceRef());
Object targetVertex = generatedVertices.get(sequenceFlow.getTargetRef());
String style = null;
if (handledFlowElements.get(sequenceFlow.getSourceRef()) instanceof BoundaryEvent) {
// Sequence flow out of boundary events are handled in a
// different way,
// to make them visually appealing for the eye of the dear end
// user.
style = STYLE_BOUNDARY_SEQUENCEFLOW;
} else {
style = STYLE_SEQUENCEFLOW;
}
Object sequenceFlowEdge = graph.insertEdge(cellParent, sequenceFlow.getId(), "", sourceVertex, targetVertex, style);
generatedSequenceFlowEdges.put(sequenceFlow.getId(), sequenceFlowEdge);
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BaseBpmnXMLConverter method convertToXML.
public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) throws Exception {
xtw.writeStartElement(BPMN2_PREFIX, getXMLElementName(), BPMN2_NAMESPACE);
boolean didWriteExtensionStartElement = false;
writeDefaultAttribute(ATTRIBUTE_ID, baseElement.getId(), xtw);
if (baseElement instanceof FlowElement) {
writeDefaultAttribute(ATTRIBUTE_NAME, ((FlowElement) baseElement).getName(), xtw);
}
if (baseElement instanceof FlowNode) {
final FlowNode flowNode = (FlowNode) baseElement;
if (flowNode.isAsynchronous()) {
writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
if (flowNode.isNotExclusive()) {
writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
}
}
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
if (activity.isForCompensation()) {
writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw);
}
if (StringUtils.isNotEmpty(activity.getDefaultFlow())) {
FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow());
if (defaultFlowElement instanceof SequenceFlow) {
writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw);
}
}
}
if (baseElement instanceof Gateway) {
final Gateway gateway = (Gateway) baseElement;
if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
if (defaultFlowElement instanceof SequenceFlow) {
writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
}
}
}
}
writeAdditionalAttributes(baseElement, model, xtw);
if (baseElement instanceof FlowElement) {
final FlowElement flowElement = (FlowElement) baseElement;
if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
xtw.writeStartElement(BPMN2_PREFIX, ELEMENT_DOCUMENTATION, BPMN2_NAMESPACE);
xtw.writeCharacters(flowElement.getDocumentation());
xtw.writeEndElement();
}
}
didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, model.getNamespaces(), xtw);
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
FailedJobRetryCountExport.writeFailedJobRetryCount(activity, xtw);
}
if (didWriteExtensionStartElement) {
xtw.writeEndElement();
}
writeIncomingOutgoingFlowElements(baseElement, model, xtw);
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
MultiInstanceExport.writeMultiInstance(activity, xtw);
}
writeAdditionalChildElements(baseElement, model, xtw);
xtw.writeEndElement();
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class SubprocessXMLConverter method parseSubModels.
private List<BpmnModel> parseSubModels(FlowElement subElement, Map<String, GraphicInfo> locations, Map<String, List<GraphicInfo>> flowLocations, Map<String, GraphicInfo> labelLocations) {
List<BpmnModel> subModels = new ArrayList<BpmnModel>();
BpmnModel subModel = new BpmnModel();
String elementId = null;
// find nested subprocess models
Collection<FlowElement> subFlowElements = ((SubProcess) subElement).getFlowElements();
// set main process in submodel to subprocess
Process newMainProcess = new Process();
newMainProcess.setId(subElement.getId());
newMainProcess.getFlowElements().addAll(subFlowElements);
newMainProcess.getArtifacts().addAll(((SubProcess) subElement).getArtifacts());
subModel.addProcess(newMainProcess);
for (FlowElement element : subFlowElements) {
elementId = element.getId();
if (element instanceof SubProcess) {
subModels.addAll(parseSubModels(element, locations, flowLocations, labelLocations));
}
if (element instanceof SequenceFlow && null != flowLocations.get(elementId)) {
// must be an edge
subModel.getFlowLocationMap().put(elementId, flowLocations.get(elementId));
} else {
// do not include data objects because they do not have a corresponding shape in the BPMNDI data
if (!(element instanceof DataObject) && null != locations.get(elementId)) {
// must be a shape
subModel.getLocationMap().put(elementId, locations.get(elementId));
}
}
// also check for any labels
if (null != labelLocations.get(elementId)) {
subModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
}
}
subModels.add(subModel);
return subModels;
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class BpmnXMLConverter method processFlowElements.
protected void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
for (FlowElement flowElement : flowElementList) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
if (sourceNode != null) {
sourceNode.getOutgoingFlows().add(sequenceFlow);
sequenceFlow.setSourceFlowElement(sourceNode);
}
FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
if (targetNode != null) {
targetNode.getIncomingFlows().add(sequenceFlow);
sequenceFlow.setTargetFlowElement(targetNode);
}
} else if (flowElement instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
if (attachedToElement instanceof Activity) {
Activity attachedActivity = (Activity) attachedToElement;
boundaryEvent.setAttachedToRef(attachedActivity);
attachedActivity.getBoundaryEvents().add(boundaryEvent);
}
} else if (flowElement instanceof SubProcess) {
SubProcess subProcess = (SubProcess) flowElement;
processFlowElements(subProcess.getFlowElements(), subProcess);
}
}
}
use of org.activiti.bpmn.model.SequenceFlow in project Activiti by Activiti.
the class SequenceFlowXMLConverter method writeAdditionalAttributes.
@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw) throws Exception {
SequenceFlow sequenceFlow = (SequenceFlow) element;
writeDefaultAttribute(ATTRIBUTE_FLOW_SOURCE_REF, sequenceFlow.getSourceRef(), xtw);
writeDefaultAttribute(ATTRIBUTE_FLOW_TARGET_REF, sequenceFlow.getTargetRef(), xtw);
if (StringUtils.isNotEmpty(sequenceFlow.getSkipExpression())) {
writeDefaultAttribute(ATTRIBUTE_FLOW_SKIP_EXPRESSION, sequenceFlow.getSkipExpression(), xtw);
}
}
Aggregations