Search in sources :

Example 11 with DMNElement

use of org.kie.workbench.common.dmn.api.definition.model.DMNElement 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 12 with DMNElement

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

the class DecisionComponentsItemViewTest method createNode.

private Node createNode(final String id) {
    final Node n1 = mock(Node.class);
    final View v1 = mock(View.class);
    final DMNElement d1 = mock(DMNElement.class);
    final Id id1 = mock(Id.class);
    when(n1.getContent()).thenReturn(v1);
    when(v1.getDefinition()).thenReturn(d1);
    when(d1.getId()).thenReturn(id1);
    when(id1.getValue()).thenReturn(id);
    return n1;
}
Also used : DecisionComponentsItemView_DuplicatedNode(org.kie.workbench.common.dmn.client.resources.i18n.DMNEditorConstants.DecisionComponentsItemView_DuplicatedNode) Node(org.kie.workbench.common.stunner.core.graph.Node) DMNElement(org.kie.workbench.common.dmn.api.definition.model.DMNElement) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Aggregations

DMNElement (org.kie.workbench.common.dmn.api.definition.model.DMNElement)12 View (org.kie.workbench.common.stunner.core.graph.content.view.View)11 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)8 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)7 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)7 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)7 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)7 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)7 List (java.util.List)6 Map (java.util.Map)6 Objects (java.util.Objects)6 Optional (java.util.Optional)6 QName (javax.xml.namespace.QName)6 Definitions (org.kie.workbench.common.dmn.api.definition.model.Definitions)6 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)5 NamedElement (org.kie.workbench.common.dmn.api.definition.model.NamedElement)5 RectangleDimensionsSet (org.kie.workbench.common.dmn.api.property.dimensions.RectangleDimensionsSet)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)5 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)5 Node (org.kie.workbench.common.stunner.core.graph.Node)5