Search in sources :

Example 6 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape in project kie-wb-common by kiegroup.

the class NodeEntriesBuilder method copy.

private JSIDMNShape copy(final JSIDMNShape shape) {
    final JSIDMNShape copy = Js.uncheckedCast(JsInteropUtils.jsCopy(shape));
    copy.setId(uniqueId());
    return copy;
}
Also used : JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)

Example 7 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape in project kie-wb-common by kiegroup.

the class NodeEntriesFactory method getShapesByDiagramId.

private Map<JSIDMNShape, String> getShapesByDiagramId(final JSITDefinitions definitions) {
    final Map<JSIDMNShape, String> dmnShapesByDiagramId = new HashMap<>();
    final List<JSIDMNDiagram> diagrams = definitions.getDMNDI().getDMNDiagram();
    forEach(diagrams, diagram -> {
        final String diagramId = diagram.getId();
        final List<JSIDiagramElement> diagramElements = diagram.getDMNDiagramElement();
        forEach(diagramElements, diagramElement -> {
            if (JSIDMNShape.instanceOf(diagramElement)) {
                final JSIDMNShape shape = Js.uncheckedCast(diagramElement);
                dmnShapesByDiagramId.put(shape, diagramId);
            }
        });
    });
    return dmnShapesByDiagramId;
}
Also used : JSIDMNDiagram(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram) HashMap(java.util.HashMap) JSIDiagramElement(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIDiagramElement) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)

Example 8 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape 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)

Example 9 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape in project kie-wb-common by kiegroup.

the class StunnerConverter method internalAugmentStyles.

private void internalAugmentStyles(final JSIDMNShape drgShape, final StylingSet stylingSet) {
    final JSIStyle jsiStyle = drgShape.getStyle();
    if (Objects.isNull(jsiStyle)) {
        return;
    }
    final JSIStyle drgStyle = getUnwrappedJSIStyle(jsiStyle);
    final JSIDMNStyle dmnStyleOfDrgShape = isJSIDMNStyle(drgStyle) ? getJSIDmnStyle(drgStyle) : null;
    if (Objects.nonNull(dmnStyleOfDrgShape)) {
        if (Objects.nonNull(dmnStyleOfDrgShape.getFillColor())) {
            stylingSet.setBgColour(new BgColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getFillColor())));
        }
        if (Objects.nonNull(dmnStyleOfDrgShape.getStrokeColor())) {
            stylingSet.setBorderColour(new BorderColour(ColorUtils.wbFromDMN(dmnStyleOfDrgShape.getStrokeColor())));
        }
    }
    final StylingSet fontStylingSet = new StylingSet();
    if (Objects.nonNull(dmnStyleOfDrgShape)) {
        mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(dmnStyleOfDrgShape));
    }
    if (Objects.nonNull(drgShape.getDMNLabel())) {
        final JSIDMNShape jsiLabel = Js.uncheckedCast(drgShape.getDMNLabel());
        final JSIStyle jsiLabelStyle = jsiLabel.getStyle();
        final Object jsiLabelSharedStyle = Js.uncheckedCast(jsiLabel.getSharedStyle());
        if (Objects.nonNull(jsiLabelSharedStyle) && JSIDMNStyle.instanceOf(jsiLabelSharedStyle)) {
            mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN((Js.uncheckedCast(jsiLabelSharedStyle))));
        }
        if (Objects.nonNull(jsiLabelStyle) && isJSIDMNStyle(jsiLabelStyle)) {
            mergeFontStylingSet(fontStylingSet, FontStylingSetPropertyConverter.wbFromDMN(Js.uncheckedCast(jsiLabelStyle)));
        }
    }
    mergeFontStylingSet(stylingSet, fontStylingSet);
}
Also used : BgColour(org.kie.workbench.common.dmn.api.property.styling.BgColour) JSIStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle) JSIDMNShape(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape) StylingSet(org.kie.workbench.common.dmn.api.property.styling.StylingSet) JSIDMNStyle(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle) BorderColour(org.kie.workbench.common.dmn.api.property.styling.BorderColour)

Example 10 with JSIDMNShape

use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape 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

JSIDMNShape (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNShape)10 JSIBounds (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIBounds)4 JSIDMNStyle (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNStyle)4 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)3 StylingSet (org.kie.workbench.common.dmn.api.property.styling.StylingSet)3 JSIPoint (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dc.JSIPoint)3 JSIStyle (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIStyle)3 JSIDMNDecisionServiceDividerLine (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDecisionServiceDividerLine)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)2 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)2 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.model.KnowledgeSource)2 TextAnnotation (org.kie.workbench.common.dmn.api.definition.model.TextAnnotation)2 Height (org.kie.workbench.common.dmn.api.property.dimensions.Height)2 Width (org.kie.workbench.common.dmn.api.property.dimensions.Width)2 BgColour (org.kie.workbench.common.dmn.api.property.styling.BgColour)2 BorderColour (org.kie.workbench.common.dmn.api.property.styling.BorderColour)2 JSIDiagramElement (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.di.JSIDiagramElement)2 JSITTextAnnotation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITTextAnnotation)2 JSIDMNDiagram (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmndi12.JSIDMNDiagram)2