use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests 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.JSITUnaryTests in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method dmnFromWB.
public static JSITUnaryTests dmnFromWB(final IsUnaryTests wb) {
if (Objects.isNull(wb)) {
return null;
}
final JSITUnaryTests result = UNARY_TESTS_FACTORY.make();
final Map<QName, String> otherAttributes = new HashMap<>();
result.setId(wb.getId().getValue());
result.setText(wb.getText().getValue());
result.setOtherAttributes(ATTRIBUTES_UTILS.cast(otherAttributes));
final ConstraintType constraint = wb.getConstraintType();
if (isNotNone(constraint)) {
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
otherAttributes.put(key, constraint.value());
result.setOtherAttributes(ATTRIBUTES_UTILS.cast(otherAttributes));
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests in project kie-wb-common by kiegroup.
the class UnaryTestsPropertyConverter method wbFromDMN.
public static UnaryTests wbFromDMN(final JSITUnaryTests dmn) {
if (Objects.isNull(dmn)) {
return null;
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
final ConstraintType constraintTypeField;
final QName key = new QName(DMNModelInstrumentedBase.Namespace.KIE.getUri(), ConstraintType.CONSTRAINT_KEY, DMNModelInstrumentedBase.Namespace.KIE.getPrefix());
final Map<QName, String> otherAttributes = JSITUnaryTests.getOtherAttributesMap(dmn);
if (otherAttributes.containsKey(key)) {
constraintTypeField = ConstraintTypeFieldPropertyConverter.wbFromDMN(otherAttributes.get(key));
} else {
constraintTypeField = NONE;
}
final UnaryTests result = new UnaryTests(id, description, new Text(dmn.getText()), expressionLanguage, constraintTypeField);
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method dmnFromWB.
public static JSITDecisionRule dmnFromWB(final DecisionRule wb) {
final JSITDecisionRule result = new JSITDecisionRule();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
for (final RuleAnnotationClauseText ruleAnnotationClauseText : wb.getAnnotationEntry()) {
final JSITRuleAnnotation ruleAnnotation = RuleAnnotationClauseTextPropertyConverter.dmnFromWB(ruleAnnotationClauseText);
result.addAnnotationEntry(ruleAnnotation);
}
for (UnaryTests ie : wb.getInputEntry()) {
final JSITUnaryTests inputEntryConverted = UnaryTestsPropertyConverter.dmnFromWB(ie);
result.addInputEntry(inputEntryConverted);
}
for (LiteralExpression oe : wb.getOutputEntry()) {
final JSITLiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.dmnFromWB(oe);
result.addOutputEntry(outputEntryConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITUnaryTests in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method wbFromDMN.
public static DecisionRule wbFromDMN(final JSITDecisionRule dmn) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final DecisionRule result = new DecisionRule();
result.setId(id);
result.setDescription(description);
final List<JSITRuleAnnotation> jsiAnnotationEntries = dmn.getAnnotationEntry();
for (int i = 0; i < jsiAnnotationEntries.size(); i++) {
final JSITRuleAnnotation jsiRuleAnnotation = Js.uncheckedCast(jsiAnnotationEntries.get(i));
final RuleAnnotationClauseText ruleAnnotationClauseText = RuleAnnotationClauseTextPropertyConverter.wbFromDMN(jsiRuleAnnotation);
if (Objects.nonNull(ruleAnnotationClauseText)) {
ruleAnnotationClauseText.setParent(result);
result.getAnnotationEntry().add(ruleAnnotationClauseText);
}
}
if (result.getAnnotationEntry().isEmpty()) {
final RuleAnnotationClauseText annotationEntryText = new RuleAnnotationClauseText();
annotationEntryText.getText().setValue(description.getValue());
annotationEntryText.setParent(result);
result.getAnnotationEntry().add(annotationEntryText);
}
final List<JSITUnaryTests> jsiInputEntries = dmn.getInputEntry();
for (int i = 0; i < jsiInputEntries.size(); i++) {
final JSITUnaryTests jsiInputEntry = Js.uncheckedCast(jsiInputEntries.get(i));
final UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.wbFromDMN(jsiInputEntry);
if (Objects.nonNull(inputEntryConverted)) {
inputEntryConverted.setParent(result);
result.getInputEntry().add(inputEntryConverted);
}
}
final List<JSITLiteralExpression> jsiOutputEntries = dmn.getOutputEntry();
for (int i = 0; i < jsiOutputEntries.size(); i++) {
final JSITLiteralExpression jsiOutputEntry = Js.uncheckedCast(jsiOutputEntries.get(i));
final LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.wbFromDMN(jsiOutputEntry);
if (Objects.nonNull(outputEntryConverted)) {
outputEntryConverted.setParent(result);
result.getOutputEntry().add(outputEntryConverted);
}
}
return result;
}
Aggregations