Search in sources :

Example 6 with LiteralExpressionPMMLDocument

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

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

the class UndefinedExpressionSelectorPopoverImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionPMMLEditorDefinition);
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(literalExpressionEditorDefinition.isUserSelectable()).thenReturn(true);
    when(literalExpressionEditorDefinition.getType()).thenReturn(ExpressionType.LITERAL_EXPRESSION);
    when(literalExpressionEditorDefinition.getName()).thenReturn(LiteralExpression.class.getSimpleName());
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionPMMLEditorDefinition.isUserSelectable()).thenReturn(false);
    when(literalExpressionPMMLEditorDefinition.getType()).thenReturn(ExpressionType.LITERAL_EXPRESSION);
    when(literalExpressionPMMLEditorDefinition.getName()).thenReturn(LiteralExpressionPMMLDocument.class.getSimpleName());
    when(literalExpressionPMMLEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpressionPMMLDocument));
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(translationService.getTranslation(Mockito.<String>any())).thenAnswer(i -> i.getArguments()[0]);
    this.popover = new UndefinedExpressionSelectorPopoverImpl(view, translationService, expressionEditorDefinitionsSupplier);
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) LiteralExpressionPMMLDocument(org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocument) Before(org.junit.Before)

Aggregations

LiteralExpressionPMMLDocument (org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocument)7 LiteralExpressionPMMLDocumentModel (org.kie.workbench.common.dmn.api.definition.model.LiteralExpressionPMMLDocumentModel)5 Context (org.kie.workbench.common.dmn.api.definition.model.Context)3 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 List (java.util.List)1 Function (java.util.function.Function)1 Before (org.junit.Before)1 Test (org.junit.Test)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 SetCellValueCommand (org.kie.workbench.common.dmn.client.commands.general.SetCellValueCommand)1 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)1 LiteralExpressionPMMLGrid (org.kie.workbench.common.dmn.client.editors.expressions.types.function.supplementary.pmml.LiteralExpressionPMMLGrid)1 GridCellValueTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)1 JSITExpression (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)1 CompositeCommand (org.kie.workbench.common.stunner.core.command.impl.CompositeCommand)1