Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 948 to each MARC record #10

Open
cappadona opened this issue Mar 11, 2021 · 2 comments
Open

Add 948 to each MARC record #10

cappadona opened this issue Mar 11, 2021 · 2 comments
Assignees

Comments

@cappadona
Copy link

cappadona commented Mar 11, 2021

Before submitting the MARC record to Source Record Storage, add the following data to the 948

//PREPARING TO ADD THE MARC RECORD TO SOURCE RECORD STORAGE:
//CONSTRUCTING THE 999 OF THE MARC RECORD for FOLIO:
DataField field = MarcFactory.newInstance().newDataField();
field.setTag("999");
field.setIndicator1('f');
field.setIndicator2('f');
Subfield one = MarcFactory.newInstance().newSubfield('i', instanceId);
Subfield two = MarcFactory.newInstance().newSubfield('s',recordTableId.toString());
field.addSubfield(one);
field.addSubfield(two);
record.addVariableField(field);
if (record.getControlNumberField() != null) {
record.getControlNumberField().setData(hrid);
}
else {
ControlField cf = MarcFactory.newInstance().newControlField("001");
cf.setData(hrid);
record.addVariableField(cf);
}
//TRANSFORM THE RECORD INTO JSON
logger.info("MARC RECORD: " + record.toString());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
MarcJsonWriter jsonWriter = new MarcJsonWriter(baos);
jsonWriter.setUnicodeNormalization(true);
jsonWriter.write(record);
jsonWriter.close();
String jsonString = baos.toString();
JSONObject mRecord = new JSONObject(jsonString);
JSONObject content = new JSONObject();
content.put("content",mRecord);
logger.info("MARC TO JSON: " + mRecord);
//GET THE RAW MARC READY TO POST TO THE API
ByteArrayOutputStream rawBaos = new ByteArrayOutputStream();
MarcWriter writer = new MarcStreamWriter(rawBaos);
writer.write(record);
JSONObject jsonWithRaw = new JSONObject();
jsonWithRaw.put("id", instanceId);
jsonWithRaw.put("content",byteArrayOutputStream);
//CREATING JOB EXECUTION?
//TODO: I'M NOT ENTIRELY SURE IF THIS IS NECESSARY?
//WHAT THE CONSEQUENCES OF THIS ARE?
//TO POST TO SOURCE RECORD STORAGE, A SNAPSHOT ID
//SEEMS TO BE REQUIRECD
JSONObject jobExecution = new JSONObject();
jobExecution.put("jobExecutionId", snapshotId.toString());
jobExecution.put("status", "PARSING_IN_PROGRESS");
String snapShotResponse = callApiPostWithUtf8(baseOkapEndpoint + "source-storage/snapshots", jobExecution,token);
//OBJECT FOR SOURCE RECORD STORAGE API CALL:
JSONObject sourceRecordStorageObject = new JSONObject();
sourceRecordStorageObject.put("recordType", "MARC");
sourceRecordStorageObject.put("snapshotId",snapshotId.toString());
sourceRecordStorageObject.put("matchedId", instanceId.toString());
//LINK THE INSTANCE TO SOURCE RECORD STORAGE
JSONObject externalId = new JSONObject();
externalId.put("instanceId",instanceId);
sourceRecordStorageObject.put("externalIdsHolder", externalId);
//RAW RECORD
JSONObject rawRecordObject = new JSONObject();
rawRecordObject.put("id",instanceId);
rawRecordObject.put("content",jsonWithRaw.toString());
//PARSED RECORD
JSONObject parsedRecord = new JSONObject();
parsedRecord.put("id", instanceId);
parsedRecord.put("content", mRecord);
sourceRecordStorageObject.put("rawRecord", rawRecordObject);
sourceRecordStorageObject.put("parsedRecord", parsedRecord);
sourceRecordStorageObject.put("id", instanceId);
//CALL SOURCE RECORD STORAGE POST
String storageResponse = callApiPostWithUtf8(baseOkapEndpoint + "source-storage/records", sourceRecordStorageObject,token);

placeholder...Jenn to add details

=948  0$a20210308$bi$dbatch$elts$happr
=948  3$a20210308$hHarrassowitz$i20210206070047.24setblo.247148.inv.mrc

The $h in the first 948 will be appr for the approval plans (Casallini and Harrassowitz).

@cappadona
Copy link
Author

@starsplatter Now that we're stamping a full 948 as part of the vendor matrix processing, do you think that covers our bases here or do you still want to account for the 948 with a 0 for the first indicator?

@cappadona
Copy link
Author

@starsplatter We also now have more robust 948 stamping via Marc Processor task...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants