Search in sources :

Example 16 with DRGElement

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

the class DefinitionsConverter method assignChildElement.

@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
    Definitions def = (Definitions) parent;
    if (IMPORT.equals(nodeName)) {
        def.getImport().add((Import) child);
    } else if (ITEM_DEFINITION.equals(nodeName)) {
        def.getItemDefinition().add((ItemDefinition) child);
    } else if (child instanceof DRGElement) {
        def.getDrgElement().add((DRGElement) child);
    } else if (child instanceof Artifact) {
        def.getArtifact().add((Artifact) child);
    } else if (ELEMENT_COLLECTION.equals(nodeName)) {
        def.getElementCollection().add((ElementCollection) child);
    } else if (child instanceof BusinessContextElement) {
        def.getBusinessContextElement().add((BusinessContextElement) child);
    } else if (child instanceof DMNDI) {
        DMNDI dmndi = (DMNDI) child;
        dmndi.normalize();
        def.setDMNDI(dmndi);
    } else {
        super.assignChildElement(def, nodeName, child);
    }
}
Also used : Definitions(org.kie.dmn.model.api.Definitions) TDefinitions(org.kie.dmn.model.v1_3.TDefinitions) ItemDefinition(org.kie.dmn.model.api.ItemDefinition) DMNDI(org.kie.dmn.model.api.dmndi.DMNDI) BusinessContextElement(org.kie.dmn.model.api.BusinessContextElement) Artifact(org.kie.dmn.model.api.Artifact) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 17 with DRGElement

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

the class DMNModelIOSets method buildIODoc.

private void buildIODoc() {
    for (DRGElement drge : model.getDefinitions().getDrgElement()) {
        if (drge instanceof InputData) {
            inputDoc.put(drge.getName(), drge.getDescription());
            outputDoc.put(drge.getName(), drge.getDescription());
        } else if (drge instanceof Decision) {
            outputDoc.put(drge.getName(), drge.getDescription());
        }
    }
}
Also used : InputData(org.kie.dmn.model.api.InputData) Decision(org.kie.dmn.model.api.Decision) DRGElement(org.kie.dmn.model.api.DRGElement)

Example 18 with DRGElement

use of org.kie.dmn.model.api.DRGElement in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testRemoveDrgElementsWithoutShape.

@Test
public void testRemoveDrgElementsWithoutShape() {
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final DRGElement e1 = createDRGElement(id1);
    final DRGElement e2 = createDRGElement(id2);
    final DRGElement e3 = createDRGElement(id3);
    final List<org.kie.dmn.model.api.DRGElement> drgElements = new ArrayList<>(Arrays.asList(e1, e2, e3));
    final DMNShape s1 = createDMNShape(id1);
    final DMNShape s3 = createDMNShape(id3);
    final List<DMNShape> dmnShapes = new ArrayList<>(Arrays.asList(s1, s3));
    getDMNMarshaller().removeDrgElementsWithoutShape(drgElements, dmnShapes);
    assertEquals(2, drgElements.size());
    assertEquals(e1, drgElements.get(0));
    assertEquals(e3, drgElements.get(1));
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ArrayList(java.util.ArrayList) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 19 with DRGElement

use of org.kie.dmn.model.api.DRGElement in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testIsImportedDRGElementWithWbDRGElement.

@Test
public void testIsImportedDRGElementWithWbDRGElement() {
    final DMNMarshallerStandalone marshaller = spy(getDMNMarshaller());
    final List<org.kie.dmn.model.api.DRGElement> importedDrgElements = new ArrayList<>();
    final org.kie.dmn.model.api.DRGElement imported = mock(org.kie.dmn.model.api.DRGElement.class);
    when(imported.getId()).thenReturn("id");
    importedDrgElements.add(imported);
    final org.kie.workbench.common.dmn.api.definition.model.DRGElement drgElement = mock(org.kie.workbench.common.dmn.api.definition.model.DRGElement.class);
    final Id id = mock(Id.class);
    when(id.getValue()).thenReturn("id");
    when(drgElement.getId()).thenReturn(id);
    final boolean actual = marshaller.isImportedDRGElement(importedDrgElements, drgElement);
    assertTrue(actual);
}
Also used : ArrayList(java.util.ArrayList) DRGElement(org.kie.dmn.model.api.DRGElement) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Example 20 with DRGElement

use of org.kie.dmn.model.api.DRGElement in project kie-wb-common by kiegroup.

the class DMNMarshallerStandaloneTest method testRemoveDrgElementsWithoutShapeWhenAllElementsHaveShape.

@Test
public void testRemoveDrgElementsWithoutShapeWhenAllElementsHaveShape() {
    final String id1 = "id1";
    final String id2 = "id2";
    final String id3 = "id3";
    final DRGElement e1 = createDRGElement(id1);
    final DRGElement e2 = createDRGElement(id2);
    final DRGElement e3 = createDRGElement(id3);
    final List<org.kie.dmn.model.api.DRGElement> drgElements = new ArrayList<>(Arrays.asList(e1, e2, e3));
    final DMNShape s1 = createDMNShape(id1);
    final DMNShape s2 = createDMNShape(id2);
    final DMNShape s3 = createDMNShape(id3);
    final List<DMNShape> dmnShapes = new ArrayList<>(Arrays.asList(s1, s2, s3));
    getDMNMarshaller().removeDrgElementsWithoutShape(drgElements, dmnShapes);
    assertEquals(3, drgElements.size());
    assertEquals(e1, drgElements.get(0));
    assertEquals(e2, drgElements.get(1));
    assertEquals(e3, drgElements.get(2));
}
Also used : DMNShape(org.kie.dmn.model.api.dmndi.DMNShape) ArrayList(java.util.ArrayList) DRGElement(org.kie.dmn.model.api.DRGElement) Test(org.junit.Test)

Aggregations

DRGElement (org.kie.dmn.model.api.DRGElement)25 Definitions (org.kie.dmn.model.api.Definitions)15 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)8 ItemDefinition (org.kie.dmn.model.api.ItemDefinition)8 Artifact (org.kie.dmn.model.api.Artifact)7 BusinessContextElement (org.kie.dmn.model.api.BusinessContextElement)7 Decision (org.kie.dmn.model.api.Decision)7 Import (org.kie.dmn.model.api.Import)7 BusinessKnowledgeModel (org.kie.dmn.model.api.BusinessKnowledgeModel)6 InputData (org.kie.dmn.model.api.InputData)6 DMNModel (org.kie.dmn.api.core.DMNModel)4 Association (org.kie.dmn.model.api.Association)4 DecisionService (org.kie.dmn.model.api.DecisionService)4 ElementCollection (org.kie.dmn.model.api.ElementCollection)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 DMNShape (org.kie.dmn.model.api.dmndi.DMNShape)4