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

Implement non-OA metadata in export outputs (#544) #629

Merged
merged 7 commits into from
Sep 26, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [551](https://github.com/thoth-pub/thoth/issues/551) - Only include chapters in Crossref metadata output if they have DOIs
- [628](https://github.com/thoth-pub/thoth/pull/628) - Upgrade `paperclip` to v0.9.1
- [628](https://github.com/thoth-pub/thoth/pull/628) - Upgrade rust to `1.81.0` in production and development `Dockerfile`
- [544](https://github.com/thoth-pub/thoth/issues/544) - Implement non-OA metadata in export outputs

### Fixed
- [565](https://github.com/thoth-pub/thoth/issues/565) - Don't generate Crossref metadata output if no DOIs (work or chapter) are present
Expand Down
15 changes: 9 additions & 6 deletions thoth-export-server/src/marc21/marc21record_thoth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,15 @@ impl Marc21Entry<Marc21RecordThoth> for Work {
.and_then(|f| builder.add_field(f))?;
}

// 506 - restrictions on access
FieldRepr::from((b"506", "0\\"))
.add_subfield(b"a", "Open Access")
.and_then(|f| f.add_subfield(b"f", "Unrestricted online access"))
.and_then(|f| f.add_subfield(b"2", "star"))
.and_then(|f| builder.add_field(f))?;
// Assume omission of licence means work is non-OA
if self.license.is_some() {
// 506 - restrictions on access
FieldRepr::from((b"506", "0\\"))
.add_subfield(b"a", "Open Access")
.and_then(|f| f.add_subfield(b"f", "Unrestricted online access"))
.and_then(|f| f.add_subfield(b"2", "star"))
.and_then(|f| builder.add_field(f))?;
}

// 520 - abstract
if let Some(mut long_abstract) = self.long_abstract.clone() {
Expand Down
36 changes: 18 additions & 18 deletions thoth-export-server/src/xml/doideposit_crossref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,20 +529,20 @@ fn write_access_content<W: Write>(
license: &Option<String>,
w: &mut EventWriter<W>,
) -> ThothResult<()> {
write_full_element_block(
"ai:program",
Some(vec![("name", "AccessIndicators")]),
w,
|w| {
write_element_block("ai:free_to_read", w, |_w| Ok(()))?;
if let Some(license) = license {
// Assume works without licences are non-OA
if let Some(license) = license {
write_full_element_block(
"ai:program",
Some(vec![("name", "AccessIndicators")]),
w,
|w| {
write_element_block("ai:free_to_read", w, |_w| Ok(()))?;
write_element_block("ai:license_ref", w, |w| {
w.write(XmlEvent::Characters(license)).map_err(|e| e.into())
})?;
}
Ok(())
},
)?;
})
},
)?;
}
Ok(())
}

Expand Down Expand Up @@ -1400,9 +1400,9 @@ mod tests {
assert!(!output.contains(r#" <month>02</month>"#));
assert!(!output.contains(r#" <day>28</day>"#));
assert!(!output.contains(r#" <year>2000</year>"#));
// No licence supplied
assert!(output.contains(r#" <ai:program name="AccessIndicators">"#));
assert!(output.contains(r#" <ai:free_to_read />"#));
// No licence supplied: assume non-OA
assert!(!output.contains(r#" <ai:program name="AccessIndicators">"#));
assert!(!output.contains(r#" <ai:free_to_read />"#));
assert!(!output.contains(
r#" <ai:license_ref>https://creativecommons.org/licenses/by/4.0/</ai:license_ref>"#
));
Expand Down Expand Up @@ -2001,9 +2001,9 @@ mod tests {
assert!(!output.contains(r#" <isbn media_type="print">978-1-4028-9462-6</isbn>"#));
// No place supplied
assert!(!output.contains(r#" <publisher_place>León, Spain</publisher_place>"#));
// No licence supplied
assert!(output.contains(r#" <ai:program name="AccessIndicators">"#));
assert!(output.contains(r#" <ai:free_to_read />"#));
// No licence supplied: assume non-OA
assert!(!output.contains(r#" <ai:program name="AccessIndicators">"#));
assert!(!output.contains(r#" <ai:free_to_read />"#));
assert!(!output.contains(
r#" <ai:license_ref>https://creativecommons.org/licenses/by/4.0/</ai:license_ref>"#
));
Expand Down
Loading
Loading