use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitSendReceiveTasks.
public void revisitSendReceiveTasks(Definitions def) {
List<Message> toAddMessages = new ArrayList<Message>();
List<ItemDefinition> toAddItemDefinitions = new ArrayList<ItemDefinition>();
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
setSendReceiveTasksInfo((Process) root, def, toAddMessages, toAddItemDefinitions);
}
}
for (ItemDefinition idef : toAddItemDefinitions) {
def.getRootElements().add(idef);
}
for (Message msg : toAddMessages) {
def.getRootElements().add(msg);
}
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitCatchEventsConvertToBoundary.
protected void revisitCatchEventsConvertToBoundary(Definitions def) {
List<CatchEvent> catchEventsToRemove = new ArrayList<>();
Map<BoundaryEvent, List<String>> boundaryEventsToAdd = new HashMap<>();
List<RootElement> rootElements = def.getRootElements();
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
revisitCatchEVentsConvertToBoundaryExecute(process, null, catchEventsToRemove, boundaryEventsToAdd);
}
}
reconnectFlows();
}
use of org.eclipse.bpmn2.Definitions 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);
}
}
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class DefaultProfileImpl method createMarshaller.
public IDiagramMarshaller createMarshaller() {
return new IDiagramMarshaller() {
public String parseModel(String jsonModel, String preProcessingData) {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
// Definitions def;
Resource res;
try {
res = unmarshaller.unmarshall(jsonModel, preProcessingData);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Map saveMap = new HashMap();
saveMap.put(XMLResource.OPTION_ENCODING, "UTF-8");
saveMap.put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
saveMap.put(XMLResource.OPTION_DISABLE_NOTIFY, true);
saveMap.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_RECORD);
res.save(outputStream, saveMap);
return outputStream.toString();
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return "";
}
public Definitions getDefinitions(String jsonModel, String preProcessingData) {
try {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
JBPMBpmn2ResourceImpl res = (JBPMBpmn2ResourceImpl) unmarshaller.unmarshall(jsonModel, preProcessingData);
return (Definitions) res.getContents().get(0);
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return null;
}
public Resource getResource(String jsonModel, String preProcessingData) {
try {
Bpmn2JsonUnmarshaller unmarshaller = new Bpmn2JsonUnmarshaller();
return (JBPMBpmn2ResourceImpl) unmarshaller.unmarshall(jsonModel, preProcessingData);
} catch (JsonParseException e) {
_logger.error(e.getMessage(), e);
} catch (IOException e) {
_logger.error(e.getMessage(), e);
}
return null;
}
};
}
use of org.eclipse.bpmn2.Definitions in project kie-wb-common by kiegroup.
the class JBPMXMLSaveImpl method traverse.
@Override
public void traverse(List<? extends EObject> contents) {
for (EObject e : contents) {
if (e instanceof Definitions) {
List<RootElement> roots = ((Definitions) e).getRootElements();
Process p = null;
for (RootElement root : roots) {
if (root instanceof Process) {
p = (Process) root;
}
}
if (p != null) {
((Definitions) e).getRootElements().remove(p);
((Definitions) e).getRootElements().add(p);
}
}
}
super.traverse(contents);
}
Aggregations