Search in sources :

Example 21 with TextAnnotation

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

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_Decision.

@Test
public void testUpdateNewNodeName_Decision() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new BusinessKnowledgeModel()));
    graph.addNode(makeMockNode(new InputData()));
    graph.addNode(makeMockNode(new KnowledgeSource()));
    graph.addNode(makeMockNode(new TextAnnotation()));
    final Decision decision1 = new Decision();
    final Decision decision2 = new Decision();
    final Decision decision3 = new Decision();
    final Decision decision4 = new Decision();
    assertUpdateNewNodeName(decision1, decision2, (decision) -> decision.getName().getValue(), () -> Decision.class.getSimpleName() + "-1", () -> Decision.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    decision1.getName().setValue("decision");
    decision2.getName().setValue(Decision.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(decision3, decision4, (decision) -> decision.getName().getValue(), () -> Decision.class.getSimpleName() + "-6", () -> Decision.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 22 with TextAnnotation

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

the class DefaultValueUtilitiesTest method testUpdateNewNodeName_BusinessKnowledgeModel.

@Test
public void testUpdateNewNodeName_BusinessKnowledgeModel() {
    // Add some existing nodes to ensure naming is not affected by existing content
    graph.addNode(makeMockNode(new Decision()));
    graph.addNode(makeMockNode(new InputData()));
    graph.addNode(makeMockNode(new KnowledgeSource()));
    graph.addNode(makeMockNode(new TextAnnotation()));
    final BusinessKnowledgeModel bkm1 = new BusinessKnowledgeModel();
    final BusinessKnowledgeModel bkm2 = new BusinessKnowledgeModel();
    final BusinessKnowledgeModel bkm3 = new BusinessKnowledgeModel();
    final BusinessKnowledgeModel bkm4 = new BusinessKnowledgeModel();
    assertUpdateNewNodeName(bkm1, bkm2, (bkm) -> bkm.getName().getValue(), () -> BusinessKnowledgeModel.class.getSimpleName() + "-1", () -> BusinessKnowledgeModel.class.getSimpleName() + "-2");
    // Update existing names manually and add two more
    bkm1.getName().setValue("bkm");
    bkm2.getName().setValue(BusinessKnowledgeModel.class.getSimpleName() + "-5");
    assertUpdateNewNodeName(bkm3, bkm4, (bkm) -> bkm.getName().getValue(), () -> BusinessKnowledgeModel.class.getSimpleName() + "-6", () -> BusinessKnowledgeModel.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 23 with TextAnnotation

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

the class DMNDeepCloneProcessTest method testCloneWhenSourceIsTextAnnotation.

@Test
public void testCloneWhenSourceIsTextAnnotation() {
    final TextAnnotation source = buildTextAnnotation();
    final TextAnnotation cloned = dmnDeepCloneProcess.clone(source, new TextAnnotation());
    assertThat(cloned).isNotNull();
    assertThat(cloned.getId().getValue()).isNotEqualTo(SOURCE_ID);
    assertThat(cloned.getText().getValue()).isEqualTo(TEXT_DATA + FIRST_INDEX_IN_SUFFIX);
}
Also used : TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) AbstractCloneProcessTest(org.kie.workbench.common.stunner.core.definition.clone.AbstractCloneProcessTest) Test(org.junit.Test)

Example 24 with TextAnnotation

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

the class DMNDiagramTextPropertyProviderImplTest method checkSupportsDMNDiagram.

@Test
@SuppressWarnings("unchecked")
public void checkSupportsDMNDiagram() {
    assertTrue(provider.supports(element));
    final Element other = mock(Element.class);
    final Definition otherContent = mock(Definition.class);
    final TextAnnotation otherDefinition = mock(TextAnnotation.class);
    when(other.getContent()).thenReturn(otherContent);
    when(otherContent.getDefinition()).thenReturn(otherDefinition);
    assertFalse(provider.supports(other));
}
Also used : Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) Test(org.junit.Test)

Example 25 with TextAnnotation

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

the class StunnerConverter method ddExtAugmentStunner.

private void ddExtAugmentStunner(final Node currentNode, final JSIDMNShape shape) {
    final View content = (View) currentNode.getContent();
    final Bound ulBound = upperLeftBound(content);
    final Bound lrBound = lowerRightBound(content);
    final Object definition = content.getDefinition();
    if (definition instanceof Decision) {
        final Decision decision = (Decision) definition;
        internalAugment(shape, ulBound, decision.getDimensionsSet(), lrBound, decision.getStylingSet(), (line) -> {
        /*NOP*/
        });
    } else if (definition instanceof InputData) {
        final InputData inputData = (InputData) definition;
        internalAugment(shape, ulBound, inputData.getDimensionsSet(), lrBound, inputData.getStylingSet(), (line) -> {
        /*NOP*/
        });
    } else if (definition instanceof BusinessKnowledgeModel) {
        final BusinessKnowledgeModel businessKnowledgeModel = (BusinessKnowledgeModel) definition;
        internalAugment(shape, ulBound, businessKnowledgeModel.getDimensionsSet(), lrBound, businessKnowledgeModel.getStylingSet(), (line) -> {
        /*NOP*/
        });
    } else if (definition instanceof KnowledgeSource) {
        final KnowledgeSource knowledgeSource = (KnowledgeSource) definition;
        internalAugment(shape, ulBound, knowledgeSource.getDimensionsSet(), lrBound, knowledgeSource.getStylingSet(), (line) -> {
        /*NOP*/
        });
    } else if (definition instanceof TextAnnotation) {
        final TextAnnotation textAnnotation = (TextAnnotation) definition;
        internalAugment(shape, ulBound, textAnnotation.getDimensionsSet(), lrBound, textAnnotation.getStylingSet(), (line) -> {
        /*NOP*/
        });
    } else if (definition instanceof DecisionService) {
        final DecisionService decisionService = (DecisionService) definition;
        internalAugment(shape, ulBound, decisionService.getDimensionsSet(), lrBound, decisionService.getStylingSet(), (dividerLineY) -> decisionService.setDividerLineY(new DecisionServiceDividerLineY(dividerLineY - ulBound.getY())));
    }
}
Also used : TextAnnotation(org.kie.workbench.common.dmn.api.definition.model.TextAnnotation) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) KnowledgeSourceConverter(org.kie.workbench.common.dmn.client.marshaller.converters.KnowledgeSourceConverter) JSITTextAnnotation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITTextAnnotation) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.upperLeftBound) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour) FontStylingSetPropertyConverter(org.kie.workbench.common.dmn.client.marshaller.converters.dd.FontStylingSetPropertyConverter) FactoryManager(org.kie.workbench.common.stunner.core.api.FactoryManager) PointUtils.widthOfShape(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.widthOfShape) Height(org.kie.workbench.common.dmn.api.property.dimensions.Height) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) DecisionServiceConverter(org.kie.workbench.common.dmn.client.marshaller.converters.DecisionServiceConverter) JSIStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.lowerRightBound) Objects(java.util.Objects) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement) JSITDecisionService(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionService) TextAnnotationConverter(org.kie.workbench.common.dmn.client.marshaller.converters.TextAnnotationConverter) List(java.util.List) NodeConverter(org.kie.workbench.common.dmn.client.marshaller.converters.NodeConverter) BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) DMNDiagramsSession(org.kie.workbench.common.dmn.client.docks.navigator.drds.DMNDiagramsSession) BusinessKnowledgeModelConverter(org.kie.workbench.common.dmn.client.marshaller.converters.BusinessKnowledgeModelConverter) Optional(java.util.Optional) JSITBusinessKnowledgeModel(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBusinessKnowledgeModel) JSITKnowledgeSource(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITKnowledgeSource) Node(org.kie.workbench.common.stunner.core.graph.Node) PointUtils.yOfShape(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.yOfShape) Width(org.kie.workbench.common.dmn.api.property.dimensions.Width) JSIDMNDecisionServiceDividerLine(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine) RectangleDimensionsSet(org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet) InputDataConverter(org.kie.workbench.common.dmn.client.marshaller.converters.InputDataConverter) JSITInputData(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputData) JSIPoint(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint) View(org.kie.workbench.common.stunner.core.graph.content.view.View) PointUtils.heightOfShape(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.heightOfShape) Inject(javax.inject.Inject) Js(jsinterop.base.Js) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) PointUtils.xOfShape(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.xOfShape) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) DecisionConverter(org.kie.workbench.common.dmn.client.marshaller.converters.DecisionConverter) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape) Consumer(java.util.function.Consumer) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) JsUtils(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JsUtils) Dependent(javax.enterprise.context.Dependent) JSIDMNStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) ColorUtils(org.kie.workbench.common.dmn.client.marshaller.converters.dd.ColorUtils) DecisionServiceDividerLineY(org.kie.workbench.common.dmn.api.property.dmn.DecisionServiceDividerLineY) JSITKnowledgeSource(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITKnowledgeSource) KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) BusinessKnowledgeModel(org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel) JSITBusinessKnowledgeModel(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBusinessKnowledgeModel) PointUtils.upperLeftBound(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.upperLeftBound) PointUtils.lowerRightBound(org.kie.workbench.common.dmn.client.marshaller.converters.dd.PointUtils.lowerRightBound) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) JSITInputData(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputData) 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) View(org.kie.workbench.common.stunner.core.graph.content.view.View) JSITDecision(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) JSITDecisionService(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionService) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService)

Aggregations

TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)25 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)14 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)14 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)14 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)14 Test (org.junit.Test)10 View (org.kie.workbench.common.stunner.core.graph.content.view.View)10 Node (org.kie.workbench.common.stunner.core.graph.Node)8 List (java.util.List)7 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)7 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)7 ArrayList (java.util.ArrayList)6 Association (org.kie.workbench.common.dmn.api.definition.model.Association)6 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)6 Edge (org.kie.workbench.common.stunner.core.graph.Edge)6 Objects (java.util.Objects)5 Optional (java.util.Optional)5 Consumer (java.util.function.Consumer)5 Inject (javax.inject.Inject)5 DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)5