use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallProcess.
protected void marshallProcess(Process process, Definitions def, JsonGenerator generator, String preProcessingData) throws JsonGenerationException, IOException {
BPMNPlane plane = null;
for (BPMNDiagram d : def.getDiagrams()) {
if (d != null) {
BPMNPlane p = d.getPlane();
if (p != null) {
if (p.getBpmnElement() == process) {
plane = p;
break;
}
}
}
}
if (plane == null) {
throw new IllegalArgumentException("Could not find BPMNDI information");
}
generator.writeArrayFieldStart("childShapes");
List<String> laneFlowElementsIds = new ArrayList<String>();
for (LaneSet laneSet : process.getLaneSets()) {
for (Lane lane : laneSet.getLanes()) {
// we only want to marshall lanes if we have the bpmndi info for them!
if (findDiagramElement(plane, lane) != null) {
laneFlowElementsIds.addAll(marshallLanes(lane, plane, generator, 0, 0, preProcessingData, def));
}
}
}
for (FlowElement flowElement : process.getFlowElements()) {
if (!laneFlowElementsIds.contains(flowElement.getId())) {
marshallFlowElement(flowElement, plane, generator, 0, 0, preProcessingData, def);
}
}
for (Artifact artifact : process.getArtifacts()) {
marshallArtifact(artifact, plane, generator, 0, 0, preProcessingData, def);
}
generator.writeEndArray();
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method linkSequenceFlows.
private void linkSequenceFlows(List<FlowElement> flowElements) {
Map<String, FlowNode> nodes = new HashMap<String, FlowNode>();
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof FlowNode) {
nodes.put(flowElement.getId(), (FlowNode) flowElement);
if (flowElement instanceof SubProcess) {
linkSequenceFlows(((SubProcess) flowElement).getFlowElements());
}
}
}
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (sequenceFlow.getSourceRef() == null && sequenceFlow.getTargetRef() == null) {
String id = sequenceFlow.getId();
try {
String[] subids = id.split("-_");
String id1 = subids[0];
String id2 = "_" + subids[1];
FlowNode source = nodes.get(id1);
if (source != null) {
sequenceFlow.setSourceRef(source);
}
FlowNode target = nodes.get(id2);
if (target != null) {
sequenceFlow.setTargetRef(target);
}
} catch (Throwable t) {
// Do nothing
}
}
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitBoundaryEventsPositions.
protected void revisitBoundaryEventsPositions(Definitions def) {
for (RootElement root : def.getRootElements()) {
if (root instanceof Process) {
Process process = (Process) root;
List<BoundaryEvent> toRemove = new ArrayList();
for (FlowElement fe : process.getFlowElements()) {
if (fe instanceof BoundaryEvent) {
BoundaryEvent be = (BoundaryEvent) fe;
FlowElementsContainer container = findContainerForBoundaryEvent(process, be);
if (container != null && !(container instanceof Process)) {
BoundaryEvent beCopy = copyBoundaryEvent(be);
container.getFlowElements().add(beCopy);
_outgoingFlows.put(beCopy, _outgoingFlows.get(be));
toRemove.add(be);
_outgoingFlows.remove(be);
}
}
}
for (BoundaryEvent be : toRemove) {
process.getFlowElements().remove(be);
}
}
}
reconnectFlows();
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateIDs.
public void updateIDs(Definitions def) {
// data object id update
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
if (process.getId() != null) {
String processId = process.getId().trim();
processId = processId.replaceAll("\\s", "");
process.setId(processId);
}
List<FlowElement> flowElements = process.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof DataObject) {
DataObject da = (DataObject) fe;
if (da.getName() != null) {
String daId = da.getName().trim();
daId = daId.replaceAll("\\W", "");
da.setId(daId);
}
}
}
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setThrowEventsInfoForLanes.
public void setThrowEventsInfoForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
for (FlowNode fe : laneFlowNodes) {
if (fe instanceof ThrowEvent) {
if (((ThrowEvent) fe).getEventDefinitions().size() > 0) {
EventDefinition ed = ((ThrowEvent) fe).getEventDefinitions().get(0);
if (ed instanceof SignalEventDefinition) {
SignalEventDefinition sed = (SignalEventDefinition) ed;
if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
String signalRef = sed.getSignalRef();
boolean shouldAddSignal = true;
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (((Signal) re).getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (toAddSignals != null) {
for (Signal s : toAddSignals) {
if (s.getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (shouldAddSignal) {
Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
signal.setName(signalRef);
toAddSignals.add(signal);
}
}
} else if (ed instanceof ErrorEventDefinition) {
String errorCode = null;
String errorId = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("erefname")) {
errorId = (String) entry.getValue();
errorCode = (String) entry.getValue();
}
}
Error err = this._errors.get(errorCode);
if (err == null) {
err = Bpmn2Factory.eINSTANCE.createError();
err.setId(errorId);
err.setErrorCode(errorCode);
this._errors.put(errorCode, err);
}
toAddErrors.add(err);
((ErrorEventDefinition) ed).setErrorRef(err);
} else if (ed instanceof EscalationEventDefinition) {
String escalationCode = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("esccode")) {
escalationCode = (String) entry.getValue();
break;
}
}
Escalation escalation = this._escalations.get(escalationCode);
if (escalation == null) {
escalation = Bpmn2Factory.eINSTANCE.createEscalation();
escalation.setEscalationCode(escalationCode);
this._escalations.put(escalationCode, escalation);
}
toAddEscalations.add(escalation);
((EscalationEventDefinition) ed).setEscalationRef(escalation);
} else if (ed instanceof MessageEventDefinition) {
((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
} else if (ed instanceof CompensateEventDefinition) {
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("actrefname")) {
String activityNameRef = (String) entry.getValue();
// we have to iterate again through all flow
// elements
// in order to find our activity name
List<RootElement> re = def.getRootElements();
for (RootElement r : re) {
if (r instanceof Process) {
Process p = (Process) r;
List<FlowElement> fes = p.getFlowElements();
for (FlowElement f : fes) {
if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
((CompensateEventDefinition) ed).setActivityRef((Activity) f);
((Activity) f).setIsForCompensation(true);
}
}
}
}
}
}
}
}
} else if (fe instanceof FlowElementsContainer) {
setThrowEventsInfo((FlowElementsContainer) fe, def, rootElements, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
}
}
}
Aggregations