use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddSameParents.
@Test(expected = ProgrammingErrorException.class)
@Request
public void testAddSameParents() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
provCentral.addGraphParent(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
Assert.fail("Able to add the same overlapping parent multiple times");
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testAddParent_Duplicate.
@Test(expected = ProgrammingErrorException.class)
@Request
public void testAddParent_Duplicate() {
ServerGeoObjectIF parent = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF child = FastTestDataset.PROV_WESTERN.getServerObject();
child.addGraphParent(parent, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
parent.addGraphParent(child, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class UndirectedGraphTest method testGetChildrenCyclic.
@Test
@Request
public void testGetChildrenCyclic() {
ServerGeoObjectIF provCentral = FastTestDataset.PROV_CENTRAL.getServerObject();
ServerGeoObjectIF provWestern = FastTestDataset.PROV_WESTERN.getServerObject();
ServerGeoObjectIF distCentral = FastTestDataset.DIST_CENTRAL.getServerObject();
ServerGeoObjectIF cambodia = FastTestDataset.CAMBODIA.getServerObject();
ServerGeoObjectIF privateCentral = FastTestDataset.PROV_CENTRAL_PRIVATE.getServerObject();
ServerGeoObjectIF centralHospital = FastTestDataset.CENTRAL_HOSPITAL.getServerObject();
provWestern.addGraphParent(provCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(distCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
provCentral.addGraphParent(cambodia, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
cambodia.addGraphParent(privateCentral, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
cambodia.addGraphParent(centralHospital, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
distCentral.addGraphParent(provWestern, type, FastTestDataset.DEFAULT_OVER_TIME_DATE, FastTestDataset.DEFAULT_OVER_TIME_DATE);
ServerChildGraphNode node = provWestern.getGraphChildren(type, true, FastTestDataset.DEFAULT_OVER_TIME_DATE);
Assert.assertNotNull(node);
}
use of net.geoprism.registry.model.ServerGeoObjectIF 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());
}
use of net.geoprism.registry.model.ServerGeoObjectIF 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")));
}
Aggregations