use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.
the class XMLImporter method createHierarchies.
private List<ServerElement> createHierarchies(Organization organization, Document doc) {
LinkedList<ServerElement> list = new LinkedList<ServerElement>();
NodeList nList = doc.getElementsByTagName("hierarchy");
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) nNode;
ServerHierarchyType type = createServerHierarchyType(organization, elem);
list.add(type);
this.cache.put(type.getCode(), type);
this.addChildren(type, RootGeoObjectType.INSTANCE, elem);
}
}
return list;
}
use of net.geoprism.registry.model.ServerElement in project geoprism-registry by terraframe.
the class XMLImporterTest method testImport.
@Request
@Test
public void testImport() throws IOException {
Organization organization = new Organization();
organization.setCode("TEST_ORG");
organization.getDisplayLabel().setValue("Test Org");
organization.apply();
try (InputStream istream = this.getClass().getResourceAsStream("/xml/test-domain.xml")) {
XMLImporter xmlImporter = new XMLImporter();
List<ServerElement> results = xmlImporter.importXMLDefinitions(organization, istream);
try {
RegistryService.getInstance().refreshMetadataCache();
Assert.assertEquals(4, results.size());
ServerGeoObjectType type = ServerGeoObjectType.get(results.get(0).getCode());
Assert.assertEquals("TEST_VILLAGE", type.getCode());
Assert.assertEquals("Test Village", type.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals(GeometryType.MULTIPOINT, type.getGeometryType());
Assert.assertFalse(type.getIsPrivate());
Assert.assertFalse(type.isGeometryEditable());
Assert.assertTrue(type.getIsAbstract());
Optional<AttributeType> oattribute = type.getAttribute("TEST_TEXT");
Assert.assertTrue(oattribute.isPresent());
AttributeType attributeType = oattribute.get();
Assert.assertEquals("Test Text", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Text Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
oattribute = type.getAttribute("TEST_BOOLEAN");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Boolean", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Boolean Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
oattribute = type.getAttribute("TEST_INTEGER");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Integer", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Integer Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
oattribute = type.getAttribute("TEST_DATE");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Date", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Date Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
oattribute = type.getAttribute("TEST_DECIMAL");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Decimal", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Decimal Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
oattribute = type.getAttribute("TEST_TERM");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Term", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Term Description", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
List<Term> terms = ((AttributeTermType) attributeType).getTerms();
Assert.assertEquals(3, terms.size());
oattribute = type.getAttribute("TEST_CLASSIFICATION");
Assert.assertTrue(oattribute.isPresent());
attributeType = oattribute.get();
Assert.assertEquals("Test Classification", attributeType.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Text Classification", attributeType.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("TEST_PROG", ((AttributeClassificationType) attributeType).getClassificationType());
Assert.assertEquals(ROOT_CODE, ((AttributeClassificationType) attributeType).getRootTerm().getCode());
type = ServerGeoObjectType.get(results.get(1).getCode());
Assert.assertEquals("TEST_GI", type.getCode());
Assert.assertEquals("Test GI", type.getLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals(GeometryType.MULTIPOINT, type.getGeometryType());
Assert.assertFalse(type.getIsPrivate());
Assert.assertFalse(type.isGeometryEditable());
Assert.assertFalse(type.getIsAbstract());
Assert.assertEquals("TEST_VILLAGE", type.getSuperType().getCode());
ServerHierarchyType hierarchy = ServerHierarchyType.get(results.get(3).getCode());
Assert.assertEquals("TEST_HIERARCHY", hierarchy.getCode());
Assert.assertEquals("Test Hierarchy", hierarchy.getDisplayLabel().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Hierarchy Description", hierarchy.getDescription().getValue(LocalizedValue.DEFAULT_LOCALE));
Assert.assertEquals("Test Progress", hierarchy.getProgress());
Assert.assertEquals("Test Disclaimer", hierarchy.getDisclaimer());
Assert.assertEquals("Test Access Constraints", hierarchy.getAccessConstraints());
Assert.assertEquals("Test Use Constraints", hierarchy.getUseConstraints());
Assert.assertEquals("Test Acknowledgement", hierarchy.getAcknowledgement());
List<HierarchyNode> nodes = hierarchy.getRootGeoObjectTypes();
Assert.assertEquals(1, nodes.size());
HierarchyNode node = nodes.get(0);
Assert.assertEquals("TEST_DISTRICT", node.getGeoObjectType().getCode());
nodes = node.getChildren();
Assert.assertEquals(1, nodes.size());
node = nodes.get(0);
Assert.assertEquals("TEST_VILLAGE", node.getGeoObjectType().getCode());
} finally {
Collections.reverse(results);
for (ServerElement result : results) {
result.delete();
}
}
} finally {
organization.delete();
}
}
Aggregations