Skip to content

Commit

Permalink
Merge pull request #1279 from emory-libraries/create_record_xml_refer…
Browse files Browse the repository at this point in the history
…ence_document_1278
  • Loading branch information
abelemlih authored Jul 12, 2022
2 parents 542616d + e52c968 commit a0c4969
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/statusable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ def items_by_holding_values(holding_id, user = nil)
description: node.xpath("following-sibling::item_data/description")&.inner_text,
status: node.xpath('following-sibling::item_data/base_status').attr("desc")&.value,
temporarily_located: node.xpath('in_temp_location')&.inner_text,
temp_library: node.xpath('temp_library').attr('desc')&.value,
temp_location: node.xpath('temp_location').attr('desc')&.value
temp_library: node.xpath('temp_library')&.inner_text,
temp_location: node.xpath('temp_location')&.inner_text
}
end
end
Expand Down
56 changes: 56 additions & 0 deletions app/views/catalog/SHOW_XML_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# A Catalog Record's XML Reference

## Summary

The template for displaying a catalog record's XML document uses two different sources: the record's SOLR document, which is created by indexing and parsing the response for that item's OAI record from Alma, and the data retrieved from a call to Alma's Real-Time Availability API. The information from the OAI is processed whenever a manual indexing is performed or picked up after changes to the Alma record have been committed by one of the four daily automatic, incremental indexings. The values taken from the Real-Time API call are processed the moment the record is requested for viewing (XML or HTML.)

## Breakdown of XML Values' Origins

