Search in sources :

Example 21 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNDecisionServiceSVGShapeDefImplTest method testNewViewInstance.

@Test
public void testNewViewInstance() {
    final DecisionService decisionService = new DecisionService();
    shapeDef.newViewInstance(viewFactory, decisionService);
    verify(viewFactory).decisionService();
    verify(viewResource).build(decisionService.getDimensionsSet().getWidth().getValue(), decisionService.getDimensionsSet().getHeight().getValue(), true);
}
Also used : DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 22 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class WrapperUtils method stunnerToDDExt.

private static JSIDMNShape stunnerToDDExt(final JSIDMNDiagram diagram, final List<String> dmnDiagramElementIds, final Definitions definitionsStunnerPojo, final View<? extends DMNElement> v, final String namespaceURI) {
    final JSIDMNShape result = new JSIDMNShape();
    final DMNElement definition = v.getDefinition();
    final String dmnElementId = definition.getId().getValue();
    final String shapeId = getShapeId(diagram, dmnDiagramElementIds, dmnElementId);
    result.setId(shapeId);
    result.setDmnElementRef(getDmnElementRef(definitionsStunnerPojo, v, namespaceURI));
    final JSIBounds bounds = new JSIBounds();
    result.setBounds(bounds);
    bounds.setX(xOfBound(upperLeftBound(v)));
    bounds.setY(yOfBound(upperLeftBound(v)));
    result.setDMNLabel(new JSIDMNLabel());
    // TODO {gcardosi}: HARDCODED
    result.setIsCollapsed(false);
    final JSIDMNStyle style = new JSIDMNStyle();
    if (v.getDefinition() instanceof Decision) {
        final Decision d = (Decision) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
    } else if (v.getDefinition() instanceof InputData) {
        InputData d = (InputData) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
    } else if (v.getDefinition() instanceof BusinessKnowledgeModel) {
        final BusinessKnowledgeModel d = (BusinessKnowledgeModel) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
    } else if (v.getDefinition() instanceof KnowledgeSource) {
        final KnowledgeSource d = (KnowledgeSource) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
    } else if (v.getDefinition() instanceof TextAnnotation) {
        final TextAnnotation d = (TextAnnotation) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
    } else if (v.getDefinition() instanceof DecisionService) {
        final DecisionService d = (DecisionService) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyStylingStyles(d.getStylingSet(), style);
        final JSIDMNDecisionServiceDividerLine dl = new JSIDMNDecisionServiceDividerLine();
        final JSIPoint leftPoint = new JSIPoint();
        leftPoint.setX(v.getBounds().getUpperLeft().getX());
        final double dlY = v.getBounds().getUpperLeft().getY() + d.getDividerLineY().getValue();
        leftPoint.setY(dlY);
        dl.addWaypoint(leftPoint);
        final JSIPoint rightPoint = new JSIPoint();
        rightPoint.setX(v.getBounds().getLowerRight().getX());
        rightPoint.setY(dlY);
        dl.addWaypoint(rightPoint);
        result.setDMNDecisionServiceDividerLine(dl);
    }
    result.setStyle(getWrappedJSIDMNStyle(style));
    return result;
}
Also used : JSIDMNDecisionServiceDividerLine(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape) JSIDMNStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) JSIBounds(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) JSIDMNLabel(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNLabel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) JSITTextAnnotation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITTextAnnotation)

Example 23 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method check_decisionservice_1outputDecision1encapsulatedDecision.

@SuppressWarnings("unchecked")
private void check_decisionservice_1outputDecision1encapsulatedDecision(Graph<?, Node<?, ?>> graph) {
    Node<?, ?> node = graph.getNode("_659a06e2-ae80-496c-8783-f790a640bb49");
    assertNodeContentDefinitionIs(node, DecisionService.class);
    DecisionService definition = ((View<DecisionService>) node.getContent()).getDefinition();
    assertEquals(1, definition.getEncapsulatedDecision().size());
    assertEquals("#" + "_afce4fb3-9a7c-4791-bbfe-63d4b76bd61a", definition.getEncapsulatedDecision().get(0).getHref());
    assertEquals(1, definition.getInputData().size());
    assertEquals("#" + "_dd5b090f-6d52-4bd8-8c7f-0c469983d44e", definition.getInputData().get(0).getHref());
    assertEquals(1, definition.getOutputDecision().size());
    assertEquals("#" + "_3a69915a-30af-4de3-a07f-6be514f53caa", definition.getOutputDecision().get(0).getHref());
    assertEquals(0, definition.getInputDecision().size());
}
Also used : View(org.kie.workbench.common.stunner.core.graph.content.view.View) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 24 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method check_decisionservice_1outputDecision.

