forked from D-Net/dnet-hadoop
added new information in support of blacklist reader
This commit is contained in:
parent
6a47e6191d
commit
564e5d6279
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
package eu.dnetlib.dhp.schema.common;
|
package eu.dnetlib.dhp.schema.common;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
|
|
||||||
/** Oaf model utility methods. */
|
/** Oaf model utility methods. */
|
||||||
public class ModelSupport {
|
public class ModelSupport {
|
||||||
|
|
||||||
|
@ -62,153 +65,213 @@ public class ModelSupport {
|
||||||
public static final Map<String, RelationInverse> relationInverseMap = Maps.newHashMap();
|
public static final Map<String, RelationInverse> relationInverseMap = Maps.newHashMap();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
relationInverseMap.put("personResult_authorship_isAuthorOf", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personResult_authorship_isAuthorOf", new RelationInverse()
|
||||||
.setRelation("isAuthorOf")
|
.setRelation("isAuthorOf")
|
||||||
.setInverse("hasAuthor")
|
.setInverse("hasAuthor")
|
||||||
.setRelType("personResult")
|
.setRelType("personResult")
|
||||||
.setSubReltype("authorship"));
|
.setSubReltype("authorship"));
|
||||||
relationInverseMap.put("personResult_authorship_hasAuthor", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personResult_authorship_hasAuthor", new RelationInverse()
|
||||||
.setInverse("isAuthorOf")
|
.setInverse("isAuthorOf")
|
||||||
.setRelation("hasAuthor")
|
.setRelation("hasAuthor")
|
||||||
.setRelType("personResult")
|
.setRelType("personResult")
|
||||||
.setSubReltype("authorship"));
|
.setSubReltype("authorship"));
|
||||||
relationInverseMap.put("projectOrganization_participation_isParticipant", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"projectOrganization_participation_isParticipant", new RelationInverse()
|
||||||
.setRelation("isParticipant")
|
.setRelation("isParticipant")
|
||||||
.setInverse("hasParticipant")
|
.setInverse("hasParticipant")
|
||||||
.setRelType("projectOrganization")
|
.setRelType("projectOrganization")
|
||||||
.setSubReltype("participation"));
|
.setSubReltype("participation"));
|
||||||
relationInverseMap.put("projectOrganization_participation_hasParticipant", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"projectOrganization_participation_hasParticipant", new RelationInverse()
|
||||||
.setInverse("isParticipant")
|
.setInverse("isParticipant")
|
||||||
.setRelation("hasParticipant")
|
.setRelation("hasParticipant")
|
||||||
.setRelType("projectOrganization")
|
.setRelType("projectOrganization")
|
||||||
.setSubReltype("participation"));
|
.setSubReltype("participation"));
|
||||||
relationInverseMap.put("resultOrganization_affiliation_hasAuthorInstitution", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultOrganization_affiliation_hasAuthorInstitution", new RelationInverse()
|
||||||
.setRelation("hasAuthorInstitution")
|
.setRelation("hasAuthorInstitution")
|
||||||
.setInverse("isAuthorInstitutionOf")
|
.setInverse("isAuthorInstitutionOf")
|
||||||
.setRelType("resultOrganization")
|
.setRelType("resultOrganization")
|
||||||
.setSubReltype("affiliation"));
|
.setSubReltype("affiliation"));
|
||||||
relationInverseMap.put("resultOrganization_affiliation_isAuthorInstitutionOf", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultOrganization_affiliation_isAuthorInstitutionOf", new RelationInverse()
|
||||||
.setInverse("hasAuthorInstitution")
|
.setInverse("hasAuthorInstitution")
|
||||||
.setRelation("isAuthorInstitutionOf")
|
.setRelation("isAuthorInstitutionOf")
|
||||||
.setRelType("resultOrganization")
|
.setRelType("resultOrganization")
|
||||||
.setSubReltype("affiliation"));
|
.setSubReltype("affiliation"));
|
||||||
relationInverseMap.put("organizationOrganization_dedup_merges", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"organizationOrganization_dedup_merges", new RelationInverse()
|
||||||
.setRelation("merges")
|
.setRelation("merges")
|
||||||
.setInverse("isMergedIn")
|
.setInverse("isMergedIn")
|
||||||
.setRelType("organizationOrganization")
|
.setRelType("organizationOrganization")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("organizationOrganization_dedup_isMergedIn", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"organizationOrganization_dedup_isMergedIn", new RelationInverse()
|
||||||
.setInverse("merges")
|
.setInverse("merges")
|
||||||
.setRelation("isMergedIn")
|
.setRelation("isMergedIn")
|
||||||
.setRelType("organizationOrganization")
|
.setRelType("organizationOrganization")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("organizationOrganization_dedupSimilarity_isSimilarTo", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"organizationOrganization_dedupSimilarity_isSimilarTo", new RelationInverse()
|
||||||
.setInverse("isSimilarTo")
|
.setInverse("isSimilarTo")
|
||||||
.setRelation("isSimilarTo")
|
.setRelation("isSimilarTo")
|
||||||
.setRelType("organizationOrganization")
|
.setRelType("organizationOrganization")
|
||||||
.setSubReltype("dedupSimilarity"));
|
.setSubReltype("dedupSimilarity"));
|
||||||
|
|
||||||
relationInverseMap.put("resultProject_outcome_isProducedBy", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultProject_outcome_isProducedBy", new RelationInverse()
|
||||||
.setRelation("isProducedBy")
|
.setRelation("isProducedBy")
|
||||||
.setInverse("produces")
|
.setInverse("produces")
|
||||||
.setRelType("resultProject")
|
.setRelType("resultProject")
|
||||||
.setSubReltype("outcome"));
|
.setSubReltype("outcome"));
|
||||||
relationInverseMap.put("resultProject_outcome_produces", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultProject_outcome_produces", new RelationInverse()
|
||||||
.setInverse("isProducedBy")
|
.setInverse("isProducedBy")
|
||||||
.setRelation("produces")
|
.setRelation("produces")
|
||||||
.setRelType("resultProject")
|
.setRelType("resultProject")
|
||||||
.setSubReltype("outcome"));
|
.setSubReltype("outcome"));
|
||||||
relationInverseMap.put("projectPerson_contactPerson_isContact", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"projectPerson_contactPerson_isContact", new RelationInverse()
|
||||||
.setRelation("isContact")
|
.setRelation("isContact")
|
||||||
.setInverse("hasContact")
|
.setInverse("hasContact")
|
||||||
.setRelType("projectPerson")
|
.setRelType("projectPerson")
|
||||||
.setSubReltype("contactPerson"));
|
.setSubReltype("contactPerson"));
|
||||||
relationInverseMap.put("projectPerson_contactPerson_hasContact", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"projectPerson_contactPerson_hasContact", new RelationInverse()
|
||||||
.setInverse("isContact")
|
.setInverse("isContact")
|
||||||
.setRelation("hasContact")
|
.setRelation("hasContact")
|
||||||
.setRelType("personPerson")
|
.setRelType("personPerson")
|
||||||
.setSubReltype("coAuthorship"));
|
.setSubReltype("coAuthorship"));
|
||||||
relationInverseMap.put("personPerson_coAuthorship_isCoauthorOf", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personPerson_coAuthorship_isCoauthorOf", new RelationInverse()
|
||||||
.setInverse("isCoAuthorOf")
|
.setInverse("isCoAuthorOf")
|
||||||
.setRelation("isCoAuthorOf")
|
.setRelation("isCoAuthorOf")
|
||||||
.setRelType("personPerson")
|
.setRelType("personPerson")
|
||||||
.setSubReltype("coAuthorship"));
|
.setSubReltype("coAuthorship"));
|
||||||
relationInverseMap.put("personPerson_dedup_merges", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personPerson_dedup_merges", new RelationInverse()
|
||||||
.setInverse("isMergedIn")
|
.setInverse("isMergedIn")
|
||||||
.setRelation("merges")
|
.setRelation("merges")
|
||||||
.setRelType("personPerson")
|
.setRelType("personPerson")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("personPerson_dedup_isMergedIn", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personPerson_dedup_isMergedIn", new RelationInverse()
|
||||||
.setInverse("merges")
|
.setInverse("merges")
|
||||||
.setRelation("isMergedIn")
|
.setRelation("isMergedIn")
|
||||||
.setRelType("personPerson")
|
.setRelType("personPerson")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("personPerson_dedupSimilarity_isSimilarTo", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"personPerson_dedupSimilarity_isSimilarTo", new RelationInverse()
|
||||||
.setInverse("isSimilarTo")
|
.setInverse("isSimilarTo")
|
||||||
.setRelation("isSimilarTo")
|
.setRelation("isSimilarTo")
|
||||||
.setRelType("personPerson")
|
.setRelType("personPerson")
|
||||||
.setSubReltype("dedupSimilarity"));
|
.setSubReltype("dedupSimilarity"));
|
||||||
relationInverseMap.put("datasourceOrganization_provision_isProvidedBy", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"datasourceOrganization_provision_isProvidedBy", new RelationInverse()
|
||||||
.setInverse("provides")
|
.setInverse("provides")
|
||||||
.setRelation("isProvidedBy")
|
.setRelation("isProvidedBy")
|
||||||
.setRelType("datasourceOrganization")
|
.setRelType("datasourceOrganization")
|
||||||
.setSubReltype("provision"));
|
.setSubReltype("provision"));
|
||||||
relationInverseMap.put("datasourceOrganization_provision_provides", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"datasourceOrganization_provision_provides", new RelationInverse()
|
||||||
.setInverse("isProvidedBy")
|
.setInverse("isProvidedBy")
|
||||||
.setRelation("provides")
|
.setRelation("provides")
|
||||||
.setRelType("datasourceOrganization")
|
.setRelType("datasourceOrganization")
|
||||||
.setSubReltype("provision"));
|
.setSubReltype("provision"));
|
||||||
relationInverseMap.put("resultResult_similarity_hasAmongTopNSimilarDocuments", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_similarity_hasAmongTopNSimilarDocuments", new RelationInverse()
|
||||||
.setInverse("isAmongTopNSimilarDocuments")
|
.setInverse("isAmongTopNSimilarDocuments")
|
||||||
.setRelation("hasAmongTopNSimilarDocuments")
|
.setRelation("hasAmongTopNSimilarDocuments")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("similarity"));
|
.setSubReltype("similarity"));
|
||||||
relationInverseMap.put("resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
|
||||||
.setInverse("hasAmongTopNSimilarDocuments")
|
.setInverse("hasAmongTopNSimilarDocuments")
|
||||||
.setRelation("isAmongTopNSimilarDocuments")
|
.setRelation("isAmongTopNSimilarDocuments")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("similarity"));
|
.setSubReltype("similarity"));
|
||||||
relationInverseMap.put("resultResult_relationship_isRelatedTo", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_relationship_isRelatedTo", new RelationInverse()
|
||||||
.setInverse("isRelatedTo")
|
.setInverse("isRelatedTo")
|
||||||
.setRelation("isRelatedTo")
|
.setRelation("isRelatedTo")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("relationship"));
|
.setSubReltype("relationship"));
|
||||||
relationInverseMap.put("resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
|
||||||
.setInverse("hasAmongTopNSimilarDocuments")
|
.setInverse("hasAmongTopNSimilarDocuments")
|
||||||
.setRelation("isAmongTopNSimilarDocuments")
|
.setRelation("isAmongTopNSimilarDocuments")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("similarity"));
|
.setSubReltype("similarity"));
|
||||||
relationInverseMap.put("resultResult_supplement_isSupplementTo", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_supplement_isSupplementTo", new RelationInverse()
|
||||||
.setInverse("isSupplementedBy")
|
.setInverse("isSupplementedBy")
|
||||||
.setRelation("isSupplementTo")
|
.setRelation("isSupplementTo")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("supplement"));
|
.setSubReltype("supplement"));
|
||||||
relationInverseMap.put("resultResult_supplement_isSupplementedBy", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_supplement_isSupplementedBy", new RelationInverse()
|
||||||
.setInverse("isSupplementTo")
|
.setInverse("isSupplementTo")
|
||||||
.setRelation("isSupplementedBy")
|
.setRelation("isSupplementedBy")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("supplement"));
|
.setSubReltype("supplement"));
|
||||||
relationInverseMap.put("resultResult_part_isPartOf", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_part_isPartOf", new RelationInverse()
|
||||||
.setInverse("hasPart")
|
.setInverse("hasPart")
|
||||||
.setRelation("isPartOf")
|
.setRelation("isPartOf")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("part"));
|
.setSubReltype("part"));
|
||||||
relationInverseMap.put("resultResult_part_hasPart", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_part_hasPart", new RelationInverse()
|
||||||
.setInverse("isPartOf")
|
.setInverse("isPartOf")
|
||||||
.setRelation("hasPart")
|
.setRelation("hasPart")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("part"));
|
.setSubReltype("part"));
|
||||||
relationInverseMap.put("resultResult_dedup_merges", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_dedup_merges", new RelationInverse()
|
||||||
.setInverse("isMergedIn")
|
.setInverse("isMergedIn")
|
||||||
.setRelation("merges")
|
.setRelation("merges")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("resultResult_dedup_isMergedIn", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_dedup_isMergedIn", new RelationInverse()
|
||||||
.setInverse("merges")
|
.setInverse("merges")
|
||||||
.setRelation("isMergedIn")
|
.setRelation("isMergedIn")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
.setSubReltype("dedup"));
|
.setSubReltype("dedup"));
|
||||||
relationInverseMap.put("resultResult_dedupSimilarity_isSimilarTo", new RelationInverse()
|
relationInverseMap
|
||||||
|
.put(
|
||||||
|
"resultResult_dedupSimilarity_isSimilarTo", new RelationInverse()
|
||||||
.setInverse("isSimilarTo")
|
.setInverse("isSimilarTo")
|
||||||
.setRelation("isSimilarTo")
|
.setRelation("isSimilarTo")
|
||||||
.setRelType("resultResult")
|
.setRelType("resultResult")
|
||||||
|
@ -218,7 +281,8 @@ public class ModelSupport {
|
||||||
|
|
||||||
private static final String schemeTemplate = "dnet:%s_%s_relations";
|
private static final String schemeTemplate = "dnet:%s_%s_relations";
|
||||||
|
|
||||||
private ModelSupport() {}
|
private ModelSupport() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks subclass-superclass relationship.
|
* Checks subclass-superclass relationship.
|
||||||
|
@ -308,7 +372,8 @@ public class ModelSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getScheme(final String sourceType, final String targetType) {
|
public static String getScheme(final String sourceType, final String targetType) {
|
||||||
return String.format(
|
return String
|
||||||
|
.format(
|
||||||
schemeTemplate,
|
schemeTemplate,
|
||||||
entityMapping.get(EntityType.valueOf(sourceType)).name(),
|
entityMapping.get(EntityType.valueOf(sourceType)).name(),
|
||||||
entityMapping.get(EntityType.valueOf(targetType)).name());
|
entityMapping.get(EntityType.valueOf(targetType)).name());
|
||||||
|
@ -325,29 +390,31 @@ public class ModelSupport {
|
||||||
|
|
||||||
private static <T extends Oaf> String idFnForRelation(T t) {
|
private static <T extends Oaf> String idFnForRelation(T t) {
|
||||||
Relation r = (Relation) t;
|
Relation r = (Relation) t;
|
||||||
return Optional.ofNullable(r.getSource())
|
return Optional
|
||||||
|
.ofNullable(r.getSource())
|
||||||
.map(
|
.map(
|
||||||
source ->
|
source -> Optional
|
||||||
Optional.ofNullable(r.getTarget())
|
.ofNullable(r.getTarget())
|
||||||
.map(
|
.map(
|
||||||
target ->
|
target -> Optional
|
||||||
Optional.ofNullable(r.getRelType())
|
.ofNullable(r.getRelType())
|
||||||
.map(
|
.map(
|
||||||
relType ->
|
relType -> Optional
|
||||||
Optional.ofNullable(r.getSubRelType())
|
.ofNullable(r.getSubRelType())
|
||||||
.map(
|
.map(
|
||||||
subRelType ->
|
subRelType -> Optional
|
||||||
Optional.ofNullable(r.getRelClass())
|
.ofNullable(r.getRelClass())
|
||||||
.map(
|
.map(
|
||||||
relClass ->
|
relClass -> String
|
||||||
String.join(
|
.join(
|
||||||
source,
|
source,
|
||||||
target,
|
target,
|
||||||
relType,
|
relType,
|
||||||
subRelType,
|
subRelType,
|
||||||
relClass))
|
relClass))
|
||||||
.orElse(
|
.orElse(
|
||||||
String.join(
|
String
|
||||||
|
.join(
|
||||||
source,
|
source,
|
||||||
target,
|
target,
|
||||||
relType,
|
relType,
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
package eu.dnetlib.dhp.schema.common;
|
package eu.dnetlib.dhp.schema.common;
|
||||||
|
|
||||||
public class RelationInverse {
|
public class RelationInverse {
|
||||||
|
@ -42,5 +43,4 @@ public class RelationInverse {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue