Spike: MODKBEKBJ-330 - Associate institution with a user
Goal: Investigate if there is an association between a logged-in user and the institution the user belongs to.
To understand the link between the institution and user, let's visualize table connections
This tool can not analyze the `jsonb` column, unfortunately, so the next steps require a manual review of schemas.
So, the schema for `location` contains following properties:
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "A (shelf) location, the forth-level location unit below institution, campus, and library.", "type": "object", "properties": { "id": { "description": "id of this (shelf) location record as UUID.", "type": "string" }, "name": { "description": "Name of the (shelf) location", "type": "string" }, "code": { "description": "Code of the (shelf) location, usually an abbreviation of the name.", "type": "string" }, "description": { "description": "Description of the (shelf) location.", "type": "string" }, "discoveryDisplayName": { "description": "Name of the (shelf) location to be shown in the discovery.", "type": "string" }, "isActive": { "description": "Whether this (shelf) location is active. Inactive (shelf) locations can no longer been used.", "type": "boolean" }, "institutionId": { "description": "The UUID of the institution, the first-level location unit, this (shelf) location belongs to.", "type": "string" }, "campusId": { "description": "The UUID of the campus, the second-level location unit, this (shelf) location belongs to.", "type": "string" }, "libraryId": { "description": "The UUID of the library, the third-level location unit, this (shelf) location belongs to.", "type": "string" }, "details": { "description": "Details about this (shelf) location.", "type": "object" }, "primaryServicePoint": { "description": "The UUID of the primary service point of this (shelf) location.", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "type": "string" }, "servicePointIds": { "description": "All service points that this (shelf) location has.", "type": "array", "items": { "description": "The UUID of a service point that belongs to this (shelf) location.", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", "not": { "type": "null" } } }, "metadata": { "type": "object", "$ref": "raml-util/schemas/metadata.schema", "readonly": true } }, "additionalProperties": false, "required": [ "name", "code", "institutionId", "campusId", "libraryId", "primaryServicePoint" ] }
Let's see `servicepointsuser.json`And as we see the most interesting part from the spike point is `servicePointIds` property, which leads us to two other schemas : `service-point` and `service-point-user`
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "The list of service points a user is allowed to work at, and the default service point for that user.", "type": "object", "properties": { "id": { "description": "The id of record as a UUID.", "type": "string" }, "userId": { "description": "Id of the user as a UUID.", "type": "string" }, "servicePointsIds": { "description": "The list of service points a user is allowed to work at.", "type": "array", "items": { "description": "The id of a service point as UUID.", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" } }, "defaultServicePointId": { "description": "The id of the user's default service point as UUID.", "type": "string", "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "metadata": { "type": "object", "$ref": "raml-util/schemas/metadata.schema", "readonly": true } }, "additionalProperties": false, "required": [ "userId" ] }
and here we can find an `userId` of user and can say that connection is following:
Settings - Tenant - Institutions - we can get list of institutions using {host}/location-units/institutions?query=cql.allRecords=1%20sortby%20name&limit=100 ; but what does this endpoint return when the tenant is a consortia and not a specific institution?
Folio database schema name are based on `tenant name + module name` and on the backend side there is no filtration based on institution, so, if we have tenant with name 'consortia', the schema name will be `consortia_mod_ inventory_storage` and for the request below we will get all entries that exist in corresponding table `institution`.
3. In case it's a tenant of a consortia, will this endpoint list out all institutions that belong to the consortia?
Short answer - no, the request `/location-units/institutions?query=cql.allRecords=1%20sortby%20name&limit=100` will return all records in table `institution`
Is there a way a default will be highlighted based on the user logged in?
There is no direct connection between user and institution but we have a connection between user->service_point→location
Location API in mod-inventory-storage
All location related data stored in mod-inventory-storage module, mod-inventory is not involved
ui-tenant module uses the following endpoints of mod-inventory-storage REST API to obtain location data:
- Service Points:
/service-points
- Institutions:
/location-units/institutions
- Campuses:
/location-units/campuses
- Libraries:
/location-units/libraries
- Locations:
/locations