Search in sources :

Example 6 with ContextEntry

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

the class PMMLIncludedModelHandlerTest method assertNestedLiteralExpression.

private void assertNestedLiteralExpression(final BusinessKnowledgeModel bkm) {
    final FunctionDefinition function = bkm.getEncapsulatedLogic();
    assertThat(function.getExpression()).isInstanceOf(Context.class);
    final Context context = (Context) function.getExpression();
    assertThat(context.getContextEntry()).hasSize(1);
    final ContextEntry contextEntry = context.getContextEntry().get(0);
    assertThat(contextEntry.getExpression()).isInstanceOf(LiteralExpression.class);
    assertThat(((LiteralExpression) contextEntry.getExpression()).getText().getValue()).isEmpty();
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 7 with ContextEntry

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

the class PMMLIncludedModelHandlerTest method makeNestedPMMLFunctionDefinition.

private Context makeNestedPMMLFunctionDefinition(final String documentName, final String modelName) {
    final Context context = new Context();
    final ContextEntry contextEntry = new ContextEntry();
    final InformationItem variable = new InformationItem();
    variable.getName().setValue("variable");
    contextEntry.setVariable(variable);
    contextEntry.setExpression(makeTopLevelPMMLFunctionDefinition(documentName, modelName));
    context.getContextEntry().add(contextEntry);
    return context;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 8 with ContextEntry

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

the class PMMLIncludedModelHandlerTest method assertNestedFunctionDefinition.

private void assertNestedFunctionDefinition(final Decision decision, final String expectedDocumentValue, final String expectedModelValue) {
    assertThat(decision.getExpression()).isInstanceOf(Context.class);
    final Context context = (Context) decision.getExpression();
    assertThat(context.getContextEntry()).hasSize(1);
    final ContextEntry contextEntry = context.getContextEntry().get(0);
    assertThat(contextEntry.getExpression()).isInstanceOf(FunctionDefinition.class);
    assertPMMLContextDefinition((FunctionDefinition) contextEntry.getExpression(), expectedDocumentValue, expectedModelValue);
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 9 with ContextEntry

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

the class ContextEntryPropertyConverter method wbFromDMN.

public static ContextEntry wbFromDMN(final JSITContextEntry dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final InformationItem variable = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
    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 ContextEntry result = new ContextEntry();
    if (Objects.nonNull(variable)) {
        variable.setParent(result);
        result.setVariable(variable);
    }
    if (Objects.nonNull(expression)) {
        expression.setParent(result);
        result.setExpression(expression);
    }
    return result;
}
Also used : JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) 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) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) JSITContextEntry(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContextEntry)

Example 10 with ContextEntry

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

the class ContextPropertyConverterTest method setupDMNFromWB.

private Context setupDMNFromWB(final Optional<Expression> defaultExpression) {
    final Context wb = new Context();
    final ContextEntry contextEntry1 = new ContextEntry();
    final ContextEntry contextEntry2 = new ContextEntry();
    final InformationItem informationItem = new InformationItem();
    literalExpression.getComponentWidths().set(0, 200.0);
    literalExpression.getId().setValue(EXPRESSION_UUID);
    contextEntry1.setExpression(literalExpression);
    contextEntry1.setVariable(informationItem);
    defaultExpression.ifPresent(contextEntry2::setExpression);
    wb.getContextEntry().add(contextEntry1);
    wb.getContextEntry().add(contextEntry2);
    return wb;
}
Also used : TContext(org.kie.dmn.model.v1_2.TContext) Context(org.kie.workbench.common.dmn.api.definition.model.Context) TInformationItem(org.kie.dmn.model.v1_2.TInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) TContextEntry(org.kie.dmn.model.v1_2.TContextEntry) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Aggregations

ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)40 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)22 Context (org.kie.workbench.common.dmn.api.definition.model.Context)19 Test (org.junit.Test)16 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)8 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)7 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)6 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)5 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)5 TContextEntry (org.kie.dmn.model.v1_2.TContextEntry)4 TInformationItem (org.kie.dmn.model.v1_2.TInformationItem)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)4 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)4 OutputClause (org.kie.workbench.common.dmn.api.definition.model.OutputClause)4 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4 TLiteralExpression (org.kie.dmn.model.v1_2.TLiteralExpression)3 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)3 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)3