Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Changed
- [691](https://github.com/thoth-pub/thoth/issues/691) - Require a license for full KBART output, fall back to work_id for KBART title ID if no DOI available

## [[0.13.12]](https://github.com/thoth-pub/thoth/releases/tag/v0.13.12) - 2025-05-28
### Changed
Expand Down
30 changes: 26 additions & 4 deletions thoth-export-server/src/csv/kbart_oclc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct KbartOclcRow {
num_last_issue_online: Option<i64>,
title_url: String,
first_author: Option<String>,
title_id: Option<String>,
title_id: String,
embargo_info: Option<String>,
coverage_depth: String,
notes: Option<String>,
Expand Down Expand Up @@ -86,6 +86,12 @@ impl TryFrom<Work> for KbartOclcRow {
KBART_ERROR.to_string(),
"Missing Publication Date".to_string(),
))
// Don't output works with no license
} else if work.license.is_none() {
Err(ThothError::IncompleteMetadataRecord(
KBART_ERROR.to_string(),
"Missing License".to_string(),
))
} else {
let mut print_identifier = None;
let mut online_identifier = None;
Expand Down Expand Up @@ -147,7 +153,10 @@ impl TryFrom<Work> for KbartOclcRow {
num_last_issue_online: None,
title_url: work.landing_page.unwrap(),
first_author,
title_id: work.doi.map(|d| d.to_string()),
title_id: work
Comment thread
ja573 marked this conversation as resolved.
.doi
.map(|d| d.to_string())
.unwrap_or_else(|| work.work_id.to_string()),
embargo_info: None,
coverage_depth: "fulltext".to_string(),
notes: None,
Expand Down Expand Up @@ -476,9 +485,9 @@ mod tests {
KbartOclc.generate(&[test_work.clone()], QuoteStyle::Necessary, DELIMITER_TAB);
assert_eq!(to_test, Ok(test_result.to_string()));

// Remove DOI: no title_id
// Remove DOI: title_id falls back to work_id
test_work.doi = None;
test_result.title_id = "".to_string();
test_result.title_id = "00000000-0000-0000-aaaa-000000000001".to_string();
// Remove paperback publication: date_monograph_published_print (for hardback)
// still appears, but no print_identifier (paperback ISBN) is present
test_work.publications.remove(2);
Expand Down Expand Up @@ -535,5 +544,18 @@ mod tests {
"Missing Publication Date".to_string(),
))
);

// Reinstate publication date but remove license: ditto
test_work.publication_date = chrono::NaiveDate::from_ymd_opt(1999, 12, 31);
test_work.license = None;
let to_test =
KbartOclc.generate(&[test_work.clone()], QuoteStyle::Necessary, DELIMITER_TAB);
assert_eq!(
to_test,
Err(ThothError::IncompleteMetadataRecord(
KBART_ERROR.to_string(),
"Missing License".to_string(),
))
);
}
}