use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class RegistryController method updateHierarchyType.
/**
* Updates the given {@link HierarchyType} represented as JSON.
*
* @param sessionId
* @param gtJSON
* JSON of the {@link HierarchyType} to be updated.
*/
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_UPDATE)
public ResponseIF updateHierarchyType(ClientRequestIF request, @RequestParamter(name = "htJSON", required = true) String htJSON) {
HierarchyType hierarchyType = ServiceFactory.getHierarchyService().updateHierarchyType(request.getSessionId(), htJSON);
CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
return new RestBodyResponse(hierarchyType.toJSON(serializer));
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class CambodiaDemoHierarchyGenerator method generateHierarchyTypes.
private static void generateHierarchyTypes() {
RegistryAdapterServer registry = new RegistryAdapterServer(RegistryIdService.getInstance());
HierarchyType ht = MetadataFactory.newHierarchyType("Cambodia", new LocalizedValue("Cambodia"), new LocalizedValue(""), null, registry);
ServiceFactory.getHierarchyService().createHierarchyType(Session.getCurrentSession().getOid(), ht.toJSON().toString());
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method updateHierarchyType.
/**
* Updates the given {@link HierarchyType} represented as JSON.
*
* @param sessionId
* @param gtJSON
* JSON of the {@link HierarchyType} to be updated.
*/
@Request(RequestType.SESSION)
public HierarchyType updateHierarchyType(String sessionId, String htJSON) {
HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, ServiceFactory.getAdapter());
ServerHierarchyType type = ServerHierarchyType.get(hierarchyType);
ServiceFactory.getHierarchyPermissionService().enforceCanWrite(type.getOrganization().getCode());
type.update(hierarchyType);
return type.toHierarchyType();
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method insertBetweenTypes.
/**
* Inserts the {@link GeoObjectType} 'middleGeoObjectTypeCode' into the
* hierarchy as the child of 'parentGeoObjectTypeCode' and the new parent for
* 'youngestGeoObjectTypeCode'. If an existing parent/child relationship
* already exists between 'youngestGeoObjectTypeCode' and
* 'parentgeoObjectTypeCode', it will first be removed.
* youngestGeoObjectTypeCode can also be an array (comma separated list).
*
* @param sessionId
* @param hierarchyTypeCode
* code of the {@link HierarchyType}
* @param parentGeoObjectTypeCode
* parent {@link GeoObjectType}.
* @param middleGeoObjectTypeCode
* middle child {@link GeoObjectType} after this method returns
* @param youngestGeoObjectTypeCode
* youngest child {@link GeoObjectType} after this method returns
*/
@Request(RequestType.SESSION)
public HierarchyType insertBetweenTypes(String sessionId, String hierarchyTypeCode, String parentGeoObjectTypeCode, String middleGeoObjectTypeCode, String youngestGeoObjectTypeCode) {
ServerHierarchyType type = ServerHierarchyType.get(hierarchyTypeCode);
ServerGeoObjectType parentType = ServerGeoObjectType.get(parentGeoObjectTypeCode);
ServerGeoObjectType middleType = ServerGeoObjectType.get(middleGeoObjectTypeCode);
List<ServerGeoObjectType> youngestTypes = Arrays.asList(youngestGeoObjectTypeCode.split(",")).stream().map(code -> ServerGeoObjectType.get(code.trim())).collect(Collectors.toList());
ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(type, parentType, middleType);
type.insertBetween(parentType, middleType, youngestTypes);
return type.toHierarchyType();
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class ServerChildTreeNode method toNode.
public ChildTreeNode toNode(boolean enforcePermissions) {
final GeoObjectRelationshipPermissionServiceIF relPermServ = ServiceFactory.getGeoObjectRelationshipPermissionService();
final GeoObjectPermissionServiceIF goPermServ = ServiceFactory.getGeoObjectPermissionService();
GeoObject go = this.getGeoObject().toGeoObject(this.getStartDate());
HierarchyType ht = this.getHierarchyType() != null ? this.getHierarchyType().toHierarchyType() : null;
ChildTreeNode node = new ChildTreeNode(go, ht);
String orgCode = go.getType().getOrganizationCode();
ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
for (ServerChildTreeNode child : this.children) {
if (!enforcePermissions || (relPermServ.canViewChild(orgCode, type, child.getGeoObject().getType()) && goPermServ.canRead(orgCode, type))) {
node.addChild(child.toNode(enforcePermissions));
}
}
return node;
}
Aggregations