mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-09 19:13:18 +00:00
99466: Fixed pubmed date not being saved like the dateFormatsToAttempt specified in pubmed-integration.xml
This commit is contained in:
@@ -121,12 +121,14 @@ public class PubmedDateMetadatumContributor<T> implements MetadataContributor<T>
|
|||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
// Use the first dcDate that has been formatted (Config should go from most specific to most lenient)
|
// Use the first dcDate that has been formatted (Config should go from most specific to most lenient)
|
||||||
while (j < dateFormatsToAttempt.size() && dcDate == null) {
|
while (j < dateFormatsToAttempt.size()) {
|
||||||
String dateFormat = dateFormatsToAttempt.get(j);
|
String dateFormat = dateFormatsToAttempt.get(j);
|
||||||
try {
|
try {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
|
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
|
||||||
Date date = formatter.parse(dateString);
|
Date date = formatter.parse(dateString);
|
||||||
dcDate = new DCDate(date);
|
dcDate = new DCDate(date);
|
||||||
|
values.add(metadataFieldMapping.toDCValue(field, formatter.format(date)));
|
||||||
|
break;
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
// Multiple dateformats can be configured, we don't want to print the entire stacktrace every
|
// Multiple dateformats can be configured, we don't want to print the entire stacktrace every
|
||||||
// time one of those formats fails.
|
// time one of those formats fails.
|
||||||
@@ -136,9 +138,7 @@ public class PubmedDateMetadatumContributor<T> implements MetadataContributor<T>
|
|||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (dcDate != null) {
|
if (dcDate == null) {
|
||||||
values.add(metadataFieldMapping.toDCValue(field, dcDate.toString()));
|
|
||||||
} else {
|
|
||||||
log.info(
|
log.info(
|
||||||
"Failed parsing " + dateString + ", check " +
|
"Failed parsing " + dateString + ", check " +
|
||||||
"the configured dataformats in config/spring/api/pubmed-integration.xml");
|
"the configured dataformats in config/spring/api/pubmed-integration.xml");
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
<value>yyyy-MMM-dd</value>
|
<value>yyyy-MMM-dd</value>
|
||||||
<value>yyyy-MMM</value>
|
<value>yyyy-MMM</value>
|
||||||
<value>yyyy-MM-dd</value>
|
<value>yyyy-MM-dd</value>
|
||||||
|
<value>yyyy</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<property name="year" ref="yearContrib"/>
|
<property name="year" ref="yearContrib"/>
|
||||||
|
Reference in New Issue
Block a user