use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause in project kie-wb-common by kiegroup.
the class OutputClausePropertyConverter method wbFromDMN.
public static OutputClause wbFromDMN(final JSITOutputClause dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final OutputClauseUnaryTests outputValues = OutputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getOutputValues());
final OutputClauseLiteralExpression defaultOutputEntry = OutputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getDefaultOutputEntry());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final OutputClause result = new OutputClause();
result.setId(id);
result.setName(dmn.getName());
result.setDescription(description);
result.setOutputValues(outputValues);
result.setDefaultOutputEntry(defaultOutputEntry);
result.setTypeRef(typeRef);
if (Objects.nonNull(outputValues)) {
outputValues.setParent(result);
}
if (Objects.nonNull(defaultOutputEntry)) {
defaultOutputEntry.setParent(result);
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause in project kie-wb-common by kiegroup.
the class OutputClausePropertyConverter method dmnFromWB.
public static JSITOutputClause dmnFromWB(final OutputClause wb) {
final JSITOutputClause result = new JSITOutputClause();
result.setId(wb.getId().getValue());
result.setName(wb.getName());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
final JSITUnaryTests outputValues = OutputClauseUnaryTestsPropertyConverter.dmnFromWB(wb.getOutputValues());
if (Objects.nonNull(outputValues) && StringUtils.nonEmpty(outputValues.getText())) {
result.setOutputValues(outputValues);
}
final JSITLiteralExpression defaultOutputEntry = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb.getDefaultOutputEntry());
if (Objects.nonNull(defaultOutputEntry) && StringUtils.nonEmpty(defaultOutputEntry.getText())) {
result.setDefaultOutputEntry(defaultOutputEntry);
}
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverter method wbFromDMN.
public static DecisionTable wbFromDMN(final JSITDecisionTable dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final DecisionTable result = new DecisionTable();
result.setId(id);
result.setDescription(description);
result.setTypeRef(typeRef);
final List<JSITRuleAnnotationClause> jsiRuleAnnotationClauses = dmn.getAnnotation();
if (jsiRuleAnnotationClauses.isEmpty()) {
final RuleAnnotationClause ruleAnnotationClause = new RuleAnnotationClause();
ruleAnnotationClause.setParent(result);
result.getAnnotations().add(ruleAnnotationClause);
} else {
for (int i = 0; i < jsiRuleAnnotationClauses.size(); i++) {
final JSITRuleAnnotationClause ruleAnnotationClause = Js.uncheckedCast(jsiRuleAnnotationClauses.get(i));
final RuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.wbFromDMN(ruleAnnotationClause);
if (Objects.nonNull(converted)) {
converted.setParent(result);
result.getAnnotations().add(converted);
}
}
}
final List<JSITInputClause> jsiInputClauses = dmn.getInput();
for (int i = 0; i < jsiInputClauses.size(); i++) {
final JSITInputClause input = Js.uncheckedCast(jsiInputClauses.get(i));
final InputClause inputClauseConverted = InputClausePropertyConverter.wbFromDMN(input);
if (Objects.nonNull(inputClauseConverted)) {
inputClauseConverted.setParent(result);
result.getInput().add(inputClauseConverted);
}
}
final List<JSITOutputClause> jsiOutputClauses = dmn.getOutput();
for (int i = 0; i < jsiOutputClauses.size(); i++) {
final JSITOutputClause output = Js.uncheckedCast(jsiOutputClauses.get(i));
final OutputClause outputClauseConverted = OutputClausePropertyConverter.wbFromDMN(output);
if (Objects.nonNull(outputClauseConverted)) {
outputClauseConverted.setParent(result);
result.getOutput().add(outputClauseConverted);
}
}
if (result.getOutput().size() == 1) {
final OutputClause outputClause = result.getOutput().get(0);
// DROOLS-3281
outputClause.setName(null);
// DROOLS-5178
outputClause.setTypeRef(BuiltInType.UNDEFINED.asQName());
}
final List<JSITDecisionRule> jsiDecisionRules = dmn.getRule();
for (int i = 0; i < jsiDecisionRules.size(); i++) {
final JSITDecisionRule dr = Js.uncheckedCast(jsiDecisionRules.get(i));
final DecisionRule decisionRuleConverted = DecisionRulePropertyConverter.wbFromDMN(dr);
if (Objects.nonNull(decisionRuleConverted)) {
decisionRuleConverted.setParent(result);
}
result.getRule().add(decisionRuleConverted);
}
// JSITHitPolicy is a String JSO so convert into the real type
final String hitPolicy = Js.uncheckedCast(dmn.getHitPolicy());
if (Objects.nonNull(hitPolicy)) {
result.setHitPolicy(HitPolicy.fromValue(hitPolicy));
}
// JSITBuiltinAggregator is a String JSO so convert into the real type
final String aggregation = Js.uncheckedCast(dmn.getAggregation());
if (Objects.nonNull(aggregation)) {
result.setAggregation(BuiltinAggregator.fromValue(aggregation));
}
// JSITDecisionTableOrientation is a String JSO so convert into the real type
final String orientation = Js.uncheckedCast(dmn.getPreferredOrientation());
if (Objects.nonNull(orientation)) {
result.setPreferredOrientation(DecisionTableOrientation.fromValue(orientation));
}
result.setOutputLabel(dmn.getOutputLabel());
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITOutputClause in project kie-wb-common by kiegroup.
the class DecisionTablePropertyConverter method dmnFromWB.
public static JSITDecisionTable dmnFromWB(final DecisionTable wb) {
final JSITDecisionTable result = new JSITDecisionTable();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (final RuleAnnotationClause annotation : wb.getAnnotations()) {
final JSITRuleAnnotationClause converted = RuleAnnotationClausePropertyConverter.dmnFromWB(annotation);
result.addAnnotation(converted);
}
for (InputClause input : wb.getInput()) {
final JSITInputClause c = InputClausePropertyConverter.dmnFromWB(input);
result.addInput(c);
}
for (OutputClause input : wb.getOutput()) {
final JSITOutputClause c = OutputClausePropertyConverter.dmnFromWB(input);
result.addOutput(c);
}
if (result.getOutput().size() == 1) {
final JSITOutputClause at = Js.uncheckedCast(result.getOutput().get(0));
// DROOLS-3281
at.setName(null);
// DROOLS-5178
at.setTypeRef(null);
}
for (DecisionRule dr : wb.getRule()) {
final JSITDecisionRule c = DecisionRulePropertyConverter.dmnFromWB(dr);
result.addRule(c);
}
if (Objects.nonNull(wb.getHitPolicy())) {
switch(wb.getHitPolicy()) {
case ANY:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.ANY.value()));
break;
case COLLECT:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.COLLECT.value()));
break;
case FIRST:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.FIRST.value()));
break;
case UNIQUE:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.UNIQUE.value()));
break;
case PRIORITY:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.PRIORITY.value()));
break;
case RULE_ORDER:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.RULE_ORDER.value()));
break;
case OUTPUT_ORDER:
result.setHitPolicy(Js.uncheckedCast(JSITHitPolicy.OUTPUT_ORDER.value()));
break;
}
}
if (Objects.nonNull(wb.getAggregation())) {
final String wbBuiltinAggregator = wb.getAggregation().value();
result.setAggregation(Js.uncheckedCast(wbBuiltinAggregator));
}
if (Objects.nonNull(wb.getPreferredOrientation())) {
final String wbPreferredOrientation = wb.getPreferredOrientation().value();
result.setPreferredOrientation(Js.uncheckedCast(wbPreferredOrientation));
}
result.setOutputLabel(wb.getOutputLabel());
return result;
}
Aggregations