Search in sources :

Example 46 with Context

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

the class PMMLIncludedModelHandlerTest method makeTopLevelPMMLFunctionDefinition.

private FunctionDefinition makeTopLevelPMMLFunctionDefinition(final String documentName, final String modelName) {
    final FunctionDefinition function = new FunctionDefinition();
    function.setKind(FunctionDefinition.Kind.PMML);
    final Context functionExpression = new Context();
    function.setExpression(functionExpression);
    final ContextEntry functionContextEntry1 = new ContextEntry();
    final InformationItem functionContextEntry1Variable = new InformationItem();
    final LiteralExpressionPMMLDocument functionContextEntry1Value = new LiteralExpressionPMMLDocument();
    functionContextEntry1Variable.getName().setValue(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT);
    functionContextEntry1.setVariable(functionContextEntry1Variable);
    functionContextEntry1Value.getText().setValue("\"" + documentName + "\"");
    functionContextEntry1.setExpression(functionContextEntry1Value);
    final ContextEntry functionContextEntry2 = new ContextEntry();
    final InformationItem functionContextEntry2Variable = new InformationItem();
    final LiteralExpressionPMMLDocumentModel functionContextEntry2Value = new LiteralExpressionPMMLDocumentModel();
    functionContextEntry2Variable.getName().setValue(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL);
    functionContextEntry2.setVariable(functionContextEntry2Variable);
    functionContextEntry2Value.getText().setValue("\"" + modelName + "\"");
    functionContextEntry2.setExpression(functionContextEntry2Value);
    functionExpression.getContextEntry().add(functionContextEntry1);
    functionExpression.getContextEntry().add(functionContextEntry2);
    return function;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) LiteralExpressionPMMLDocumentModel(org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocumentModel) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) LiteralExpressionPMMLDocument(org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocument) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 47 with Context

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

the class PMMLIncludedModelHandlerTest method makeNestedLiteralExpression.

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

Example 48 with Context

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

the class PMMLIncludedModelHandlerTest method assertNestedLiteralExpression.

private void assertNestedLiteralExpression(final Decision decision) {
    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(LiteralExpression.class);
    assertThat(((LiteralExpression) contextEntry.getExpression()).getText().getValue()).isEmpty();
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.model.Context) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 49 with Context

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

the class PMMLIncludedModelHandlerTest method assertNestedFunctionDefinition.

private void assertNestedFunctionDefinition(final BusinessKnowledgeModel bkm, final String expectedDocumentValue, final String expectedModelValue) {
    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(FunctionDefinition.class);
    assertPMMLContextDefinition((FunctionDefinition) contextEntry.getExpression(), expectedDocumentValue, expectedModelValue);
}
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)

Aggregations

Context (org.kie.workbench.common.dmn.api.definition.model.Context)49 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)21 Test (org.junit.Test)20 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)15 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)13 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)12 TContext (org.kie.dmn.model.v1_2.TContext)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)8 DecisionTable (org.kie.workbench.common.dmn.api.definition.model.DecisionTable)7 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)7 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 NamespaceContext (javax.xml.namespace.NamespaceContext)6 Before (org.junit.Before)6 DMNContext (org.kie.dmn.api.core.DMNContext)6 HasComponentWidths (org.kie.workbench.common.dmn.api.definition.HasComponentWidths)5 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)5 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)5 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)5 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 ArrayList (java.util.ArrayList)4