Search in sources :

Example 91 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class InheritedHierarchyAnnotationTest method testGetTypeAncestors.

@Test
@Request
public void testGetTypeAncestors() {
    ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
    ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
    ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
    InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
    try {
        ServerGeoObjectType childType = TEST_CHILD.getServerObject();
        List<GeoObjectType> results = childType.getTypeAncestors(TEST_HT.getServerObject(), false);
        Assert.assertEquals(1, results.size());
    } finally {
        annotation.delete();
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 92 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class GeoObjectAtTimeShapefileExporterTest method testCreateFeatureType.

@Test
@Request
public void testCreateFeatureType() {
    ServerGeoObjectType type = ServerGeoObjectType.get(FastTestDataset.PROVINCE.getCode());
    GeoObjectAtTimeShapefileExporter exporter = new GeoObjectAtTimeShapefileExporter(type, FastTestDataset.DEFAULT_OVER_TIME_DATE);
    SimpleFeatureType featureType = exporter.createFeatureType();
    Assert.assertNotNull(featureType);
    Assert.assertEquals(GeoObjectAtTimeShapefileExporter.GEOM, featureType.getGeometryDescriptor().getLocalName());
    List<AttributeDescriptor> attributes = featureType.getAttributeDescriptors();
    Assert.assertEquals(3, attributes.size());
}
Also used : SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) GeoObjectAtTimeShapefileExporter(net.geoprism.registry.shapefile.GeoObjectAtTimeShapefileExporter) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 93 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class GeoObjectUtilTest method testGetAncestorMapForTreeType.

@Test
@Request
public void testGetAncestorMapForTreeType() {
    ServerGeoObjectType type = USATestData.AREA.getServerObject();
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
    ServerGeoObjectIF object = new ServerGeoObjectService().getGeoObjectByCode(USATestData.CO_A_ONE.getCode(), type);
    List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
    List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
    for (GeoObjectType ancestor : dtoAncestors) {
        ancestors.add(ServerGeoObjectType.get(ancestor));
    }
    Map<String, LocationInfo> map = object.getAncestorMap(hierarchyType, ancestors);
    Assert.assertEquals(3, map.size());
    // Validate the county values
    Assert.assertTrue(map.containsKey(USATestData.COUNTY.getCode()));
    LocationInfo vObject = map.get(USATestData.COUNTY.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.CO_C_ONE.getDisplayLabel(), vObject.getLabel());
    // Validate the state values
    Assert.assertTrue(map.containsKey(USATestData.STATE.getCode()));
    vObject = map.get(USATestData.STATE.getCode());
    Assert.assertEquals(USATestData.COLORADO.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.COLORADO.getDisplayLabel(), vObject.getLabel());
    // Validate the country values
    Assert.assertTrue(map.containsKey(USATestData.COUNTRY.getCode()));
    vObject = map.get(USATestData.COUNTRY.getCode());
    Assert.assertEquals(USATestData.USA.getCode(), vObject.getCode());
    Assert.assertEquals(USATestData.USA.getDisplayLabel(), vObject.getLabel());
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList) LocationInfo(net.geoprism.registry.model.LocationInfo) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 94 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class ListTypeGeoObjectShapefileExporterTest method testCreateFeatures.

@Test
@Request
public void testCreateFeatures() {
    ServerGeoObjectIF object = FastTestDataset.PROV_CENTRAL.getServerObject();
    ServerGeoObjectType type = object.getType();
    ListTypeShapefileExporter exporter = new ListTypeShapefileExporter(version, mdBusiness, mdAttributes, new JsonObject());
    SimpleFeatureType featureType = exporter.createFeatureType();
    FeatureCollection<SimpleFeatureType, SimpleFeature> features = exporter.features(featureType);
    Assert.assertEquals(2, features.size());
    FeatureIterator<SimpleFeature> it = features.features();
    SimpleFeature feature = null;
    while (it.hasNext()) {
        SimpleFeature f = it.next();
        if (object.getCode().equals(f.getAttribute(GeoObject.CODE))) {
            feature = f;
        }
    }
    Assert.assertNotNull(feature);
    Assert.assertEquals("Attributes not equal [code]", object.getCode(), feature.getAttribute(GeoObject.CODE));
    Object geometry = feature.getDefaultGeometry();
    Assert.assertNotNull(geometry);
    ImportAttributeSerializer serializer = new ImportAttributeSerializer(Session.getCurrentLocale(), false, false, LocalizationFacade.getInstalledLocales());
    Collection<AttributeType> attributes = serializer.attributes(type.getType());
    for (AttributeType attribute : attributes) {
        String attributeName = attribute.getName();
        Object oValue = object.getValue(attributeName);
        Object fValue = feature.getAttribute(exporter.getColumnName(attributeName));
        if (attribute instanceof AttributeTermType) {
            Assert.assertEquals("Attributes not equal [" + attributeName + "]", GeoObjectUtil.convertToTermString((AttributeTermType) attribute, oValue), fValue);
        } else if (attribute instanceof AttributeLocalType) {
            Assert.assertEquals("Attributes not equal [" + attributeName + "]", ((LocalizedValue) oValue).getValue(), fValue);
        } else {
            Assert.assertEquals("Attributes not equal [" + attributeName + "]", oValue, fValue);
        }
    }
    Assert.assertEquals(FastTestDataset.CAMBODIA.getCode(), feature.getAttribute(exporter.getColumnName("fastadmincodefastcountry")));
    Assert.assertEquals(FastTestDataset.CAMBODIA.getDisplayLabel(), feature.getAttribute(exporter.getColumnName("fastadmincodefastcountryDefaultLocale")));
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) SimpleFeature(org.opengis.feature.simple.SimpleFeature) AttributeLocalType(org.commongeoregistry.adapter.metadata.AttributeLocalType) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ListTypeShapefileExporter(net.geoprism.registry.shapefile.ListTypeShapefileExporter) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) JsonObject(com.google.gson.JsonObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) AttributeTermType(org.commongeoregistry.adapter.metadata.AttributeTermType) ListTypeTest(net.geoprism.registry.service.ListTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 95 with ServerGeoObjectType

use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.

the class AttributeClassificationTest method setUpInReq.

@Request
private static void setUpInReq() {
    type = ClassificationType.apply(ClassificationTypeTest.createMock());
    TEST_GOT.apply();
    Classification root = Classification.newInstance(type);
    root.setCode(CODE);
    root.setDisplayLabel(new LocalizedValue("Test Classification"));
    root.apply(null);
    testClassification = (AttributeClassificationType) AttributeType.factory("testClassification", new LocalizedValue("testClassificationLocalName"), new LocalizedValue("testClassificationLocalDescrip"), AttributeClassificationType.TYPE, false, false, false);
    testClassification.setClassificationType(type.getCode());
    testClassification.setRootTerm(root.toTerm());
    ServerGeoObjectType got = ServerGeoObjectType.get(TEST_GOT.getCode());
    testClassification = (AttributeClassificationType) got.createAttributeType(testClassification.toJSON().toString());
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Classification(net.geoprism.registry.model.Classification) Request(com.runwaysdk.session.Request)

Aggregations

ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)201 Request (com.runwaysdk.session.Request)69 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)57 JsonObject (com.google.gson.JsonObject)48 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)32 JsonArray (com.google.gson.JsonArray)30 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)30 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)27 LinkedList (java.util.LinkedList)27 Test (org.junit.Test)27 VertexObject (com.runwaysdk.business.graph.VertexObject)26 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)26 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)23 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)23 Date (java.util.Date)21 GraphQuery (com.runwaysdk.business.graph.GraphQuery)19 List (java.util.List)18 EdgeObject (com.runwaysdk.business.graph.EdgeObject)17 SimpleDateFormat (java.text.SimpleDateFormat)17 Locale (java.util.Locale)17