use of org.kie.dmn.model.v1_2.TLiteralExpression in project drools by kiegroup.
the class XLS2DMNParser method appendDecisionDT.
private void appendDecisionDT(Definitions definitions, Map<String, DTHeaderInfo> headerInfos) {
for (DTHeaderInfo hi : headerInfos.values()) {
Decision decision = new TDecision();
decision.setName(hi.getSheetName());
decision.setId("d_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
InformationItem variable = new TInformationItem();
variable.setName(hi.getSheetName());
variable.setId("dvar_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
variable.setTypeRef(new QName("Any"));
decision.setVariable(variable);
for (String ri : hi.getRequiredInput()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#id_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredInput(er);
decision.getInformationRequirement().add(ir);
}
for (String ri : hi.getRequiredDecision()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#d_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredDecision(er);
decision.getInformationRequirement().add(ir);
}
DecisionTable dt = new TDecisionTable();
dt.setOutputLabel(hi.getSheetName());
dt.setId("ddt_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
dt.setHitPolicy(HitPolicy.ANY);
for (String ri : hi.getRequiredInput()) {
InputClause ic = new TInputClause();
ic.setLabel(ri);
LiteralExpression le = new TLiteralExpression();
le.setText(ri);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
for (String rd : hi.getRequiredDecision()) {
InputClause ic = new TInputClause();
ic.setLabel(rd);
LiteralExpression le = new TLiteralExpression();
le.setText(rd);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
OutputClause oc = new TOutputClause();
dt.getOutput().add(oc);
decision.setExpression(dt);
definitions.getDrgElement().add(decision);
}
}
use of org.kie.dmn.model.v1_2.TLiteralExpression in project drools by kiegroup.
the class DTSheetListener method newCell.
@Override
public void newCell(int row, int column, String value, int mergedColStart) {
if (row == 0) {
// TODO row 0 being the header.
return;
}
if (curRule == null) {
return;
}
if (value == null || value.isEmpty()) {
LOG.trace("ignoring row {}, col {} having value {}", row, column, value);
return;
}
if (column < headerInfo.gethIndex()) {
valueCheck(row, column, value);
UnaryTests ut = new TUnaryTests();
ut.setText(eValue(value));
curRule.getInputEntry().add(ut);
} else if (column == headerInfo.gethIndex()) {
valueCheck(row, column, value);
LiteralExpression le = new TLiteralExpression();
le.setText(eValue(value));
curRule.getOutputEntry().add(le);
} else {
LOG.trace("ignoring row {}, col {} having value {}", row, column, value);
}
}
use of org.kie.dmn.model.v1_2.TLiteralExpression 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.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.
the class InvocationPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final org.kie.dmn.model.api.Invocation dmn = new TInvocation();
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
literalExpression.setId(EXPRESSION_UUID);
dmn.setId(INVOCATION_UUID);
dmn.setDescription(INVOCATION_DESCRIPTION);
dmn.setTypeRef(new QName(INVOCATION_QNAME_LOCALPART));
dmn.setExpression(literalExpression);
final Invocation wb = InvocationPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(INVOCATION_UUID);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(INVOCATION_DESCRIPTION);
assertThat(wb.getTypeRef()).isNotNull();
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(INVOCATION_QNAME_LOCALPART);
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
use of org.kie.dmn.model.v1_2.TLiteralExpression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverterTest method testWBFromDMN.
@Test
public void testWBFromDMN() {
final org.kie.dmn.model.api.FunctionDefinition dmn = new TFunctionDefinition();
final org.kie.dmn.model.api.LiteralExpression literalExpression = new TLiteralExpression();
literalExpression.setId(EXPRESSION_UUID);
dmn.setId(FUNCTION_DEFINITION_UUID);
dmn.setDescription(FUNCTION_DEFINITION_DESCRIPTION);
dmn.setTypeRef(new QName(FUNCTION_DEFINITION_QNAME_LOCALPART));
dmn.setKind(FunctionKind.JAVA);
dmn.setExpression(literalExpression);
final FunctionDefinition wb = FunctionDefinitionPropertyConverter.wbFromDMN(dmn, hasComponentWidthsConsumer);
assertThat(wb).isNotNull();
assertThat(wb.getId()).isNotNull();
assertThat(wb.getId().getValue()).isEqualTo(FUNCTION_DEFINITION_UUID);
assertThat(wb.getDescription()).isNotNull();
assertThat(wb.getDescription().getValue()).isEqualTo(FUNCTION_DEFINITION_DESCRIPTION);
assertThat(wb.getTypeRef()).isNotNull();
assertThat(wb.getTypeRef().getLocalPart()).isEqualTo(FUNCTION_DEFINITION_QNAME_LOCALPART);
assertThat(wb.getKind()).isNotNull();
assertThat(wb.getKind()).isEqualTo(FunctionDefinition.Kind.JAVA);
assertThat(wb.getExpression()).isNotNull();
assertThat(wb.getExpression().getId().getValue()).isEqualTo(EXPRESSION_UUID);
verify(hasComponentWidthsConsumer).accept(eq(EXPRESSION_UUID), hasComponentWidthsCaptor.capture());
final HasComponentWidths hasComponentWidths = hasComponentWidthsCaptor.getValue();
assertThat(hasComponentWidths).isNotNull();
assertThat(hasComponentWidths).isEqualTo(wb.getExpression());
}
Aggregations