diff --git a/thoth-api/migrations/v0.11.19/up.sql b/thoth-api/migrations/v0.11.19/up.sql index d6fa1defe..9f2f56d91 100644 --- a/thoth-api/migrations/v0.11.19/up.sql +++ b/thoth-api/migrations/v0.11.19/up.sql @@ -1,2 +1,2 @@ ALTER TABLE imprint - ADD crossmark_doi TEXT CHECK (doi ~* 'https:\/\/doi.org\/10.\d{4,9}\/[-._\;\(\)\/:a-zA-Z0-9]+$'); + ADD COLUMN crossmark_doi TEXT CHECK (crossmark_doi ~* 'https:\/\/doi.org\/10.\d{4,9}\/[-._\;\(\)\/:a-zA-Z0-9]+$'); diff --git a/thoth-api/src/graphql/model.rs b/thoth-api/src/graphql/model.rs index 6f608b9ca..7089aa4e3 100644 --- a/thoth-api/src/graphql/model.rs +++ b/thoth-api/src/graphql/model.rs @@ -3035,10 +3035,16 @@ impl Imprint { &self.imprint_name } + #[graphql(description = "URL of the imprint's landing page")] pub fn imprint_url(&self) -> Option<&String> { self.imprint_url.as_ref() } + #[graphql(description = "DOI of the imprint's Crossmark policy page, if publisher participates. Crossmark, a service from Crossref, 'gives readers quick and easy access to the current status of an item of content, including any corrections, retractions, or updates to that record'. Learn more: https://www.crossref.org/services/crossmark/")] + pub fn crossmark_doi(&self) -> Option<&String> { + self.crossmark_doi.as_ref() + } + pub fn created_at(&self) -> Timestamp { self.created_at.clone() } diff --git a/thoth-api/src/model/imprint/mod.rs b/thoth-api/src/model/imprint/mod.rs index a87b965f8..6226ab7c7 100644 --- a/thoth-api/src/model/imprint/mod.rs +++ b/thoth-api/src/model/imprint/mod.rs @@ -27,6 +27,8 @@ pub enum ImprintField { ImprintName, #[strum(serialize = "ImprintURL")] ImprintUrl, + #[strum(serialize = "CrossmarkDOI")] + CrossmarkDOI, CreatedAt, UpdatedAt, } @@ -39,6 +41,7 @@ pub struct Imprint { pub publisher_id: Uuid, pub imprint_name: String, pub imprint_url: Option, + pub crossref_doi: Option, pub created_at: Timestamp, pub updated_at: Timestamp, } @@ -49,6 +52,7 @@ pub struct ImprintWithPublisher { pub imprint_id: Uuid, pub imprint_name: String, pub imprint_url: Option, + pub crossref_doi: Option, pub updated_at: Timestamp, pub publisher: Publisher, } @@ -62,6 +66,7 @@ pub struct NewImprint { pub publisher_id: Uuid, pub imprint_name: String, pub imprint_url: Option, + pub crossref_doi: Option, } #[cfg_attr( @@ -74,6 +79,7 @@ pub struct PatchImprint { pub publisher_id: Uuid, pub imprint_name: String, pub imprint_url: Option, + pub crossref_doi: Option, } #[cfg_attr(feature = "backend", derive(Queryable))] @@ -118,6 +124,7 @@ fn test_imprintfield_display() { assert_eq!(format!("{}", ImprintField::ImprintId), "ID"); assert_eq!(format!("{}", ImprintField::ImprintName), "Imprint"); assert_eq!(format!("{}", ImprintField::ImprintUrl), "ImprintURL"); + assert_eq!(format!("{}", ImprintField::CrossmarkDOI), "CrossmarkDOI"); assert_eq!(format!("{}", ImprintField::CreatedAt), "CreatedAt"); assert_eq!(format!("{}", ImprintField::UpdatedAt), "UpdatedAt"); } @@ -137,6 +144,10 @@ fn test_imprintfield_fromstr() { ImprintField::from_str("ImprintURL").unwrap(), ImprintField::ImprintUrl ); + assert_eq!( + ImprintField::from_str("CrossmarkDOI").unwrap(), + ImprintField::CrossmarkDOI + ); assert_eq!( ImprintField::from_str("CreatedAt").unwrap(), ImprintField::CreatedAt diff --git a/thoth-api/src/schema.rs b/thoth-api/src/schema.rs index cada1078b..795ffa493 100644 --- a/thoth-api/src/schema.rs +++ b/thoth-api/src/schema.rs @@ -189,6 +189,7 @@ table! { publisher_id -> Uuid, imprint_name -> Text, imprint_url -> Nullable, + crossmark_doi -> Nullable, created_at -> Timestamptz, updated_at -> Timestamptz, }