WIP: align Solr JSON records to the explore portal requirements
This commit is contained in:
parent
fb731b6d46
commit
a7a54aab47
|
@ -5,11 +5,11 @@ import java.io.StringReader;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dom4j.Document;
|
import org.dom4j.Document;
|
||||||
import org.dom4j.DocumentException;
|
import org.dom4j.DocumentException;
|
||||||
import org.dom4j.io.SAXReader;
|
import org.dom4j.io.SAXReader;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
@ -77,6 +77,7 @@ public class ProvisionModelSupport {
|
||||||
r.setCollectedfrom(asProvenance(e.getCollectedfrom()));
|
r.setCollectedfrom(asProvenance(e.getCollectedfrom()));
|
||||||
r.setContext(asContext(e.getContext(), contextMapper));
|
r.setContext(asContext(e.getContext(), contextMapper));
|
||||||
r.setPid(asPid(e.getPid()));
|
r.setPid(asPid(e.getPid()));
|
||||||
|
r.setMeasures(mapMeasures(e.getMeasures()));
|
||||||
|
|
||||||
if (e instanceof eu.dnetlib.dhp.schema.oaf.Result) {
|
if (e instanceof eu.dnetlib.dhp.schema.oaf.Result) {
|
||||||
r.setResult(mapResult((eu.dnetlib.dhp.schema.oaf.Result) e));
|
r.setResult(mapResult((eu.dnetlib.dhp.schema.oaf.Result) e));
|
||||||
|
@ -107,6 +108,13 @@ public class ProvisionModelSupport {
|
||||||
final RelatedEntity re = rew.getTarget();
|
final RelatedEntity re = rew.getTarget();
|
||||||
final RecordType relatedRecordType = RecordType.valueOf(re.getType());
|
final RecordType relatedRecordType = RecordType.valueOf(re.getType());
|
||||||
final Relation relation = rew.getRelation();
|
final Relation relation = rew.getRelation();
|
||||||
|
final String relationProvenance = Optional
|
||||||
|
.ofNullable(relation.getDataInfo())
|
||||||
|
.map(d -> Optional
|
||||||
|
.ofNullable(d.getProvenanceaction())
|
||||||
|
.map(Qualifier::getClassid)
|
||||||
|
.orElse(null))
|
||||||
|
.orElse(null);
|
||||||
rr
|
rr
|
||||||
.setHeader(
|
.setHeader(
|
||||||
RelatedRecordHeader
|
RelatedRecordHeader
|
||||||
|
@ -115,9 +123,8 @@ public class ProvisionModelSupport {
|
||||||
relation.getRelClass(),
|
relation.getRelClass(),
|
||||||
StringUtils.substringAfter(relation.getTarget(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
StringUtils.substringAfter(relation.getTarget(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
||||||
relatedRecordType,
|
relatedRecordType,
|
||||||
Optional.ofNullable(relation.getDataInfo())
|
relationProvenance,
|
||||||
.map(d -> Optional.ofNullable(d.getProvenanceaction())
|
Optional.ofNullable(relation.getDataInfo()).map(DataInfo::getTrust).orElse(null)));
|
||||||
.map(Qualifier::getClassid).orElse(null)).orElse(null)));
|
|
||||||
|
|
||||||
rr.setAcronym(re.getAcronym());
|
rr.setAcronym(re.getAcronym());
|
||||||
rr.setCode(re.getCode());
|
rr.setCode(re.getCode());
|
||||||
|
@ -135,6 +142,7 @@ public class ProvisionModelSupport {
|
||||||
rr.setOfficialname(re.getOfficialname());
|
rr.setOfficialname(re.getOfficialname());
|
||||||
rr.setOpenairecompatibility(mapCodeLabel(re.getOpenairecompatibility()));
|
rr.setOpenairecompatibility(mapCodeLabel(re.getOpenairecompatibility()));
|
||||||
rr.setPid(asPid(re.getPid()));
|
rr.setPid(asPid(re.getPid()));
|
||||||
|
rr.setWebsiteurl(re.getWebsiteurl());
|
||||||
rr.setProjectTitle(re.getProjectTitle());
|
rr.setProjectTitle(re.getProjectTitle());
|
||||||
rr.setPublisher(re.getPublisher());
|
rr.setPublisher(re.getPublisher());
|
||||||
rr.setResulttype(mapQualifier(re.getResulttype()));
|
rr.setResulttype(mapQualifier(re.getResulttype()));
|
||||||
|
@ -277,6 +285,7 @@ public class ProvisionModelSupport {
|
||||||
ds.setOfficialname(mapField(d.getOfficialname()));
|
ds.setOfficialname(mapField(d.getOfficialname()));
|
||||||
ds.setDescription(mapField(d.getDescription()));
|
ds.setDescription(mapField(d.getDescription()));
|
||||||
ds.setJournal(mapJournal(d.getJournal()));
|
ds.setJournal(mapJournal(d.getJournal()));
|
||||||
|
ds.setWebsiteurl(mapField(d.getWebsiteurl()));
|
||||||
ds.setLogourl(mapField(d.getLogourl()));
|
ds.setLogourl(mapField(d.getLogourl()));
|
||||||
ds.setAccessinfopackage(mapFieldList(d.getAccessinfopackage()));
|
ds.setAccessinfopackage(mapFieldList(d.getAccessinfopackage()));
|
||||||
ds.setCertificates(mapField(d.getCertificates()));
|
ds.setCertificates(mapField(d.getCertificates()));
|
||||||
|
@ -322,6 +331,7 @@ public class ProvisionModelSupport {
|
||||||
ds.setSubjects(asSubjectSP(d.getSubjects()));
|
ds.setSubjects(asSubjectSP(d.getSubjects()));
|
||||||
ds.setSubmissionpolicyurl(d.getSubmissionpolicyurl());
|
ds.setSubmissionpolicyurl(d.getSubmissionpolicyurl());
|
||||||
ds.setThematic(d.getThematic());
|
ds.setThematic(d.getThematic());
|
||||||
|
ds.setContentpolicies(mapCodeLabel(d.getContentpolicies()));
|
||||||
ds.setVersioncontrol(d.getVersioncontrol());
|
ds.setVersioncontrol(d.getVersioncontrol());
|
||||||
ds.setVersioning(mapField(d.getVersioning()));
|
ds.setVersioning(mapField(d.getVersioning()));
|
||||||
|
|
||||||
|
@ -440,7 +450,7 @@ public class ProvisionModelSupport {
|
||||||
Instance i = new Instance();
|
Instance i = new Instance();
|
||||||
i.setCollectedfrom(asProvenance(instance.getCollectedfrom()));
|
i.setCollectedfrom(asProvenance(instance.getCollectedfrom()));
|
||||||
i.setHostedby(asProvenance(instance.getHostedby()));
|
i.setHostedby(asProvenance(instance.getHostedby()));
|
||||||
i.setFulltext(i.getFulltext());
|
i.setFulltext(instance.getFulltext());
|
||||||
i.setPid(asPid(instance.getPid()));
|
i.setPid(asPid(instance.getPid()));
|
||||||
i.setAlternateIdentifier(asPid(instance.getAlternateIdentifier()));
|
i.setAlternateIdentifier(asPid(instance.getAlternateIdentifier()));
|
||||||
i.setAccessright(mapAccessRight(instance.getAccessright()));
|
i.setAccessright(mapAccessRight(instance.getAccessright()));
|
||||||
|
@ -471,7 +481,8 @@ public class ProvisionModelSupport {
|
||||||
private static AccessRight mapAccessRight(eu.dnetlib.dhp.schema.oaf.AccessRight accessright) {
|
private static AccessRight mapAccessRight(eu.dnetlib.dhp.schema.oaf.AccessRight accessright) {
|
||||||
return AccessRight
|
return AccessRight
|
||||||
.newInstance(
|
.newInstance(
|
||||||
mapQualifier(accessright),
|
accessright.getClassid(),
|
||||||
|
accessright.getClassname(),
|
||||||
Optional
|
Optional
|
||||||
.ofNullable(accessright.getOpenAccessRoute())
|
.ofNullable(accessright.getOpenAccessRoute())
|
||||||
.map(route -> OpenAccessRoute.valueOf(route.toString()))
|
.map(route -> OpenAccessRoute.valueOf(route.toString()))
|
||||||
|
@ -532,6 +543,14 @@ public class ProvisionModelSupport {
|
||||||
kv.getValue())).orElse(null);
|
kv.getValue())).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<Measure> mapMeasures(List<eu.dnetlib.dhp.schema.oaf.Measure> measures) {
|
||||||
|
return Optional.ofNullable(measures)
|
||||||
|
.map(ml -> ml.stream()
|
||||||
|
.map(m -> Measure.newInstance(m.getId(), mapCodeLabelKV(m.getUnit())))
|
||||||
|
.collect(Collectors.toList()))
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
private static List<Context> asContext(List<eu.dnetlib.dhp.schema.oaf.Context> ctxList,
|
private static List<Context> asContext(List<eu.dnetlib.dhp.schema.oaf.Context> ctxList,
|
||||||
ContextMapper contextMapper) {
|
ContextMapper contextMapper) {
|
||||||
|
|
||||||
|
@ -715,7 +734,7 @@ public class ProvisionModelSupport {
|
||||||
private static CodeLabel mapCodeLabel(KeyValue kv) {
|
private static CodeLabel mapCodeLabel(KeyValue kv) {
|
||||||
return Optional
|
return Optional
|
||||||
.ofNullable(kv)
|
.ofNullable(kv)
|
||||||
.map(q -> CodeLabel.newInstance(kv.getKey(), kv.getValue()))
|
.map(k -> CodeLabel.newInstance(k.getKey(), k.getValue()))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue