use of org.commongeoregistry.adapter.metadata.GeoObjectType 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 org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class ListType method getAncestorMap.
public Map<ServerHierarchyType, List<ServerGeoObjectType>> getAncestorMap(ServerGeoObjectType type) {
Map<ServerHierarchyType, List<ServerGeoObjectType>> map = new HashMap<>();
JsonArray hierarchies = this.getHierarchiesAsJson();
for (int i = 0; i < hierarchies.size(); i++) {
JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
List<String> pCodes = this.getParentCodes(hierarchy);
if (pCodes.size() > 0) {
String hCode = hierarchy.get("code").getAsString();
ServerHierarchyType hierarchyType = ServerHierarchyType.get(hCode);
List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
for (GeoObjectType ancestor : dtoAncestors) {
ancestors.add(ServerGeoObjectType.get(ancestor));
}
map.put(hierarchyType, ancestors);
}
}
return map;
}
use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class UpdateGeoObjectAction method getMessage.
@Override
protected String getMessage() {
GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), this.getGeoObjectJson());
GeoObjectType got = go.getType();
String message = LocalizationFacade.getFromBundles("change.request.email.update.object");
message = message.replaceAll("\\{0\\}", go.getCode());
message = message.replaceAll("\\{1\\}", got.getLabel().getValue(Session.getCurrentLocale()));
return message;
}
use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class GeoObjectTypeMetadata method hasPublicChildren.
public boolean hasPublicChildren() {
ServerGeoObjectType type = this.getServerType();
GeoObjectType typeDTO = type.getType();
List<ServerHierarchyType> hierarchyTypes = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
for (ServerHierarchyType ht : hierarchyTypes) {
List<HierarchyNode> roots = ht.getRootGeoObjectTypes();
for (HierarchyNode root : roots) {
HierarchyNode node = root.findChild(typeDTO);
if (node != null) {
Iterator<HierarchyNode> it = node.getDescendantsIterator();
while (it.hasNext()) {
HierarchyNode child = it.next();
if (!child.getGeoObjectType().getIsPrivate()) {
return true;
}
}
}
}
}
return false;
}
use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method build.
public ServerGeoObjectType build(Universal universal) {
MdBusiness mdBusiness = universal.getMdBusiness();
MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(universal.getUniversalId());
com.runwaysdk.system.gis.geo.GeometryType geoPrismgeometryType = universal.getGeometryType().get(0);
org.commongeoregistry.adapter.constants.GeometryType cgrGeometryType = GeometryTypeFactory.get(geoPrismgeometryType);
LocalizedValue label = convert(universal.getDisplayLabel());
LocalizedValue description = convert(universal.getDescription());
String ownerActerOid = universal.getOwnerOid();
String organizationCode = Organization.getRootOrganizationCode(ownerActerOid);
MdGeoVertexDAOIF superType = mdVertex.getSuperClass();
GeoObjectType geoObjType = new GeoObjectType(universal.getUniversalId(), cgrGeometryType, label, description, universal.getIsGeometryEditable(), organizationCode, ServiceFactory.getAdapter());
geoObjType.setIsAbstract(mdBusiness.getIsAbstract());
try {
GeoObjectTypeMetadata metadata = GeoObjectTypeMetadata.getByKey(universal.getKey());
geoObjType.setIsPrivate(metadata.getIsPrivate());
} catch (DataNotFoundException | AttributeDoesNotExistException e) {
geoObjType.setIsPrivate(false);
}
if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
String parentCode = superType.getTypeName();
geoObjType.setSuperTypeCode(parentCode);
}
geoObjType = this.convertAttributeTypes(universal, geoObjType, mdBusiness);
return new ServerGeoObjectType(geoObjType, universal, mdBusiness, mdVertex);
}
Aggregations