use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class MasterList 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 CreateGeoObjectAction 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.create.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 RegistryController method listGeoObjectTypes.
/**
* Returns an array of (label, code) pairs that define all of the geo object
* types in the system.
*
* @pre
* @post
*
* @returns @throws
*/
@Endpoint(url = "geoobjecttype/list-types", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF listGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = "includeAbstractTypes", required = true) Boolean includeAbstractTypes) {
GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), null, null, PermissionContext.READ);
Arrays.sort(gots, new Comparator<GeoObjectType>() {
@Override
public int compare(GeoObjectType o1, GeoObjectType o2) {
return o1.getLabel().getValue().compareTo(o2.getLabel().getValue());
}
});
JsonArray jarray = new JsonArray();
for (int i = 0; i < gots.length; ++i) {
GeoObjectType geoObjectType = gots[i];
if (!geoObjectType.getCode().equals("ROOT") && (includeAbstractTypes || !geoObjectType.getIsAbstract())) {
JsonObject type = new JsonObject();
type.addProperty("label", geoObjectType.getLabel().getValue());
type.addProperty("code", geoObjectType.getCode());
type.addProperty("orgCode", geoObjectType.getOrganizationCode());
type.addProperty("superTypeCode", geoObjectType.getSuperTypeCode());
jarray.add(type);
}
}
return new RestBodyResponse(jarray);
}
use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class RegistryController method getTypeAncestors.
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobjecttype/get-ancestors")
public ResponseIF getTypeAncestors(ClientRequestIF request, @RequestParamter(name = "code", required = true) String code, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "includeInheritedTypes") Boolean includeInheritedTypes, @RequestParamter(name = "includeChild") Boolean includeChild) {
if (includeInheritedTypes == null) {
includeInheritedTypes = false;
}
JsonArray response = new JsonArray();
List<GeoObjectType> ancestors = this.registryService.getAncestors(request.getSessionId(), code, hierarchyCode, includeInheritedTypes, includeChild);
for (GeoObjectType ancestor : ancestors) {
JsonObject object = new JsonObject();
object.addProperty("label", ancestor.getLabel().getValue());
object.addProperty("code", ancestor.getCode());
response.add(object);
}
return new RestBodyResponse(response.toString());
}
use of org.commongeoregistry.adapter.metadata.GeoObjectType in project geoprism-registry by terraframe.
the class RegistryController method getGeoObjectTypes.
/**
* Returns an array of {@link GeoOjectType} objects that define the given list
* of types.
*
* @pre @post
*
* @param types
* A serialized json array of GeoObjectType codes. If blank then all
* GeoObjectType objects are returned.
* @param hierarchies
* A serialized json array of HierarchyType codes. If blank then
* GeoObjectTypes belonging to all hierarchies are returned.
*
* @returns @throws
*/
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL)
public ResponseIF getGeoObjectTypes(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_TYPES) String types, @RequestParamter(name = RegistryUrls.GEO_OBJECT_TYPE_GET_ALL_PARAM_HIERARCHIES) String hierarchies, @RequestParamter(name = "context") String context) {
String[] aTypes = null;
if (types != null) {
JSONArray jaTypes = new JSONArray(types);
aTypes = new String[jaTypes.length()];
for (int i = 0; i < jaTypes.length(); i++) {
aTypes[i] = jaTypes.getString(i);
}
}
String[] aHierarchies = null;
if (hierarchies != null) {
JSONArray jaHierarchies = new JSONArray(hierarchies);
aHierarchies = new String[jaHierarchies.length()];
for (int i = 0; i < jaHierarchies.length(); i++) {
aHierarchies[i] = jaHierarchies.getString(i);
}
}
PermissionContext pContext = PermissionContext.get(context);
GeoObjectType[] gots = this.registryService.getGeoObjectTypes(request.getSessionId(), aTypes, aHierarchies, pContext);
JsonArray jarray = new JsonArray();
for (int i = 0; i < gots.length; ++i) {
JsonObject jo = this.registryService.serialize(request.getSessionId(), gots[i]);
jarray.add(jo);
}
return new RestBodyResponse(jarray);
}
Aggregations