mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +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;
|
||||
// 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);
|
||||
try {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat);
|
||||
Date date = formatter.parse(dateString);
|
||||
dcDate = new DCDate(date);
|
||||
values.add(metadataFieldMapping.toDCValue(field, formatter.format(date)));
|
||||
break;
|
||||
} catch (ParseException e) {
|
||||
// Multiple dateformats can be configured, we don't want to print the entire stacktrace every
|
||||
// time one of those formats fails.
|
||||
@@ -136,9 +138,7 @@ public class PubmedDateMetadatumContributor<T> implements MetadataContributor<T>
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (dcDate != null) {
|
||||
values.add(metadataFieldMapping.toDCValue(field, dcDate.toString()));
|
||||
} else {
|
||||
if (dcDate == null) {
|
||||
log.info(
|
||||
"Failed parsing " + dateString + ", check " +
|
||||
"the configured dataformats in config/spring/api/pubmed-integration.xml");
|
||||
|
@@ -38,6 +38,7 @@
|
||||
<value>yyyy-MMM-dd</value>
|
||||
<value>yyyy-MMM</value>
|
||||
<value>yyyy-MM-dd</value>
|
||||
<value>yyyy</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="year" ref="yearContrib"/>
|
||||
@@ -160,4 +161,4 @@
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
</beans>
|
||||
|
Reference in New Issue
Block a user