Search in sources :

Example 61 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class HierarchyService method getHierarchyTypes.

/**
 * Returns the {@link HierarchyType}s with the given codes or all
 * {@link HierarchyType}s if no codes are provided.
 *
 * @param sessionId
 * @param codes
 *          codes of the {@link HierarchyType}s.
 * @param context
 * @return the {@link HierarchyType}s with the given codes or all
 *         {@link HierarchyType}s if no codes are provided.
 */
@Request(RequestType.SESSION)
public HierarchyType[] getHierarchyTypes(String sessionId, String[] codes, PermissionContext context) {
    final HierarchyTypePermissionServiceIF hierPermServ = ServiceFactory.getHierarchyPermissionService();
    List<ServerHierarchyType> types = ServerHierarchyType.getAll();
    if (codes != null && codes.length > 0) {
        final List<String> list = Arrays.asList(codes);
        types = types.stream().filter(type -> list.contains(type.getCode())).collect(Collectors.toList());
    }
    // Filter out what they're not allowed to see
    List<HierarchyType> hierarchies = types.stream().filter(type -> {
        Organization org = Organization.getByCode(type.getOrganizationCode());
        return !((context.equals(PermissionContext.READ) && !hierPermServ.canRead(org.getCode())) || (context.equals(PermissionContext.WRITE) && !hierPermServ.canWrite(org.getCode())));
    }).filter(type -> type.hasVisibleRoot()).map(type -> type.toHierarchyType(false)).collect(Collectors.toList());
    return hierarchies.toArray(new HierarchyType[hierarchies.size()]);
}
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) Organization(net.geoprism.registry.Organization) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) HierarchyTypePermissionServiceIF(net.geoprism.registry.permission.HierarchyTypePermissionServiceIF) Request(com.runwaysdk.session.Request)

Example 62 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class HierarchyService method setInheritedHierarchy.

/**
 * Modifies a hierarchy to inherit from another hierarchy at the given
 * GeoObjectType
 *
 * @param sessionId
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param inheritedHierarchyTypeCode
 *          code of the {@link HierarchyType} being inherited.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Request(RequestType.SESSION)
public HierarchyType setInheritedHierarchy(String sessionId, String hierarchyTypeCode, String inheritedHierarchyTypeCode, String geoObjectTypeCode) {
    ServerHierarchyType forHierarchy = ServerHierarchyType.get(hierarchyTypeCode);
    ServerHierarchyType inheritedHierarchy = ServerHierarchyType.get(inheritedHierarchyTypeCode);
    ServerGeoObjectType childType = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(forHierarchy, null, childType);
    ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    type.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
    forHierarchy.refresh();
    return forHierarchy.toHierarchyType();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 63 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class HierarchyService method filterHierarchiesFromPermissions.

public static void filterHierarchiesFromPermissions(ServerGeoObjectType type, ServerParentTreeNodeOverTime pot) {
    GeoObjectRelationshipPermissionServiceIF service = ServiceFactory.getGeoObjectRelationshipPermissionService();
    Collection<ServerHierarchyType> hierarchies = pot.getHierarchies();
    for (ServerHierarchyType hierarchy : hierarchies) {
        Organization organization = hierarchy.getOrganization();
        // null, type) ))
        if (!service.canViewChild(organization.getCode(), null, type)) {
            pot.remove(hierarchy);
        }
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) GeoObjectRelationshipPermissionServiceIF(net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF) Organization(net.geoprism.registry.Organization)

Example 64 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class HierarchyService method removeFromHierarchy.

/**
 * Removes the {@link GeoObjectType} with the given child code from the parent
 * {@link GeoObjectType} with the given code for the given
 * {@link HierarchyType} code.
 *
 * @param sessionId
 * @param hierarchyCode
 *          code of the {@link HierarchyType} the child is being added to.
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param childGeoObjectTypeCode
 *          child {@link GeoObjectType}.
 */
@Request(RequestType.SESSION)
public HierarchyType removeFromHierarchy(String sessionId, String hierarchyTypeCode, String parentGeoObjectTypeCode, String childGeoObjectTypeCode, boolean migrateChildren) {
    ServerHierarchyType type = ServerHierarchyType.get(hierarchyTypeCode);
    ServerGeoObjectType parentType = ServerGeoObjectType.get(parentGeoObjectTypeCode);
    ServerGeoObjectType childType = ServerGeoObjectType.get(childGeoObjectTypeCode);
    ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanRemoveChild(type, parentType, childType);
    type.removeChild(parentType, childType, migrateChildren);
    return type.toHierarchyType();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 65 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class VertexServerGeoObject method removeChild.

@Transaction
public void removeChild(ServerGeoObjectIF child, String hierarchyCode, Date startDate, Date endDate) {
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(hierarchyCode);
    child.removeParent(this, hierarchyType, startDate, endDate);
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)86 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)55 Request (com.runwaysdk.session.Request)38 JsonObject (com.google.gson.JsonObject)20 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)17 JsonArray (com.google.gson.JsonArray)16 LinkedList (java.util.LinkedList)14 List (java.util.List)14 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)12 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 Locale (java.util.Locale)10 Point (com.vividsolutions.jts.geom.Point)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)8 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)8 Organization (net.geoprism.registry.Organization)8