Search in sources :

Example 1 with InputData

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

the class DMNMarshallerStandalone method stunnerToDDExt.

@SuppressWarnings("unchecked")
private static DMNShape stunnerToDDExt(final Definitions definitions, final View<? extends DMNElement> v) {
    final DMNShape result = new org.kie.dmn.model.v1_2.dmndi.DMNShape();
    result.setId("dmnshape-" + v.getDefinition().getId().getValue());
    result.setDmnElementRef(getDmnElementRef(definitions, v));
    final Bounds bounds = new org.kie.dmn.model.v1_2.dmndi.Bounds();
    result.setBounds(bounds);
    bounds.setX(xOfBound(upperLeftBound(v)));
    bounds.setY(yOfBound(upperLeftBound(v)));
    result.setStyle(new org.kie.dmn.model.v1_2.dmndi.DMNStyle());
    result.setDMNLabel(new org.kie.dmn.model.v1_2.dmndi.DMNLabel());
    if (v.getDefinition() instanceof Decision) {
        final Decision d = (Decision) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
    } else if (v.getDefinition() instanceof InputData) {
        final InputData d = (InputData) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
    } else if (v.getDefinition() instanceof BusinessKnowledgeModel) {
        final BusinessKnowledgeModel d = (BusinessKnowledgeModel) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
    } else if (v.getDefinition() instanceof KnowledgeSource) {
        final KnowledgeSource d = (KnowledgeSource) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
    } else if (v.getDefinition() instanceof TextAnnotation) {
        final TextAnnotation d = (TextAnnotation) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
    } else if (v.getDefinition() instanceof DecisionService) {
        final DecisionService d = (DecisionService) v.getDefinition();
        applyBounds(d.getDimensionsSet(), bounds);
        applyBackgroundStyles(d.getStylingSet(), result);
        applyFontStyle(d.getStylingSet(), result);
        final DMNDecisionServiceDividerLine dl = new org.kie.dmn.model.v1_2.dmndi.DMNDecisionServiceDividerLine();
        final org.kie.dmn.model.api.dmndi.Point leftPoint = new org.kie.dmn.model.v1_2.dmndi.Point();
        leftPoint.setX(v.getBounds().getUpperLeft().getX());
        final double dlY = v.getBounds().getUpperLeft().getY() + d.getDividerLineY().getValue();
        leftPoint.setY(dlY);
        dl.getWaypoint().add(leftPoint);
        final org.kie.dmn.model.api.dmndi.Point rightPoint = new org.kie.dmn.model.v1_2.dmndi.Point();
        rightPoint.setX(v.getBounds().getLowerRight().getX());
        rightPoint.setY(dlY);
        dl.getWaypoint().add(rightPoint);
        result.setDMNDecisionServiceDividerLine(dl);
    }
    return result;
}
Also used : Bounds(org.kie.dmn.model.api.dmndi.Bounds) DMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine) Point(org.kie.dmn.model.api.dmndi.Point) ControlPoint(org.kie.workbench.common.stunner.core.graph.content.view.ControlPoint) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) DecisionService(org.kie.workbench.common.dmn.api.definition.model.DecisionService) DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) 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)

Example 2 with InputData

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

the class DRDContextMenuServiceTest method mockNodes.

private Collection<Node<? extends Definition<?>, Edge>> mockNodes() {
    final Node node = mock(Node.class);
    final Node clonedNode = mock(Node.class);
    final View content = mock(View.class);
    final View clonedContent = mock(View.class);
    final Bounds bounds = mock(Bounds.class);
    final Bound upperLeft = mock(Bound.class);
    final Bound lowerRight = mock(Bound.class);
    final InputData inputData = spy(new InputData());
    final InputData clonedInputData = spy(new InputData());
    final Collection<Node<? extends Definition<?>, Edge>> nodes = new ArrayList<>();
    when(node.getContent()).thenReturn(content);
    when(content.getDefinition()).thenReturn(inputData);
    when(content.getBounds()).thenReturn(bounds);
    when(bounds.getUpperLeft()).thenReturn(upperLeft);
    when(bounds.getLowerRight()).thenReturn(lowerRight);
    when(factoryManager.newElement(Mockito.<String>any(), Mockito.<String>any())).thenReturn(clonedNode);
    when(clonedNode.asNode()).thenReturn(clonedNode);
    when(clonedNode.getContent()).thenReturn(clonedContent);
    when(clonedContent.getDefinition()).thenReturn(clonedInputData);
    when(dmnDeepCloneProcess.clone(eq(inputData))).thenReturn(clonedInputData);
    nodes.add(node);
    return nodes;
}
Also used : Node(org.kie.workbench.common.stunner.core.graph.Node) Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) Bound(org.kie.workbench.common.stunner.core.graph.content.Bound) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) ArrayList(java.util.ArrayList) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 3 with InputData

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

