cleaning wf: bestaccessrights defaults to [UNKNOWN, not available] when the instance level access rights cannot be mapped to a value known in the dnet:access_modes vocabulary
This commit is contained in:
parent
0b5f2ebd89
commit
a1d795d3b7
|
@ -652,15 +652,11 @@ public class GraphCleaningFunctions extends CleaningFunctions {
|
||||||
if (Objects.isNull(r.getBestaccessright())
|
if (Objects.isNull(r.getBestaccessright())
|
||||||
|| StringUtils.isBlank(r.getBestaccessright().getClassid())) {
|
|| StringUtils.isBlank(r.getBestaccessright().getClassid())) {
|
||||||
Qualifier bestaccessrights = OafMapperUtils.createBestAccessRights(r.getInstance());
|
Qualifier bestaccessrights = OafMapperUtils.createBestAccessRights(r.getInstance());
|
||||||
if (Objects.isNull(bestaccessrights)) {
|
if (!vocs.termExists(ModelConstants.DNET_ACCESS_MODES, bestaccessrights.getClassid())) {
|
||||||
r
|
bestaccessrights.setClassid(UNKNOWN);
|
||||||
.setBestaccessright(
|
bestaccessrights.setClassname(NOT_AVAILABLE);
|
||||||
qualifier(
|
|
||||||
ModelConstants.UNKNOWN, ModelConstants.NOT_AVAILABLE,
|
|
||||||
ModelConstants.DNET_ACCESS_MODES));
|
|
||||||
} else {
|
|
||||||
r.setBestaccessright(bestaccessrights);
|
|
||||||
}
|
}
|
||||||
|
r.setBestaccessright(bestaccessrights);
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(r.getAuthor())) {
|
if (Objects.nonNull(r.getAuthor())) {
|
||||||
r
|
r
|
||||||
|
|
|
@ -14,6 +14,7 @@ import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import eu.dnetlib.dhp.schema.common.AccessRightComparator;
|
import eu.dnetlib.dhp.schema.common.AccessRightComparator;
|
||||||
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
|
|
||||||
public class OafMapperUtils {
|
public class OafMapperUtils {
|
||||||
|
@ -365,8 +366,10 @@ public class OafMapperUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Qualifier getBestAccessRights(final List<Instance> instanceList) {
|
protected static Qualifier getBestAccessRights(final List<Instance> instanceList) {
|
||||||
if (instanceList != null) {
|
return Optional
|
||||||
final Optional<AccessRight> min = instanceList
|
.ofNullable(instanceList)
|
||||||
|
.map(list -> {
|
||||||
|
Optional<AccessRight> min = list
|
||||||
.stream()
|
.stream()
|
||||||
.map(Instance::getAccessright)
|
.map(Instance::getAccessright)
|
||||||
.min(new AccessRightComparator<>());
|
.min(new AccessRightComparator<>());
|
||||||
|
@ -388,8 +391,11 @@ public class OafMapperUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return rights;
|
return rights;
|
||||||
}
|
})
|
||||||
return null;
|
.orElse(
|
||||||
|
qualifier(
|
||||||
|
ModelConstants.UNKNOWN, ModelConstants.NOT_AVAILABLE,
|
||||||
|
ModelConstants.DNET_ACCESS_MODES, DNET_ACCESS_MODES));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyValue newKeyValueInstance(String key, String value, DataInfo dataInfo) {
|
public static KeyValue newKeyValueInstance(String key, String value, DataInfo dataInfo) {
|
||||||
|
|
Loading…
Reference in New Issue