From 1366e77295bacf1f50f351625f6f0dcfcda10efc Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 08:36:16 +0000 Subject: [PATCH 1/6] Do not hard-code ProductAvailability --- thoth-export-server/src/xml/onix3_thoth.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/thoth-export-server/src/xml/onix3_thoth.rs b/thoth-export-server/src/xml/onix3_thoth.rs index 10c74de1..38941347 100644 --- a/thoth-export-server/src/xml/onix3_thoth.rs +++ b/thoth-export-server/src/xml/onix3_thoth.rs @@ -924,9 +924,18 @@ impl XmlElementBlock for Work { } Ok(()) })?; - // 99 Contact supplier write_element_block("ProductAvailability", w, |w| { - w.write(XmlEvent::Characters("99")).map_err(|e| e.into()) + let availability = match self.work_status { + WorkStatus::CANCELLED => "01", // 01 – Cancelled + WorkStatus::FORTHCOMING => "10", // 10 – Not yet available + WorkStatus::POSTPONED_INDEFINITELY => "09", // 09 – Not yet available, postponed indefinitely + WorkStatus::ACTIVE => "20", // 20 – Available + WorkStatus::SUPERSEDED => "41", // 41 – Not available, replaced by new product + WorkStatus::WITHDRAWN => "49", // 49 – Recalled + WorkStatus::Other(_) => unreachable!(), + }; + w.write(XmlEvent::Characters(availability)) + .map_err(|e| e.into()) })?; if let Some(date) = &self.publication_date { write_element_block("SupplyDate", w, |w| { @@ -2836,7 +2845,7 @@ mod tests { https://www.book.com/pb_landing - 99 + 20 08 19991231 From 061161c2376de6750abd8ab60ab532cb9903e433 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 08:37:49 +0000 Subject: [PATCH 2/6] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1803f630..0ab385a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 + - [642](https://github.com/thoth-pub/thoth/issues/642) - Output `ProductAvailability` based on work status in Thoth ONIX 3.0 ## [[0.12.13]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.13) - 2024-10-23 ### Fixed From 97bf5fcdc25ecc774e44a545450cbb3f1beaec78 Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 08:41:26 +0000 Subject: [PATCH 3/6] Assume lack of pricing means free --- thoth-export-server/src/xml/onix3_thoth.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/thoth-export-server/src/xml/onix3_thoth.rs b/thoth-export-server/src/xml/onix3_thoth.rs index 38941347..34c5870c 100644 --- a/thoth-export-server/src/xml/onix3_thoth.rs +++ b/thoth-export-server/src/xml/onix3_thoth.rs @@ -958,9 +958,9 @@ impl XmlElementBlock for Work { })?; } if publication.prices.is_empty() { - // 04 Contact supplier + // 01 Free of charge write_element_block("UnpricedItemType", w, |w| { - w.write(XmlEvent::Characters("04")).map_err(|e| e.into()) + w.write(XmlEvent::Characters("01")).map_err(|e| e.into()) }) } else { for price in &publication.prices { @@ -3366,7 +3366,7 @@ mod tests { "# )); // UnpricedItemType block instead of any Prices - assert!(output.contains(r#" 04"#)); + assert!(output.contains(r#" 01"#)); assert!(!output.contains(r#" "#)); // Remove chapter DOI: can't output ContentDetail block From eae2726425fe1e110bb5cf859a0b9faabad855cf Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 08:42:39 +0000 Subject: [PATCH 4/6] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ab385a1..88dc87f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed - [642](https://github.com/thoth-pub/thoth/issues/642) - Output `ProductAvailability` based on work status in Thoth ONIX 3.0 + - [642](https://github.com/thoth-pub/thoth/issues/642) - Use `UnpricedItemType` code `01` (Free of charge) for unpriced products in Thoth ONIX 3.0 + ## [[0.12.13]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.13) - 2024-10-23 ### Fixed From 7eec6e9aeaa87208b832b22ae951ebd97d76eaba Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 10:19:16 +0000 Subject: [PATCH 5/6] Bump v0.12.14 --- Cargo.lock | 16 ++++++++-------- Cargo.toml | 12 ++++++------ thoth-api-server/Cargo.toml | 6 +++--- thoth-api/Cargo.toml | 4 ++-- thoth-app-server/Cargo.toml | 2 +- thoth-app/Cargo.toml | 6 +++--- thoth-client/Cargo.toml | 8 ++++---- thoth-errors/Cargo.toml | 2 +- thoth-export-server/Cargo.toml | 8 ++++---- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 30318ea6..5a57063b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3182,7 +3182,7 @@ dependencies = [ [[package]] name = "thoth" -version = "0.12.13" +version = "0.12.14" dependencies = [ "cargo-husky", "clap", @@ -3197,7 +3197,7 @@ dependencies = [ [[package]] name = "thoth-api" -version = "0.12.13" +version = "0.12.14" dependencies = [ "actix-web", "argon2rs", @@ -3226,7 +3226,7 @@ dependencies = [ [[package]] name = "thoth-api-server" -version = "0.12.13" +version = "0.12.14" dependencies = [ "actix-cors", "actix-identity", @@ -3242,7 +3242,7 @@ dependencies = [ [[package]] name = "thoth-app" -version = "0.12.13" +version = "0.12.14" dependencies = [ "anyhow", "chrono", @@ -3271,7 +3271,7 @@ dependencies = [ [[package]] name = "thoth-app-server" -version = "0.12.13" +version = "0.12.14" dependencies = [ "actix-cors", "actix-web", @@ -3281,7 +3281,7 @@ dependencies = [ [[package]] name = "thoth-client" -version = "0.12.13" +version = "0.12.14" dependencies = [ "chrono", "graphql_client", @@ -3297,7 +3297,7 @@ dependencies = [ [[package]] name = "thoth-errors" -version = "0.12.13" +version = "0.12.14" dependencies = [ "actix-web", "csv", @@ -3318,7 +3318,7 @@ dependencies = [ [[package]] name = "thoth-export-server" -version = "0.12.13" +version = "0.12.14" dependencies = [ "actix-cors", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index c7bebaa1..5917c59d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -16,11 +16,11 @@ maintenance = { status = "actively-developed" } members = ["thoth-api", "thoth-api-server", "thoth-app", "thoth-app-server", "thoth-client", "thoth-errors", "thoth-export-server"] [dependencies] -thoth-api = { version = "=0.12.13", path = "thoth-api", features = ["backend"] } -thoth-api-server = { version = "=0.12.13", path = "thoth-api-server" } -thoth-app-server = { version = "=0.12.13", path = "thoth-app-server" } -thoth-errors = { version = "=0.12.13", path = "thoth-errors" } -thoth-export-server = { version = "=0.12.13", path = "thoth-export-server" } +thoth-api = { version = "=0.12.14", path = "thoth-api", features = ["backend"] } +thoth-api-server = { version = "=0.12.14", path = "thoth-api-server" } +thoth-app-server = { version = "=0.12.14", path = "thoth-app-server" } +thoth-errors = { version = "=0.12.14", path = "thoth-errors" } +thoth-export-server = { version = "=0.12.14", path = "thoth-export-server" } clap = { version = "4.5.16", features = ["cargo", "env"] } dialoguer = { version = "0.11.0", features = ["password"] } dotenv = "0.15.0" diff --git a/thoth-api-server/Cargo.toml b/thoth-api-server/Cargo.toml index 1ffc407d..06fb4fcb 100644 --- a/thoth-api-server/Cargo.toml +++ b/thoth-api-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api-server" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -9,8 +9,8 @@ repository = "https://github.com/thoth-pub/thoth" readme = "README.md" [dependencies] -thoth-api = { version = "=0.12.13", path = "../thoth-api", features = ["backend"] } -thoth-errors = { version = "=0.12.13", path = "../thoth-errors" } +thoth-api = { version = "=0.12.14", path = "../thoth-api", features = ["backend"] } +thoth-errors = { version = "=0.12.14", path = "../thoth-errors" } actix-web = "4.9" actix-cors = "0.7.0" actix-identity = "0.7.1" diff --git a/thoth-api/Cargo.toml b/thoth-api/Cargo.toml index df89a588..d3703fbf 100644 --- a/thoth-api/Cargo.toml +++ b/thoth-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-api" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -16,7 +16,7 @@ maintenance = { status = "actively-developed" } backend = ["diesel", "diesel-derive-enum", "diesel_migrations", "futures", "actix-web", "jsonwebtoken"] [dependencies] -thoth-errors = { version = "=0.12.13", path = "../thoth-errors" } +thoth-errors = { version = "=0.12.14", path = "../thoth-errors" } actix-web = { version = "4.8", optional = true } argon2rs = "0.2.5" isbn2 = "0.4.0" diff --git a/thoth-app-server/Cargo.toml b/thoth-app-server/Cargo.toml index 654da282..7ace5432 100644 --- a/thoth-app-server/Cargo.toml +++ b/thoth-app-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app-server" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" diff --git a/thoth-app/Cargo.toml b/thoth-app/Cargo.toml index f6333d7b..0119b6c9 100644 --- a/thoth-app/Cargo.toml +++ b/thoth-app/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-app" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -36,8 +36,8 @@ uuid = { version = "1.10.0", features = ["serde", "v4"] } # `getrandom` is a dependency of `uuid`, we need to explicitly import and include the `js` feature to enable wasm # https://docs.rs/getrandom/latest/getrandom/#webassembly-support getrandom = { version = "0.2", features = ["js"] } -thoth-api = { version = "=0.12.13", path = "../thoth-api" } -thoth-errors = { version = "=0.12.13", path = "../thoth-errors" } +thoth-api = { version = "=0.12.14", path = "../thoth-api" } +thoth-errors = { version = "=0.12.14", path = "../thoth-errors" } [build-dependencies] dotenv = "0.15.0" diff --git a/thoth-client/Cargo.toml b/thoth-client/Cargo.toml index de8f812f..ce6e3e1c 100644 --- a/thoth-client/Cargo.toml +++ b/thoth-client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-client" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -10,8 +10,8 @@ readme = "README.md" build = "build.rs" [dependencies] -thoth-api = {version = "=0.12.13", path = "../thoth-api" } -thoth-errors = {version = "=0.12.13", path = "../thoth-errors" } +thoth-api = {version = "=0.12.14", path = "../thoth-api" } +thoth-errors = {version = "=0.12.14", path = "../thoth-errors" } graphql_client = "0.14.0" chrono = { version = "0.4.38", features = ["serde"] } reqwest = { version = "0.12", features = ["json"] } @@ -22,4 +22,4 @@ serde_json = "1.0" uuid = { version = "1.10.0", features = ["serde"] } [build-dependencies] -thoth-api = { version = "=0.12.13", path = "../thoth-api", features = ["backend"] } +thoth-api = { version = "=0.12.14", path = "../thoth-api", features = ["backend"] } diff --git a/thoth-errors/Cargo.toml b/thoth-errors/Cargo.toml index afabe0e5..dfce7b1e 100644 --- a/thoth-errors/Cargo.toml +++ b/thoth-errors/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-errors" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" diff --git a/thoth-export-server/Cargo.toml b/thoth-export-server/Cargo.toml index a5d32396..e53a5bb2 100644 --- a/thoth-export-server/Cargo.toml +++ b/thoth-export-server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "thoth-export-server" -version = "0.12.13" +version = "0.12.14" authors = ["Javier Arias ", "Ross Higman "] edition = "2021" license = "Apache-2.0" @@ -10,9 +10,9 @@ readme = "README.md" build = "build.rs" [dependencies] -thoth-api = { version = "=0.12.13", path = "../thoth-api" } -thoth-errors = { version = "=0.12.13", path = "../thoth-errors" } -thoth-client = { version = "=0.12.13", path = "../thoth-client" } +thoth-api = { version = "=0.12.14", path = "../thoth-api" } +thoth-errors = { version = "=0.12.14", path = "../thoth-errors" } +thoth-client = { version = "=0.12.14", path = "../thoth-client" } actix-web = "4.9" actix-cors = "0.7.0" cc_license = "0.1.0" From e71d5ae719d23ed65ffd5c70ead37922f4a09a2e Mon Sep 17 00:00:00 2001 From: Javier Arias Date: Mon, 4 Nov 2024 10:19:52 +0000 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88dc87f0..6a074f77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,11 +5,12 @@ 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] + +## [[0.12.14]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.14) - 2024-11-04 ### Changed - [642](https://github.com/thoth-pub/thoth/issues/642) - Output `ProductAvailability` based on work status in Thoth ONIX 3.0 - [642](https://github.com/thoth-pub/thoth/issues/642) - Use `UnpricedItemType` code `01` (Free of charge) for unpriced products in Thoth ONIX 3.0 - ## [[0.12.13]](https://github.com/thoth-pub/thoth/releases/tag/v0.12.13) - 2024-10-23 ### Fixed - [639](https://github.com/thoth-pub/thoth/issues/639) - Make new locations canonical by default