use of net.geoprism.registry.model.LocationInfoHolder in project geoprism-registry by terraframe.
the class VertexServerGeoObject method getAncestorMap.
@SuppressWarnings("unchecked")
public Map<String, LocationInfo> getAncestorMap(ServerHierarchyType hierarchy, List<ServerGeoObjectType> parents) {
TreeMap<String, LocationInfo> map = new TreeMap<String, LocationInfo>();
GraphQuery<Map<String, Object>> query = buildAncestorQueryFast(hierarchy, parents);
List<Map<String, Object>> results = query.getResults();
if (results.size() <= 1) {
return map;
}
// First result is the child object
results.remove(0);
results.forEach(result -> {
String clazz = (String) result.get("cl");
String code = (String) result.get("code");
List<Map<String, Object>> displayLabelRaw = (List<Map<String, Object>>) result.get("label");
LocalizedValue localized = LocalizedValueConverter.convert(displayLabelRaw, this.date);
ServerGeoObjectType type = null;
for (ServerGeoObjectType parent : parents) {
if (parent.getMdVertex().getDBClassName().equals(clazz)) {
type = parent;
}
}
if (type != null && localized != null) {
LocationInfoHolder holder = new LocationInfoHolder(code, localized, type);
map.put(type.getUniversal().getKey(), holder);
} else {
logger.error("Could not find [" + clazz + "] or the localized value was null.");
}
});
return map;
}
Aggregations