Search in sources :

Example 1 with InputData

use of org.kie.dmn.model.api.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);
    }
}
Also used : InputData(org.kie.dmn.model.api.InputData) TInputData(org.kie.dmn.model.v1_2.TInputData)

Example 2 with InputData

use of org.kie.dmn.model.api.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);
    }
}
Also used : InputData(org.kie.dmn.model.api.InputData) TInputData(org.kie.dmn.model.v1_2.TInputData)

Example 3 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class DMNXMLLoaderTest method testLoadingDefinitions.

@Test
public void testLoadingDefinitions() {
    final DMNMarshaller DMNMarshaller = DMNMarshallerFactory.newDefaultMarshaller();
    final InputStream is = this.getClass().getResourceAsStream("0001-input-data-string.dmn");
    final InputStreamReader isr = new InputStreamReader(is);
    final Definitions def = DMNMarshaller.unmarshal(isr);
    assertThat(def, not(nullValue()));
    assertThat(def.getName(), is("0001-input-data-string"));
    assertThat(def.getId(), is("_0001-input-data-string"));
    assertThat(def.getNamespace(), is("https://github.com/agilepro/dmn-tck"));
    assertThat(def.getDrgElement().size(), is(2));
    assertThat(def.getDrgElement().get(0), is(instanceOf(Decision.class)));
    Decision dec = (Decision) def.getDrgElement().get(0);
    assertThat(dec.getName(), is("Greeting Message"));
    assertThat(dec.getId(), is("d_GreetingMessage"));
    assertThat(dec.getVariable().getName(), is("Greeting Message"));
    assertThat(dec.getVariable().getTypeRef().getPrefix(), is("feel"));
    assertThat(dec.getVariable().getTypeRef().getLocalPart(), is("string"));
    assertThat(dec.getVariable().getTypeRef().getNamespaceURI(), is(XMLConstants.NULL_NS_URI));
    assertThat(dec.getInformationRequirement().size(), is(1));
    assertThat(dec.getInformationRequirement().get(0).getRequiredInput().getHref(), is("#i_FullName"));
    assertThat(dec.getExpression(), is(instanceOf(LiteralExpression.class)));
    LiteralExpression le = (LiteralExpression) dec.getExpression();
    assertThat(le.getText(), is("\"Hello \" + Full Name"));
    InputData idata = (InputData) def.getDrgElement().get(1);
    assertThat(idata.getId(), is("i_FullName"));
    assertThat(idata.getName(), is("Full Name"));
    assertThat(idata.getVariable().getName(), is("Full Name"));
    assertThat(idata.getVariable().getTypeRef().getPrefix(), is("feel"));
    assertThat(idata.getVariable().getTypeRef().getLocalPart(), is("string"));
    assertThat(idata.getVariable().getTypeRef().getNamespaceURI(), is(XMLConstants.NULL_NS_URI));
}
Also used : DMNMarshaller(org.kie.dmn.api.marshalling.DMNMarshaller) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Definitions(org.kie.dmn.model.api.Definitions) LiteralExpression(org.kie.dmn.model.api.LiteralExpression) InputData(org.kie.dmn.model.api.InputData) Decision(org.kie.dmn.model.api.Decision) Test(org.junit.Test)

Example 4 with InputData

use of org.kie.dmn.model.api.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);
    }
}
Also used : TInputData(org.kie.dmn.model.v1_4.TInputData) InputData(org.kie.dmn.model.api.InputData)

Example 5 with InputData

use of org.kie.dmn.model.api.InputData in project drools by kiegroup.

the class DMNExtensionRegisterTest method testUsingKModuleProperty_WrongClasses.

@Test
public void testUsingKModuleProperty_WrongClasses() {
    final KieServices ks = KieServices.Factory.get();
    final KieFileSystem kfs = ks.newKieFileSystem();
    final KieModuleModel kmm = ks.newKieModuleModel();
    kmm.setConfigurationProperty("org.kie.dmn.profiles.FirstNameLastNameProfile", "foo");
    kfs.writeKModuleXML(kmm.toXML());
    kfs.write(ks.getResources().newClassPathResource("0001-input-data-string-with-extensions.dmn", this.getClass()));
    final KieBuilder kieBuilder = ks.newKieBuilder(kfs).buildAll();
    final Results results = kieBuilder.getResults();
    LOG.info("buildAll() completed.");
    results.getMessages(Level.WARNING).forEach(e -> LOG.warn("{}", e));
    assertTrue(results.getMessages(Level.WARNING).size() > 0);
    final KieContainer kieContainer = ks.newKieContainer(ks.getRepository().getDefaultReleaseId());
    final DMNRuntime runtime = kieContainer.newKieSession().getKieRuntime(DMNRuntime.class);
    final 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());
    final InputData inputData1 = (InputData) dmnModel.getDefinitions().getDrgElement().get(1);
    assertEquals("First Name", inputData1.getName());
    final DMNElement.ExtensionElements id1elements = inputData1.getExtensionElements();
    assertNotNull(id1elements);
    assertEquals(0, id1elements.getAny().size());
    final InputData inputData2 = (InputData) dmnModel.getDefinitions().getDrgElement().get(2);
    assertEquals("Last Name", inputData2.getName());
    final DMNElement.ExtensionElements id2elements = inputData2.getExtensionElements();
    assertNotNull(id2elements);
    assertEquals(0, id2elements.getAny().size());
}
Also used : KieFileSystem(org.kie.api.builder.KieFileSystem) Results(org.kie.api.builder.Results) KieModuleModel(org.kie.api.builder.model.KieModuleModel) DMNElement(org.kie.dmn.model.api.DMNElement) KieServices(org.kie.api.KieServices) KieBuilder(org.kie.api.builder.KieBuilder) InputData(org.kie.dmn.model.api.InputData) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) DMNModel(org.kie.dmn.api.core.DMNModel) KieContainer(org.kie.api.runtime.KieContainer) Test(org.junit.Test)

Aggregations

InputData (org.kie.dmn.model.api.InputData)19 Decision (org.kie.dmn.model.api.Decision)6 DRGElement (org.kie.dmn.model.api.DRGElement)5 Definitions (org.kie.dmn.model.api.Definitions)5 Test (org.junit.Test)4 Artifact (org.kie.dmn.model.api.Artifact)4 Association (org.kie.dmn.model.api.Association)4 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)4 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)4 Import (org.kie.dmn.model.api.Import)4 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)4 KnowledgeSource (org.kie.dmn.model.api.KnowledgeSource)4 OrganizationUnit (org.kie.dmn.model.api.OrganizationUnit)4 PerformanceIndicator (org.kie.dmn.model.api.PerformanceIndicator)4 TextAnnotation (org.kie.dmn.model.api.TextAnnotation)4 DMNModel (org.kie.dmn.api.core.DMNModel)3 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)3 DMNElement (org.kie.dmn.model.api.DMNElement)3 DecisionService (org.kie.dmn.model.api.DecisionService)3