@SuppressWarnings("unchecked")
private void check_decisionservice_1outputDecision(Graph<?, Node<?, ?>> graph) {
    Node<?, ?> node = graph.getNode("_659a06e2-ae80-496c-8783-f790a640bb49");
    assertNodeContentDefinitionIs(node, DecisionService.class);
    DecisionService definition = ((View<DecisionService>) node.getContent()).getDefinition();
    assertEquals(0, definition.getEncapsulatedDecision().size());
    assertEquals(0, definition.getInputData().size());
    assertEquals(1, definition.getOutputDecision().size());
    assertEquals("#" + "_3a69915a-30af-4de3-a07f-6be514f53caa", definition.getOutputDecision().get(0).getHref());
    assertEquals(1, definition.getInputDecision().size());
    assertEquals("#" + "_afce4fb3-9a7c-4791-bbfe-63d4b76bd61a", definition.getInputDecision().get(0).getHref());
}
Also used : View(org.kie.workbench.common.stunner.core.graph.content.view.View) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Example 25 with DecisionService

use of org.kie.workbench.common.dmn.api.definition.model.DecisionService in project kie-wb-common by kiegroup.

the class DecisionServiceConverterTest method testDMNFromWB.

@Test
public void testDMNFromWB() {
    final DecisionService wb = new DecisionService();
    final InformationItemPrimary informationItem = new InformationItemPrimary();
    wb.getId().setValue(DECISION_SERVICE_UUID);
    wb.getName().setValue(DECISION_SERVICE_NAME);
    wb.getDescription().setValue(DECISION_SERVICE_DESCRIPTION);
    wb.setVariable(informationItem);
    final Node<View<DecisionService>, ?> node = new NodeImpl<>(UUID.uuid());
    final View<DecisionService> view = new ViewImpl<>(wb, Bounds.create());
    node.setContent(view);
    final org.kie.dmn.model.api.DecisionService dmn = converter.dmnFromNode(node, componentWidthsConsumer);
    assertThat(dmn).isNotNull();
    assertThat(dmn.getId()).isNotNull();
    assertThat(dmn.getId()).isEqualTo(DECISION_SERVICE_UUID);
    assertThat(dmn.getName()).isNotNull();
    assertThat(dmn.getName()).isEqualTo(DECISION_SERVICE_NAME);
    assertThat(dmn.getDescription()).isNotNull();
    assertThat(dmn.getDescription()).isEqualTo(DECISION_SERVICE_DESCRIPTION);
    assertThat(dmn.getVariable()).isNotNull();
    assertThat(dmn.getVariable().getName()).isEqualTo(DECISION_SERVICE_NAME);
    verifyNoMoreInteractions(componentWidthsConsumer);
}
Also used : InformationItemPrimary(org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) TDecisionService(org.kie.dmn.model.v1_2.TDecisionService) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Aggregations

DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)38 Test (org.junit.Test)19 View (org.kie.workbench.common.stunner.core.graph.content.view.View)19 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)13 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)13 Node (org.kie.workbench.common.stunner.core.graph.Node)13 ArrayList (java.util.ArrayList)12 List (java.util.List)12 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)12 Edge (org.kie.workbench.common.stunner.core.graph.Edge)12 DecisionServiceDividerLineY (org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY)11 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)9 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)9 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)9 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)9 Optional (java.util.Optional)7 DMNElementReference (org.kie.workbench.common.dmn.api.definition.model.DMNElementReference)7 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)6