Commit 0cd4b259 by Steinberg, Jan

added Wzb2SsoarBundleFilter ... year.issued >= 2016 -> untested

parent 1688ac19
......@@ -11,6 +11,7 @@ import org.gesis.dda.filter.impl.Aseas2SsoarBundleFilter;
import org.gesis.dda.filter.impl.Fqs2SsoarBundleFilter;
import org.gesis.dda.filter.impl.SsoarTargetRepositoryBundleFilter;
import org.gesis.dda.filter.impl.Wbv2SsoarBundleFilter;
import org.gesis.dda.filter.impl.Wzb2SsoarBundleFilter;
import org.gesis.dda.persist.PersistableHelper;
import org.gesis.dda.publishing.domain.BundlesStreamSource;
import org.gesis.dda.publishing.domain.BundlesStreamSourceFactory;
......@@ -133,6 +134,10 @@ public class FeedingContextFactory {
log.info("using Aseas2SsoarBundleFilter");
result = new Aseas2SsoarBundleFilter();
break;
case "http://www.econstor.eu/dspace-oai/request$$ssoar":
log.info("using Wzb2SsoarBundleFilter");
result = new Wzb2SsoarBundleFilter();
break;
default:
log.debug("using default IdentityMetadataTransformer");
result = new AcceptAnyBundleFilter();
......
package org.gesis.dda.filter.impl;
import java.util.Set;
import org.gesis.dda.filter.BundleFilter;
import org.gesis.dda.publishing.domain.Bundle;
import org.gesis.dda.publishing.domain.Metadatum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Wzb2SsoarBundleFilter implements BundleFilter {
private final static Logger LOG = LoggerFactory.getLogger(Fqs2SsoarBundleFilter.class);
/**
* SSOAR already has everything up to and including dc.date.issued=2015
* therefore: harvest everything with yearIssuedValue >= 2016
*/
@Override
public boolean test(Bundle bundle) {
boolean result;
Set<Metadatum> metadata = bundle.getMetadata();
Metadatum yearIssued = metadata.stream().filter( m -> m.getKey().equals("dc.date.issued") ).findFirst().orElse(null);
if (null != yearIssued) {
String yearIssuedValueString = yearIssued.getValue();
try {
int yearIssuedValue = Integer.parseInt(yearIssuedValueString);
if ( yearIssuedValue >= 2016 ) {
result = true;
}
else {
LOG.info("filtering away bundle.reference={}", bundle.getReference() );
result = false;
}
}
catch (NumberFormatException e) {
LOG.warn("unparsable dc.date.issued={} for bundle.reference={}", yearIssuedValueString, bundle.getReference() );
result = true;
}
}
else {
result = true;
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment