Search in sources :

Example 6 with LiteralExpressionPMMLDocumentModel

use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocumentModel 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)

Aggregations

LiteralExpressionPMMLDocument (org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocument)6 LiteralExpressionPMMLDocumentModel (org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocumentModel)6 Context (org.kie.workbench.common.dmn.api.definition.model.Context)3 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)2 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)2 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1 Inject (javax.inject.Inject)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Test (org.junit.Test)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 FunctionDefinition (org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition)1