Search in sources :

Example 11 with Node

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

the class DecisionConverter method nodeFromDMN.

@Override
public Node<View<Decision>, ?> nodeFromDMN(final org.kie.dmn.model.v1_1.Decision dmn) {
    @SuppressWarnings("unchecked") Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(dmn.getId(), Decision.class).asNode();
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    Name name = new Name(dmn.getName());
    InformationItem informationItem = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
    Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression());
    Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new BackgroundSet(), new FontSet(), new RectangleDimensionsSet());
    node.getContent().setDefinition(decision);
    return node;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Node(org.kie.workbench.common.stunner.core.graph.Node) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) AllowedAnswers(org.kie.workbench.common.dmn.api.property.dmn.AllowedAnswers) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) FontSet(org.kie.workbench.common.dmn.api.property.font.FontSet) BackgroundSet(org.kie.workbench.common.dmn.api.property.background.BackgroundSet) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) Question(org.kie.workbench.common.dmn.api.property.dmn.Question) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 12 with Node

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

the class InputDataConverter method nodeFromDMN.

@Override
public Node<View<InputData>, ?> nodeFromDMN(final org.kie.dmn.model.v1_1.InputData dmn) {
    @SuppressWarnings("unchecked") Node<View<InputData>, ?> node = (Node<View<InputData>, ?>) factoryManager.newElement(dmn.getId(), InputData.class).asNode();
    Id id = new Id(dmn.getId());
    Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    Name name = new Name(dmn.getName());
    InformationItem informationItem = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
    InputData inputData = new InputData(id, description, name, informationItem, new BackgroundSet(), new FontSet(), new RectangleDimensionsSet());
    node.getContent().setDefinition(inputData);
    return node;
}
Also used : FontSet(org.kie.workbench.common.dmn.api.property.font.FontSet) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) BackgroundSet(org.kie.workbench.common.dmn.api.property.background.BackgroundSet) Node(org.kie.workbench.common.stunner.core.graph.Node) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) InputData(org.kie.workbench.common.dmn.api.definition.v1_1.InputData) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 13 with Node

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

the class GraphBuilder method addDockedNode.

private void addDockedNode(String parentId, String candidateId) {
    Node parent = executionContext.getGraphIndex().getNode(parentId);
    Node candidate = executionContext.getGraphIndex().getNode(candidateId);
    addDockedNode(parent, candidate);
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node)

Example 14 with Node

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

the class SequenceFlowConverter method convertEdge.

public BpmnEdge convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes) {
    Edge<View<SequenceFlow>, Node> edge = factoryManager.newEdge(seq.getId(), SequenceFlow.class);
    SequenceFlow definition = edge.getContent().getDefinition();
    SequenceFlowPropertyReader p = propertyReaderFactory.of(seq);
    definition.setGeneral(new BPMNGeneralSet(new Name(seq.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new SequenceFlowExecutionSet(new Priority(p.getPriority()), new ConditionExpression(p.getConditionExpression())));
    return BpmnEdge.of(edge, nodes.get(p.getSourceId()), p.getSourceConnection(), nodes.get(p.getTargetId()), p.getTargetConnection());
}
Also used : SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Priority(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.Priority) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.ConditionExpression) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Node(org.kie.workbench.common.stunner.core.graph.Node) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SequenceFlowPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 15 with Node

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

the class GraphValidatorImplTest method testValidateEmptyViewConnectorNodes.

@Test
@SuppressWarnings("unchecked")
public void testValidateEmptyViewConnectorNodes() {
    final RuleSet ruleSet = graphTestHandler.ruleSet;
    final Graph<DefinitionSet, Node> graph = graphTestHandler.graph;
    final TestingGraphInstanceBuilder.TestGraph1 testGraph1 = TestingGraphInstanceBuilder.newGraph1(graphTestHandler);
    // Update the edge2 and remove the connection's target node.
    // From this point, a validation error is expected.
    graphTestHandler.removeTargetConnection(testGraph1.edge2);
    tested.validate(graph, ruleSet, ruleViolations -> {
        assertEquals(1, ruleViolations.size());
        final RuleViolation violation = ruleViolations.iterator().next();
        assertNotNull(violation);
        assertTrue(violation instanceof EmptyConnectionViolation);
        EmptyConnectionViolation v = (EmptyConnectionViolation) violation;
        final Optional<Object[]> arguments = v.getArguments();
        assertTrue(arguments.isPresent());
        assertEquals(testGraph1.edge2.getUUID(), arguments.get()[0]);
        assertEquals(testGraph1.intermNode.getUUID(), arguments.get()[1]);
        assertNull(arguments.get()[2]);
    });
}
Also used : RuleSet(org.kie.workbench.common.stunner.core.rule.RuleSet) EmptyConnectionViolation(org.kie.workbench.common.stunner.core.rule.violations.EmptyConnectionViolation) TestingGraphInstanceBuilder(org.kie.workbench.common.stunner.core.TestingGraphInstanceBuilder) Node(org.kie.workbench.common.stunner.core.graph.Node) DefinitionSet(org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet) RuleViolation(org.kie.workbench.common.stunner.core.rule.RuleViolation) Test(org.junit.Test)

Aggregations

Node (org.kie.workbench.common.stunner.core.graph.Node)153 Edge (org.kie.workbench.common.stunner.core.graph.Edge)85 View (org.kie.workbench.common.stunner.core.graph.content.view.View)59 Test (org.junit.Test)38 Graph (org.kie.workbench.common.stunner.core.graph.Graph)32 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)24 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)21 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)17 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)15 Element (org.kie.workbench.common.stunner.core.graph.Element)14 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)13 DefinitionSet (org.kie.workbench.common.stunner.core.graph.content.definition.DefinitionSet)13 EdgeImpl (org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl)13 Matchers.anyString (org.mockito.Matchers.anyString)13 List (java.util.List)12 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 Before (org.junit.Before)11 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)11 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11