|
|
|
@ -67,6 +67,18 @@ public class IdentifierFactory implements Serializable {
|
|
|
|
|
DELEGATED_PID_AUTHORITY.get(PidType.doi).put(ZENODO_R3_ID, "zenodo");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Declares the associations PID_TYPE -> [DATASOURCE ID, NAME] whose records are considered enrichment for the graph.
|
|
|
|
|
* Their OpenAIRE ID is built from the declared PID type. Are merged with their corresponding record, identified by
|
|
|
|
|
* the same OpenAIRE id.
|
|
|
|
|
*/
|
|
|
|
|
public static final Map<PidType, HashBiMap<String, String>> ENRICHMENT_PROVIDER = Maps.newHashMap();
|
|
|
|
|
|
|
|
|
|
static {
|
|
|
|
|
ENRICHMENT_PROVIDER.put(PidType.doi, HashBiMap.create());
|
|
|
|
|
ENRICHMENT_PROVIDER.get(PidType.doi).put(OPEN_APC_ID, OPEN_APC_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Set<String> delegatedAuthorityDatasourceIds() {
|
|
|
|
|
return DELEGATED_PID_AUTHORITY.values()
|
|
|
|
|
.stream()
|
|
|
|
@ -184,23 +196,34 @@ public class IdentifierFactory implements Serializable {
|
|
|
|
|
.stream()
|
|
|
|
|
// filter away PIDs provided by a DS that is not considered an authority for the
|
|
|
|
|
// given PID Type
|
|
|
|
|
.filter(p -> shouldFilterPidByAuthority(collectedFrom, p, mapHandles))
|
|
|
|
|
.filter(p -> shouldFilterPidByCriteria(collectedFrom, p, mapHandles))
|
|
|
|
|
.map(CleaningFunctions::normalizePidValue)
|
|
|
|
|
.filter(p -> isNotFromDelegatedAuthority(collectedFrom, p))
|
|
|
|
|
.filter(CleaningFunctions::pidFilter))
|
|
|
|
|
.orElse(Stream.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean shouldFilterPidByAuthority(KeyValue collectedFrom, StructuredProperty p, boolean mapHandles) {
|
|
|
|
|
|
|
|
|
|
private static boolean shouldFilterPidByCriteria(KeyValue collectedFrom, StructuredProperty p, boolean mapHandles) {
|
|
|
|
|
final PidType pType = PidType.tryValueOf(p.getQualifier().getClassid());
|
|
|
|
|
return (mapHandles && pType.equals(PidType.handle)) || Optional.ofNullable(collectedFrom).isPresent() &&
|
|
|
|
|
Optional
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(collectedFrom)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean isEnrich = Optional
|
|
|
|
|
.ofNullable(ENRICHMENT_PROVIDER.get(pType))
|
|
|
|
|
.map(enrich -> enrich.containsKey(collectedFrom.getKey())
|
|
|
|
|
|| enrich.containsValue(collectedFrom.getValue()))
|
|
|
|
|
.orElse(false);
|
|
|
|
|
|
|
|
|
|
boolean isAuthority = Optional
|
|
|
|
|
.ofNullable(PID_AUTHORITY.get(pType))
|
|
|
|
|
.map(authorities -> {
|
|
|
|
|
return authorities.containsKey(collectedFrom.getKey())
|
|
|
|
|
|| authorities.containsValue(collectedFrom.getValue());
|
|
|
|
|
})
|
|
|
|
|
.map(authorities -> authorities.containsKey(collectedFrom.getKey())
|
|
|
|
|
|| authorities.containsValue(collectedFrom.getValue()))
|
|
|
|
|
.orElse(false);
|
|
|
|
|
|
|
|
|
|
return (mapHandles && pType.equals(PidType.handle)) || isEnrich || isAuthority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static boolean isNotFromDelegatedAuthority(KeyValue collectedFrom, StructuredProperty p) {
|
|
|
|
|