use of org.kie.dmn.model.v1_1.InputData in project drools by kiegroup.
the class InputDataConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
InputData id = (InputData) parent;
if (id.getVariable() != null) {
writeChildrenNode(writer, context, id.getVariable(), VARIABLE);
}
}
use of org.kie.dmn.model.v1_1.InputData in project drools by kiegroup.
the class InputDataCompiler method compileNode.
@Override
public void compileNode(DRGElement de, DMNCompilerImpl compiler, DMNModelImpl model) {
InputData input = (InputData) de;
InputDataNodeImpl idn = new InputDataNodeImpl(input);
if (input.getVariable() != null) {
DMNCompilerHelper.checkVariableName(model, input, input.getName());
DMNType type = compiler.resolveTypeRef(model, idn, de, input.getVariable(), input.getVariable().getTypeRef());
idn.setType(type);
} else {
idn.setType(DMNTypeRegistry.UNKNOWN);
DMNCompilerHelper.reportMissingVariable(model, de, input, Msg.MISSING_VARIABLE_FOR_INPUT);
}
model.addInput(idn);
}
use of org.kie.dmn.model.v1_1.InputData in project drools by kiegroup.
the class DecisionServiceConverter method parseElements.
@Override
protected void parseElements(HierarchicalStreamReader reader, UnmarshallingContext context, Object parent) {
while (reader.hasMoreChildren()) {
reader.moveDown();
Object object = null;
String nodeName = reader.getNodeName();
if (nodeName.equals(INPUT_DATA)) {
// Patch because the tag name inputData is used in both decision services and as a DRG Element
DMNElementReference ref = new DMNElementReference();
ref.setHref(reader.getAttribute("href"));
object = ref;
} else {
// Default behaviour
object = readItem(reader, context, null);
}
if (object instanceof DMNModelInstrumentedBase) {
((DMNModelInstrumentedBase) object).setParent((DMNModelInstrumentedBase) parent);
((DMNModelInstrumentedBase) parent).addChildren((DMNModelInstrumentedBase) object);
}
reader.moveUp();
assignChildElement(parent, nodeName, object);
}
}
use of org.kie.dmn.model.v1_1.InputData in project drools by kiegroup.
the class DMNExtensionRegisterTest method testUsingSystemProperty.
@Test
public void testUsingSystemProperty() {
try {
System.setProperty("org.kie.dmn.profiles.FirstNameLastNameProfile", FirstNameLastNameProfile.class.getCanonicalName());
assertEquals(FirstNameLastNameProfile.class.getCanonicalName(), System.getProperty("org.kie.dmn.profiles.FirstNameLastNameProfile"));
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("0001-input-data-string-with-extensions.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("https://github.com/kiegroup/kie-dmn", "0001-input-data-string");
assertThat(dmnModel, notNullValue());
assertThat(formatMessages(dmnModel.getMessages()), dmnModel.hasErrors(), is(false));
assertEquals(3, dmnModel.getDefinitions().getDrgElement().size());
InputData inputData1 = (InputData) dmnModel.getDefinitions().getDrgElement().get(1);
assertEquals("First Name", inputData1.getName());
DMNElement.ExtensionElements id1elements = inputData1.getExtensionElements();
assertTrue(id1elements != null);
assertEquals(1, id1elements.getAny().size());
FirstNameDescription firstNameDescription = (FirstNameDescription) id1elements.getAny().get(0);
assertTrue(firstNameDescription.getContent().equals("First name in latin characters"));
InputData inputData2 = (InputData) dmnModel.getDefinitions().getDrgElement().get(2);
assertEquals("Last Name", inputData2.getName());
DMNElement.ExtensionElements id2elements = inputData2.getExtensionElements();
assertTrue(id2elements != null);
assertEquals(1, id2elements.getAny().size());
LastNameDescription lastNameDescription = (LastNameDescription) id2elements.getAny().get(0);
assertTrue(lastNameDescription.getContent().equals("Last name in latin characters"));
} catch (Exception e) {
LOG.error("{}", e.getLocalizedMessage(), e);
throw e;
} finally {
System.clearProperty("org.kie.dmn.profiles.FirstNameLastNameProfile");
assertNull(System.getProperty("org.kie.dmn.profiles.FirstNameLastNameProfile"));
}
}
Aggregations