From 7ac4d6cf82d98253a12879313fecfb1e32457547 Mon Sep 17 00:00:00 2001 From: rhigman <73792779+rhigman@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:21:07 +0000 Subject: [PATCH 1/3] Extend csv_thoth output to include recent data model enhancements (references, etc) --- thoth-export-server/src/csv/csv_thoth.rs | 189 +++++++++++++++++++---- 1 file changed, 159 insertions(+), 30 deletions(-) diff --git a/thoth-export-server/src/csv/csv_thoth.rs b/thoth-export-server/src/csv/csv_thoth.rs index 77185d33..de3369b6 100644 --- a/thoth-export-server/src/csv/csv_thoth.rs +++ b/thoth-export-server/src/csv/csv_thoth.rs @@ -4,7 +4,7 @@ use std::io::Write; use thoth_client::{ SubjectType, Work, WorkContributions, WorkContributionsAffiliations, WorkFundings, WorkIssues, WorkLanguages, WorkPublications, WorkPublicationsLocations, WorkPublicationsPrices, - WorkRelations, WorkSubjects, + WorkReferences, WorkRelations, WorkSubjects, }; use thoth_errors::ThothResult; @@ -46,7 +46,7 @@ struct CsvThothRow { cover_url: Option, cover_caption: Option, #[serde( - rename = "contributions [(type, first_name, last_name, full_name, orcid, [(position, ordinal, institution)])]" + rename = "contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, [(position, ordinal, institution, ror)])]" )] contributions: String, #[serde( @@ -59,24 +59,28 @@ struct CsvThothRow { series: String, #[serde(rename = "languages [(relation, ISO_639-3/B_language, is_main)]")] languages: String, - #[serde(rename = "BIC [code]")] + #[serde(rename = "BIC [(code, ordinal)]")] bic: String, - #[serde(rename = "THEMA [code]")] + #[serde(rename = "THEMA [(code, ordinal)]")] thema: String, - #[serde(rename = "BISAC [code]")] + #[serde(rename = "BISAC [(code, ordinal)]")] bisac: String, - #[serde(rename = "LCC [code]")] + #[serde(rename = "LCC [(code, ordinal)]")] lcc: String, - #[serde(rename = "custom_categories [category]")] + #[serde(rename = "custom_categories [(category, ordinal)]")] custom: String, - #[serde(rename = "keywords [keyword]")] + #[serde(rename = "keywords [(keyword, ordinal)]")] keywords: String, #[serde( rename = "funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]" )] funding: String, - #[serde(rename = "relations [(related_work, relation_type, ordinal)]")] + #[serde(rename = "relations [(related_work, doi, relation_type, ordinal)]")] relations: String, + #[serde( + rename = "references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, date)]" + )] + references: String, } impl CsvSpecification for CsvThoth { @@ -214,6 +218,13 @@ impl From for CsvThothRow { .map(CsvCell::::csv_cell) .collect::>(), ), + references: CsvCell::::csv_cell( + &work + .references + .iter() + .map(CsvCell::::csv_cell) + .collect::>(), + ), } } } @@ -302,11 +313,14 @@ impl CsvCell for WorkPublications { impl CsvCell for WorkContributions { fn csv_cell(&self) -> String { format!( - "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", + "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", self.contribution_type, self.first_name.clone().unwrap_or_default(), self.last_name, self.full_name, + self.main_contribution, + self.biography.clone().unwrap_or_default(), + self.contribution_ordinal, self.contributor .orcid .as_ref() @@ -344,10 +358,15 @@ impl CsvCell for WorkPublicationsLocations { impl CsvCell for WorkContributionsAffiliations { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{}\", \"{}\")", + "(\"{}\", \"{}\", \"{}\", \"{}\")", self.position.clone().unwrap_or_default(), self.affiliation_ordinal, self.institution.institution_name, + self.institution + .ror + .as_ref() + .map(|r| r.to_string()) + .unwrap_or_default(), ) } } @@ -379,7 +398,7 @@ impl CsvCell for WorkLanguages { impl CsvCell for WorkSubjects { fn csv_cell(&self) -> String { - format!("{:?}", self.subject_code) + format!("(\"{}\", \"{}\")", self.subject_code, self.subject_ordinal,) } } @@ -414,8 +433,41 @@ impl CsvCell for WorkFundings { impl CsvCell for WorkRelations { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{:?}\", \"{}\")", - self.related_work.full_title, self.relation_type, self.relation_ordinal, + "(\"{}\", \"{}\", \"{:?}\", \"{}\")", + self.related_work.full_title, + self.related_work + .doi + .as_ref() + .map(|d| d.to_string()) + .unwrap_or_default(), + self.relation_type, + self.relation_ordinal, + ) + } +} + +impl CsvCell for WorkReferences { + fn csv_cell(&self) -> String { + format!( + "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", + self.reference_ordinal, + self.doi.as_ref().map(|d| d.to_string()).unwrap_or_default(), + self.unstructured_citation.clone().unwrap_or_default(), + self.issn.clone().unwrap_or_default(), + self.isbn.as_ref().map(|i| i.to_string()).unwrap_or_default(), + self.journal_title.clone().unwrap_or_default(), + self.article_title.clone().unwrap_or_default(), + self.series_title.clone().unwrap_or_default(), + self.volume_title.clone().unwrap_or_default(), + self.edition.as_ref().map(|e| e.to_string()).unwrap_or_default(), + self.author.clone().unwrap_or_default(), + self.volume.clone().unwrap_or_default(), + self.issue.clone().unwrap_or_default(), + self.first_page.clone().unwrap_or_default(), + self.component_number.clone().unwrap_or_default(), + self.standard_designator.clone().unwrap_or_default(), + self.standards_body_name.clone().unwrap_or_default(), + self.publication_date.map(|d| d.to_string()).unwrap_or_default(), ) } } @@ -500,7 +552,7 @@ mod tests { last_name: "1".to_string(), full_name: "Author 1".to_string(), main_contribution: true, - biography: None, + biography: Some("Author 1 is an author".to_string()), contribution_ordinal: 1, contributor: WorkContributionsContributor { orcid: Some(Orcid::from_str("https://orcid.org/0000-0002-0000-0001").unwrap()), @@ -511,7 +563,7 @@ mod tests { affiliation_ordinal: 1, institution: WorkContributionsAffiliationsInstitution { institution_name: "University of Life".to_string(), - ror: None, + ror: Some(Ror::from_str("https://ror.org/0abcdef12").unwrap()), }, }, ], @@ -746,7 +798,7 @@ mod tests { title: "N/A".to_string(), subtitle: None, edition: None, - doi: None, + doi: Some(Doi::from_str("https://doi.org/10.00001/RELATION.0001").unwrap()), publication_date: None, license: None, short_abstract: None, @@ -766,12 +818,32 @@ mod tests { fundings: vec![], }, }], - references: vec![] + references: vec![WorkReferences { + reference_ordinal: 1, + doi: Some(Doi::from_str("https://doi.org/10.00001/reference").unwrap()), + unstructured_citation: Some("Author, A. (2022) Article, Journal.".to_string()), + issn: Some("1111-2222".to_string()), + isbn: None, + journal_title: Some("Journal".to_string()), + article_title: Some("Article".to_string()), + series_title: None, + volume_title: None, + edition: None, + author: Some("Author, A".to_string()), + volume: None, + issue: None, + first_page: Some("3".to_string()), + component_number: None, + standard_designator: None, + standards_body_name: None, + standards_body_acronym: None, + publication_date: Some(chrono::NaiveDate::from_ymd(2022, 1, 1)), + }], }; } - const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, orcid, [(position, ordinal, institution)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [code]","THEMA [code]","BISAC [code]","LCC [code]","custom_categories [category]","keywords [keyword]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, relation_type, ordinal)]" -"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""0000-0002-0000-0001"", [(""Manager"", ""1"", ""University of Life"")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[""AAA"",""AAB""]","[""JWA""]","[""AAA000000"",""AAA000001""]","[""JA85""]","[""Category1""]","[""keyword1"",""keyword2""]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""HAS_CHILD"", ""1"")]" + const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, [(position, ordinal, institution, ror)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [(code, ordinal)]","THEMA [(code, ordinal)]","BISAC [(code, ordinal)]","LCC [(code, ordinal)]","custom_categories [(category, ordinal)]","keywords [(keyword, ordinal)]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, doi, relation_type, ordinal)]","references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, date)]" +"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""true"", ""Author 1 is an author"", ""1"", ""0000-0002-0000-0001"", [(""Manager"", ""1"", ""University of Life"", ""0abcdef12"")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", ""true"", """", ""2"", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[(""AAA"", ""1""),(""AAB"", ""2"")]","[(""JWA"", ""1"")]","[(""AAA000000"", ""1""),(""AAA000001"", ""2"")]","[(""JA85"", ""1"")]","[(""Category1"", ""1"")]","[(""keyword1"", ""1""),(""keyword2"", ""2"")]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""10.00001/RELATION.0001"", ""HAS_CHILD"", ""1"")]","[(""1"", ""10.00001/reference"", ""Author, A. (2022) Article, Journal."", ""1111-2222"", """", ""Journal"", ""Article"", """", """", """", ""Author, A"", """", """", ""3"", """", """", """", ""2022-01-01"")]" "#; #[test] @@ -853,7 +925,7 @@ mod tests { last_name: "1".to_string(), full_name: "Author 1".to_string(), main_contribution: true, - biography: None, + biography: Some("Author 1 was born".to_string()), contribution_ordinal: 1, contributor: WorkContributionsContributor { orcid: Some(Orcid::from_str("https://orcid.org/0000-0002-0000-0001").unwrap()), @@ -862,14 +934,17 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("AUTHOR", "Author", "1", "Author 1", "0000-0002-0000-0001", )"#.to_string() + r#"("AUTHOR", "Author", "1", "Author 1", "true", "Author 1 was born", "1", "0000-0002-0000-0001", )"#.to_string() ); contribution.contribution_type = ContributionType::TRANSLATOR; contribution.first_name = None; + contribution.main_contribution = false; + contribution.biography = None; + contribution.contribution_ordinal = 2; contribution.contributor.orcid = None; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("TRANSLATOR", "", "1", "Author 1", "", )"#.to_string() + r#"("TRANSLATOR", "", "1", "Author 1", "false", "", "2", "", )"#.to_string() ); } @@ -880,18 +955,20 @@ mod tests { affiliation_ordinal: 1, institution: WorkContributionsAffiliationsInstitution { institution_name: "University of Life".to_string(), - ror: None, + ror: Some(Ror::from_str("https://ror.org/0abcdef12").unwrap()), }, }; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("Manager", "1", "University of Life")"#.to_string() + r#"("Manager", "1", "University of Life", "0abcdef12")"#.to_string() ); affiliation.position = None; affiliation.affiliation_ordinal = 2; + affiliation.institution.institution_name = "Polytechnic of Life".to_string(); + affiliation.institution.ror = None; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("", "2", "University of Life")"#.to_string() + r#"("", "2", "Polytechnic of Life", "")"#.to_string() ); } @@ -990,7 +1067,7 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&subject), - r#""AAB""#.to_string() + r#"("AAB", "2")"#.to_string() ); } @@ -1036,7 +1113,7 @@ mod tests { title: "N/A".to_string(), subtitle: None, edition: None, - doi: None, + doi: Some(Doi::from_str("https://doi.org/10.00001/RELATION.0001").unwrap()), publication_date: None, license: None, short_abstract: None, @@ -1058,14 +1135,66 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&relation), - r#"("Related work title", "HAS_CHILD", "1")"#.to_string() + r#"("Related work title", "10.00001/RELATION.0001", "HAS_CHILD", "1")"#.to_string() ); relation.relation_type = RelationType::IS_TRANSLATION_OF; relation.relation_ordinal = 2; relation.related_work.full_title = "Different related work title".to_string(); + relation.related_work.doi = None; assert_eq!( CsvCell::::csv_cell(&relation), - r#"("Different related work title", "IS_TRANSLATION_OF", "2")"#.to_string() + r#"("Different related work title", "", "IS_TRANSLATION_OF", "2")"#.to_string() + ); + } + + #[test] + fn test_csv_thoth_references() { + let mut reference = WorkReferences { + reference_ordinal: 1, + doi: Some(Doi::from_str("https://doi.org/10.00001/reference").unwrap()), + unstructured_citation: Some("Author, A. (2022) Article, Journal.".to_string()), + issn: Some("1111-2222".to_string()), + isbn: None, + journal_title: Some("Journal".to_string()), + article_title: Some("Article".to_string()), + series_title: None, + volume_title: None, + edition: None, + author: Some("Author, A".to_string()), + volume: None, + issue: None, + first_page: Some("3".to_string()), + component_number: None, + standard_designator: Some("14064-1".to_string()), + standards_body_name: Some("International Organization for Standardization".to_string()), + standards_body_acronym: None, + publication_date: Some(chrono::NaiveDate::from_ymd(2022, 1, 1)), + }; + assert_eq!( + CsvCell::::csv_cell(&reference), + r#"("1", "10.00001/reference", "Author, A. (2022) Article, Journal.", "1111-2222", "", "Journal", "Article", "", "", "", "Author, A", "", "", "3", "", "14064-1", "International Organization for Standardization", "2022-01-01")"#.to_string() + ); + reference.reference_ordinal = 2; + reference.doi = None; + reference.unstructured_citation = None; + reference.issn = None; + reference.isbn = Some(Isbn::from_str("978-92-95055-02-5").unwrap()); + reference.journal_title = None; + reference.article_title = None; + reference.series_title = Some("Series".to_string()); + reference.volume_title = Some("Volume".to_string()); + reference.edition = Some(41); + reference.author = None; + reference.volume = Some("5".to_string()); + reference.issue = Some("99".to_string()); + reference.first_page = None; + reference.component_number = Some("13".to_string()); + reference.standard_designator = None; + reference.standards_body_name = None; + reference.publication_date = None; + assert_eq!( + CsvCell::::csv_cell(&reference), + r#"("2", "", "", "", "978-92-95055-02-5", "", "", "Series", "Volume", "41", "", "5", "99", "", "13", "", "", "")"#.to_string() ); } } From f4fed3a1c1bca0958ad502976ed5013ed3b12311 Mon Sep 17 00:00:00 2001 From: rhigman <73792779+rhigman@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:21:25 +0000 Subject: [PATCH 2/3] Add fields to csv_thoth output which were previously omitted from WorkQuery --- thoth-export-server/src/csv/csv_thoth.rs | 56 +++++++++++++++++------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/thoth-export-server/src/csv/csv_thoth.rs b/thoth-export-server/src/csv/csv_thoth.rs index 05ddb2ff..43db71ed 100644 --- a/thoth-export-server/src/csv/csv_thoth.rs +++ b/thoth-export-server/src/csv/csv_thoth.rs @@ -23,6 +23,7 @@ struct CsvThothRow { subtitle: Option, edition: Option, doi: Option, + reference: Option, publication_date: Option, publication_place: Option, license: Option, @@ -46,7 +47,7 @@ struct CsvThothRow { cover_url: Option, cover_caption: Option, #[serde( - rename = "contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, [(position, ordinal, institution, ror)])]" + rename = "contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, website, [(position, ordinal, institution, institution_doi, ror, country)])]" )] contributions: String, #[serde( @@ -78,7 +79,7 @@ struct CsvThothRow { #[serde(rename = "relations [(related_work, doi, relation_type, ordinal)]")] relations: String, #[serde( - rename = "references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, date)]" + rename = "references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" )] references: String, } @@ -111,6 +112,7 @@ impl From for CsvThothRow { work_status: format!("{:?}", work.work_status), title: work.title, subtitle: work.subtitle, + reference: work.reference, edition: work.edition, doi: work.doi.map(|d| d.to_string()), publication_date: work.publication_date.map(|d| d.to_string()), @@ -314,7 +316,7 @@ impl CsvCell for WorkPublications { impl CsvCell for WorkContributions { fn csv_cell(&self) -> String { format!( - "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", + "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", self.contribution_type, self.first_name.clone().unwrap_or_default(), self.last_name, @@ -327,6 +329,7 @@ impl CsvCell for WorkContributions { .as_ref() .map(|o| o.to_string()) .unwrap_or_default(), + self.contributor.website.clone().unwrap_or_default(), CsvCell::::csv_cell( &self .affiliations @@ -359,15 +362,25 @@ impl CsvCell for WorkPublicationsLocations { impl CsvCell for WorkContributionsAffiliations { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{}\", \"{}\", \"{}\")", + "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", self.position.clone().unwrap_or_default(), self.affiliation_ordinal, self.institution.institution_name, + self.institution + .institution_doi + .as_ref() + .map(|d| d.to_string()) + .unwrap_or_default(), self.institution .ror .as_ref() .map(|r| r.to_string()) .unwrap_or_default(), + self.institution + .country_code + .as_ref() + .map(|c| format!("{:?}", c)) + .unwrap_or_default(), ) } } @@ -450,7 +463,7 @@ impl CsvCell for WorkRelations { impl CsvCell for WorkReferences { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", + "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", self.reference_ordinal, self.doi.as_ref().map(|d| d.to_string()).unwrap_or_default(), self.unstructured_citation.clone().unwrap_or_default(), @@ -469,6 +482,7 @@ impl CsvCell for WorkReferences { self.standard_designator.clone().unwrap_or_default(), self.standards_body_name.clone().unwrap_or_default(), self.publication_date.map(|d| d.to_string()).unwrap_or_default(), + self.retrieval_date.map(|d| d.to_string()).unwrap_or_default(), ) } } @@ -503,9 +517,9 @@ mod tests { title: "Book Title".to_string(), subtitle: Some("Book Subtitle".to_string()), work_type: WorkType::MONOGRAPH, - reference: None, edition: Some(1), doi: Some(Doi::from_str("https://doi.org/10.00001/BOOK.0001").unwrap()), + reference: Some("IntRef1".to_string()), publication_date: Some(chrono::NaiveDate::from_ymd(1999, 12, 31)), license: Some("http://creativecommons.org/licenses/by/4.0/".to_string()), copyright_holder: Some("Author 1; Author 2".to_string()), @@ -846,12 +860,13 @@ mod tests { standards_body_name: None, standards_body_acronym: None, publication_date: Some(chrono::NaiveDate::from_ymd(2022, 1, 1)), + retrieval_date: Some(chrono::NaiveDate::from_ymd(2022, 12, 31)), }], }; } - const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, [(position, ordinal, institution, ror)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [(code, ordinal)]","THEMA [(code, ordinal)]","BISAC [(code, ordinal)]","LCC [(code, ordinal)]","custom_categories [(category, ordinal)]","keywords [(keyword, ordinal)]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, doi, relation_type, ordinal)]","references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, date)]" -"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""true"", ""Author 1 is an author"", ""1"", ""0000-0002-0000-0001"", [(""Manager"", ""1"", ""University of Life"", ""0abcdef12"")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", ""true"", """", ""2"", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[(""AAA"", ""1""),(""AAB"", ""2"")]","[(""JWA"", ""1"")]","[(""AAA000000"", ""1""),(""AAA000001"", ""2"")]","[(""JA85"", ""1"")]","[(""Category1"", ""1"")]","[(""keyword1"", ""1""),(""keyword2"", ""2"")]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""10.00001/RELATION.0001"", ""HAS_CHILD"", ""1"")]","[(""1"", ""10.00001/reference"", ""Author, A. (2022) Article, Journal."", ""1111-2222"", """", ""Journal"", ""Article"", """", """", """", ""Author, A"", """", """", ""3"", """", """", """", ""2022-01-01"")]" + const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","reference","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, website, [(position, ordinal, institution, institution_doi, ror, country)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [(code, ordinal)]","THEMA [(code, ordinal)]","BISAC [(code, ordinal)]","LCC [(code, ordinal)]","custom_categories [(category, ordinal)]","keywords [(keyword, ordinal)]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, doi, relation_type, ordinal)]","references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" +"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","IntRef1","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""true"", ""Author 1 is an author"", ""1"", ""0000-0002-0000-0001"", """", [(""Manager"", ""1"", ""University of Life"", """", ""0abcdef12"", """")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", ""true"", """", ""2"", """", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[(""AAA"", ""1""),(""AAB"", ""2"")]","[(""JWA"", ""1"")]","[(""AAA000000"", ""1""),(""AAA000001"", ""2"")]","[(""JA85"", ""1"")]","[(""Category1"", ""1"")]","[(""keyword1"", ""1""),(""keyword2"", ""2"")]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""10.00001/RELATION.0001"", ""HAS_CHILD"", ""1"")]","[(""1"", ""10.00001/reference"", ""Author, A. (2022) Article, Journal."", ""1111-2222"", """", ""Journal"", ""Article"", """", """", """", ""Author, A"", """", """", ""3"", """", """", """", ""2022-01-01"", ""2022-12-31"")]" "#; #[test] @@ -937,13 +952,13 @@ mod tests { contribution_ordinal: 1, contributor: WorkContributionsContributor { orcid: Some(Orcid::from_str("https://orcid.org/0000-0002-0000-0001").unwrap()), - website: None, + website: Some("https://www.author1.org".to_string()), }, affiliations: vec![], }; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("AUTHOR", "Author", "1", "Author 1", "true", "Author 1 was born", "1", "0000-0002-0000-0001", )"#.to_string() + r#"("AUTHOR", "Author", "1", "Author 1", "true", "Author 1 was born", "1", "0000-0002-0000-0001", "https://www.author1.org", )"#.to_string() ); contribution.contribution_type = ContributionType::TRANSLATOR; contribution.first_name = None; @@ -951,9 +966,10 @@ mod tests { contribution.biography = None; contribution.contribution_ordinal = 2; contribution.contributor.orcid = None; + contribution.contributor.website = None; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("TRANSLATOR", "", "1", "Author 1", "false", "", "2", "", )"#.to_string() + r#"("TRANSLATOR", "", "1", "Author 1", "false", "", "2", "", "", )"#.to_string() ); } @@ -964,22 +980,26 @@ mod tests { affiliation_ordinal: 1, institution: WorkContributionsAffiliationsInstitution { institution_name: "University of Life".to_string(), - institution_doi: None, + institution_doi: Some( + Doi::from_str("https://doi.org/10.00001/INSTITUTION.0001").unwrap(), + ), ror: Some(Ror::from_str("https://ror.org/0abcdef12").unwrap()), - country_code: None, + country_code: Some(CountryCode::MDA), }, }; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("Manager", "1", "University of Life", "0abcdef12")"#.to_string() + r#"("Manager", "1", "University of Life", "10.00001/INSTITUTION.0001", "0abcdef12", "MDA")"#.to_string() ); affiliation.position = None; affiliation.affiliation_ordinal = 2; affiliation.institution.institution_name = "Polytechnic of Life".to_string(); + affiliation.institution.institution_doi = None; affiliation.institution.ror = None; + affiliation.institution.country_code = None; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("", "2", "Polytechnic of Life", "")"#.to_string() + r#"("", "2", "Polytechnic of Life", "", "", "")"#.to_string() ); } @@ -1180,10 +1200,11 @@ mod tests { standards_body_name: Some("International Organization for Standardization".to_string()), standards_body_acronym: None, publication_date: Some(chrono::NaiveDate::from_ymd(2022, 1, 1)), + retrieval_date: Some(chrono::NaiveDate::from_ymd(2022, 12, 31)), }; assert_eq!( CsvCell::::csv_cell(&reference), - r#"("1", "10.00001/reference", "Author, A. (2022) Article, Journal.", "1111-2222", "", "Journal", "Article", "", "", "", "Author, A", "", "", "3", "", "14064-1", "International Organization for Standardization", "2022-01-01")"#.to_string() + r#"("1", "10.00001/reference", "Author, A. (2022) Article, Journal.", "1111-2222", "", "Journal", "Article", "", "", "", "Author, A", "", "", "3", "", "14064-1", "International Organization for Standardization", "2022-01-01", "2022-12-31")"#.to_string() ); reference.reference_ordinal = 2; reference.doi = None; @@ -1203,9 +1224,10 @@ mod tests { reference.standard_designator = None; reference.standards_body_name = None; reference.publication_date = None; + reference.retrieval_date = None; assert_eq!( CsvCell::::csv_cell(&reference), - r#"("2", "", "", "", "978-92-95055-02-5", "", "", "Series", "Volume", "41", "", "5", "99", "", "13", "", "", "")"#.to_string() + r#"("2", "", "", "", "978-92-95055-02-5", "", "", "Series", "Volume", "41", "", "5", "99", "", "13", "", "", "", "")"#.to_string() ); } } From 74666af27b22fe5e29e1d3c988fdd83ca0ddbe68 Mon Sep 17 00:00:00 2001 From: rhigman <73792779+rhigman@users.noreply.github.com> Date: Wed, 16 Nov 2022 10:52:29 +0000 Subject: [PATCH 3/3] Review markups: remove ordinals where unnecessary i.e. already sorted; update changelog --- CHANGELOG.md | 3 ++ thoth-export-server/src/csv/csv_thoth.rs | 54 ++++++++++++------------ 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bce67ef6..1c7def2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - [#456](https://github.com/thoth-pub/thoth/pull/456) - Implement JSON output format +### Changed + - [#455](https://github.com/thoth-pub/thoth/pull/455) - Extend CSV output format to include all available fields + ## [[0.9.2]](https://github.com/thoth-pub/thoth/releases/tag/v0.9.2) - 2022-11-01 ### Changed - [#396](https://github.com/thoth-pub/thoth/pull/396) - Expand the list of contribution types with: SoftwareBy, ResearchBy, ContributionsBy, Indexer diff --git a/thoth-export-server/src/csv/csv_thoth.rs b/thoth-export-server/src/csv/csv_thoth.rs index 43db71ed..f4cb76bb 100644 --- a/thoth-export-server/src/csv/csv_thoth.rs +++ b/thoth-export-server/src/csv/csv_thoth.rs @@ -46,8 +46,11 @@ struct CsvThothRow { toc: Option, cover_url: Option, cover_caption: Option, + // All child objects with ordinals will be emitted in ordinal order as this + // is how they are retrieved by WorkQuery - don't print out ordinals explicitly + // (except for Series and Relations, as these represent real-world issue/chapter numbers etc) #[serde( - rename = "contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, website, [(position, ordinal, institution, institution_doi, ror, country)])]" + rename = "contributions [(type, first_name, last_name, full_name, is_main, biography, orcid, website, [(position, institution, institution_doi, ror, country)])]" )] contributions: String, #[serde( @@ -60,26 +63,26 @@ struct CsvThothRow { series: String, #[serde(rename = "languages [(relation, ISO_639-3/B_language, is_main)]")] languages: String, - #[serde(rename = "BIC [(code, ordinal)]")] + #[serde(rename = "BIC [code]")] bic: String, - #[serde(rename = "THEMA [(code, ordinal)]")] + #[serde(rename = "THEMA [code]")] thema: String, - #[serde(rename = "BISAC [(code, ordinal)]")] + #[serde(rename = "BISAC [code]")] bisac: String, - #[serde(rename = "LCC [(code, ordinal)]")] + #[serde(rename = "LCC [code]")] lcc: String, - #[serde(rename = "custom_categories [(category, ordinal)]")] + #[serde(rename = "custom_categories [category]")] custom: String, - #[serde(rename = "keywords [(keyword, ordinal)]")] + #[serde(rename = "keywords [keyword]")] keywords: String, #[serde( rename = "funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]" )] funding: String, - #[serde(rename = "relations [(related_work, doi, relation_type, ordinal)]")] + #[serde(rename = "relations [(related_work, doi, relation_type, relation_number)]")] relations: String, #[serde( - rename = "references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" + rename = "references [(doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" )] references: String, } @@ -316,14 +319,13 @@ impl CsvCell for WorkPublications { impl CsvCell for WorkContributions { fn csv_cell(&self) -> String { format!( - "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", + "(\"{:?}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", {})", self.contribution_type, self.first_name.clone().unwrap_or_default(), self.last_name, self.full_name, self.main_contribution, self.biography.clone().unwrap_or_default(), - self.contribution_ordinal, self.contributor .orcid .as_ref() @@ -362,9 +364,8 @@ impl CsvCell for WorkPublicationsLocations { impl CsvCell for WorkContributionsAffiliations { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", + "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", self.position.clone().unwrap_or_default(), - self.affiliation_ordinal, self.institution.institution_name, self.institution .institution_doi @@ -412,7 +413,7 @@ impl CsvCell for WorkLanguages { impl CsvCell for WorkSubjects { fn csv_cell(&self) -> String { - format!("(\"{}\", \"{}\")", self.subject_code, self.subject_ordinal,) + format!("\"{}\"", self.subject_code) } } @@ -463,8 +464,7 @@ impl CsvCell for WorkRelations { impl CsvCell for WorkReferences { fn csv_cell(&self) -> String { format!( - "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", - self.reference_ordinal, + "(\"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\", \"{}\")", self.doi.as_ref().map(|d| d.to_string()).unwrap_or_default(), self.unstructured_citation.clone().unwrap_or_default(), self.issn.clone().unwrap_or_default(), @@ -865,8 +865,8 @@ mod tests { }; } - const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","reference","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, is_main, biography, ordinal, orcid, website, [(position, ordinal, institution, institution_doi, ror, country)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [(code, ordinal)]","THEMA [(code, ordinal)]","BISAC [(code, ordinal)]","LCC [(code, ordinal)]","custom_categories [(category, ordinal)]","keywords [(keyword, ordinal)]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, doi, relation_type, ordinal)]","references [(ordinal, doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" -"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","IntRef1","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""true"", ""Author 1 is an author"", ""1"", ""0000-0002-0000-0001"", """", [(""Manager"", ""1"", ""University of Life"", """", ""0abcdef12"", """")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", ""true"", """", ""2"", """", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[(""AAA"", ""1""),(""AAB"", ""2"")]","[(""JWA"", ""1"")]","[(""AAA000000"", ""1""),(""AAA000001"", ""2"")]","[(""JA85"", ""1"")]","[(""Category1"", ""1"")]","[(""keyword1"", ""1""),(""keyword2"", ""2"")]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""10.00001/RELATION.0001"", ""HAS_CHILD"", ""1"")]","[(""1"", ""10.00001/reference"", ""Author, A. (2022) Article, Journal."", ""1111-2222"", """", ""Journal"", ""Article"", """", """", """", ""Author, A"", """", """", ""3"", """", """", """", ""2022-01-01"", ""2022-12-31"")]" + const TEST_RESULT: &str = r#""publisher","imprint","work_type","work_status","title","subtitle","edition","doi","reference","publication_date","publication_place","license","copyright_holder","landing_page","page_count","page_breakdown","first_page","last_page","page_interval","image_count","table_count","audio_count","video_count","lccn","oclc","short_abstract","long_abstract","general_note","toc","cover_url","cover_caption","contributions [(type, first_name, last_name, full_name, is_main, biography, orcid, website, [(position, institution, institution_doi, ror, country)])]","publications [(type, isbn, width (mm), width (cm), width (in), height (mm), height (cm), height (in), depth (mm), depth (cm), depth (in), weight (g), weight (oz), [(ISO_4217_currency, price)], [(landing_page, full_text, platform, is_canonical)])]","series [(type, name, issn_print, issn_digital, url, cfp_url, description, issue)]","languages [(relation, ISO_639-3/B_language, is_main)]","BIC [code]","THEMA [code]","BISAC [code]","LCC [code]","custom_categories [category]","keywords [keyword]","funding [(institution, institution_doi, ror, country, program, project, grant, jurisdiction)]","relations [(related_work, doi, relation_type, relation_number)]","references [(doi, citation, issn, isbn, journal_title, article_title, series_title, volume_title, edition, author, volume, issue, first_page, component_number, standard_designator, standards_body, publication_date, retrieval_date)]" +"OA Editions","OA Editions Imprint","MONOGRAPH","ACTIVE","Book Title","Book Subtitle","1","10.00001/BOOK.0001","IntRef1","1999-12-31","León, Spain","http://creativecommons.org/licenses/by/4.0/","Author 1; Author 2","https://www.book.com","334","x+334","","","","15","20","25","30","123456789","987654321","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.","Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum vel libero eleifend, ultrices purus vitae, suscipit ligula. Aliquam ornare quam et nulla vestibulum, id euismod tellus malesuada. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam ornare bibendum ex nec dapibus. Proin porta risus elementum odio feugiat tempus. Etiam eu felis ac metus viverra ornare. In consectetur neque sed feugiat ornare. Mauris at purus fringilla orci tincidunt pulvinar sed a massa. Nullam vestibulum posuere augue, sit amet tincidunt nisl pulvinar ac.","This is a general note","1. Chapter 1","https://www.book.com/cover","This is a cover caption","[(""AUTHOR"", ""Author"", ""1"", ""Author 1"", ""true"", ""Author 1 is an author"", ""0000-0002-0000-0001"", """", [(""Manager"", ""University of Life"", """", ""0abcdef12"", """")]),(""AUTHOR"", ""Author"", ""2"", ""Author 2"", ""true"", """", """", """", )]","[(""PAPERBACK"", ""978-3-16-148410-0"", ""156"", ""15.6"", ""6.14"", ""234"", ""23.4"", ""9.21"", ""25"", ""2.5"", ""1"", ""152"", ""5.3616"", [(""EUR"", ""25.95""),(""GBP"", ""22.95""),(""USD"", ""31.95"")], [(""https://www.book.com/paperback"", """", ""OTHER"", ""true""),(""https://www.jstor.com/paperback"", """", ""JSTOR"", ""false"")]),(""HARDBACK"", ""978-1-4028-9462-6"", """", """", """", """", """", """", """", """", """", """", """", [(""EUR"", ""36.95""),(""GBP"", ""32.95""),(""USD"", ""40.95"")], ),(""PDF"", ""978-1-56619-909-4"", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/pdf_landing"", ""https://www.book.com/pdf_fulltext"", ""OTHER"", ""true"")]),(""HTML"", """", """", """", """", """", """", """", """", """", """", """", """", , [(""https://www.book.com/html_landing"", ""https://www.book.com/html_fulltext"", ""OTHER"", ""true"")]),(""XML"", ""978-92-95055-02-5"", """", """", """", """", """", """", """", """", """", """", """", , )]","[(""JOURNAL"", ""Name of series"", ""1234-5678"", ""8765-4321"", ""https://www.series.com"", ""https://www.series.com/cfp"", ""Description of series"", ""1"")]","[(""ORIGINAL"", ""SPA"", ""true"")]","[""AAA"",""AAB""]","[""JWA""]","[""AAA000000"",""AAA000001""]","[""JA85""]","[""Category1""]","[""keyword1"",""keyword2""]","[(""Name of institution"", ""10.00001/INSTITUTION.0001"", ""0aaaaaa00"", ""MDA"", ""Name of program"", ""Name of project"", ""Number of grant"", ""Funding jurisdiction"")]","[(""Related work title"", ""10.00001/RELATION.0001"", ""HAS_CHILD"", ""1"")]","[(""10.00001/reference"", ""Author, A. (2022) Article, Journal."", ""1111-2222"", """", ""Journal"", ""Article"", """", """", """", ""Author, A"", """", """", ""3"", """", """", """", ""2022-01-01"", ""2022-12-31"")]" "#; #[test] @@ -958,18 +958,17 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("AUTHOR", "Author", "1", "Author 1", "true", "Author 1 was born", "1", "0000-0002-0000-0001", "https://www.author1.org", )"#.to_string() + r#"("AUTHOR", "Author", "1", "Author 1", "true", "Author 1 was born", "0000-0002-0000-0001", "https://www.author1.org", )"#.to_string() ); contribution.contribution_type = ContributionType::TRANSLATOR; contribution.first_name = None; contribution.main_contribution = false; contribution.biography = None; - contribution.contribution_ordinal = 2; contribution.contributor.orcid = None; contribution.contributor.website = None; assert_eq!( CsvCell::::csv_cell(&contribution), - r#"("TRANSLATOR", "", "1", "Author 1", "false", "", "2", "", "", )"#.to_string() + r#"("TRANSLATOR", "", "1", "Author 1", "false", "", "", "", )"#.to_string() ); } @@ -989,17 +988,17 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("Manager", "1", "University of Life", "10.00001/INSTITUTION.0001", "0abcdef12", "MDA")"#.to_string() + r#"("Manager", "University of Life", "10.00001/INSTITUTION.0001", "0abcdef12", "MDA")"# + .to_string() ); affiliation.position = None; - affiliation.affiliation_ordinal = 2; affiliation.institution.institution_name = "Polytechnic of Life".to_string(); affiliation.institution.institution_doi = None; affiliation.institution.ror = None; affiliation.institution.country_code = None; assert_eq!( CsvCell::::csv_cell(&affiliation), - r#"("", "2", "Polytechnic of Life", "", "", "")"#.to_string() + r#"("", "Polytechnic of Life", "", "", "")"#.to_string() ); } @@ -1098,7 +1097,7 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&subject), - r#"("AAB", "2")"#.to_string() + r#""AAB""#.to_string() ); } @@ -1204,9 +1203,8 @@ mod tests { }; assert_eq!( CsvCell::::csv_cell(&reference), - r#"("1", "10.00001/reference", "Author, A. (2022) Article, Journal.", "1111-2222", "", "Journal", "Article", "", "", "", "Author, A", "", "", "3", "", "14064-1", "International Organization for Standardization", "2022-01-01", "2022-12-31")"#.to_string() + r#"("10.00001/reference", "Author, A. (2022) Article, Journal.", "1111-2222", "", "Journal", "Article", "", "", "", "Author, A", "", "", "3", "", "14064-1", "International Organization for Standardization", "2022-01-01", "2022-12-31")"#.to_string() ); - reference.reference_ordinal = 2; reference.doi = None; reference.unstructured_citation = None; reference.issn = None; @@ -1227,7 +1225,7 @@ mod tests { reference.retrieval_date = None; assert_eq!( CsvCell::::csv_cell(&reference), - r#"("2", "", "", "", "978-92-95055-02-5", "", "", "Series", "Volume", "41", "", "5", "99", "", "13", "", "", "", "")"#.to_string() + r#"("", "", "", "978-92-95055-02-5", "", "", "Series", "Volume", "41", "", "5", "99", "", "13", "", "", "", "")"#.to_string() ); } }