Commit 581542c4 by Steinberg, Jan

doabooks

parent 8e31d63d
......@@ -8,6 +8,7 @@ import org.gesis.dda.feeder.NextIncrementalHarvestingIntervalStrategy;
import org.gesis.dda.filter.BundleFilter;
import org.gesis.dda.filter.impl.AcceptAnyBundleFilter;
import org.gesis.dda.filter.impl.Aseas2SsoarBundleFilter;
import org.gesis.dda.filter.impl.Doabooks2SsoarBundleFilter;
import org.gesis.dda.filter.impl.Fqs2SsoarBundleFilter;
import org.gesis.dda.filter.impl.SsoarTargetRepositoryBundleFilter;
import org.gesis.dda.filter.impl.Wbv2SsoarBundleFilter;
......@@ -138,6 +139,10 @@ public class FeedingContextFactory {
log.info("using Wzb2SsoarBundleFilter");
result = new Wzb2SsoarBundleFilter();
break;
case "https://doabooks.org/oai@@oai:doab-books":
log.info("using Doabooks2SsoarBundleFilter");
result = new Doabooks2SsoarBundleFilter();
break;
default:
log.debug("using default IdentityMetadataTransformer");
result = new AcceptAnyBundleFilter();
......
package org.gesis.dda.filter.impl;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
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 Doabooks2SsoarBundleFilter implements BundleFilter {
private final static Logger LOG = LoggerFactory.getLogger(Doabooks2SsoarBundleFilter.class);
/**
* SSOAR only gets the given class notation's publications from this source
*/
@Override
public boolean test(Bundle bundle) {
LOG.debug("doabooks filter...");
boolean result;
String[] valuesToBeFilteredTo = {"Political institutions and public administration (General)",
"Political science",
"Political science (General)",
"Political theory"};
Set<Metadatum> metadata = bundle.getMetadata();
Set<Metadatum> clasShorts = metadata.stream().filter( m -> m.getKey().equals("dc.subject.classhort") ).collect(Collectors.toSet());
if (null != clasShorts.stream().filter(cls -> Arrays.asList(valuesToBeFilteredTo).contains(cls.getValue()))) {
LOG.debug("clasShort-Set not null.");
if (clasShorts.stream().filter(cls -> Arrays.asList(valuesToBeFilteredTo).contains(cls.getValue())).count() > 0) {
result = true;
LOG.debug("We take it: {}", clasShorts.stream().map(Metadatum::getValue).collect(Collectors.joining("; ")));
}
else {
result = false;
LOG.debug("Filtered away because of: {}", clasShorts.stream().map(Metadatum::getValue).collect(Collectors.joining("; ")));
}
return result;
} else {
LOG.error("null pointer?");
return false;
}
}
}
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