Search in sources :

Example 1 with JSITInvocation

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

the class ExpressionPropertyConverter method dmnFromWB.

public static JSITExpression dmnFromWB(final Expression wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
    if (Objects.isNull(wb)) {
        return null;
    }
    final String uuid = wb.getId().getValue();
    if (Objects.nonNull(uuid)) {
        final JSITComponentWidths componentWidths = new JSITComponentWidths();
        componentWidths.setDmnElementRef(uuid);
        wb.getComponentWidths().stream().filter(Objects::nonNull).forEach(w -> componentWidths.addWidth(new Float(w)));
        componentWidthsConsumer.accept(componentWidths);
    }
    if (wb instanceof IsLiteralExpression) {
        final JSITLiteralExpression unwrappedJSITLiteralExpression = LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
        final JSITLiteralExpression wrappedJSITLiteralExpression = getWrappedJSITLiteralExpression(unwrappedJSITLiteralExpression, "dmn", "literalExpression");
        return wrappedJSITLiteralExpression;
    } else if (wb instanceof Context) {
        final JSITContext unwrappedJSITContext = ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
        final JSITContext wrappedJSITContext = getWrappedJSITContext(unwrappedJSITContext, "dmn", "context");
        return wrappedJSITContext;
    } else if (wb instanceof Relation) {
        final JSITRelation unwrappedJSITRelation = RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
        final JSITRelation wrappedJSITRelation = getWrappedJSITRelation(unwrappedJSITRelation, "dmn", "relation");
        return wrappedJSITRelation;
    } else if (wb instanceof List) {
        final JSITList unwrappedJSITList = ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
        final JSITList wrappedJSITList = getWrappedJSITList(unwrappedJSITList, "dmn", "list");
        return wrappedJSITList;
    } else if (wb instanceof Invocation) {
        final JSITInvocation unwrappedJSITInvocation = InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
        final JSITInvocation wrappedJSITInvocation = getWrappedJSITInvocation(unwrappedJSITInvocation, "dmn", "invocation");
        return wrappedJSITInvocation;
    } else if (wb instanceof FunctionDefinition) {
        final JSITFunctionDefinition unwrappedJSITFunctionDefinition = FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
        final JSITFunctionDefinition wrappedJSITFunctionDefinition = getWrappedJSITFunctionDefinition(unwrappedJSITFunctionDefinition, "dmn", "functionDefinition");
        return wrappedJSITFunctionDefinition;
    } else if (wb instanceof DecisionTable) {
        final JSITDecisionTable unwrappedJSITDecisionTable = DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
        final JSITDecisionTable wrappedJSITDecisionTable = getWrappedJSITDecisionTable(unwrappedJSITDecisionTable, "dmn", "decisionTable");
        return wrappedJSITDecisionTable;
    }
    return null;
}
Also used : JSITContext(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext) WrapperUtils.getWrappedJSITContext(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) WrapperUtils.getWrappedJSITFunctionDefinition(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition) JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) IsLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression) JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) WrapperUtils.getWrappedJSITRelation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) WrapperUtils.getWrappedJSITList(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList) WrapperUtils.getWrappedJSITInvocation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) WrapperUtils.getWrappedJSITLiteralExpression(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) WrapperUtils.getWrappedJSITDecisionTable(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) WrapperUtils.getWrappedJSITRelation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation) JSITContext(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext) WrapperUtils.getWrappedJSITContext(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext) List(org.kie.workbench.common.dmn.api.definition.model.List) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) WrapperUtils.getWrappedJSITList(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList) WrapperUtils.getWrappedJSITInvocation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) WrapperUtils.getWrappedJSITFunctionDefinition(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) JSITComponentWidths(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.kie.JSITComponentWidths) JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) WrapperUtils.getWrappedJSITDecisionTable(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable)

Example 2 with JSITInvocation

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

the class ExpressionPropertyConverter method wbFromDMN.

