use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DecisionComponentFilterTest method testQueryFilteredByTerm.
@Test
public void testQueryFilteredByTerm() {
final DecisionComponentsItem item1 = item("Can Drive?", new Decision());
final DecisionComponentsItem item2 = item("Is Allowed?", new Decision());
final DecisionComponentsItem item3 = item("Age", new InputData());
final DecisionComponentsItem item4 = item("Name", new InputData());
final Stream<DecisionComponentsItem> stream = Stream.of(item1, item2, item3, item4);
filter.setTerm("name");
final Stream<DecisionComponentsItem> query = filter.query(stream);
final List<DecisionComponentsItem> actualResult = query.collect(Collectors.toList());
final List<DecisionComponentsItem> expectedResult = singletonList(item4);
assertEquals(expectedResult, actualResult);
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision 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.Decision in project kie-wb-common by kiegroup.
the class DMNCommonActionsToolboxFactoryTest method testAddEditDecisionAction.
@Test
public void testAddEditDecisionAction() {
final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>();
final Element element = mock(Element.class);
final Node node = mock(Node.class);
final Definition definition = mock(Definition.class);
final Decision decision = mock(Decision.class);
when(element.asNode()).thenReturn(node);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(decision);
tested.addEditAction(element, actions);
assertEquals(1, actions.size());
assertTrue(DMNEditDecisionToolboxAction.class.isInstance(actions.get(0)));
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DMNDeepCloneProcess method clone.
/**
* <p>It defines additive fields, specific to DMN domain, to be included in the target</p>
* <p>Then, the "classic" clone operation, defined in {@link DeepCloneProcess} will be executed</p>
* <p>Note that {@link DeepCloneProcess} is already taking care of aspects related to look&feel, such as background color, font, etc.</p>
* <p>Every time we copy a node, in order to respect the name uniqueness logic, a new node will be created with a suffix {@code -X},
* where {@code X} it is an incremental numeric value</p>
*
* @param source node to be cloned
* @param target destination of the cloning operation
* @return cloned instance, i.e. target element
*/
@Override
public <S, T> T clone(final S source, final T target) {
super.clone(source, target);
if (source instanceof DRGElement) {
cloneDRGElementBasicInfo((DRGElement) source, (DRGElement) target);
}
if (source instanceof HasText) {
cloneTextElementBasicInfo((HasText) source, (HasText) target);
}
if (source instanceof HasVariable) {
final IsInformationItem sourceVariable = ((HasVariable) source).getVariable();
final IsInformationItem targetVariable = ((HasVariable) target).getVariable();
cloneTypeRefInfo(sourceVariable, targetVariable);
}
if (source instanceof Decision) {
cloneDecision((Decision) source, (Decision) target);
}
if (source instanceof BusinessKnowledgeModel) {
cloneBusinessKnowledgeModel((BusinessKnowledgeModel) source, (BusinessKnowledgeModel) target);
}
return target;
}
use of org.kie.workbench.common.dmn.api.definition.model.Decision in project kie-wb-common by kiegroup.
the class DMNEditDecisionToolboxAction method onMouseClick.
@Override
@SuppressWarnings("unchecked")
public ToolboxAction<AbstractCanvasHandler> onMouseClick(final AbstractCanvasHandler canvasHandler, final String uuid, final MouseClickEvent event) {
// Notice the toolbox factory ensure this action is only being included
// for Decision definitions, next cast is safe.
final Node<View<? extends Decision>, Edge> decisionNode = (Node<View<? extends Decision>, Edge>) CanvasLayoutUtils.getElement(canvasHandler, uuid).asNode();
final Decision decision = (Decision) DefinitionUtils.getElementDefinition(decisionNode);
final boolean isReadOnly = decision.isAllowOnlyVisualChange() || readOnlyProvider.isReadOnlyDiagram();
editExpressionEvent.fire(new EditExpressionEvent(sessionManager.getCurrentSession(), uuid, decision, Optional.of(decision), isReadOnly));
return this;
}
Aggregations