use of org.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class ItemDefinitionConverter method writeAttributes.
@Override
protected void writeAttributes(HierarchicalStreamWriter writer, Object parent) {
super.writeAttributes(writer, parent);
ItemDefinition id = (ItemDefinition) parent;
if (id.getTypeLanguage() != null)
writer.addAttribute(TYPE_LANGUAGE, id.getTypeLanguage());
writer.addAttribute(IS_COLLECTION, Boolean.valueOf(id.isIsCollection()).toString());
}
use of org.kie.dmn.model.api.ItemDefinition 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);
}
}
use of org.kie.dmn.model.api.ItemDefinition in project drools by kiegroup.
the class TDefinitions method processQNameURIs.
private static void processQNameURIs(ItemDefinition iDef) {
final QName typeRef = iDef.getTypeRef();
if (typeRef != null && XMLConstants.NULL_NS_URI.equals(typeRef.getNamespaceURI())) {
final String namespace = iDef.getNamespaceURI(typeRef.getPrefix());
iDef.setTypeRef(new QName(namespace, typeRef.getLocalPart(), typeRef.getPrefix()));
}
for (ItemDefinition comp : iDef.getItemComponent()) {
processQNameURIs(comp);
}
}
use of org.kie.dmn.model.api.ItemDefinition in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsHelperStandaloneImplTest method testGetImportedItemDefinitions.
@Test
public void testGetImportedItemDefinitions() {
final Map<Import, Definitions> importDefinitions = new HashMap<>();
final Import anImport = mock(Import.class);
final Definitions definitions = mock(Definitions.class);
final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition3 = mock(ItemDefinition.class);
final List<ItemDefinition> expectedItemDefinitions = asList(itemDefinition1, itemDefinition2, itemDefinition3);
doReturn(expectedItemDefinitions).when(helper).getItemDefinitionsWithNamespace(definitions, anImport);
importDefinitions.put(anImport, definitions);
final List<ItemDefinition> actualItemDefinitions = helper.getImportedItemDefinitions(importDefinitions);
assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
use of org.kie.dmn.model.api.ItemDefinition in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsHelperStandaloneImplTest method testGetImportedItemDefinitionsByNamespace.
@Test
public void testGetImportedItemDefinitionsByNamespace() {
final WorkspaceProject workspaceProject = mock(WorkspaceProject.class);
final String modelName = "model1";
final String namespace = "://namespace1";
final Path path1 = makePath("../file1.dmn");
final Path path2 = makePath("../file2.dmn");
final Path path3 = makePath("../file3.dmn");
final Path path4 = makePath("../file4.dmn");
final InputStream inputStream1 = mock(InputStream.class);
final InputStream inputStream2 = mock(InputStream.class);
final InputStream inputStream3 = mock(InputStream.class);
final InputStreamReader inputStreamReader1 = mock(InputStreamReader.class);
final InputStreamReader inputStreamReader2 = mock(InputStreamReader.class);
final InputStreamReader inputStreamReader3 = mock(InputStreamReader.class);
final Definitions definitions1 = mock(Definitions.class);
final Definitions definitions2 = mock(Definitions.class);
final Definitions definitions3 = mock(Definitions.class);
final ItemDefinition itemDefinition1 = mock(ItemDefinition.class);
final ItemDefinition itemDefinition2 = mock(ItemDefinition.class);
final List<Path> paths = asList(path1, path2, path3, path4);
when(pathsHelper.getDMNModelsPaths(any())).thenReturn(paths);
doReturn(Optional.of(inputStream1)).when(helper).loadPath(path1);
doReturn(Optional.of(inputStream2)).when(helper).loadPath(path2);
doReturn(Optional.of(inputStream3)).when(helper).loadPath(path3);
doReturn(inputStreamReader1).when(helper).toInputStreamReader(inputStream1);
doReturn(inputStreamReader2).when(helper).toInputStreamReader(inputStream2);
doReturn(inputStreamReader3).when(helper).toInputStreamReader(inputStream3);
doReturn(Optional.empty()).when(helper).loadPath(path4);
when(marshaller.unmarshal(inputStreamReader1)).thenReturn(definitions1);
when(marshaller.unmarshal(inputStreamReader2)).thenReturn(definitions2);
when(marshaller.unmarshal(inputStreamReader3)).thenReturn(definitions3);
when(definitions1.getNamespace()).thenReturn("://namespace1");
when(definitions2.getNamespace()).thenReturn("://namespace2");
when(definitions3.getNamespace()).thenReturn("://namespace3");
when(definitions1.getItemDefinition()).thenReturn(asList(itemDefinition1, itemDefinition2));
final List<ItemDefinition> actualItemDefinitions = helper.getImportedItemDefinitionsByNamespace(workspaceProject, modelName, namespace);
final List<ItemDefinition> expectedItemDefinitions = asList(itemDefinition1, itemDefinition2);
assertEquals(expectedItemDefinitions, actualItemDefinitions);
}
Aggregations