[org dedup] avoid NPEs in SparkPrepareNewOrgs

This commit is contained in:
Claudio Atzori 2024-05-26 21:23:30 +02:00
parent d7daf54333
commit fb266efbcb
1 changed files with 8 additions and 6 deletions

View File

@ -22,7 +22,9 @@ import eu.dnetlib.dhp.oa.dedup.model.OrgSimRel;
import eu.dnetlib.dhp.schema.common.EntityType; import eu.dnetlib.dhp.schema.common.EntityType;
import eu.dnetlib.dhp.schema.common.ModelConstants; import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.common.ModelSupport;
import eu.dnetlib.dhp.schema.oaf.Field;
import eu.dnetlib.dhp.schema.oaf.Organization; import eu.dnetlib.dhp.schema.oaf.Organization;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import eu.dnetlib.dhp.schema.oaf.Relation; import eu.dnetlib.dhp.schema.oaf.Relation;
import eu.dnetlib.dhp.utils.ISLookupClientFactory; import eu.dnetlib.dhp.utils.ISLookupClientFactory;
import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService;
@ -164,12 +166,12 @@ public class SparkPrepareNewOrgs extends AbstractSparkAction {
.map( .map(
(MapFunction<Tuple2<Tuple2<String, Organization>, Tuple2<String, String>>, OrgSimRel>) r -> new OrgSimRel( (MapFunction<Tuple2<Tuple2<String, Organization>, Tuple2<String, String>>, OrgSimRel>) r -> new OrgSimRel(
"", "",
r._1()._2().getOriginalId().get(0), Optional.ofNullable(r._1()._2().getOriginalId()).map(oid -> oid.get(0)).orElse(null),
r._1()._2().getLegalname() != null ? r._1()._2().getLegalname().getValue() : "", Optional.ofNullable(r._1()._2().getLegalname()).map(Field::getValue).orElse(""),
r._1()._2().getLegalshortname() != null ? r._1()._2().getLegalshortname().getValue() : "", Optional.ofNullable(r._1()._2().getLegalshortname()).map(Field::getValue).orElse(""),
r._1()._2().getCountry() != null ? r._1()._2().getCountry().getClassid() : "", Optional.ofNullable(r._1()._2().getCountry()).map(Qualifier::getClassid).orElse(""),
r._1()._2().getWebsiteurl() != null ? r._1()._2().getWebsiteurl().getValue() : "", Optional.ofNullable(r._1()._2().getWebsiteurl()).map(Field::getValue).orElse(""),
r._1()._2().getCollectedfrom().get(0).getValue(), Optional.ofNullable(r._1()._2().getCollectedfrom()).map(cf -> cf.get(0).getValue()).orElse(null),
"", "",
structuredPropertyListToString(r._1()._2().getPid()), structuredPropertyListToString(r._1()._2().getPid()),
parseECField(r._1()._2().getEclegalbody()), parseECField(r._1()._2().getEclegalbody()),