use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandler method destroy.
@Override
public void destroy(final String oldModelName) {
final List<Decision> decisions = getDecisions();
final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels();
final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels);
final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions);
// The values in the DMN model are stored with quotes
final String quotedOldModelName = StringUtils.createQuotedString(oldModelName);
for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) {
final Context context = entry.getValue();
for (final ContextEntry contextEntry : context.getContextEntry()) {
if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) {
final Expression expression = contextEntry.getExpression();
if (expression instanceof IsLiteralExpression) {
final IsLiteralExpression ile = (IsLiteralExpression) expression;
if (Objects.nonNull(ile.getText())) {
final Text text = ile.getText();
if (Objects.equals(quotedOldModelName, text.getValue())) {
clearContextValues(context);
entry.getKey().getFormalParameter().clear();
}
}
}
}
}
}
// Refresh cached grids from the DMN model
refreshCachedExpressionGrids(decisions, businessKnowledgeModels);
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class RemoveParameterCommandTest method setup.
@Before
public void setup() {
this.function = new FunctionDefinition();
this.parameter = new InformationItem();
this.function.getFormalParameter().add(parameter);
this.command = new RemoveParameterCommand(function, parameter, canvasOperation);
doReturn(ruleManager).when(handler).getRuleManager();
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class SetParametersCommandTest method setup.
@Before
public void setup() {
this.function = new FunctionDefinition();
this.parameter1 = new InformationItem();
this.parameter2 = new InformationItem();
doReturn(ruleManager).when(handler).getRuleManager();
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class SetKindCommandTest method setup.
@Before
public void setup() {
this.function = new FunctionDefinition();
this.function.setKind(originalKind);
this.function.setExpression(originalExpression);
this.uiModel = new BaseGridData();
this.uiModel.appendColumn(mockColumn);
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.setCellValue(0, 0, new ExpressionCellValue(Optional.of(originalEditor)));
doReturn(uiModel).when(gridWidget).getModel();
doReturn(ruleManager).when(handler).getRuleManager();
}
use of org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition in project kie-wb-common by kiegroup.
the class RegisterNodeCommandTest method testExecuteWithBusinessKnowledgeModelNodeWhenNodeIsNotNew.
@Test
public void testExecuteWithBusinessKnowledgeModelNodeWhenNodeIsNotNew() {
final FunctionDefinition functionDefinition = new FunctionDefinition();
final LiteralExpression literalExpression = makeLiteralExpression("123");
when(candidateContent.getDefinition()).thenReturn(businessKnowledgeModel);
doReturn(functionDefinition).when(businessKnowledgeModel).getEncapsulatedLogic();
functionDefinition.setExpression(literalExpression);
literalExpression.setParent(functionDefinition);
assertThat(command.execute(graphCommandExecutionContext).getType()).isEqualTo(CommandResult.Type.INFO);
final FunctionDefinition encapsulatedLogic = businessKnowledgeModel.getEncapsulatedLogic();
final Expression expression = encapsulatedLogic.getExpression();
assertThat(expression).isEqualTo(makeLiteralExpression("123"));
assertThat(expression.getParent()).isEqualTo(encapsulatedLogic);
assertThat(KindUtilities.getKind(encapsulatedLogic)).isEqualTo(FunctionDefinition.Kind.FEEL);
}
Aggregations