Commit 323c31e6 authored by Gerrit Hübbers's avatar Gerrit Hübbers 🃏
Browse files

Fix FQS bundle filtering to be based on correct volume number

parent 1c39370d
......@@ -5,28 +5,42 @@ 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 Fqs2SsoarBundleFilter implements BundleFilter {
private final static Logger LOG = LoggerFactory.getLogger(Fqs2SsoarBundleFilter.class);
/**
* SSOAR already has everything up to and including dc.source.volume=16 dc.source.issue=3 ->
* there are only three issues in volume=16 -> therefore: if volume <= 16, then filter away bundle
* SSOAR already has everything up to and including dc.source.volume=17 dc.source.issue=3 ->
* there are only three issues in volume=17 -> therefore: harvest everything starting with volume>=18
*/
@Override
public boolean test(Bundle bundle) {
boolean result;
Set<Metadatum> metadata = bundle.getMetadata();
Metadatum volume = metadata.stream().filter( m -> m.getKey().equals("dc.source.volume") ).findFirst().orElse(null);
if (null != volume) {
String volumeValueString = volume.getValue();
int volumeValue = Integer.parseInt(volumeValueString);
if ( volumeValue <= 16 ) {
result = false;
try {
int volumeValue = Integer.parseInt(volumeValueString);
if ( volumeValue >= 18 ) {
result = true;
}
else {
LOG.info("filtering away bundle.reference={}", bundle.getReference() );
result = false;
}
}
else {
catch (NumberFormatException e) {
LOG.warn("unparsable dc.source.volume={} for bundle.reference={}", volumeValueString, bundle.getReference() );
result = true;
}
}
else {
result = true;
......
Supports Markdown
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