the class DecisionTableEditorDefinitionEnricherTest method setup.

@Before
public void setup() {
    super.setup();
    this.diagram = new DMNDiagram();
    this.inputData1 = new InputData();
    this.inputData2 = new InputData();
    this.decision1 = new Decision();
}
Also used : DMNDiagram(org.kie.workbench.common.dmn.api.definition.model.DMNDiagram) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Before(org.junit.Before)

Example 4 with InputData

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

the class DMNMarshallerStandaloneTest method checkFontsize_sharedStyle.

@SuppressWarnings("unchecked")
private void checkFontsize_sharedStyle(Graph<?, Node<?, ?>> graph) {
    Node<?, ?> node = graph.getNode("_38b74e2e-32f8-42c5-ab51-8a3e927637e0");
    assertNodeContentDefinitionIs(node, InputData.class);
    InputData definition = ((View<InputData>) node.getContent()).getDefinition();
    assertEquals(Double.valueOf(21), definition.getStylingSet().getFontSize().getValue());
}
Also used : TInputData(org.kie.dmn.model.v1_2.TInputData) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Example 5 with InputData

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

the class KnowledgeSourceConverter method dmnFromNode.

@Override
public org.kie.dmn.model.api.KnowledgeSource dmnFromNode(final Node<View<KnowledgeSource>, ?> node, final Consumer<ComponentWidths> componentWidthsConsumer) {
    final KnowledgeSource source = (KnowledgeSource) DefinitionUtils.getElementDefinition(node);
    final org.kie.dmn.model.api.KnowledgeSource result = new org.kie.dmn.model.v1_2.TKnowledgeSource();
    result.setId(source.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
    result.setName(source.getName().getValue());
    result.setType(source.getType().getValue());
    result.setLocationURI(source.getLocationURI().getValue());
    DMNExternalLinksToExtensionElements.loadExternalLinksIntoExtensionElements(source, result);
    // DMN spec table 2: Requirements connection rules
    final List<Edge<?, ?>> inEdges = (List<Edge<?, ?>>) node.getInEdges();
    for (Edge<?, ?> e : inEdges) {
        final Node<?, ?> sourceNode = e.getSourceNode();
        if (sourceNode.getContent() instanceof View<?>) {
            final View<?> view = (View<?>) sourceNode.getContent();
            if (view.getDefinition() instanceof DRGElement) {
                final DRGElement drgElement = (DRGElement) view.getDefinition();
                if (drgElement instanceof Decision) {
                    final org.kie.dmn.model.api.AuthorityRequirement iReq = new org.kie.dmn.model.v1_2.TAuthorityRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredDecision(ri);
                    result.getAuthorityRequirement().add(iReq);
                } else if (drgElement instanceof KnowledgeSource) {
                    final org.kie.dmn.model.api.AuthorityRequirement iReq = new org.kie.dmn.model.v1_2.TAuthorityRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredAuthority(ri);
                    result.getAuthorityRequirement().add(iReq);
                } else if (drgElement instanceof InputData) {
                    final org.kie.dmn.model.api.AuthorityRequirement iReq = new org.kie.dmn.model.v1_2.TAuthorityRequirement();
                    iReq.setId(e.getUUID());
                    final org.kie.dmn.model.api.DMNElementReference ri = new org.kie.dmn.model.v1_2.TDMNElementReference();
                    ri.setHref(getHref(drgElement));
                    iReq.setRequiredInput(ri);
                    result.getAuthorityRequirement().add(iReq);
                } else {
                    throw new UnsupportedOperationException("wrong model definition.");
                }
            }
        }
    }
    return result;
}
Also used : KnowledgeSource(org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource) List(java.util.List) InputData(org.kie.workbench.common.dmn.api.definition.model.InputData) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Decision(org.kie.workbench.common.dmn.api.definition.model.Decision) Edge(org.kie.workbench.common.stunner.core.graph.Edge) DRGElement(org.kie.workbench.common.dmn.api.definition.model.DRGElement)

Aggregations

InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)67 Test (org.junit.Test)42 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)37 View (org.kie.workbench.common.stunner.core.graph.content.view.View)26 Node (org.kie.workbench.common.stunner.core.graph.Node)22 Edge (org.kie.workbench.common.stunner.core.graph.Edge)21 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)17 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)17 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)15 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)15 ArrayList (java.util.ArrayList)14 List (java.util.List)14 InformationItemPrimary (org.kie.workbench.common.dmn.api.definition.model.InformationItemPrimary)13 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)12 Child (org.kie.workbench.common.stunner.core.graph.content.relationship.Child)11 Optional (java.util.Optional)9 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)8 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)8 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7