Search in sources :

Example 1 with HierarchyService

use of net.geoprism.registry.hierarchy.HierarchyService in project geoprism-registry by terraframe.

the class LocationService method getLocationInformation.

@Request(RequestType.SESSION)
public LocationInformation getLocationInformation(String sessionId, Date date, String typeCode, String hierarchyCode) {
    LocationInformation information = new LocationInformation();
    HierarchyService hService = ServiceFactory.getHierarchyService();
    HierarchyType[] hierarchies = hService.getHierarchyTypes(sessionId, null, PermissionContext.READ);
    ServerHierarchyType hierarchy = null;
    if (hierarchyCode == null || hierarchyCode.length() == 0) {
        hierarchy = ServerHierarchyType.get(hierarchies[0]);
    } else {
        hierarchy = ServerHierarchyType.get(hierarchyCode);
    }
    List<ServerGeoObjectType> nodes = hierarchy.getDirectRootNodes();
    if (nodes.size() > 0) {
        /*
       * If a typeCode is given and it is an option based on the hierarchy than
       * use that type otherwise use the first type code
       */
        ServerGeoObjectType type = nodes.get(0);
        if (typeCode != null && typeCode.length() > 0) {
            for (ServerGeoObjectType node : nodes) {
                if (node.getCode().equals(typeCode)) {
                    type = ServerGeoObjectType.get(typeCode);
                }
            }
        }
        if (type != null) {
            ServiceFactory.getGeoObjectPermissionService().enforceCanRead(type.getOrganization().getCode(), type);
            information.setChildType(type.getType());
            List<VertexServerGeoObject> children = this.getGeoObjects(type.getCode(), date);
            for (VertexServerGeoObject child : children) {
                information.addChild(child.toGeoObject(date));
            }
        }
    }
    information.setHierarchies(hierarchies);
    information.setHierarchy(hierarchy.getCode());
    information.setChildTypes(nodes);
    return information;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) LocationInformation(net.geoprism.registry.view.LocationInformation) HierarchyService(net.geoprism.registry.hierarchy.HierarchyService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Request(com.runwaysdk.session.Request)

Example 2 with HierarchyService

use of net.geoprism.registry.hierarchy.HierarchyService in project geoprism-registry by terraframe.

the class ServiceFactory method initialize.

private void initialize() {
    this.registryService = new RegistryService();
    this.cs = new ConversionService();
    this.idService = new RegistryIdService();
    this.adapter = new RegistryAdapterServer(this.idService);
    this.accountService = new AccountService();
    this.goPermissionServ = new GeoObjectPermissionService();
    this.serverGoService = new ServerGeoObjectService(goPermissionServ);
    this.hierarchyService = new HierarchyService();
    this.orgServ = new OrganizationPermissionService();
    this.hierarchyPermServ = new HierarchyTypePermissionService();
    this.goRelPermissionServ = new GeoObjectRelationshipPermissionService();
    this.goTypeRelPermissionServ = new GeoObjectTypeRelationshipPermissionService();
    this.goTypePermissionServ = new GeoObjectTypePermissionService();
    this.rolePermissionServ = new RolePermissionService();
    this.metadataCache = new ServerMetadataCache(this.adapter);
    this.metadataCache.rebuild();
    this.registryService.initialize(this.adapter);
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) HierarchyTypePermissionService(net.geoprism.registry.permission.HierarchyTypePermissionService) HierarchyService(net.geoprism.registry.hierarchy.HierarchyService) ServerMetadataCache(net.geoprism.registry.cache.ServerMetadataCache) OrganizationPermissionService(net.geoprism.registry.permission.OrganizationPermissionService) RegistryAdapterServer(org.commongeoregistry.adapter.RegistryAdapterServer) GeoObjectRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectRelationshipPermissionService) GeoObjectPermissionService(net.geoprism.registry.permission.GeoObjectPermissionService) GeoObjectTypeRelationshipPermissionService(net.geoprism.registry.permission.GeoObjectTypeRelationshipPermissionService) GeoObjectTypePermissionService(net.geoprism.registry.permission.GeoObjectTypePermissionService)

Aggregations

HierarchyService (net.geoprism.registry.hierarchy.HierarchyService)2 Request (com.runwaysdk.session.Request)1 ServerMetadataCache (net.geoprism.registry.cache.ServerMetadataCache)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1 GeoObjectPermissionService (net.geoprism.registry.permission.GeoObjectPermissionService)1 GeoObjectRelationshipPermissionService (net.geoprism.registry.permission.GeoObjectRelationshipPermissionService)1 GeoObjectTypePermissionService (net.geoprism.registry.permission.GeoObjectTypePermissionService)1 GeoObjectTypeRelationshipPermissionService (net.geoprism.registry.permission.GeoObjectTypeRelationshipPermissionService)1 HierarchyTypePermissionService (net.geoprism.registry.permission.HierarchyTypePermissionService)1 OrganizationPermissionService (net.geoprism.registry.permission.OrganizationPermissionService)1 RolePermissionService (net.geoprism.registry.permission.RolePermissionService)1 LocationInformation (net.geoprism.registry.view.LocationInformation)1 RegistryAdapterServer (org.commongeoregistry.adapter.RegistryAdapterServer)1 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)1