use of org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method createBpmn2Resource.
private Bpmn2Resource createBpmn2Resource() {
DroolsFactoryImpl.init();
BpsimFactoryImpl.init();
ResourceSet rSet = new ResourceSetImpl();
rSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("bpmn2", new JBPMBpmn2ResourceFactory());
Bpmn2Resource resource = (Bpmn2Resource) rSet.createResource(URI.createURI("virtual.bpmn2"));
rSet.getResources().add(resource);
return resource;
}
use of org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory in project kie-wb-common by kiegroup.
the class BaseDirectDiagramMarshaller method parseDefinitions.
private static DefinitionsHandler 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 JBPMBpmn2ResourceFactory());
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 JBPMBpmn2Resource resource = (JBPMBpmn2Resource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
resource.getDefaultLoadOptions().put(JBPMBpmn2Resource.OPTION_ENCODING, "UTF-8");
resource.setEncoding("UTF-8");
final Map<String, Object> options = new HashMap<>();
options.put(JBPMBpmn2Resource.OPTION_ENCODING, "UTF-8");
options.put(JBPMBpmn2Resource.OPTION_DEFER_IDREF_RESOLUTION, true);
options.put(JBPMBpmn2Resource.OPTION_DISABLE_NOTIFY, true);
options.put(JBPMBpmn2Resource.OPTION_PROCESS_DANGLING_HREF, JBPMBpmn2Resource.OPTION_PROCESS_DANGLING_HREF_RECORD);
try {
resource.load(inputStream, options);
} finally {
inputStream.close();
}
final DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
return new DefinitionsHandler(root);
}
Aggregations