Search in sources :

Example 6 with KnowledgeSource

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

the class DMNDeepCloneProcessTest method testCloneWhenSourceIsKnowledgeSource.

@Test
public void testCloneWhenSourceIsKnowledgeSource() {
    final KnowledgeSource source = buildKnowledgeSource();
    setLinks(source, FIRST_URL, SECOND_URL);
    final KnowledgeSource cloned = dmnDeepCloneProcess.clone(source, new KnowledgeSource());
    assertThat(cloned).isNotNull();
    assertThat(cloned.getId().getValue()).isNotEqualTo(SOURCE_ID);
    assertThat(cloned.getName().getValue()).isEqualTo(KNOWLEDGE_SOURCE_NAME + FIRST_INDEX_IN_SUFFIX);
    assertThat(cloned.getLinksHolder().getValue().getLinks()).hasSize(2).extracting(DMNExternalLink::getUrl).contains(FIRST_URL, SECOND_URL);
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) AbstractCloneProcessTest(org.kie.workbench.common.stunner.core.definition.clone.AbstractCloneProcessTest) Test(org.junit.Test)

Example 7 with KnowledgeSource

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

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_DecisionService.

@Test
public void testUpdateNewNodeName_DecisionService() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
    graph.addNode(makeMockNode(new Decision()));
    graph.addNode(makeMockNode(new InputData()));
    graph.addNode(makeMockNode(new KnowledgeSource()));
    final DecisionService decisionService1 = new DecisionService();
    final DecisionService decisionService2 = new DecisionService();
    final DecisionService decisionService3 = new DecisionService();
    final DecisionService decisionService4 = new DecisionService();
    assertUpdateNewNodeName(decisionService1, decisionService2, (decisionService) -> decisionService.getName().getValue(), () -> DecisionService.class.getSimpleName() + "-1", () -> DecisionService.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    decisionService1.getName().setValue("decisionService");
    decisionService2.getName().setValue(DecisionService.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(decisionService3, decisionService4, (decisionService) -> decisionService.getName().getValue(), () -> DecisionService.class.getSimpleName() + "-6", () -> DecisionService.class.getSimpleName() + "-7");
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) Test(org.junit.Test)

Example 8 with KnowledgeSource

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

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_InputData.

@Test
public void testUpdateNewNodeName_InputData() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
    graph.addNode(makeMockNode(new Decision()));
    graph.addNode(makeMockNode(new KnowledgeSource()));
    graph.addNode(makeMockNode(new TextAnnotation()));
    final InputData inputData1 = new InputData();
    final InputData inputData2 = new InputData();
    final InputData inputData3 = new InputData();
    final InputData inputData4 = new InputData();
    assertUpdateNewNodeName(inputData1, inputData2, (inputData) -> inputData.getName().getValue(), () -> InputData.class.getSimpleName() + "-1", () -> InputData.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    inputData1.getName().setValue("inputData");
    inputData2.getName().setValue(InputData.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(inputData3, inputData4, (inputData) -> inputData.getName().getValue(), () -> InputData.class.getSimpleName() + "-6", () -> InputData.class.getSimpleName() + "-7");
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 9 with KnowledgeSource

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

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_TextAnnotation.

@Test
public void testUpdateNewNodeName_TextAnnotation() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
    graph.addNode(makeMockNode(new Decision()));
    graph.addNode(makeMockNode(new InputData()));
    graph.addNode(makeMockNode(new KnowledgeSource()));
    final TextAnnotation textAnnotation1 = new TextAnnotation();
    final TextAnnotation textAnnotation2 = new TextAnnotation();
    final TextAnnotation textAnnotation3 = new TextAnnotation();
    final TextAnnotation textAnnotation4 = new TextAnnotation();
    assertUpdateNewNodeName(textAnnotation1, textAnnotation2, (textAnnotation) -> textAnnotation.getText().getValue(), () -> TextAnnotation.class.getSimpleName() + "-1", () -> TextAnnotation.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    textAnnotation1.getText().setValue("textAnnotation");
    textAnnotation2.getText().setValue(TextAnnotation.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(textAnnotation3, textAnnotation4, (textAnnotation) -> textAnnotation.getText().getValue(), () -> TextAnnotation.class.getSimpleName() + "-6", () -> TextAnnotation.class.getSimpleName() + "-7");
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Test(org.junit.Test)

Example 10 with KnowledgeSource

use of org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource 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)

Aggregations

KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)23 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)16 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)16 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)16 Test (org.junit.Test)11 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)11 View (org.kie.workbench.common.stunner.core.graph.content.view.View)10 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)9 List (java.util.List)8 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)8 Edge (org.kie.workbench.common.stunner.core.graph.Edge)7 ArrayList (java.util.ArrayList)5 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)5 Node (org.kie.workbench.common.stunner.core.graph.Node)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)4 BindableAdapterUtils.getDefinitionId (org.kie.workbench.common.stunner.core.definition.adapter.binding.BindableAdapterUtils.getDefinitionId)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)3 KnowledgeSourceType (org.kie.workbench.common.dmn.api.property.dmn.KnowledgeSourceType)3 LocationURI (org.kie.workbench.common.dmn.api.property.dmn.LocationURI)3