Search in sources :

Example 1 with Bpmn2Resource

use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshaller method marshall.

@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
    LOG.debug("Starting diagram marshalling...");
    Bpmn2Resource resource = createBpmn2Resource();
    // we start converting from the root, then pull out the result
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(diagram.getGraph());
    Definitions definitions = definitionsConverter.toDefinitions();
    resource.getContents().add(definitions);
    LOG.debug("Diagram marshalling completed successfully.");
    String outputString = renderToString(resource);
    LOG.trace(outputString);
    return outputString;
}
Also used : Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) Definitions(org.eclipse.bpmn2.Definitions) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter)

Example 2 with Bpmn2Resource

use of org.eclipse.bpmn2.util.Bpmn2Resource 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 3 with Bpmn2Resource

use of org.eclipse.bpmn2.util.Bpmn2Resource 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;
    }
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) Definitions(org.eclipse.bpmn2.Definitions) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) JBPMBpmn2ResourceFactoryImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl) IOException(java.io.IOException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 4 with Bpmn2Resource

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

Example 5 with Bpmn2Resource

use of org.eclipse.bpmn2.util.Bpmn2Resource in project kie-wb-common by kiegroup.

the class BaseDirectDiagramMarshaller method marshall.

@Override
@SuppressWarnings("unchecked")
public String marshall(final Diagram<Graph, Metadata> diagram) throws IOException {
    LOG.debug("Starting diagram marshalling...");
    Bpmn2Resource resource = createBpmn2Resource();
    // we start converting from the root, then pull out the result
    PropertyWriterFactory propertyWriterFactory = new PropertyWriterFactory();
    DefinitionsConverter definitionsConverter = new DefinitionsConverter(new ConverterFactory(new DefinitionsBuildingContext(diagram.getGraph(), getDiagramClass()), propertyWriterFactory), propertyWriterFactory);
    Definitions definitions = definitionsConverter.toDefinitions();
    resource.getContents().add(definitions);
    LOG.debug("Diagram marshalling completed successfully.");
    String outputString = renderToString(resource);
    LOG.trace(outputString);
    return outputString;
}
Also used : JBPMBpmn2Resource(org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource) Bpmn2Resource(org.eclipse.bpmn2.util.Bpmn2Resource) Definitions(org.eclipse.bpmn2.Definitions) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) BaseConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BaseConverterFactory) DefinitionsConverter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter) PropertyWriterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)

Aggregations

Bpmn2Resource (org.eclipse.bpmn2.util.Bpmn2Resource)5 Definitions (org.eclipse.bpmn2.Definitions)3 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)3 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 DefinitionsConverter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsConverter)2 JBPMBpmn2ResourceFactoryImpl (org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceFactoryImpl)2 JBPMBpmn2Resource (org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2Resource)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)1 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)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 JBPMBpmn2ResourceFactory (org.kie.workbench.common.stunner.bpmn.backend.resource.JBPMBpmn2ResourceFactory)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1