Search in sources :

Example 6 with HierarchyType

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));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 7 with HierarchyType

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());
}
Also used : RegistryAdapterServer(org.commongeoregistry.adapter.RegistryAdapterServer) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue)

Example 8 with HierarchyType

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();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) Request(com.runwaysdk.session.Request)

Example 9 with HierarchyType

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();
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyTypePermissionServiceIF(net.geoprism.registry.permission.HierarchyTypePermissionServiceIF) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) Collection(java.util.Collection) RequestType(com.runwaysdk.session.RequestType) GeoRegistryUtil(net.geoprism.registry.GeoRegistryUtil) Set(java.util.Set) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Collectors(java.util.stream.Collectors) Request(com.runwaysdk.session.Request) ServiceFactory(net.geoprism.registry.service.ServiceFactory) PermissionContext(net.geoprism.registry.permission.PermissionContext) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) GeoObjectRelationshipPermissionServiceIF(net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF) List(java.util.List) JsonArray(com.google.gson.JsonArray) Organization(net.geoprism.registry.Organization) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) Session(com.runwaysdk.session.Session) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 10 with HierarchyType

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;
}
Also used : GeoObjectRelationshipPermissionServiceIF(net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) GeoObjectPermissionServiceIF(net.geoprism.registry.permission.GeoObjectPermissionServiceIF) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) ChildTreeNode(org.commongeoregistry.adapter.dataaccess.ChildTreeNode)

Aggregations

HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)40 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)21 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)12 Endpoint (com.runwaysdk.mvc.Endpoint)11 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)11 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)9 Test (org.junit.Test)9 JsonArray (com.google.gson.JsonArray)6 Request (com.runwaysdk.session.Request)6 JsonObject (com.google.gson.JsonObject)5 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)5 HierarchyNode (org.commongeoregistry.adapter.metadata.HierarchyNode)4 List (java.util.List)3 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)3 GeoObjectRelationshipPermissionServiceIF (net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF)3 TestUserInfo (net.geoprism.registry.test.TestUserInfo)3 SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)2 MdAttributeCharacterDAO (com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO)2 MdAttributeUUIDDAO (com.runwaysdk.dataaccess.metadata.MdAttributeUUIDDAO)2