avoid NPEs
This commit is contained in:
parent
8fe934810f
commit
a8d68c9d29
|
@ -1,13 +1,9 @@
|
||||||
|
|
||||||
package eu.dnetlib.dhp.schema.oaf.utils;
|
package eu.dnetlib.dhp.schema.oaf.utils;
|
||||||
|
|
||||||
import static eu.dnetlib.dhp.schema.common.ModelConstants.CROSSREF_ID;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
|
||||||
import eu.dnetlib.dhp.schema.oaf.Oaf;
|
import eu.dnetlib.dhp.schema.oaf.Oaf;
|
||||||
import eu.dnetlib.dhp.schema.oaf.OafEntity;
|
import eu.dnetlib.dhp.schema.oaf.OafEntity;
|
||||||
import eu.dnetlib.dhp.schema.oaf.Result;
|
import eu.dnetlib.dhp.schema.oaf.Result;
|
||||||
|
@ -42,17 +38,23 @@ public class MergeEntitiesComparator implements Comparator<Oaf> {
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
// pid authority
|
// pid authority
|
||||||
int cfp1 = left
|
int cfp1 = Optional
|
||||||
.getCollectedfrom()
|
.ofNullable(left.getCollectedfrom())
|
||||||
.stream()
|
.map(
|
||||||
.map(kv -> PID_AUTHORITIES.indexOf(kv.getKey()))
|
cf -> cf
|
||||||
.max(Integer::compare)
|
.stream()
|
||||||
|
.map(kv -> PID_AUTHORITIES.indexOf(kv.getKey()))
|
||||||
|
.max(Integer::compare)
|
||||||
|
.orElse(-1))
|
||||||
.orElse(-1);
|
.orElse(-1);
|
||||||
int cfp2 = right
|
int cfp2 = Optional
|
||||||
.getCollectedfrom()
|
.ofNullable(right.getCollectedfrom())
|
||||||
.stream()
|
.map(
|
||||||
.map(kv -> PID_AUTHORITIES.indexOf(kv.getKey()))
|
cf -> cf
|
||||||
.max(Integer::compare)
|
.stream()
|
||||||
|
.map(kv -> PID_AUTHORITIES.indexOf(kv.getKey()))
|
||||||
|
.max(Integer::compare)
|
||||||
|
.orElse(-1))
|
||||||
.orElse(-1);
|
.orElse(-1);
|
||||||
|
|
||||||
if (cfp1 >= 0 && cfp1 > cfp2) {
|
if (cfp1 >= 0 && cfp1 > cfp2) {
|
||||||
|
|
Loading…
Reference in New Issue