Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Jira Legacy
serverSystem Jira
serverId01505d01-b853-3c2e-90f1-ee9b165564fc
keyMODQM-311

...

  1. Determine complexity of allowing for configuration of 001 generation (prefix + starting value) 
  2. Adding the ability to select the desired authority source file at point of creation of new record (so the system would know how to generate the 001 per the configuration)

Approach 

  1. Create new endpoint to retrieve HRID by authority file id 
  2. Implement sequence number generation mechanism for authority local files
  3. On the UI user will select file name. And before creation UI should put to 001 field value from the HRID endpoint. 

Tickets

OverviewApproachModuleTicket
Extend authority source file schema to store local files
  1. Extend authoritySourceFile schema to contain HRID information.
  2. Implement AuthoritySourceFileHridManager with Validation:
      - (if source = 'local' then codes.size = 1) else throw exception
      - (if source = 'local' and startNumber = null) set startValue = 1
mod-inventory-storage2 sp
Implement sequence number generation mechanism for authority local files
  1. Extend AuthoritySourceFileHridManager to work with sequences
      - Create sequence for authority local file after validation
      - Update sequence name for authority local file if prefix was updated
      - Drop sequence for authority local file after deletion
  2. Extend AuthorityService createAuthority()
      - Retrieve from repository 'local' file by sourceFileId
      - Retrieve next value from localFile sequence 
      - Format next value to NaturalId(HRID) format
      - Set NaturalId for Authority   
mod-inventory-storage5 sp

...

Settings application UI preview:

localauthoritydefinition.PNGTo have the ability to store authority local files. Authority schema should be updated

Endpoints:

GET: /authority-source-files/{id}/hrid
Description:  Endpoint returns current hrid value and increment it. Should be called once user clicked on the "create" button to put value in the 001 field.

Code Block
themeDJango
borderStyledashed
titleAuthority Source File Example
collapsetrue
{
    "id": "cb58492d-018e-442d-9ce3-35aabfc524aa",
    "nameprefix": "Test",
    "type": "Subjects",
    "codes": [
        "loc"
    ],
    "startNumberhrid": "000000001"
    "source": "local"
},}

POST: /authority-source-files
New query parameter: startNumber (default = 1)

Code Block
themeDJango
borderStyledashed
titleAuthority Source File Schema
collapsetrue
{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "description": "An Authority source file",
  "type": "object",
  "properties": {
    "id": {
      "description": "unique ID of the Authority source file; a UUID",
      "$ref": "uuid.json"
    },
    "name": {
      "type": "string",
      "description": "Authority source file name"
    },
    "codes": {
      "type" : "array",
      "description": "List of identifying prefix",
      "items": {
        "type": "string",
        "description": "identifying prefix, i.e. 'n', 'D', 'fst'"
        "pattern": "^[0-9a-zA-Z.-]{0,10}$"
       }
    },
    "type": {
      "type": "string",
      "description": "Type of authority records stored in source file"
    },
    "baseUrl": {
      "type": "string",
      "description": "Base URL of the source file origin"
    },         
    "startNumber": {
      "description": "The number from which to start generating HRIDs",

     "type": "integer",
  
   "minimum": 1,
   
  "maximum": 99999999999

   },
    "source": {
      "type": "string",
      "description": "label indicating where the authority source file entry originates from, i.e. 'folio' or 'local'",
      "enum": [
        "folio",
        "local"
      ]
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema",
      "readonly": true
    }
  },
  "additionalProperties": false,
  "required": [
    "name",
    "codes",
    "type",
    "source"
  ]
} 

Sequence number generation mechanism for authority local files

Approach

...

}


Sequence number generation mechanism for authority local files

Sequences Approach

There is a similar approach that works already in the mod-inventory-storage. It generates Hrid numbers for Instances, Holdings, and Item records, and can be configured from UI (Settings → Inventory → Hrid handling);
The problem here is that we will create new sequences in Runtime for each new authority file. (format: "hrid_authority_local_file_{prefix}_seq") 


Table with counter Approach

New table should be created

CREATE TABLE IF NOT EXISTS hrid_authority_source_file
(
authorityFileId UUID NOT NULL,
hridSeq INT NOT NULL,
CONSTRAINT hrid_authority_source_file_pkey PRIMARY KEY (authorityFileId),
CONSTRAINT hrid_authority_source_file_fkey FOREIGN KEY (authorityFileId)
REFERENCES authority_source_file (id)
);


To work with table it's better to use SERIALIZABLE Isolation:

@Transactional(isolation = Isolation.SERIALIZABLE)

Select local authority file on the UI

...