Search in sources :

Example 1 with LocationInformation

use of net.geoprism.registry.view.LocationInformation 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 LocationInformation

use of net.geoprism.registry.view.LocationInformation in project geoprism-registry by terraframe.

the class LocationService method getLocationInformationJson.

@Request(RequestType.SESSION)
public JsonElement getLocationInformationJson(String sessionId, Date date, String typeCode, String hierarchyCode) {
    LocationInformation information = this.getLocationInformation(sessionId, date, typeCode, hierarchyCode);
    CustomSerializer serializer = ServiceFactory.getRegistryService().serializer(sessionId);
    return information.toJson(serializer);
}
Also used : LocationInformation(net.geoprism.registry.view.LocationInformation) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)2 LocationInformation (net.geoprism.registry.view.LocationInformation)2 HierarchyService (net.geoprism.registry.hierarchy.HierarchyService)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)1 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)1