Search in sources :

Example 16 with JSITInformationItem

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

the class FunctionDefinitionPropertyConverter method wbFromDMN.

public static FunctionDefinition wbFromDMN(final JSITFunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (Objects.isNull(dmn)) {
        return null;
    }
    final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
    Expression expression = null;
    final JSITExpression jsiWrapped = dmn.getExpression();
    if (Objects.nonNull(jsiWrapped)) {
        final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
        expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
    }
    final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression);
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
    }
    // JSITFunctionKind is a String JSO so convert into the real type
    final String sKind = Js.uncheckedCast(dmn.getKind());
    final Kind kind = Kind.fromValue(sKind);
    switch(kind) {
        case FEEL:
            result.setKind(Kind.FEEL);
            break;
        case JAVA:
            result.setKind(Kind.JAVA);
            break;
        case PMML:
            result.setKind(Kind.PMML);
            convertPMMLFunctionExpression(result, hasComponentWidthsConsumer);
            break;
        default:
            result.setKind(Kind.FEEL);
            break;
    }
    final List<JSITInformationItem> jsiInformationItems = dmn.getFormalParameter();
    for (int i = 0; i < jsiInformationItems.size(); i++) {
        final JSITInformationItem jsiInformationItem = Js.uncheckedCast(jsiInformationItems.get(i));
        final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(jsiInformationItem);
        if (Objects.nonNull(iiConverted)) {
            iiConverted.setParent(result);
        }
        result.getFormalParameter().add(iiConverted);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) JSITFunctionKind(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionKind) Kind(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition.Kind) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Aggregations

JSITInformationItem (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem)15 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)5 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)4 JSITExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)4 DRGElement (org.kie.workbench.common.dmn.api.definition.model.DRGElement)3 DecisionService (org.kie.workbench.common.dmn.api.definition.model.DecisionService)3 InputData (org.kie.workbench.common.dmn.api.definition.model.InputData)3 KnowledgeRequirement (org.kie.workbench.common.dmn.api.definition.model.KnowledgeRequirement)3 JSITDMNElementReference (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDMNElementReference)3 JSITDecision (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecision)3 JSITFunctionDefinition (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition)3 JSITInputData (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputData)3 Edge (org.kie.workbench.common.stunner.core.graph.Edge)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.model.BusinessKnowledgeModel)2 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)2