use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setUserTaskInfo.
private void setUserTaskInfo(FlowElementsContainer container) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
// Set name and metaData "elementname" to "Task_n" if empty
if (fe instanceof UserTask) {
UserTask task = (UserTask) fe;
String name = task.getName();
if (name == null || name.length() == 0) {
LastUserTaskID++;
String newName = DEFAULT_USERTASK_NAME_PREFIX + LastUserTaskID;
task.setName(newName);
if (task.getExtensionValues() != null && task.getExtensionValues().size() > 0) {
for (ExtensionAttributeValue extattrval : task.getExtensionValues()) {
FeatureMap extensionElements = extattrval.getValue();
List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
for (MetaDataType eleMetadata : metadataExtensions) {
if (eleMetadata.getName() != null && eleMetadata.getName().equals("elementname")) {
eleMetadata.setMetaValue(wrapInCDATABlock(newName));
}
}
}
}
}
}
if (fe instanceof FlowElementsContainer) {
setUserTaskInfo((FlowElementsContainer) fe);
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setSendReceiveTasksInfo.
public void setSendReceiveTasksInfo(FlowElementsContainer container, Definitions def, List<Message> toAddMessages, List<ItemDefinition> toAddItemDefinitions) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof ReceiveTask) {
ReceiveTask rt = (ReceiveTask) fe;
rt.setMessageRef(extractMessage(rt, toAddMessages, toAddItemDefinitions));
} else if (fe instanceof SendTask) {
SendTask st = (SendTask) fe;
st.setMessageRef(extractMessage(st, toAddMessages, toAddItemDefinitions));
} else if (fe instanceof FlowElementsContainer) {
setSendReceiveTasksInfo((FlowElementsContainer) fe, def, toAddMessages, toAddItemDefinitions);
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method createDiagram.
private void createDiagram(Definitions def) {
for (RootElement rootElement : def.getRootElements()) {
if (rootElement instanceof Process) {
Process process = (Process) rootElement;
BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
BPMNDiagram diagram = factory.createBPMNDiagram();
BPMNPlane plane = factory.createBPMNPlane();
plane.setBpmnElement(process);
diagram.setPlane(plane);
// first process flowNodes
for (FlowElement flowElement : process.getFlowElements()) {
if (flowElement instanceof FlowNode) {
createBpmnShapeForElement(factory, plane, flowElement);
if (flowElement instanceof BoundaryEvent) {
createDockersForBoundaryEvent((BoundaryEvent) flowElement);
}
// check if its a subprocess
if (flowElement instanceof SubProcess) {
createSubProcessDiagram(plane, flowElement, factory);
}
} else if (flowElement instanceof DataObject) {
createBpmnShapeForElement(factory, plane, flowElement);
} else if (flowElement instanceof SequenceFlow) {
createBpmnEdgeForSequenceFlow(factory, plane, (SequenceFlow) flowElement);
}
}
// then process artifacts
if (process.getArtifacts() != null) {
List<Association> incompleteAssociations = new ArrayList<Association>();
for (Artifact artifact : process.getArtifacts()) {
// if (artifact instanceof TextAnnotation || artifact instanceof Group) {
if (artifact instanceof Group) {
createBpmnShapeForElement(factory, plane, artifact);
}
if (artifact instanceof Association) {
Association association = (Association) artifact;
if (association.getSourceRef() != null && association.getTargetRef() != null) {
createBpmnEdgeForAssociation(factory, plane, association);
} else {
incompleteAssociations.add(association);
}
}
}
if (!incompleteAssociations.isEmpty()) {
for (Association incompleteAssociation : incompleteAssociations) {
process.getArtifacts().remove(incompleteAssociation);
}
}
}
// finally process lanes
if (process.getLaneSets() != null && process.getLaneSets().size() > 0) {
for (LaneSet ls : process.getLaneSets()) {
for (Lane lane : ls.getLanes()) {
createBpmnShapeForElement(factory, plane, lane);
}
}
}
def.getDiagrams().add(diagram);
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setGatewayInfo.
private void setGatewayInfo(FlowElementsContainer container) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof Gateway) {
Gateway gateway = (Gateway) fe;
int incoming = gateway.getIncoming() == null ? 0 : gateway.getIncoming().size();
int outgoing = gateway.getOutgoing() == null ? 0 : gateway.getOutgoing().size();
if (incoming <= 1 && outgoing > 1) {
gateway.setGatewayDirection(GatewayDirection.DIVERGING);
} else if (incoming > 1 && outgoing <= 1) {
gateway.setGatewayDirection(GatewayDirection.CONVERGING);
} else // temp. removing support for mixed gateway direction (not supported by runtime yet)
// else if (incoming > 1 && outgoing > 1) {
// gateway.setGatewayDirection(GatewayDirection.MIXED);
// }
// else if (incoming == 1 && outgoing == 1) {
// // this handles the 1:1 case of the diverging gateways
// }
{
gateway.setGatewayDirection(GatewayDirection.UNSPECIFIED);
}
}
if (fe instanceof InclusiveGateway) {
InclusiveGateway ig = (InclusiveGateway) fe;
List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
if (ig.getIncoming() != null) {
sqList.addAll(ig.getIncoming());
}
if (ig.getOutgoing() != null) {
sqList.addAll(ig.getOutgoing());
}
setDefaultGateway(fe, sqList);
}
if (fe instanceof ExclusiveGateway) {
ExclusiveGateway eg = (ExclusiveGateway) fe;
List<SequenceFlow> sqList = new ArrayList<SequenceFlow>();
if (eg.getIncoming() != null) {
sqList.addAll(eg.getIncoming());
}
if (eg.getOutgoing() != null) {
sqList.addAll(eg.getOutgoing());
}
setDefaultGateway(fe, sqList);
}
if (fe instanceof FlowElementsContainer) {
setGatewayInfo((FlowElementsContainer) fe);
}
}
}
use of org.osate.aadl2.FlowElement in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecuteForLanes.
private void revisitServiceTasksExecuteForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
for (FlowElement fe : laneFlowNodes) {
if (fe instanceof ServiceTask) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
String serviceImplementation = null;
String serviceInterface = null;
String serviceOperation = null;
EStructuralFeature serviceInterfaceFeature = null;
EStructuralFeature serviceOperationFeature = null;
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
serviceImplementation = (String) entry.getValue();
}
if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
serviceOperation = (String) entry.getValue();
serviceOperationFeature = entry.getEStructuralFeature();
}
if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
serviceInterface = (String) entry.getValue();
serviceInterfaceFeature = entry.getEStructuralFeature();
}
}
boolean foundInterface = false;
Interface touseInterface = null;
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
}
if (!foundInterface) {
touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
if (serviceInterface == null || serviceInterface.length() == 0) {
serviceInterface = fe.getId() + "_ServiceInterface";
if (serviceInterfaceFeature != null) {
fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
}
}
touseInterface.setName(serviceInterface);
touseInterface.setImplementationRef(serviceInterface);
touseInterface.setId(fe.getId() + "_ServiceInterface");
toAddInterfaces.add(touseInterface);
}
if (serviceOperation != null) {
boolean foundOperation = false;
for (Operation oper : touseInterface.getOperations()) {
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
if (oper.getName().equals(serviceOperation)) {
foundOperation = true;
break;
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
if (oper.getImplementationRef().equals(serviceOperation)) {
foundOperation = true;
break;
}
}
}
if (!foundOperation) {
Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
if (serviceOperation == null || serviceOperation.length() == 0) {
serviceOperation = fe.getId() + "_ServiceOperation";
if (serviceOperationFeature != null) {
fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
}
}
touseOperation.setId(fe.getId() + "_ServiceOperation");
touseOperation.setName(serviceOperation);
touseOperation.setImplementationRef(serviceOperation);
Message message = Bpmn2Factory.eINSTANCE.createMessage();
message.setId(fe.getId() + "_InMessage");
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(message.getId() + "Type");
message.setItemRef(itemdef);
toAddDefinitions.add(itemdef);
toAddMessages.add(message);
touseOperation.setInMessageRef(message);
touseInterface.getOperations().add(touseOperation);
((ServiceTask) fe).setOperationRef(touseOperation);
}
}
} else if (fe instanceof FlowElementsContainer) {
revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
}
Aggregations