Search in sources :

Example 1 with JBPMBpmn2ResourceFactory

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;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) JBPMBpmn2Resource(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource) Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) JBPMBpmn2ResourceFactory(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet)

Example 2 with JBPMBpmn2ResourceFactory

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);
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) LoggerFactory(org.slf4j.LoggerFactory) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory) BaseConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory) JBPMBpmn2ResourceFactory(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory) GraphCommandFactory(org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) EPackage(org.eclipse.emf.ecore.EPackage) JBPMBpmn2Resource(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource) JBPMBpmn2ResourceFactory(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory)

Aggregations

ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)2 JBPMBpmn2Resource (org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource)2 JBPMBpmn2ResourceFactory (org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory)2 HashMap (java.util.HashMap)1 DocumentRoot (org.eclipse.bpmn2.DocumentRoot)1 Bpmn2Resource (org.eclipse.bpmn2.util.Bpmn2Resource)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)1 PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)1 BaseConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory)1 GraphCommandFactory (org.kie.workbench.common.stunner.core.graph.command.impl.GraphCommandFactory)1 LoggerFactory (org.slf4j.LoggerFactory)1