|
|
|
@ -3,13 +3,12 @@ package eu.dnetlib.dhp.oa.graph.clean;
|
|
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
|
|
|
|
import javax.jws.WebParam;
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.SerializationUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
|
|
import eu.dnetlib.dhp.common.FunctionalInterfaceSupport.SerializableConsumer;
|
|
|
|
|
import eu.dnetlib.dhp.common.vocabulary.Vocabulary;
|
|
|
|
|
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
|
|
|
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
|
|
|
|
import eu.dnetlib.dhp.schema.oaf.*;
|
|
|
|
@ -31,23 +30,30 @@ public class CleaningRuleMap extends HashMap<Class<?>, SerializableConsumer<Obje
|
|
|
|
|
return mapping;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void cleanSubject(VocabularyGroup vocabularies, Subject s) {
|
|
|
|
|
// TODO cleaning based on different subject vocabs can be added here
|
|
|
|
|
cleanSubjectForVocabulary(ModelConstants.DNET_SUBJECT_FOS_CLASSID, vocabularies, s);
|
|
|
|
|
private static void cleanSubject(VocabularyGroup vocabularies, Subject subject) {
|
|
|
|
|
if (cleanSubjectForVocabulary(ModelConstants.DNET_SUBJECT_FOS_CLASSID, vocabularies, subject)) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
// TODO cleaning based on different subject vocabs can be added here
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void cleanSubjectForVocabulary(String vocabularyId, VocabularyGroup vocabularies, Subject s) {
|
|
|
|
|
private static boolean cleanSubjectForVocabulary(String vocabularyId, VocabularyGroup vocabularies,
|
|
|
|
|
Subject subject) {
|
|
|
|
|
AtomicReference<Boolean> modified = new AtomicReference<>(false);
|
|
|
|
|
vocabularies.find(vocabularyId).ifPresent(vocabulary -> {
|
|
|
|
|
if (!ModelConstants.DNET_SUBJECT_KEYWORD.equalsIgnoreCase(s.getQualifier().getClassid())) {
|
|
|
|
|
if (!ModelConstants.DNET_SUBJECT_KEYWORD.equalsIgnoreCase(subject.getQualifier().getClassid())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Qualifier newValue = vocabulary.lookup(s.getValue());
|
|
|
|
|
if (!s.getValue().equals(newValue.getClassid())) {
|
|
|
|
|
s.setValue(newValue.getClassid());
|
|
|
|
|
s.getQualifier().setClassid(vocabularyId);
|
|
|
|
|
s.getQualifier().setClassname(vocabulary.getName());
|
|
|
|
|
Qualifier newValue = vocabulary.lookup(subject.getValue());
|
|
|
|
|
if (!subject.getValue().equals(newValue.getClassid())) {
|
|
|
|
|
subject.setValue(newValue.getClassid());
|
|
|
|
|
subject.getQualifier().setClassid(vocabularyId);
|
|
|
|
|
subject.getQualifier().setClassname(vocabulary.getName());
|
|
|
|
|
modified.set(true);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return modified.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void cleanRelation(VocabularyGroup vocabularies, Relation r) {
|
|
|
|
|