use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverterTest method testDMNFromWB_ContextConversion.
@Test
public void testDMNFromWB_ContextConversion() {
final Context wb = new Context();
final List<Double> wbComponentWidths = wb.getComponentWidths();
wbComponentWidths.set(0, 100.0);
wbComponentWidths.set(1, 200.0);
wbComponentWidths.set(2, 300.0);
wb.getId().setValue(EXPRESSION_UUID);
assertDMNFromWBConversion(wb, TContext.class, 100.0, 200.0, 300.0);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context 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.Context in project kie-wb-common by kiegroup.
the class DMNDeepCloneProcessTest method buildFunctionDefinition.
private FunctionDefinition buildFunctionDefinition() {
final FunctionDefinition encapsulatedLogic = new FunctionDefinition(new Id(FUNCTION_ID), new Description(), new QName(BuiltInType.BOOLEAN), new Context(new Id(CONTEXT_ID), new Description(), new QName(BuiltInType.NUMBER)));
encapsulatedLogic.setKind(JAVA);
return encapsulatedLogic;
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class AddContextEntryCommandTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.context = new Context();
this.contextEntry = new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("variable"));
}
});
}
};
this.defaultResultContextEntry = new ContextEntry();
this.context.getContextEntry().add(defaultResultContextEntry);
this.uiModel = new BaseGridData();
this.uiModelRow = new BaseGridRow();
this.uiDefaultResultModelRow = new BaseGridRow();
this.uiModel.appendRow(uiDefaultResultModelRow);
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(uiModel).when(gridWidget).getModel();
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
this.uiModel.setCellValue(0, 2, new ExpressionCellValue(Optional.of(undefinedExpressionEditor)));
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(parent).when(undefinedExpressionEditor).getParentInformation();
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
this.uiModelMapper = new ContextUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(context), () -> false, () -> expressionEditorDefinitions, listSelector, 0);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class DeleteContextEntryCommandTest method setup.
@Before
public void setup() {
this.context = new Context();
this.context.getContextEntry().add(new ContextEntry());
this.uiModel = new BaseGridData(false);
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiModelColumn).getIndex();
}
Aggregations