forked from D-Net/dnet-hadoop
code formatting
This commit is contained in:
parent
75144dacb3
commit
3256b9c836
|
@ -5,13 +5,13 @@ import java.util.*;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import eu.dnetlib.dhp.schema.oaf.utils.PidBlacklistProvider;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import com.clearspring.analytics.util.Lists;
|
import com.clearspring.analytics.util.Lists;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.utils.PidBlacklistProvider;
|
||||||
|
|
||||||
public class CleaningFunctions {
|
public class CleaningFunctions {
|
||||||
|
|
||||||
|
@ -148,13 +148,15 @@ public class CleaningFunctions {
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(r.getInstance())) {
|
if (Objects.nonNull(r.getInstance())) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (Instance i : r.getInstance()) {
|
for (Instance i : r.getInstance()) {
|
||||||
final Set<StructuredProperty> pids = Sets.newHashSet(i.getPid());
|
final Set<StructuredProperty> pids = Sets.newHashSet(i.getPid());
|
||||||
i.setAlternateIdentifier(
|
i
|
||||||
Optional.ofNullable(i.getAlternateIdentifier())
|
.setAlternateIdentifier(
|
||||||
.map(altId -> altId.stream()
|
Optional
|
||||||
|
.ofNullable(i.getAlternateIdentifier())
|
||||||
|
.map(
|
||||||
|
altId -> altId
|
||||||
|
.stream()
|
||||||
.filter(p -> !pids.contains(p))
|
.filter(p -> !pids.contains(p))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(Lists.newArrayList()));
|
.orElse(Lists.newArrayList()));
|
||||||
|
@ -236,7 +238,8 @@ public class CleaningFunctions {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<StructuredProperty> processPidCleaning(List<StructuredProperty> pids) {
|
private static List<StructuredProperty> processPidCleaning(List<StructuredProperty> pids) {
|
||||||
return pids.stream()
|
return pids
|
||||||
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(sp -> StringUtils.isNotBlank(StringUtils.trim(sp.getValue())))
|
.filter(sp -> StringUtils.isNotBlank(StringUtils.trim(sp.getValue())))
|
||||||
.filter(sp -> !PID_BLACKLIST.contains(sp.getValue().trim().toLowerCase()))
|
.filter(sp -> !PID_BLACKLIST.contains(sp.getValue().trim().toLowerCase()))
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class IdentifierFactory implements Serializable {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(s -> s.getQualifier() != null && "doi".equalsIgnoreCase(s.getQualifier().getClassid()))
|
.filter(s -> s.getQualifier() != null && "doi".equalsIgnoreCase(s.getQualifier().getClassid()))
|
||||||
.filter(IdentifierFactory::pidFilter)
|
.filter(CleaningFunctions::pidFilter)
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
} else {
|
} else {
|
||||||
|
@ -81,7 +81,7 @@ public class IdentifierFactory implements Serializable {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(i -> i.getPid() != null)
|
.filter(i -> i.getPid() != null)
|
||||||
.flatMap(i -> i.getPid().stream())
|
.flatMap(i -> i.getPid().stream())
|
||||||
.filter(IdentifierFactory::pidFilter)
|
.filter(CleaningFunctions::pidFilter)
|
||||||
.findAny()
|
.findAny()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue