use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
when(wb.getId()).thenReturn(new Id(UUID));
when(wb.getDescription()).thenReturn(new Description(DESCRIPTION));
when(wb.getTypeRef()).thenReturn(new QName(KIE.getUri(), TYPE_REF, KIE.getPrefix()));
when(wb.getText()).thenReturn(new Text(TEXT));
when(wb.getExpressionLanguage()).thenReturn(new ExpressionLanguage(EXPRESSION_LANGUAGE));
final JSITLiteralExpression result = LiteralExpressionPropertyConverter.dmnFromWB(wb);
verify(result).setId(UUID);
verify(result).setDescription(DESCRIPTION);
verify(result).setTypeRef("{" + KIE.getUri() + "}" + TYPE_REF);
verify(result).setText(TEXT);
verify(result).setExpressionLanguage(EXPRESSION_LANGUAGE);
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression in project kie-wb-common by kiegroup.
the class WrapperUtils method getWrappedJSITLiteralExpression.
public static JSITLiteralExpression getWrappedJSITLiteralExpression(final JSITLiteralExpression toWrap, final String prefix, final String localPart) {
final JSITLiteralExpression toReturn = Js.uncheckedCast(JsUtils.getWrappedElement(toWrap));
final JSIName jsiName = JSITLiteralExpression.getJSIName();
updateJSIName(jsiName, prefix, localPart);
JsUtils.setNameOnWrapped(toReturn, jsiName);
return toReturn;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression 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.JSITLiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverter method dmnFromWB.
public static JSITLiteralExpression dmnFromWB(final IsLiteralExpression wb) {
if (Objects.isNull(wb)) {
return null;
}
final JSITLiteralExpression result = LITERAL_EXPRESSION_PROVIDER.make();
result.setId(wb.getId().getValue());
final String description = wb.getDescription().getValue();
if (StringUtils.nonEmpty(description)) {
result.setDescription(description);
}
if (wb instanceof LiteralExpression) {
final String expressionLanguage = ((LiteralExpression) wb).getExpressionLanguage().getValue();
if (StringUtils.nonEmpty(expressionLanguage)) {
result.setExpressionLanguage(expressionLanguage);
}
}
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
result.setText(wb.getText().getValue());
final JSITImportedValues importedValues = ImportedValuesConverter.dmnFromWB(wb.getImportedValues());
if (Objects.nonNull(importedValues)) {
result.setImportedValues(importedValues);
}
return result;
}
use of org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverter method wbFromDMN.
public static LiteralExpression wbFromDMN(final JSITLiteralExpression dmn) {
if (Objects.isNull(dmn)) {
return null;
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final Text text = new Text(Objects.nonNull(dmn.getText()) ? dmn.getText() : "");
final ExpressionLanguage expressionLanguage = ExpressionLanguagePropertyConverter.wbFromDMN(dmn.getExpressionLanguage());
final ImportedValues importedValues = ImportedValuesConverter.wbFromDMN(dmn.getImportedValues());
final LiteralExpression result = new LiteralExpression(id, description, typeRef, text, importedValues, expressionLanguage);
if (Objects.nonNull(importedValues)) {
importedValues.setParent(result);
}
return result;
}
Aggregations