use of org.kie.workbench.common.dmn.api.definition.v1_1.InputData in project kie-wb-common by kiegroup.
the class InputDataConverter method dmnFromNode.
@Override
public org.kie.dmn.model.v1_1.InputData dmnFromNode(final Node<View<InputData>, ?> node) {
InputData source = node.getContent().getDefinition();
org.kie.dmn.model.v1_1.InputData result = new org.kie.dmn.model.v1_1.InputData();
result.setId(source.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(source.getDescription()));
result.setName(source.getName().getValue());
result.setVariable(InformationItemPropertyConverter.dmnFromWB(source.getVariable()));
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InputData in project drools by kiegroup.
the class InputDataConverter method assignChildElement.
@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
super.assignChildElement(parent, nodeName, child);
InputData id = (InputData) parent;
if (VARIABLE.equals(nodeName)) {
id.setVariable((InformationItem) child);
} else {
super.assignChildElement(parent, nodeName, child);
}
}
use of org.kie.workbench.common.dmn.api.definition.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.workbench.common.dmn.api.definition.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.workbench.common.dmn.api.definition.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