use of org.eclipse.bpmn2.DocumentRoot 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