- "title": A value stored in the record's SOLR document, which originates from the Alma's OAI field of "245" and is formed by combining that datafield's subfield strings from "a", "b", "f", "g", "k", "n", "p", and "s", and stripping away the end punctuation.
- "author": The first author stored in the record's SOLR document derived from either of the following combinations of datafields/subfields (and stripping away the end punctuation):
- Datafield "100" and subfields "a", "b", "c", "d", "g", "q", and "e", in that order.
- Datafield "110" and subfields "a", "b", "c", "d", "g", "n", and "e", in that order.
- Datafield "111" and subfields "a", "c", "d", "e", "g", "j", "n", "q", and "j", in that order.
- "is\_physical\_holding": Another value pulled from the SOLR document. This value is set to "true" by the following logic:
- An OAI field of "997" with the subfield of "b" is present, OR
- The above field isn't present, and neither are "998" with the subfield "c" containing the string of "available" (down cased) or "856" with a field indicator 2 of "0", "1", or not "2" and subfields "z" or "3" that do not contain the strings "abstract", "description", "sample text", or "table of contents", AND the record's leader field, seventh position, contains either "e", "f", "g", "k", "o", or "r", as well as "008"'s value at the thirtieth position not equaling "o" or "s", OR the record's leader field, seventh position, not containing either "e", "f", "g", "k", "o", or "r" and the twenty-fourth position of "008" not containing "o" or "s".
- "is\_electronic\_holding: Pulled from the SOLR document, this is set to "true" by the logic below:
- The datafield "998" with the subfield "c" containing the string of "available" (down cased) or "856" with a field indicator 2 of "0", "1", or not "2" and subfields "z" or "3" that do not contain the strings "abstract", "description", "sample text", or "table of contents", OR
- The above field isn't present, and neither is "997" with the subfield of "b" AND the record's leader field, seventh position, contains either "e", "f", "g", "k", "o", or "r" and "008"'s value at the thirtieth position equaling "o" or "s" OR the record's leader field, seventh position, not containing either "e", "f", "g", "k", "o", or "r" and the twenty-fourth position of "008" containing "o" or "s".
- "edition": The first value taken from the SOLR document fed by extracting values from OAI datafields "250", subfield "a" or "254", subfield "a".
- "physical\_description": A SOLR document value processed from scraping the values of OAI datafield "300", subfields "a", "b", "c", "e", and "f".
- "publisher": This SOLR document value is pulled by presenting the very first item that exists in the fields below, ordered by priority:
- Datafield "264", subfield "b"
- Datafield "260", subfield "b"
- Datafield "502", subfield "c"
- "publication\_date": This is, once again, a value taken from the SOLR document for the record. The customized logic used to pull this value is quite extensive and could warrant a document this size just to explain the processing used to extract this data. Below are summary points for this value:
- This displays only the starting year of publication, taken from datafield "008", pulling a four-digit value from positions eight through eleven.
- If the value derived from the positions above proves to be out of the range of what is deemed acceptable by Product Owners, the extraction defaults to the logic provided by our extraction tool, which is based off MARC Standards.
- "isbn": SOLR document value generated by pulling the value from the OAI record's "020" datafield, subfield "a". It goes through standardization provided by our extraction tool, which always returns the thirteen-digit code if it's available.
- "issn": A value that lives in the SOLR document that is pulled from the first OAI field listed below that produces a result:
- "022", subfield "a"
- "022", subfield "y"
- "800", subfield "x"
- "810", subfield "x"
- "811", subfield "x"
- "830", subfield "x"
- "supplemental\_links": This is still derived from the SOLR document. In this case, multiple values stored will display separately as elements wrapped in "supplemental\_link".
- These values are pulled from the OAI datafield "856" that only have a field indicator 2 value that is either blank, "0", "1", or "2", and contains a path string in subfield "u".
- That mentioned subfield "u" feeds the XML "link" element.
- The "label" element is derived from the first available subfields of "y", "3", or "z".
- When the field indicator 2 equals either "0" or "1", the value taken from that list of possible subfields above must not be nil or deviate from the list of approved labels (down cased): "table of contents", "table of contents only", "publisher description", "cover image", or "contributor biographical information".
- If the label value in the SOLR document is empty (which can happen when the field indicator 2 equals "2"), the path string is provided in the "label" element instead.
- 'physical\_holdings": This group of elements is processed from the Real-Time API provided by Alma.
- A "physical\_holding" is produced for each "holding" with a positive number of "items" in the resulting API response.
- "call\_number": This is taken from the response's datafield "AVA", subfield "d".
- "items": a grouping element that contains all the holding's Items.
- "item"
- "library": This depends on whether the item's "in\_temp\_location" field is populated with "true".
- If it is, the value will be taken from the item's "temp\_library" field.
- Else, it will populate the "AVA", subfield "b" value.
- "location": This also depends on whether the item's "in\_temp\_location" field is populated with "true".
- If yes, then this will return the value in "temp\_location" of the item.
- Else, "AVA", subfield "j".
- "barcode": filled by the "item\_data"/"barcode" field.
- "volume\_or\_issue": parsed from the "item\_data"/"description" inner text.
- "status": pulled from "item\_data"/"base\_status".
4 changes: 2 additions & 2 deletions app/views/catalog/_physical_holding.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ if ph[:items].size.positive?
xml.items do
ph[:items]&.each do |i|
xml.item do
xml.library ActiveModel::Type::Boolean.new.cast(i[:temporarily_located]) ? i[:temp_library] : ph[:library][:label]
xml.location ActiveModel::Type::Boolean.new.cast(i[:temporarily_located]) ? i[:temp_location] : ph[:location][:label]
xml.library ActiveModel::Type::Boolean.new.cast(i[:temporarily_located]) ? i[:temp_library] : ph[:library][:value]
xml.location ActiveModel::Type::Boolean.new.cast(i[:temporarily_located]) ? i[:temp_location] : ph[:location][:value]
xml.barcode i[:barcode]
xml.volume_or_issue i[:description]
xml.status i[:status]
Expand Down
1 change: 1 addition & 0 deletions app/views/catalog/show.xml.builder
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ xml.document do
xml.is_physical_holding @document['marc_resource_ssim']&.include?('At the Library')
xml.is_electronic_holding @document['marc_resource_ssim']&.include?('Online')
xml.edition @document['edition_tsim']&.first
xml.physical_description @document['material_type_display_tesim']&.first
xml.publisher @document['published_tesim']&.first
xml.publication_date @document['pub_date_isim']&.first
xml.isbn @document['isbn_ssim']&.first
Expand Down
4 changes: 2 additions & 2 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
barcode: "010002752069", type: "Bound Issue", pid: "23236301160002486",
policy: { policy_desc: "30 Day Loan Storage", policy_id: "17", due_date_policy: "28 Days Loan" },
description: "v.75(2013)", status: "Item in place", type_code: "ISSBD",
temp_library: nil, temp_location: nil, temporarily_located: "false"
temp_library: "", temp_location: "", temporarily_located: "false"
}
)
expect(solr_doc.hold_requestable?).to eq true
Expand All @@ -192,7 +192,7 @@
barcode: "010002752069", type: "Bound Issue", pid: "23236301160002486",
policy: { policy_desc: "30 Day Loan Storage", policy_id: "17", due_date_policy: "Loanable" },
description: "v.75(2013)", status: "Item in place", type_code: "ISSBD",
temp_library: nil, temp_location: nil, temporarily_located: "false"
temp_library: "", temp_location: "", temporarily_located: "false"
}
)
expect(solr_doc.hold_requestable?).to eq true
Expand Down
9 changes: 5 additions & 4 deletions spec/system/view_show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,13 @@
let(:expected_values_arr) do
[['//title', 'The Title of my Work'], ['//author', 'George Jenkins'], ['//edition', 'A sample edition'],
['//is_physical_holding', 'false'], ['//is_electronic_holding', 'false'],
['//publisher', ''], ['//publication_date', '2015'], ['//isbn', 'SOME MAGICAL NUM .66G'],
['//issn', 'SOME OTHER MAGICAL NUMBER .12Q'], ['//supplemental_links//supplemental_link//link', 'http://www.example.com'],
['//physical_description', '1 online resource (111 pages)'], ['//publisher', ''],
['//publication_date', '2015'], ['//isbn', 'SOME MAGICAL NUM .66G'], ['//issn', 'SOME OTHER MAGICAL NUMBER .12Q'],
['//supplemental_links//supplemental_link//link', 'http://www.example.com'],
['//supplemental_links//supplemental_link//label', 'http://www.example.com'],
['//physical_holdings//physical_holding//call_number', 'PT2613 .M45 Z92 2006'],
['//physical_holdings//physical_holding//library', 'Robert W. Woodruff Library'],
['//physical_holdings//physical_holding//location', 'Book Stacks'], ['//physical_holdings//physical_holding//items//item//barcode', '010001233671'],
['//physical_holdings//physical_holding//library', 'UNIV'],
['//physical_holdings//physical_holding//location', 'STACK'], ['//physical_holdings//physical_holding//items//item//barcode', '010001233671'],
['//physical_holdings//physical_holding//items/item//volume_or_issue', ''],
['//physical_holdings//physical_holding//items/item//status', 'Item in place']]
end
Expand Down

0 comments on commit a0c4969

Please sign in to comment.