Search in sources :

Example 1 with ConverterFactory

use of org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshaller method unmarshall.

@Override
public Graph<DefinitionSet, Node> unmarshall(final Metadata metadata, final InputStream inputStream) throws IOException {
    LOG.debug("Starting diagram unmarshalling...");
    // definition resolver provides utlities to access elements of the BPMN datamodel
    DefinitionResolver definitionResolver = new DefinitionResolver(parseDefinitions(inputStream));
    metadata.setCanvasRootUUID(definitionResolver.getDefinitions().getId());
    metadata.setTitle(definitionResolver.getProcess().getName());
    ConverterFactory converterFactory = new ConverterFactory(definitionResolver, typedFactoryManager);
    // perform actual conversion. Process is the root of the diagram
    BpmnNode diagramRoot = converterFactory.rootProcessConverter().convertProcess();
    LOG.debug("Diagram unmarshalling completed successfully.");
    // the root node contains all of the information
    // needed to build the entire graph (including parent/child relationships)
    // thus, we can now walk the graph to issue all the commands
    // to draw it on our canvas
    Diagram<Graph<DefinitionSet, Node>, Metadata> diagram = typedFactoryManager.newDiagram(definitionResolver.getDefinitions().getId(), BPMNDefinitionSet.class, metadata);
    GraphBuilder graphBuilder = new GraphBuilder(diagram.getGraph(), definitionManager, typedFactoryManager, ruleManager, commandFactory, commandManager);
    graphBuilder.render(diagramRoot);
    LOG.debug("Diagram drawing completed successfully.");
    return diagram.getGraph();
}
Also used : DefinitionResolver(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory) GraphBuilder(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.GraphBuilder) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)

Aggregations

BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)1 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.ConverterFactory)1 DefinitionResolver (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.DefinitionResolver)1 GraphBuilder (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.GraphBuilder)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 Graph (org.kie.workbench.common.stunner.core.graph.Graph)1