use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method enrichOutputClauses.
void enrichOutputClauses(final DecisionTable dtable) {
if (dtable.getParent() instanceof ContextEntry && dtable.getOutput().isEmpty()) {
final ContextEntry contextEntry = (ContextEntry) dtable.getParent();
final OutputClause outputClause = new OutputClause();
outputClause.setName(getOutputClauseName(contextEntry).orElse(DecisionTableDefaultValueUtilities.getNewOutputClauseName(dtable)));
outputClause.setTypeRef(getOutputClauseTypeRef(contextEntry).orElse(BuiltInType.UNDEFINED.asQName()));
dtable.getOutput().add(outputClause);
dtable.getRule().stream().forEach(decisionRule -> {
final LiteralExpression decisionRuleLiteralExpression = new LiteralExpression();
decisionRuleLiteralExpression.getText().setValue(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT);
decisionRule.getOutputEntry().add(decisionRuleLiteralExpression);
decisionRuleLiteralExpression.setParent(decisionRule);
});
outputClause.setParent(dtable);
}
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionTableEditorDefinitionEnricher method populateOutputEntries.
private void populateOutputEntries(final DecisionRule decisionRule) {
final LiteralExpression decisionRuleLiteralExpression = new LiteralExpression();
decisionRuleLiteralExpression.getText().setValue(DecisionTableDefaultValueUtilities.OUTPUT_CLAUSE_EXPRESSION_TEXT);
decisionRuleLiteralExpression.setParent(decisionRule);
decisionRule.getOutputEntry().add(decisionRuleLiteralExpression);
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionRuleFactory method duplicateDecisionRule.
public static DecisionRule duplicateDecisionRule(final int index, final DecisionTable dtable) {
final DecisionRule rule = new DecisionRule();
final DecisionRule source = dtable.getRule().get(index);
for (UnaryTests ie : source.getInputEntry()) {
final UnaryTests ut = new UnaryTests();
ut.getText().setValue(ie.getText().getValue());
ut.setConstraintType(ie.getConstraintType());
rule.getInputEntry().add(ut);
ut.setParent(rule);
}
for (LiteralExpression oe : source.getOutputEntry()) {
final LiteralExpression le = new LiteralExpression();
le.getText().setValue(oe.getText().getValue());
rule.getOutputEntry().add(le);
le.setParent(rule);
}
for (final RuleAnnotationClauseText text : source.getAnnotationEntry()) {
final RuleAnnotationClauseText copy = new RuleAnnotationClauseText();
copy.getText().setValue(text.getText().getValue());
copy.setParent(rule);
rule.getAnnotationEntry().add(copy);
}
rule.setParent(dtable);
return rule;
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class InvocationEditorDefinition method enrich.
@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Invocation> expression) {
expression.ifPresent(invocation -> {
final LiteralExpression literalExpression = new LiteralExpression();
invocation.setExpression(literalExpression);
final InformationItem parameter = new InformationItem();
parameter.getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
final Binding binding = new Binding();
binding.setParameter(parameter);
invocation.getBinding().add(binding);
// Setup parent relationships
literalExpression.setParent(invocation);
binding.setParent(invocation);
parameter.setParent(binding);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionTableGrid method doAfterSelectionChange.
@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
return;
}
if (getExpression().get().isPresent()) {
final DecisionTable dtable = getExpression().get().get();
final DecisionTableUIModelMapperHelper.DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, uiColumnIndex);
switch(section) {
case INPUT_CLAUSES:
final int icIndex = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, uiColumnIndex);
final UnaryTests unaryTests = dtable.getRule().get(uiRowIndex).getInputEntry().get(icIndex);
fireDomainObjectSelectionEvent(unaryTests);
return;
case OUTPUT_CLAUSES:
final int ocIndex = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, uiColumnIndex);
final LiteralExpression literalExpression = dtable.getRule().get(uiRowIndex).getOutputEntry().get(ocIndex);
fireDomainObjectSelectionEvent(literalExpression);
return;
}
}
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Aggregations