Search in sources :

Example 1 with FunctionKind

use of org.kie.dmn.model.api.FunctionKind in project kie-wb-common by kiegroup.

the class FunctionDefinitionPropertyConverter method wbFromDMN.

public static FunctionDefinition wbFromDMN(final org.kie.dmn.model.api.FunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final Expression expression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression);
    if (expression != null) {
        expression.setParent(result);
    }
    final FunctionKind kind = dmn.getKind();
    switch(kind) {
        case FEEL:
            result.setKind(Kind.FEEL);
            break;
        case JAVA:
            result.setKind(Kind.JAVA);
            break;
        case PMML:
            result.setKind(Kind.PMML);
            convertPMMLFunctionExpression(result);
            break;
        default:
            result.setKind(Kind.FEEL);
            break;
    }
    for (org.kie.dmn.model.api.InformationItem ii : dmn.getFormalParameter()) {
        final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(ii);
        if (iiConverted != null) {
            iiConverted.setParent(result);
        }
        result.getFormalParameter().add(iiConverted);
    }
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) FunctionKind(org.kie.dmn.model.api.FunctionKind)

Aggregations

FunctionKind (org.kie.dmn.model.api.FunctionKind)1 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)1 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)1 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)1 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)1 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)1 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)1 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)1