use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause 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.JSITInputClause in project kie-wb-common by kiegroup.
the class InputClausePropertyConverter method dmnFromWB.
public static JSITInputClause dmnFromWB(final InputClause wb) {
final JSITInputClause result = new JSITInputClause();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
final JSITLiteralExpression expression = LiteralExpressionPropertyConverter.dmnFromWB(wb.getInputExpression());
final JSITUnaryTests inputValues = UnaryTestsPropertyConverter.dmnFromWB(wb.getInputValues());
result.setInputExpression(expression);
if (Objects.nonNull(inputValues) && StringUtils.nonEmpty(inputValues.getText())) {
result.setInputValues(inputValues);
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause in project kie-wb-common by kiegroup.
the class InputClausePropertyConverter method wbFromDMN.
public static InputClause wbFromDMN(final JSITInputClause dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final InputClauseLiteralExpression inputExpression = InputClauseLiteralExpressionPropertyConverter.wbFromDMN(dmn.getInputExpression());
final InputClauseUnaryTests inputValues = Optional.ofNullable(InputClauseUnaryTestsPropertyConverter.wbFromDMN(dmn.getInputValues())).orElse(new InputClauseUnaryTests());
final InputClause result = new InputClause(id, description, inputExpression, inputValues);
if (Objects.nonNull(inputExpression)) {
inputExpression.setParent(result);
}
inputValues.setParent(result);
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInputClause 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