public static Expression wbFromDMN(final JSITExpression dmn, final JSITExpression parent, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (JSITLiteralExpression.instanceOf(dmn)) {
        final JSITLiteralExpression jsiExpression = Js.uncheckedCast(dmn);
        final LiteralExpression e = LiteralExpressionPropertyConverter.wbFromDMN(jsiExpression);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITContext.instanceOf(dmn)) {
        final JSITContext jsiExpression = Js.uncheckedCast(dmn);
        final Context e = ContextPropertyConverter.wbFromDMN(jsiExpression, parent, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITRelation.instanceOf(dmn)) {
        final JSITRelation jsiExpression = Js.uncheckedCast(dmn);
        final Relation e = RelationPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITList.instanceOf(dmn)) {
        final JSITList jsiExpression = Js.uncheckedCast(dmn);
        final List e = ListPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITInvocation.instanceOf(dmn)) {
        final JSITInvocation jsiExpression = Js.uncheckedCast(dmn);
        final Invocation e = InvocationPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITFunctionDefinition.instanceOf(dmn)) {
        final JSITFunctionDefinition jsiExpression = Js.uncheckedCast(dmn);
        final FunctionDefinition e = FunctionDefinitionPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    } else if (JSITDecisionTable.instanceOf(dmn)) {
        final JSITDecisionTable jsiExpression = Js.uncheckedCast(dmn);
        final DecisionTable e = DecisionTablePropertyConverter.wbFromDMN(jsiExpression);
        hasComponentWidthsConsumer.accept(dmn.getId(), e);
        return e;
    }
    return null;
}
Also used : JSITContext(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext) WrapperUtils.getWrappedJSITContext(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) WrapperUtils.getWrappedJSITFunctionDefinition(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition) JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) WrapperUtils.getWrappedJSITRelation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) WrapperUtils.getWrappedJSITList(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList) WrapperUtils.getWrappedJSITInvocation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) WrapperUtils.getWrappedJSITLiteralExpression(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression) IsLiteralExpression(org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) WrapperUtils.getWrappedJSITLiteralExpression(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) WrapperUtils.getWrappedJSITDecisionTable(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) WrapperUtils.getWrappedJSITRelation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation) JSITContext(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext) WrapperUtils.getWrappedJSITContext(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext) List(org.kie.workbench.common.dmn.api.definition.model.List) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) WrapperUtils.getWrappedJSITList(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList) WrapperUtils.getWrappedJSITInvocation(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) WrapperUtils.getWrappedJSITFunctionDefinition(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) JSITDecisionTable(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable) WrapperUtils.getWrappedJSITDecisionTable(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable)

Example 3 with JSITInvocation

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

the class InvocationPropertyConverter method dmnFromWB.

public static JSITInvocation dmnFromWB(final Invocation wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
    if (Objects.isNull(wb)) {
        return null;
    }
    final JSITInvocation result = new JSITInvocation();
    result.setId(wb.getId().getValue());
    final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    description.ifPresent(result::setDescription);
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    final JSITExpression convertedExpression = ExpressionPropertyConverter.dmnFromWB(wb.getExpression(), componentWidthsConsumer);
    result.setExpression(convertedExpression);
    for (Binding b : wb.getBinding()) {
        final JSITBinding bConverted = BindingPropertyConverter.dmnFromWB(b, componentWidthsConsumer);
        result.addBinding(bConverted);
    }
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Example 4 with JSITInvocation

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

the class WrapperUtils method getWrappedJSITInvocation.

public static JSITInvocation getWrappedJSITInvocation(final JSITInvocation toWrap, final String prefix, final String localPart) {
    final JSITInvocation toReturn = Js.uncheckedCast(JsUtils.getWrappedElement(toWrap));
    final JSIName jsiName = JSITInvocation.getJSIName();
    updateJSIName(jsiName, prefix, localPart);
    JsUtils.setNameOnWrapped(toReturn, jsiName);
    return toReturn;
}
Also used : JSIName(org.kie.workbench.common.dmn.webapp.kogito.marshaller.mapper.JSIName) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation)

Example 5 with JSITInvocation

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

the class InvocationPropertyConverter method wbFromDMN.

public static Invocation wbFromDMN(final JSITInvocation 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());
    final Invocation result = new Invocation();
    result.setId(id);
    result.setDescription(description);
    result.setTypeRef(typeRef);
    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);
    }
    result.setExpression(expression);
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
    }
    final List<JSITBinding> jsiBindings = dmn.getBinding();
    for (int i = 0; i < jsiBindings.size(); i++) {
        final JSITBinding jsiBinding = Js.uncheckedCast(jsiBindings.get(i));
        final Binding bConverted = BindingPropertyConverter.wbFromDMN(jsiBinding, hasComponentWidthsConsumer);
        if (Objects.nonNull(bConverted)) {
            bConverted.setParent(result);
        }
        result.getBinding().add(bConverted);
    }
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) JSITInvocation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation) Invocation(org.kie.workbench.common.dmn.api.definition.model.Invocation) 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) JSITBinding(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)

Aggregations

JSITInvocation (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInvocation)5 Invocation (org.kie.workbench.common.dmn.api.definition.model.Invocation)3 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)2 Context (org.kie.workbench.common.dmn.api.definition.model.Context)2 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)2 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)2 IsLiteralExpression (org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)2 WrapperUtils.getWrappedJSITContext (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITContext)2 WrapperUtils.getWrappedJSITDecisionTable (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITDecisionTable)2 WrapperUtils.getWrappedJSITFunctionDefinition (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITFunctionDefinition)2 WrapperUtils.getWrappedJSITInvocation (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITInvocation)2 WrapperUtils.getWrappedJSITList (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITList)2 WrapperUtils.getWrappedJSITLiteralExpression (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression)2 WrapperUtils.getWrappedJSITRelation (org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITRelation)2 JSITBinding (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITBinding)2 JSITContext (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContext)2 JSITDecisionTable (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITDecisionTable)2 JSITExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)2