|
|
|
@ -3,7 +3,6 @@ package eu.dnetlib.dhp.actionmanager.ror;
|
|
|
|
|
|
|
|
|
|
import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkSession;
|
|
|
|
|
import static eu.dnetlib.dhp.schema.common.ModelConstants.ENTITYREGISTRY_PROVENANCE_ACTION;
|
|
|
|
|
import static eu.dnetlib.dhp.schema.common.ModelConstants.ORG_ORG_RELTYPE;
|
|
|
|
|
import static eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils.dataInfo;
|
|
|
|
|
import static eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils.field;
|
|
|
|
|
import static eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils.listKeyValues;
|
|
|
|
@ -39,7 +38,6 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.actionmanager.ror.model.ExternalIdType;
|
|
|
|
|
import eu.dnetlib.dhp.actionmanager.ror.model.Relationship;
|
|
|
|
|
import eu.dnetlib.dhp.actionmanager.ror.model.RorOrganization;
|
|
|
|
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
|
|
|
|
import eu.dnetlib.dhp.common.HdfsSupport;
|
|
|
|
@ -51,7 +49,6 @@ import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.Oaf;
|
|
|
|
|
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.StructuredProperty;
|
|
|
|
|
import eu.dnetlib.dhp.utils.DHPUtils;
|
|
|
|
|
import scala.Tuple2;
|
|
|
|
@ -168,38 +165,10 @@ public class GenerateRorActionSetJob {
|
|
|
|
|
final List<AtomicAction<? extends Oaf>> res = new ArrayList<>();
|
|
|
|
|
res.add(new AtomicAction<>(Organization.class, o));
|
|
|
|
|
|
|
|
|
|
for (final Relationship rorRel : r.getRelationships()) {
|
|
|
|
|
if (rorRel.getType().equalsIgnoreCase("parent")) {
|
|
|
|
|
final String orgId1 = calculateOpenaireId(r.getId());
|
|
|
|
|
final String orgId2 = calculateOpenaireId(rorRel.getId());
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
new AtomicAction<>(Relation.class,
|
|
|
|
|
calculateHierarchyRel(orgId1, orgId2, ModelConstants.IS_PARENT_OF)));
|
|
|
|
|
res
|
|
|
|
|
.add(
|
|
|
|
|
new AtomicAction<>(Relation.class,
|
|
|
|
|
calculateHierarchyRel(orgId2, orgId1, ModelConstants.IS_CHILD_OF)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Relation calculateHierarchyRel(final String source, final String target, final String relClass) {
|
|
|
|
|
final Relation rel = new Relation();
|
|
|
|
|
rel.setSource(source);
|
|
|
|
|
rel.setTarget(target);
|
|
|
|
|
rel.setRelType(ORG_ORG_RELTYPE);
|
|
|
|
|
rel.setSubRelType(ModelConstants.RELATIONSHIP);
|
|
|
|
|
rel.setRelClass(relClass);
|
|
|
|
|
rel.setCollectedfrom(ROR_COLLECTED_FROM);
|
|
|
|
|
rel.setDataInfo(ROR_DATA_INFO);
|
|
|
|
|
rel.setLastupdatetimestamp(System.currentTimeMillis());
|
|
|
|
|
return rel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String calculateOpenaireId(final String rorId) {
|
|
|
|
|
return String.format("20|%s::%s", ROR_NS_PREFIX, DHPUtils.md5(rorId));
|
|
|
|
|
}
|
|
|
|
|