use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramFactoryImplTest method testModelName.
@Test
@SuppressWarnings("unchecked")
public void testModelName() {
final Diagram diagram = factory.build(NAME, metadata, graph);
// We can safely get the first object on the iterator as we know the graph only contains one node
final Node<View, Edge> root = (Node<View, Edge>) diagram.getGraph().nodes().iterator().next();
final DMNDiagram dmnDiagram = (DMNDiagram) DefinitionUtils.getElementDefinition(root);
final Definitions dmnDefinitions = dmnDiagram.getDefinitions();
assertEquals(NAME, dmnDefinitions.getName().getValue());
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramFactoryImplTest method testModelNameWithNonEmptyExistingName.
@Test
@SuppressWarnings("unchecked")
public void testModelNameWithNonEmptyExistingName() {
final Node<View, Edge> existingRoot = (Node<View, Edge>) graph.nodes().iterator().next();
final DMNDiagram existingDMNDiagram = (DMNDiagram) DefinitionUtils.getElementDefinition(existingRoot);
final Definitions existingDMNDefinitions = existingDMNDiagram.getDefinitions();
existingDMNDefinitions.getName().setValue(EXISTING_NAME);
final Diagram newDiagram = factory.build(NAME, metadata, graph);
final Node<View, Edge> newRoot = (Node<View, Edge>) newDiagram.getGraph().nodes().iterator().next();
final DMNDiagram newDMNDiagram = (DMNDiagram) DefinitionUtils.getElementDefinition(newRoot);
final Definitions newDMNDefinitions = newDMNDiagram.getDefinitions();
assertEquals(EXISTING_NAME, newDMNDefinitions.getName().getValue());
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DMNDiagramsSessionState method getDiagramTuple.
DMNDiagramTuple getDiagramTuple(final String dmnDiagramElementId) {
final Diagram diagram = getDiagram(dmnDiagramElementId);
final DMNDiagramElement dmnDiagramElement = getDMNDiagramElement(dmnDiagramElementId);
return new DMNDiagramTuple(diagram, dmnDiagramElement);
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class DecisionNavigatorItemsProvider method getItems.
public List<DecisionNavigatorItem> getItems() {
final List<DecisionNavigatorItem> items = new ArrayList<>();
dmnDiagramsSession.getDMNDiagrams().stream().sorted((e1, e2) -> {
final String dmnElementName1 = e1.getDMNDiagram().getName().getValue();
final String dmnElementName2 = e2.getDMNDiagram().getName().getValue();
return DRG.equals(dmnElementName1) ? -1 : DRG.equals(dmnElementName2) ? 1 : 0;
}).forEach(diagramTuple -> {
final Diagram stunner = diagramTuple.getStunnerDiagram();
final DecisionNavigatorItem root = makeRoot(diagramTuple);
items.add(root);
getNodes(stunner).forEach(node -> makeItem(root, node));
});
if (items.size() > 1) {
items.add(0, itemFactory.makeSeparator(DRG));
items.add(2, itemFactory.makeSeparator(DRDs));
}
return items;
}
use of org.kie.workbench.common.stunner.core.diagram.Diagram in project kie-wb-common by kiegroup.
the class PreviewDiagramScreen method isSameDiagramSession.
private boolean isSameDiagramSession(final ClientSession session) {
final CanvasHandler canvasHandler = session.getCanvasHandler();
final Diagram diagram = canvasHandler.getDiagram();
return Optional.ofNullable(diagram).map((Function<Diagram, Metadata>) Diagram::getMetadata).map(this::isSameDiagramSession).orElse(false);
}
Aggregations