Search in sources :

Example 11 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DMNSetConnectionSourceNodeCommandTest method createNode.

private Node createNode(final String diagramId) {
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    when(node.getContent()).thenReturn(definition);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(diagramId);
    when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
    return node;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Example 12 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DMNSetConnectionTargetNodeCommandTest method createNode.

private Node createNode(final String diagramId) {
    final Node node = mock(Node.class);
    final Definition definition = mock(Definition.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    when(node.getContent()).thenReturn(definition);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(diagramId);
    when(definition.getDefinition()).thenReturn(hasContentDefinitionId);
    return node;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Example 13 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class NodeDefinitionHelperTest method createNode.

private Node createNode(final String contentDefinitionId, final String diagramId) {
    final Node node = mock(Node.class);
    final Definition content = mock(Definition.class);
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    when(hasContentDefinitionId.getContentDefinitionId()).thenReturn(contentDefinitionId);
    when(hasContentDefinitionId.getDiagramId()).thenReturn(diagramId);
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(hasContentDefinitionId);
    return node;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Node(org.kie.workbench.common.stunner.core.graph.Node) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Example 14 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DMNCanvasHandlerTest method testUpdateDiagramIdWhenDiagramIdIsEmpty.

@Test
public void testUpdateDiagramIdWhenDiagramIdIsEmpty() {
    final String diagramId = "diagram id";
    final String currentDiagramId = "";
    final HasContentDefinitionId hasContentDefinitionId = mock(HasContentDefinitionId.class);
    final Element element = getElementForTestUpdateDiagramId(diagramId, currentDiagramId, hasContentDefinitionId);
    canvasHandler.updateDiagramId(element);
    verify(hasContentDefinitionId).setDiagramId(diagramId);
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Element(org.kie.workbench.common.stunner.core.graph.Element) Test(org.junit.Test)

Example 15 with HasContentDefinitionId

use of org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId in project kie-wb-common by kiegroup.

the class DeleteNodeConfirmationImpl method isReferredInAnotherGraph.

boolean isReferredInAnotherGraph(final Element element) {
    if (element.getContent() instanceof Definition) {
        final Definition def = (Definition) element.getContent();
        if (def.getDefinition() instanceof HasContentDefinitionId) {
            final HasContentDefinitionId hasContentDefinitionId = (HasContentDefinitionId) def.getDefinition();
            final String contentId = hasContentDefinitionId.getContentDefinitionId();
            final List<Graph> graphs = getGraphsProvider().getNonGlobalGraphs();
            return graphs.stream().anyMatch(graph -> containsNodeWithContentId(graph, contentId));
        }
    }
    return false;
}
Also used : HasContentDefinitionId(org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId) Graph(org.kie.workbench.common.stunner.core.graph.Graph) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition)

Aggregations

HasContentDefinitionId (org.kie.workbench.common.stunner.core.graph.content.HasContentDefinitionId)18 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)9 Node (org.kie.workbench.common.stunner.core.graph.Node)8 Test (org.junit.Test)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Element (org.kie.workbench.common.stunner.core.graph.Element)4 DMNDiagramElement (org.kie.workbench.common.dmn.api.definition.model.DMNDiagramElement)3 Graph (org.kie.workbench.common.stunner.core.graph.Graph)3 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)2 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1