Skip to content

Commit

Permalink
Updated onix3_thoth.rs for issn optional, formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-oconnell committed Mar 11, 2024
1 parent c039160 commit 4e6cb68
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions thoth-api/src/graphql/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3313,11 +3313,11 @@ impl Series {
}

pub fn issn_print(&self) -> Option<&String> {
self.issn_print.as_ref()
self.issn_print.as_ref()
}

pub fn issn_digital(&self) -> Option<&String> {
self.issn_digital.as_ref()
self.issn_digital.as_ref()
}

#[graphql(description = "URL of the series' landing page")]
Expand Down
25 changes: 22 additions & 3 deletions thoth-export-server/src/marc21/marc21record_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,10 +635,29 @@ impl Marc21Field<Marc21RecordThoth> for WorkIssues {
f.add_subfield(b"v", format!("vol. {}.", self.issue_ordinal).as_bytes())
})
.and_then(|f| f.add_subfield(b"x", self.series.issn_digital.as_deref().unwrap_or_default().as_bytes()))
.and_then(|f| f.add_subfield(b"x", self.series.issn_print.as_deref().unwrap_or_default().as_bytes()))
.and_then(|f| {
f.add_subfield(
b"x",
self.series
.issn_digital
.as_deref()
.unwrap_or_default()
.as_bytes(),
)
})
.and_then(|f| {
f.add_subfield(
b"x",
self.series
.issn_print
.as_deref()
.unwrap_or_default()
.as_bytes(),
)
})
.and_then(|f| builder.add_field(f))?;
}
Ok(())
}
Ok(())
}
}

Expand Down
8 changes: 4 additions & 4 deletions thoth-export-server/src/xml/onix3_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ impl XmlElementBlock<Onix3Thoth> for WorkIssues {
})?;
write_element_block("IDValue", w, |w| {
w.write(XmlEvent::Characters(
&self.series.issn_digital.replace('-', ""),
&self.series.issn_digital.as_deref().unwrap_or_default().replace('-', ""),
))
.map_err(|e| e.into())
})
Expand Down Expand Up @@ -1641,8 +1641,8 @@ mod tests {
series: WorkIssuesSeries {
series_type: thoth_client::SeriesType::JOURNAL,
series_name: "Name of series".to_string(),
issn_print: "1234-5678".to_string(),
issn_digital: "8765-4321".to_string(),
issn_print: Some("1234-5678".to_string()),
issn_digital: Some("8765-4321".to_string()),
series_url: Some("https://series.url".to_string()),
series_description: None,
series_cfp_url: Some("https://series.cfp.url".to_string()),
Expand Down Expand Up @@ -1700,7 +1700,7 @@ mod tests {
// Change all possible values to test that output is updated
test_issue.issue_ordinal = 2;
test_issue.series.series_name = "Different series".to_string();
test_issue.series.issn_digital = "1111-2222".to_string();
test_issue.series.issn_digital = Some("1111-2222".to_string());
test_issue.series.series_url = None;
test_issue.series.series_cfp_url = None;
let output = generate_test_output(true, &test_issue);
Expand Down

0 comments on commit 4e6cb68

Please sign in to comment.