Search in sources :

Example 1 with DroolsResourceFactoryImpl

use of org.jboss.drools.util.DroolsResourceFactoryImpl in project kie-wb-common by kiegroup.

the class BPMFinderServiceImpl method parse.

protected Optional<Definitions> parse(FileUtils.ScanResult process) {
    org.uberfire.java.nio.file.Path formPath = process.getFile();
    try {
        ResourceSet resourceSet = new ResourceSetImpl();
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new DroolsResourceFactoryImpl());
        resourceSet.getPackageRegistry().put(DroolsPackage.eNS_URI, DroolsPackage.eINSTANCE);
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new Bpmn2ResourceFactoryImpl());
        resourceSet.getPackageRegistry().put("http://www.omg.org/spec/BPMN/20100524/MODEL", Bpmn2Package.eINSTANCE);
        XMLResource outResource = (XMLResource) resourceSet.createResource(URI.createURI("inputStream://dummyUriWithValidSuffix.xml"));
        outResource.getDefaultLoadOptions().put(XMLResource.OPTION_ENCODING, "UTF-8");
        outResource.setEncoding("UTF-8");
        Map<String, Object> options = new HashMap<String, Object>();
        options.put(XMLResource.OPTION_ENCODING, "UTF-8");
        outResource.load(ioService.newInputStream(formPath), options);
        DocumentRoot root = (DocumentRoot) outResource.getContents().get(0);
        return Optional.of(root.getDefinitions());
    } catch (Exception ex) {
        logger.warn("Error reading process '" + process.getFile().getFileName(), ex);
    }
    return Optional.empty();
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) HashMap(java.util.HashMap) DocumentRoot(org.eclipse.bpmn2.DocumentRoot) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) XMLResource(org.eclipse.emf.ecore.xmi.XMLResource) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl) Bpmn2ResourceFactoryImpl(org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl)

Example 2 with DroolsResourceFactoryImpl

use of org.jboss.drools.util.DroolsResourceFactoryImpl in project jbpm by kiegroup.

the class BPMN2EmfExtTest method setUp.

@Override
protected void setUp() throws Exception {
    resourceSet = new ResourceSetImpl();
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new DroolsResourceFactoryImpl());
    resourceSet.getPackageRegistry().put(DroolsPackage.eNS_URI, DroolsPackage.eINSTANCE);
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) DroolsResourceFactoryImpl(org.jboss.drools.util.DroolsResourceFactoryImpl)

Aggregations

ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)2 DroolsResourceFactoryImpl (org.jboss.drools.util.DroolsResourceFactoryImpl)2 HashMap (java.util.HashMap)1 DocumentRoot (org.eclipse.bpmn2.DocumentRoot)1 Bpmn2ResourceFactoryImpl (org.eclipse.bpmn2.util.Bpmn2ResourceFactoryImpl)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 XMLResource (org.eclipse.emf.ecore.xmi.XMLResource)1