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();
}
Aggregations