use of org.kie.dmn.model.api.LiteralExpression in project kie-wb-common by kiegroup.
the class BaseLiteralExpressionPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final org.kie.workbench.common.dmn.api.definition.model.ImportedValues importedValues = new org.kie.workbench.common.dmn.api.definition.model.ImportedValues();
importedValues.setImportedElement(IMPORTED_ELEMENT);
final org.kie.workbench.common.dmn.api.definition.model.LiteralExpression wb = new org.kie.workbench.common.dmn.api.definition.model.LiteralExpression(new Id(UUID), new Description(DESCRIPTION), BuiltInType.BOOLEAN.asQName(), new Text(TEXT), importedValues, new ExpressionLanguage(EXPRESSION_LANGUAGE));
final LiteralExpression dmn = LiteralExpressionPropertyConverter.dmnFromWB(wb);
assertThat(dmn.getId()).isEqualTo(UUID);
assertThat(dmn.getDescription()).isEqualTo(DESCRIPTION);
assertThat(dmn.getTypeRef().getNamespaceURI()).isEmpty();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(BuiltInType.BOOLEAN.getName());
assertThat(dmn.getText()).isEqualTo(TEXT);
assertThat(dmn.getImportedValues()).isNotNull();
assertThat(dmn.getImportedValues().getImportedElement()).isEqualTo(IMPORTED_ELEMENT);
assertThat(dmn.getExpressionLanguage()).isEqualTo(EXPRESSION_LANGUAGE);
}
use of org.kie.dmn.model.api.LiteralExpression in project kie-wb-common by kiegroup.
the class BaseLiteralExpressionPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final LiteralExpression dmn = new TLiteralExpression();
final QName typeRef = new QName(KIE.getUri(), LOCAL, KIE.getPrefix());
final ImportedValues importedValues = new TImportedValues();
importedValues.setImportedElement(IMPORTED_ELEMENT);
dmn.setId(UUID);
dmn.setDescription(DESCRIPTION);
dmn.setTypeRef(typeRef);
dmn.setText(TEXT);
dmn.setImportedValues(importedValues);
final T wb = convertWBFromDMN(dmn);
assertThat(wb.getId().getValue()).isEqualTo(UUID);
assertThat(wb.getDescription().getValue()).isEqualTo(DESCRIPTION);
assertThat(wb.getTypeRef().getNamespaceURI()).isEqualTo(KIE.getUri());
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(LOCAL);
assertThat(wb.getTypeRef().getPrefix()).isEqualTo(KIE.getPrefix());
assertThat(wb.getText().getValue()).isEqualTo(TEXT);
assertThat(wb.getImportedValues().getImportedElement()).isEqualTo(IMPORTED_ELEMENT);
assertThat(wb.getImportedValues().getParent()).isEqualTo(wb);
}
use of org.kie.dmn.model.api.LiteralExpression in project drools by kiegroup.
the class LiteralExpressionConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
LiteralExpression le = (LiteralExpression) parent;
if (le.getText() != null)
writeChildrenNodeAsValue(writer, context, le.getText(), TEXT);
if (le.getImportedValues() != null)
writeChildrenNode(writer, context, le.getImportedValues(), IMPORTED_VALUES);
}
use of org.kie.dmn.model.api.LiteralExpression in project drools by kiegroup.
the class LiteralExpressionConverter method assignAttributes.
@Override
protected void assignAttributes(HierarchicalStreamReader reader, Object parent) {
super.assignAttributes(reader, parent);
LiteralExpression le = (LiteralExpression) parent;
String exprLanguage = reader.getAttribute(EXPR_LANGUAGE);
le.setExpressionLanguage(exprLanguage);
}
use of org.kie.dmn.model.api.LiteralExpression in project drools by kiegroup.
the class DMNEvaluatorCompiler method compileRelation.
private DMNExpressionEvaluator compileRelation(DMNCompilerContext ctx, DMNModelImpl model, DMNBaseNode node, String relationName, Relation expression) {
Relation relationDef = expression;
DMNRelationEvaluator relationEval = new DMNRelationEvaluator(node.getName(), node.getSource(), relationDef);
for (InformationItem col : relationDef.getColumn()) {
DMNCompilerHelper.checkVariableName(model, col, col.getName());
relationEval.addColumn(col.getName());
}
for (org.kie.dmn.model.api.List row : relationDef.getRow()) {
java.util.List<DMNExpressionEvaluator> values = new ArrayList<>();
for (Expression expr : row.getExpression()) {
if (expr instanceof LiteralExpression) {
// DROOLS-2439
LiteralExpression literalExpression = (LiteralExpression) expr;
if (literalExpression.getText() == null || literalExpression.getText().isEmpty()) {
LiteralExpression nullProxy = (literalExpression instanceof org.kie.dmn.model.v1_1.TLiteralExpression) ? new org.kie.dmn.model.v1_1.TLiteralExpression() : new org.kie.dmn.model.v1_2.TLiteralExpression();
nullProxy.setText("null");
nullProxy.setImportedValues(literalExpression.getImportedValues());
nullProxy.setExpressionLanguage(literalExpression.getExpressionLanguage());
nullProxy.setTypeRef(literalExpression.getTypeRef());
nullProxy.setId(literalExpression.getId());
nullProxy.setLabel(literalExpression.getLabel());
nullProxy.setDescription(literalExpression.getDescription());
nullProxy.setExtensionElements(literalExpression.getExtensionElements());
nullProxy.setParent(literalExpression.getParent());
nullProxy.getNsContext().putAll(literalExpression.getNsContext());
nullProxy.setAdditionalAttributes(literalExpression.getAdditionalAttributes());
nullProxy.setLocation(literalExpression.getLocation());
// do not add `temp` as child of parent.
expr = nullProxy;
}
}
values.add(compileExpression(ctx, model, node, relationName, expr));
}
relationEval.addRow(values);
}
return relationEval;
}
Aggregations