From a24386b127ce4e7c06bf5ec9373cf033922a5091 Mon Sep 17 00:00:00 2001 From: Brendan OConnell Date: Fri, 23 Feb 2024 10:25:50 +0100 Subject: [PATCH] Updated onix3_google_books.rs to allow BIC, BISAC or LCC Subject codes, onix3_jstor.rs to only allow BISAC codes --- .../src/xml/onix3_google_books.rs | 10 +++++----- thoth-export-server/src/xml/onix3_jstor.rs | 16 ++++++++-------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/thoth-export-server/src/xml/onix3_google_books.rs b/thoth-export-server/src/xml/onix3_google_books.rs index 013adea2..1b89bbec 100644 --- a/thoth-export-server/src/xml/onix3_google_books.rs +++ b/thoth-export-server/src/xml/onix3_google_books.rs @@ -66,16 +66,16 @@ impl XmlSpecification for Onix3GoogleBooks { impl XmlElementBlock for Work { fn xml_element(&self, w: &mut EventWriter) -> ThothResult<()> { - // Don't output works with no BIC or BISAC subject code + // Don't output works with no BIC, BISAC or LCC subject code // Google Books can only ingest works which have at least one if !self .subjects .iter() - .any(|s| matches!(s.subject_type, SubjectType::BISAC | SubjectType::BIC)) + .any(|s| matches!(s.subject_type, SubjectType::BISAC | SubjectType::BIC | SubjectType::LCC)) { return Err(ThothError::IncompleteMetadataRecord( ONIX_ERROR.to_string(), - "No BIC or BISAC subject code".to_string(), + "No BIC, BISAC or LCC subject code".to_string(), )); } // Don't output works with no publication date (mandatory in Google Books) @@ -1117,12 +1117,12 @@ mod tests { assert!(!output.contains(r#" 1. Chapter 1"#)); // Remove all subjects - // Result: error (can't generate Google Books ONIX without either a BIC or BISAC subject) + // Result: error (can't generate Google Books ONIX without a BIC, BISAC, or LCC subject) test_work.subjects.clear(); let output = generate_test_output(false, &test_work); assert_eq!( output, - "Could not generate onix_3.0::google_books: No BIC or BISAC subject code".to_string() + "Could not generate onix_3.0::google_books: No BIC, BISAC or LCC subject code".to_string() ); // Reinstate the BIC subject but remove publication date: result is error diff --git a/thoth-export-server/src/xml/onix3_jstor.rs b/thoth-export-server/src/xml/onix3_jstor.rs index 3c971ae0..9026627e 100644 --- a/thoth-export-server/src/xml/onix3_jstor.rs +++ b/thoth-export-server/src/xml/onix3_jstor.rs @@ -60,16 +60,16 @@ impl XmlSpecification for Onix3Jstor { impl XmlElementBlock for Work { fn xml_element(&self, w: &mut EventWriter) -> ThothResult<()> { - // Don't output works with no BIC or BISAC subject code + // Don't output works with no BISAC subject code // JSTOR can only ingest works which have at least one if !self .subjects .iter() - .any(|s| matches!(s.subject_type, SubjectType::BISAC | SubjectType::BIC)) + .any(|s| matches!(s.subject_type, SubjectType::BISAC)) { return Err(ThothError::IncompleteMetadataRecord( ONIX_ERROR.to_string(), - "No BIC or BISAC subject code".to_string(), + "No BISAC subject code".to_string(), )); } // We can only generate the document if there's a PDF @@ -1031,19 +1031,19 @@ mod tests { assert!(!output.contains(r#" 9781402894626"#)); // Remove all subjects - // Result: error (can't generate JSTOR ONIX without either a BIC or BISAC subject) + // Result: error (can't generate JSTOR ONIX without a BISAC subject) test_work.subjects.clear(); let output = generate_test_output(false, &test_work); assert_eq!( output, - "Could not generate onix_3.0::jstor: No BIC or BISAC subject code".to_string() + "Could not generate onix_3.0::jstor: No BISAC subject code".to_string() ); - // Reinstate the BIC subject but remove the only publication, which is the PDF + // Reinstate the BISAC subject but remove the only publication, which is the PDF // Result: error (can't generate JSTOR ONIX without PDF URL) test_work.subjects = vec![WorkSubjects { - subject_code: "AAB".to_string(), - subject_type: SubjectType::BIC, + subject_code: "AAA000000".to_string(), + subject_type: SubjectType::BISAC, subject_ordinal: 1, }]; test_work.publications.clear();