sul-dlss / folio_client

Interface for interacting with the Folio ILS API.
Other
0 stars 0 forks source link

Get HRID back after stub MARC record loaded #12

Closed lwrubel closed 1 year ago

lwrubel commented 1 year ago

As described in https://github.com/sul-dlss/folio_client/issues/5, there is a jobExecutionId present in an uploadDefinition returned in the first step of the data-import load process. Once the data-import step to processFiles runs, the jobExecutionId can be used to check that records were created. If records were successfully created, then it is possible to look up the HRID of the new instance record:

GET /metadata-provider/journalRecords/{jobExecutionId} returns a response such as:

{'journalRecords': [{'id': 'ac01df37-1bec-4e61-bca8-d2932881c253',
   'jobExecutionId': '0087063f-73ff-4a52-8890-f318771963e4',
   'sourceId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'sourceRecordOrder': 0,
   'entityType': 'MARC_BIBLIOGRAPHIC',
   'entityId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'entityHrId': '',
   'actionType': 'CREATE',
   'actionStatus': 'COMPLETED',
   'error': '',
   'title': 'TEST5: TOPICS IN CONVEX OPTIMIZATION FOR MACHINE LEARNING / Youngsuk Park.',
   'actionDate': '2023-02-16T18:14:46.032+00:00'},
  {'id': 'a61f5475-c612-4df2-8bec-e1775c06093d',
   'jobExecutionId': '0087063f-73ff-4a52-8890-f318771963e4',
   'sourceId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'sourceRecordOrder': 0,
   'entityType': 'MARC_BIBLIOGRAPHIC',
   'entityId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'entityHrId': '',
   'actionType': 'CREATE',
   'actionStatus': 'COMPLETED',
   'error': '',
   'title': 'TEST5: TOPICS IN CONVEX OPTIMIZATION FOR MACHINE LEARNING / Youngsuk Park.',
   'actionDate': '2023-02-16T18:14:53.323+00:00'},
  {'id': '1e699607-59a0-4620-a620-2004e49c3bb7',
   'jobExecutionId': '0087063f-73ff-4a52-8890-f318771963e4',
   'sourceId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'sourceRecordOrder': 0,
   'entityType': 'INSTANCE',
   'entityId': '45e401f8-ae58-42a5-9ccc-cc020cac7c3e',
   'entityHrId': 'in00000000010',
   'actionType': 'CREATE',
   'actionStatus': 'COMPLETED',
   'error': '',
   'actionDate': '2023-02-16T18:14:53.444+00:00'},
  {'id': '45b2cec6-b681-4913-ac59-30bfdac1407d',
   'jobExecutionId': '0087063f-73ff-4a52-8890-f318771963e4',
   'sourceId': '6faca97d-d081-4f19-8d2b-5e17ce32fd57',
   'sourceRecordOrder': 0,
   'entityType': 'HOLDINGS',
   'entityId': 'f45c450f-d06c-452a-9e24-55551dcb2047',
   'instanceId': '45e401f8-ae58-42a5-9ccc-cc020cac7c3e',
   'entityHrId': 'ho00000000008',
   'actionType': 'CREATE',
   'actionStatus': 'COMPLETED',
   'error': '',
   'title': 'TEST5: TOPICS IN CONVEX OPTIMIZATION FOR MACHINE LEARNING / Youngsuk Park.',
   'actionDate': '2023-02-16T18:14:55.714+00:00'}],
 'totalRecords': 4}

The HRID we want to save in the ETD database is the entityHrid for the records of entityType INSTANCE. In the response above, it's in00000000010.

This lookup could be included in the data-import process, and the entityHrid returned to the consumer (usually hydra_etd) so it could save it in its db.

lwrubel commented 1 year ago

@justinlittman suggested that adding this method to the DataImport class (see #25) could be one way to implement this.