use of org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshaller method parseDefinitions.
private static Definitions parseDefinitions(final InputStream inputStream) throws IOException {
DroolsPackageImpl.init();
BpsimPackageImpl.init();
final ResourceSet resourceSet = new ResourceSetImpl();
Resource.Factory.Registry resourceFactoryRegistry = resourceSet.getResourceFactoryRegistry();
resourceFactoryRegistry.getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new JBPMBpmn2ResourceFactoryImpl());
EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
packageRegistry.put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
packageRegistry.put("http://www.jboss.org/drools", DroolsPackage.eINSTANCE);
final JBPMBpmn2ResourceImpl resource = (JBPMBpmn2ResourceImpl) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
resource.setEncoding("UTF-8");
final Map<String, Object> options = new HashMap<String, Object>();
options.put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
options.put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
resource.load(inputStream, options);
final DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
return root.getDefinitions();
}
use of org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method unmarshall.
/**
* NOTE: This method has been set protected for Stunner support. Stunner bpmn implementation provides a custom JsonParser that
* is used instead of the one used in jbpm-designer-backend.
* <p>
* Start unmarshalling using the parser.
* @param parser
* @param preProcessingData
* @return the root element of a bpmn2 document.
* @throws JsonParseException
* @throws IOException
*/
protected Bpmn2Resource unmarshall(JsonParser parser, String preProcessingData) throws JsonParseException, IOException {
try {
// open the object
parser.nextToken();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource bpmn2 = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(bpmn2);
_currentResource = bpmn2;
if (preProcessingData == null || preProcessingData.length() < 1) {
preProcessingData = "ReadOnlyService";
}
// do the unmarshalling now:
Definitions def = (Definitions) unmarshallItem(parser, preProcessingData);
def.setExporter("jBPM Designer");
def.setExporterVersion("6.2.0");
revisitUserTasks(def);
revisitServiceTasks(def);
revisitMessages(def);
revisitCatchEvents(def);
revisitThrowEvents(def);
revisitLanes(def);
revisitSubProcessItemDefs(def);
revisitArtifacts(def);
revisitGroups(def);
revisitTaskAssociations(def);
revisitSendReceiveTasks(def);
reconnectFlows();
revisitGateways(def);
revisitCatchEventsConvertToBoundary(def);
revisitBoundaryEventsPositions(def);
createDiagram(def);
updateIDs(def);
revisitDataObjects(def);
revisitAssociationsIoSpec(def);
revisitWsdlImports(def);
revisitMultiInstanceTasks(def);
addSimulation(def);
revisitItemDefinitions(def);
revisitProcessDoc(def);
revisitDI(def);
revisitSignalRef(def);
orderDiagramElements(def);
// return def;
_currentResource.getContents().add(def);
return _currentResource;
} catch (Exception e) {
_logger.error(e.getMessage());
return _currentResource;
} finally {
parser.close();
_objMap.clear();
_idMap.clear();
_outgoingFlows.clear();
_sequenceFlowTargets.clear();
_bounds.clear();
_currentResource = null;
}
}
use of org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshaller method createBpmn2Resource.
private Bpmn2Resource createBpmn2Resource() {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactoryImpl());
Bpmn2Resource resource = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(resource);
return resource;
}
use of org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl in project kie-wb-common by kiegroup.
the class BaseDiagramMarshaller method parseDefinitions.
private Definitions parseDefinitions(final InputStream inputStream) throws IOException {
try {
DroolsPackageImpl.init();
BpsimPackageImpl.init();
final ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new JBPMBpmn2ResourceFactoryImpl());
resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
resourceSet.getPackageRegistry().put("http://www.jboss.org/drools", DroolsPackage.eINSTANCE);
final JBPMBpmn2ResourceImpl resource = (JBPMBpmn2ResourceImpl) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
resource.getDefaultLoadOptions().put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
resource.setEncoding("UTF-8");
final Map<String, Object> options = new HashMap<String, Object>();
options.put(JBPMBpmn2ResourceImpl.OPTION_ENCODING, "UTF-8");
options.put(JBPMBpmn2ResourceImpl.OPTION_DEFER_IDREF_RESOLUTION, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_DISABLE_NOTIFY, true);
options.put(JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2ResourceImpl.OPTION_PROCESS_DANGLING_HREF_RECORD);
resource.load(inputStream, options);
final DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
return root.getDefinitions();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (inputStream != null) {
inputStream.close();
}
}
return null;
}
Aggregations