forked from D-Net/dnet-hadoop
[cleaning] deactivating the cleaning of FOS subjects found in the metadata provided by repositories
This commit is contained in:
parent
a5d13d5d27
commit
0486227185
|
@ -4,6 +4,7 @@ package eu.dnetlib.dhp.oa.graph.clean;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
|
@ -29,7 +30,10 @@ public class CleaningRuleMap extends HashMap<Class<?>, SerializableConsumer<Obje
|
||||||
mapping.put(AccessRight.class, o -> cleanQualifier(vocabularies, (AccessRight) o));
|
mapping.put(AccessRight.class, o -> cleanQualifier(vocabularies, (AccessRight) o));
|
||||||
mapping.put(Country.class, o -> cleanCountry(vocabularies, (Country) o));
|
mapping.put(Country.class, o -> cleanCountry(vocabularies, (Country) o));
|
||||||
mapping.put(Relation.class, o -> cleanRelation(vocabularies, (Relation) o));
|
mapping.put(Relation.class, o -> cleanRelation(vocabularies, (Relation) o));
|
||||||
mapping.put(Subject.class, o -> cleanSubject(vocabularies, (Subject) o));
|
|
||||||
|
// commenting out the subject cleaning until we decide if we want to it or not and the implementation will
|
||||||
|
// be completed. At the moment it is not capable of expanding the whole hierarchy.
|
||||||
|
// mapping.put(Subject.class, o -> cleanSubject(vocabularies, (Subject) o));
|
||||||
return mapping;
|
return mapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +42,15 @@ public class CleaningRuleMap extends HashMap<Class<?>, SerializableConsumer<Obje
|
||||||
// TODO cleaning based on different subject vocabs can be added here
|
// TODO cleaning based on different subject vocabs can be added here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The procedure cleans out the subject values, using a vocabulary identified by the field subject.qualifier.classid.
|
||||||
|
*
|
||||||
|
* @param vocabularyId
|
||||||
|
* @param vocabularies
|
||||||
|
* @param subject
|
||||||
|
*/
|
||||||
private static void cleanSubjectForVocabulary(String vocabularyId, VocabularyGroup vocabularies,
|
private static void cleanSubjectForVocabulary(String vocabularyId, VocabularyGroup vocabularies,
|
||||||
Subject subject) {
|
Subject subject) {
|
||||||
|
|
||||||
vocabularies.find(vocabularyId).ifPresent(vocabulary -> {
|
vocabularies.find(vocabularyId).ifPresent(vocabulary -> {
|
||||||
if (ModelConstants.DNET_SUBJECT_KEYWORD.equalsIgnoreCase(subject.getQualifier().getClassid())) {
|
if (ModelConstants.DNET_SUBJECT_KEYWORD.equalsIgnoreCase(subject.getQualifier().getClassid())) {
|
||||||
|
@ -49,14 +60,21 @@ public class CleaningRuleMap extends HashMap<Class<?>, SerializableConsumer<Obje
|
||||||
subject.getQualifier().setClassid(vocabularyId);
|
subject.getQualifier().setClassid(vocabularyId);
|
||||||
subject.getQualifier().setClassname(vocabulary.getName());
|
subject.getQualifier().setClassname(vocabulary.getName());
|
||||||
}
|
}
|
||||||
} else if (vocabularyId.equals(subject.getQualifier().getClassid()) &&
|
} else {
|
||||||
Objects.nonNull(subject.getDataInfo()) &&
|
final String provenanceActionClassId = Optional.ofNullable(subject.getDataInfo())
|
||||||
!"subject:fos".equals(subject.getDataInfo().getProvenanceaction())) {
|
.map(DataInfo::getProvenanceaction)
|
||||||
Qualifier syn = vocabulary.getSynonymAsQualifier(subject.getValue());
|
.map(Qualifier::getClassid)
|
||||||
VocabularyTerm term = vocabulary.getTerm(subject.getValue());
|
.orElse(null);
|
||||||
if (Objects.isNull(syn) && Objects.isNull(term)) {
|
|
||||||
subject.getQualifier().setClassid(ModelConstants.DNET_SUBJECT_KEYWORD);
|
if (vocabularyId.equals(subject.getQualifier().getClassid()) &&
|
||||||
subject.getQualifier().setClassname(ModelConstants.DNET_SUBJECT_KEYWORD);
|
!"subject:fos".equals(provenanceActionClassId)) {
|
||||||
|
|
||||||
|
Qualifier syn = vocabulary.getSynonymAsQualifier(subject.getValue());
|
||||||
|
VocabularyTerm term = vocabulary.getTerm(subject.getValue());
|
||||||
|
if (Objects.isNull(syn) && Objects.isNull(term)) {
|
||||||
|
subject.getQualifier().setClassid(ModelConstants.DNET_SUBJECT_KEYWORD);
|
||||||
|
subject.getQualifier().setClassname(ModelConstants.DNET_SUBJECT_KEYWORD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue