use of org.activiti.bpmn.model.DataObject in project Activiti by Activiti.
the class SubprocessXMLConverter method parseSubModels.
protected List<BpmnModel> parseSubModels(BpmnModel model) {
List<BpmnModel> subModels = new ArrayList<BpmnModel>();
// find all subprocesses
Collection<FlowElement> flowElements = model.getMainProcess().getFlowElements();
Map<String, GraphicInfo> locations = new HashMap<String, GraphicInfo>();
Map<String, List<GraphicInfo>> flowLocations = new HashMap<String, List<GraphicInfo>>();
Map<String, GraphicInfo> labelLocations = new HashMap<String, GraphicInfo>();
locations.putAll(model.getLocationMap());
flowLocations.putAll(model.getFlowLocationMap());
labelLocations.putAll(model.getLabelLocationMap());
// include main process as separate model
BpmnModel mainModel = new BpmnModel();
// set main process in submodel to subprocess
mainModel.addProcess(model.getMainProcess());
String elementId = null;
for (FlowElement element : flowElements) {
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
mainModel.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
mainModel.getLocationMap().put(elementId, locations.get(elementId));
}
}
// also check for any labels
if (null != labelLocations.get(elementId)) {
mainModel.getLabelLocationMap().put(elementId, labelLocations.get(elementId));
}
}
// add main process model to list
subModels.add(mainModel);
return subModels;
}
use of org.activiti.bpmn.model.DataObject in project Activiti by Activiti.
the class BpmnAutoLayout method translateNestedSubprocessElements.
protected void translateNestedSubprocessElements(SubProcess subProcess) {
GraphicInfo subProcessGraphicInfo = bpmnModel.getLocationMap().get(subProcess.getId());
double subProcessX = subProcessGraphicInfo.getX();
double subProcessY = subProcessGraphicInfo.getY();
List<SubProcess> nestedSubProcesses = new ArrayList<SubProcess>();
for (FlowElement flowElement : subProcess.getFlowElements()) {
if (flowElement instanceof SequenceFlow) {
List<GraphicInfo> graphicInfos = bpmnModel.getFlowLocationMap().get(flowElement.getId());
for (GraphicInfo graphicInfo : graphicInfos) {
graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
}
} else if (flowElement instanceof DataObject == false) {
// Regular element
GraphicInfo graphicInfo = bpmnModel.getLocationMap().get(flowElement.getId());
graphicInfo.setX(graphicInfo.getX() + subProcessX + subProcessMargin);
graphicInfo.setY(graphicInfo.getY() + subProcessY + subProcessMargin);
}
if (flowElement instanceof SubProcess) {
nestedSubProcesses.add((SubProcess) flowElement);
}
}
// Continue for next level of nested subprocesses
for (SubProcess nestedSubProcess : nestedSubProcesses) {
translateNestedSubprocessElements(nestedSubProcess);
}
}
use of org.activiti.bpmn.model.DataObject in project Activiti by Activiti.
the class BaseBpmnXMLConverter method convertToBpmnModel.
public void convertToBpmnModel(XMLStreamReader xtr, BpmnModel model, Process activeProcess, List<SubProcess> activeSubProcessList) throws Exception {
String elementId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
String elementName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
boolean async = parseAsync(xtr);
boolean notExclusive = parseNotExclusive(xtr);
String defaultFlow = xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT);
boolean isForCompensation = parseForCompensation(xtr);
BaseElement parsedElement = convertXMLToElement(xtr, model);
if (parsedElement instanceof Artifact) {
Artifact currentArtifact = (Artifact) parsedElement;
currentArtifact.setId(elementId);
if (!activeSubProcessList.isEmpty()) {
activeSubProcessList.get(activeSubProcessList.size() - 1).addArtifact(currentArtifact);
} else {
activeProcess.addArtifact(currentArtifact);
}
}
if (parsedElement instanceof FlowElement) {
FlowElement currentFlowElement = (FlowElement) parsedElement;
currentFlowElement.setId(elementId);
currentFlowElement.setName(elementName);
if (currentFlowElement instanceof FlowNode) {
FlowNode flowNode = (FlowNode) currentFlowElement;
flowNode.setAsynchronous(async);
flowNode.setNotExclusive(notExclusive);
if (currentFlowElement instanceof Activity) {
Activity activity = (Activity) currentFlowElement;
activity.setForCompensation(isForCompensation);
if (StringUtils.isNotEmpty(defaultFlow)) {
activity.setDefaultFlow(defaultFlow);
}
}
if (currentFlowElement instanceof Gateway) {
Gateway gateway = (Gateway) currentFlowElement;
if (StringUtils.isNotEmpty(defaultFlow)) {
gateway.setDefaultFlow(defaultFlow);
}
}
}
if (currentFlowElement instanceof DataObject) {
if (!activeSubProcessList.isEmpty()) {
SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1);
subProcess.getDataObjects().add((ValuedDataObject) parsedElement);
} else {
activeProcess.getDataObjects().add((ValuedDataObject) parsedElement);
}
}
if (!activeSubProcessList.isEmpty()) {
SubProcess subProcess = activeSubProcessList.get(activeSubProcessList.size() - 1);
subProcess.addFlowElement(currentFlowElement);
} else {
activeProcess.addFlowElement(currentFlowElement);
}
}
}
use of org.activiti.bpmn.model.DataObject 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;
}
Aggregations