Search in sources :

Example 86 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType 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();
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(net.geoprism.registry.Organization) InputStream(java.io.InputStream) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Term(org.commongeoregistry.adapter.Term) AttributeClassificationType(org.commongeoregistry.adapter.metadata.AttributeClassificationType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) ServerElement(net.geoprism.registry.model.ServerElement) HierarchyNode(org.commongeoregistry.adapter.metadata.HierarchyNode) Test(org.junit.Test) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Request(com.runwaysdk.session.Request)

Aggregations

ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)86 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)55 Request (com.runwaysdk.session.Request)38 JsonObject (com.google.gson.JsonObject)20 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)17 JsonArray (com.google.gson.JsonArray)16 LinkedList (java.util.LinkedList)14 List (java.util.List)14 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)12 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 Locale (java.util.Locale)10 Point (com.vividsolutions.jts.geom.Point)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)8 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)8 Organization (net.geoprism.registry.Organization)8