Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/577 complete onix 3 1 #664

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4b91be5
First commit, update changelog
brendan-oconnell Jan 2, 2025
6ef6697
Added first draft of ONIX 3.1 specification, copying from ONIX 3.0 Thoth
brendan-oconnell Jan 3, 2025
052f2e3
Updated description to reflect release 3.1.2
brendan-oconnell Jan 10, 2025
ea0b01d
Changed all references from 3.1 to 3.1.2
brendan-oconnell Jan 10, 2025
eac4d8e
Implement AffiliationIdentifier block and update tests
brendan-oconnell Jan 13, 2025
8593886
Fixed indentation for TextItem, PageRun, and NumberOfPages to include…
brendan-oconnell Jan 13, 2025
6906977
Merge with develop
brendan-oconnell Jan 20, 2025
51f52ff
Added chapter license, title, and contributions to work export. Contr…
brendan-oconnell Jan 21, 2025
05a3c16
Add biography and website to relatedWork
brendan-oconnell Jan 21, 2025
92db670
Add languages to WorkRelationsRelatedWork and update relevant tests
brendan-oconnell Jan 27, 2025
ec6492b
Add tests for Contributor and Language
brendan-oconnell Jan 27, 2025
5622122
Add abstract and copyright holder to chapter
brendan-oconnell Jan 29, 2025
4a493dc
Merge branch 'develop' into feature/577_complete_onix_3_1
brendan-oconnell Jan 29, 2025
b786769
Add references
brendan-oconnell Jan 30, 2025
52a0712
Refactor license for chapter and work
brendan-oconnell Jan 30, 2025
3032efc
Refactor title, subtitle for work and chapter
brendan-oconnell Jan 30, 2025
863572e
Add copyright, short abstract
brendan-oconnell Feb 3, 2025
660ec97
Refactor long abstract, general note
brendan-oconnell Feb 3, 2025
201b447
Fix formatter and clippy errors
brendan-oconnell Feb 3, 2025
bc03a1d
Refactor open access statement for chapter and work, correct indentat…
brendan-oconnell Feb 4, 2025
a16f0bc
Fix formatter errors
brendan-oconnell Feb 4, 2025
e736177
Update changelog
brendan-oconnell Feb 4, 2025
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]
### Added
- [577](https://github.com/thoth-pub/thoth/pull/577) - Implement ONIX 3.1.2 "Thoth" specification (i.e. complete record reflecting all updates to ONIX 3.1.2 that can be implemented based on existing data model)

## [[0.13.6]](https://github.com/thoth-pub/thoth/releases/tag/v0.13.6) - 2025-01-28
### Changed
Expand Down
9 changes: 9 additions & 0 deletions thoth-client/assets/queries.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ fragment Work on Work {
withdrawnDate
workStatus
license
copyrightHolder
shortAbstract
longAbstract
generalNote
place
firstPage
lastPage
Expand All @@ -186,9 +188,11 @@ fragment Work on Work {
firstName
lastName
fullName
biography
contributionOrdinal
contributor {
orcid
website
}
affiliations(order: {field: AFFILIATION_ORDINAL, direction: ASC}) {
position
Expand All @@ -199,6 +203,11 @@ fragment Work on Work {
}
}
}
languages {
languageCode
languageRelation
mainLanguage
}
publications {
publicationType
isbn
Expand Down
6 changes: 6 additions & 0 deletions thoth-export-server/src/bibtex/bibtex_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,10 @@ mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -501,6 +503,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
},
WorkRelations {
Expand All @@ -516,8 +519,10 @@ mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -534,6 +539,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}],
references: vec![]
Expand Down
6 changes: 6 additions & 0 deletions thoth-export-server/src/csv/csv_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,10 @@ mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -851,6 +853,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}],
references: vec![WorkReferences {
Expand Down Expand Up @@ -1162,8 +1165,10 @@ mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -1180,6 +1185,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
};
assert_eq!(
Expand Down
19 changes: 19 additions & 0 deletions thoth-export-server/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ use crate::specification::model::Specification;

lazy_static! {
pub static ref ALL_SPECIFICATIONS: Vec<Specification<'static>> = vec![
Specification {
id: "onix_3.1.2::thoth",
brendan-oconnell marked this conversation as resolved.
Show resolved Hide resolved
name: "Thoth ONIX 3.1.2",
format: concat!(env!("THOTH_EXPORT_API"), "/formats/onix_3.1.2"),
accepted_by: vec![concat!(env!("THOTH_EXPORT_API"), "/platforms/thoth"),],
},
Specification {
id: "onix_3.0::thoth",
name: "Thoth ONIX 3.0",
Expand Down Expand Up @@ -142,6 +148,10 @@ lazy_static! {
),
concat!(env!("THOTH_EXPORT_API"), "/specifications/marc21xml::thoth"),
concat!(env!("THOTH_EXPORT_API"), "/specifications/onix_3.0::thoth"),
concat!(
env!("THOTH_EXPORT_API"),
"/specifications/onix_3.1.2::thoth"
),
],
},
Platform {
Expand Down Expand Up @@ -285,6 +295,15 @@ lazy_static! {
},
];
pub(crate) static ref ALL_FORMATS: Vec<Format<'static>> = vec![
Format {
id: "onix_3.1.2",
name: "ONIX",
version: Some("3.1.2"),
specifications: vec![concat!(
env!("THOTH_EXPORT_API"),
"/specifications/onix_3.1.2::thoth"
),],
},
Format {
id: "onix_3.0",
name: "ONIX",
Expand Down
6 changes: 6 additions & 0 deletions thoth-export-server/src/json/json_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,10 @@ mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -412,6 +414,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}],
references: vec![WorkReferences {
Expand Down Expand Up @@ -767,8 +770,10 @@ mod tests {
"withdrawnDate": null,
"workStatus": "ACTIVE",
"license": null,
"copyrightHolder": null,
"shortAbstract": null,
"longAbstract": null,
"generalNote": null,
"place": null,
"firstPage": null,
"lastPage": null,
Expand All @@ -782,6 +787,7 @@ mod tests {
}
},
"contributions": [],
"languages": [],
"publications": [],
"fundings": [],
"references": []
Expand Down
9 changes: 8 additions & 1 deletion thoth-export-server/src/marc21/marc21record_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,10 @@ pub(crate) mod tests {
publication_date: None,
withdrawn_date: None,
license: None,
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: None,
first_page: None,
last_page: None,
Expand All @@ -1096,13 +1098,18 @@ pub(crate) mod tests {
first_name: Some("Chapter-One".to_string()),
last_name: "Author".to_string(),
full_name: "Chapter-One Author".to_string(),
biography: None,
contribution_ordinal: 1,
contributor: WorkRelationsRelatedWorkContributionsContributor { orcid: None },
contributor: WorkRelationsRelatedWorkContributionsContributor {
orcid: None,
website: None,
},
affiliations: vec![],
}],
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}
}
Expand Down
22 changes: 20 additions & 2 deletions thoth-export-server/src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ use crate::json::{JsonSpecification, JsonThoth};
use crate::marc21::{Marc21MarkupThoth, Marc21RecordThoth, Marc21Specification};
use crate::specification_query::SpecificationQuery;
use crate::xml::{
DoiDepositCrossref, Marc21XmlThoth, Onix21EbscoHost, Onix21ProquestEbrary, Onix3GoogleBooks,
Onix3Jstor, Onix3Oapen, Onix3Overdrive, Onix3ProjectMuse, Onix3Thoth, XmlSpecification,
DoiDepositCrossref, Marc21XmlThoth, Onix21EbscoHost, Onix21ProquestEbrary, Onix312Thoth,
Onix3GoogleBooks, Onix3Jstor, Onix3Oapen, Onix3Overdrive, Onix3ProjectMuse, Onix3Thoth,
XmlSpecification,
};

pub const DELIMITER_COMMA: u8 = b',';
Expand All @@ -29,6 +30,7 @@ pub const DOCTYPE_ONIX21_REF: &str = "<!DOCTYPE ONIXMessage SYSTEM \"http://www.

#[derive(Copy, Clone)]
pub(crate) enum MetadataSpecification {
Onix312Thoth(Onix312Thoth),
Onix3Thoth(Onix3Thoth),
Onix3ProjectMuse(Onix3ProjectMuse),
Onix3Oapen(Onix3Oapen),
Expand Down Expand Up @@ -84,6 +86,7 @@ impl MetadataRecord {

fn content_type(&self) -> &'static str {
match &self.specification {
MetadataSpecification::Onix312Thoth(_) => Self::XML_MIME_TYPE,
MetadataSpecification::Onix3Thoth(_) => Self::XML_MIME_TYPE,
MetadataSpecification::Onix3ProjectMuse(_) => Self::XML_MIME_TYPE,
MetadataSpecification::Onix3Oapen(_) => Self::XML_MIME_TYPE,
Expand All @@ -105,6 +108,7 @@ impl MetadataRecord {

fn file_name(&self) -> String {
match &self.specification {
MetadataSpecification::Onix312Thoth(_) => self.xml_file_name(),
MetadataSpecification::Onix3Thoth(_) => self.xml_file_name(),
MetadataSpecification::Onix3ProjectMuse(_) => self.xml_file_name(),
MetadataSpecification::Onix3Oapen(_) => self.xml_file_name(),
Expand Down Expand Up @@ -230,6 +234,9 @@ impl MetadataRecord {

fn generate(&self, data: Vec<Work>) -> ThothResult<String> {
match &self.specification {
MetadataSpecification::Onix312Thoth(onix312_thoth) => {
onix312_thoth.generate(&data, None)
}
MetadataSpecification::Onix3Thoth(onix3_thoth) => onix3_thoth.generate(&data, None),
MetadataSpecification::Onix3ProjectMuse(onix3_project_muse) => {
onix3_project_muse.generate(&data, None)
Expand Down Expand Up @@ -307,6 +314,7 @@ impl FromStr for MetadataSpecification {

fn from_str(input: &str) -> ThothResult<Self> {
match input {
"onix_3.1.2::thoth" => Ok(MetadataSpecification::Onix312Thoth(Onix312Thoth {})),
"onix_3.0::thoth" => Ok(MetadataSpecification::Onix3Thoth(Onix3Thoth {})),
"onix_3.0::project_muse" => {
Ok(MetadataSpecification::Onix3ProjectMuse(Onix3ProjectMuse {}))
Expand Down Expand Up @@ -345,6 +353,7 @@ impl FromStr for MetadataSpecification {
impl Display for MetadataSpecification {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
MetadataSpecification::Onix312Thoth(_) => "onix_3.1.2::thoth",
MetadataSpecification::Onix3Thoth(_) => "onix_3.0::thoth",
MetadataSpecification::Onix3ProjectMuse(_) => "onix_3.0::project_muse",
MetadataSpecification::Onix3Oapen(_) => "onix_3.0::oapen",
Expand Down Expand Up @@ -406,6 +415,15 @@ mod tests {
to_test.file_name(),
"onix_3.0__thoth__some_id.xml".to_string()
);
let to_test = MetadataRecord::new(
"some_id".to_string(),
MetadataSpecification::Onix312Thoth(Onix312Thoth {}),
timestamp,
);
assert_eq!(
to_test.file_name(),
"onix_3.1.2__thoth__some_id.xml".to_string()
);
let to_test = MetadataRecord::new(
"some_id".to_string(),
MetadataSpecification::Onix3ProjectMuse(Onix3ProjectMuse {}),
Expand Down
1 change: 1 addition & 0 deletions thoth-export-server/src/specification_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ impl TryFrom<QueryConfiguration> for QueryParameters {

fn try_from(q: QueryConfiguration) -> ThothResult<Self> {
match q.specification {
MetadataSpecification::Onix312Thoth(_) => Ok(QueryParameters::new().with_all()),
MetadataSpecification::Onix3Thoth(_) => Ok(QueryParameters::new().with_all()),
MetadataSpecification::Onix3ProjectMuse(_) => Ok(QueryParameters::new()
.with_all()
Expand Down
11 changes: 11 additions & 0 deletions thoth-export-server/src/xml/doideposit_crossref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1254,8 +1254,10 @@ mod tests {
publication_date: chrono::NaiveDate::from_ymd_opt(2000, 2, 28),
withdrawn_date: None,
license: Some("https://creativecommons.org/licenses/by-nd/4.0/".to_string()),
copyright_holder: None,
short_abstract: Some("A shorter abstract".to_string()),
long_abstract: Some("First paragraph.\n\nSecond paragraph.".to_string()),
general_note: None,
place: Some("Other Place".to_string()),
first_page: Some("10".to_string()),
last_page: Some("20".to_string()),
Expand All @@ -1275,11 +1277,13 @@ mod tests {
first_name: Some("Chapter One".to_string()),
last_name: "Author".to_string(),
full_name: "Chapter One Author".to_string(),
biography: None,
contribution_ordinal: 1,
contributor: WorkRelationsRelatedWorkContributionsContributor {
orcid: Some(
Orcid::from_str("https://orcid.org/0000-0002-0000-0011").unwrap(),
),
website: None,
},
affiliations: vec![WorkRelationsRelatedWorkContributionsAffiliations {
position: None,
Expand All @@ -1300,6 +1304,7 @@ mod tests {
}],
references: vec![],
fundings: vec![],
languages: vec![],
},
};

Expand Down Expand Up @@ -1711,8 +1716,10 @@ mod tests {
publication_date: chrono::NaiveDate::from_ymd_opt(2000, 2, 28),
withdrawn_date: None,
license: Some("https://creativecommons.org/licenses/by-nd/4.0/".to_string()),
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: Some("Other Place".to_string()),
first_page: Some("10".to_string()),
last_page: Some("20".to_string()),
Expand All @@ -1729,6 +1736,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}],
references: vec![WorkReferences {
Expand Down Expand Up @@ -1924,8 +1932,10 @@ mod tests {
publication_date: chrono::NaiveDate::from_ymd_opt(1997, 2, 28),
withdrawn_date: chrono::NaiveDate::from_ymd_opt(1998, 2, 28),
license: Some("https://creativecommons.org/licenses/by-nd/4.0/".to_string()),
copyright_holder: None,
short_abstract: None,
long_abstract: None,
general_note: None,
place: Some("Other Place".to_string()),
first_page: Some("10".to_string()),
last_page: Some("20".to_string()),
Expand All @@ -1942,6 +1952,7 @@ mod tests {
publications: vec![],
references: vec![],
fundings: vec![],
languages: vec![],
},
}];
let output = generate_test_output(true, &test_work);
Expand Down
Loading