Add support to create/update solr collection aliases #449
|
@ -32,6 +32,7 @@ import eu.dnetlib.dhp.schema.solr.Datasource;
|
||||||
import eu.dnetlib.dhp.schema.solr.EoscIfGuidelines;
|
import eu.dnetlib.dhp.schema.solr.EoscIfGuidelines;
|
||||||
import eu.dnetlib.dhp.schema.solr.Instance;
|
import eu.dnetlib.dhp.schema.solr.Instance;
|
||||||
import eu.dnetlib.dhp.schema.solr.Journal;
|
import eu.dnetlib.dhp.schema.solr.Journal;
|
||||||
|
import eu.dnetlib.dhp.schema.solr.Measure;
|
||||||
import eu.dnetlib.dhp.schema.solr.OpenAccessColor;
|
import eu.dnetlib.dhp.schema.solr.OpenAccessColor;
|
||||||
import eu.dnetlib.dhp.schema.solr.OpenAccessRoute;
|
import eu.dnetlib.dhp.schema.solr.OpenAccessRoute;
|
||||||
import eu.dnetlib.dhp.schema.solr.Organization;
|
import eu.dnetlib.dhp.schema.solr.Organization;
|
||||||
|
@ -76,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));
|
||||||
|
@ -106,6 +108,14 @@ 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
|
||||||
|
@ -113,7 +123,9 @@ public class ProvisionModelSupport {
|
||||||
relation.getRelType(),
|
relation.getRelType(),
|
||||||
relation.getRelClass(),
|
relation.getRelClass(),
|
||||||
StringUtils.substringAfter(relation.getTarget(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
StringUtils.substringAfter(relation.getTarget(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
||||||
relatedRecordType));
|
relatedRecordType,
|
||||||
|
relationProvenance,
|
||||||
|
Optional.ofNullable(relation.getDataInfo()).map(DataInfo::getTrust).orElse(null)));
|
||||||
|
|
||||||
rr.setAcronym(re.getAcronym());
|
rr.setAcronym(re.getAcronym());
|
||||||
rr.setCode(re.getCode());
|
rr.setCode(re.getCode());
|
||||||
|
@ -131,11 +143,20 @@ 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.setProjectTitle(rr.getProjectTitle());
|
rr.setWebsiteurl(re.getWebsiteurl());
|
||||||
|
rr.setProjectTitle(re.getProjectTitle());
|
||||||
rr.setPublisher(re.getPublisher());
|
rr.setPublisher(re.getPublisher());
|
||||||
rr.setResulttype(mapQualifier(re.getResulttype()));
|
rr.setResulttype(mapQualifier(re.getResulttype()));
|
||||||
rr.setTitle(Optional.ofNullable(re.getTitle()).map(StructuredProperty::getValue).orElse(null));
|
rr.setTitle(Optional.ofNullable(re.getTitle()).map(StructuredProperty::getValue).orElse(null));
|
||||||
|
|
||||||
|
if (relation.getValidated() == null) {
|
||||||
|
relation.setValidated(false);
|
||||||
|
}
|
||||||
|
if (ModelConstants.OUTCOME.equals(relation.getSubRelType())
|
||||||
|
&& StringUtils.isNotBlank(relation.getValidationDate())) {
|
||||||
|
rr.setValidationDate(relation.getValidationDate());
|
||||||
|
}
|
||||||
|
|
||||||
return rr;
|
return rr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +287,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()));
|
||||||
|
@ -311,6 +333,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()));
|
||||||
|
|
||||||
|
@ -326,6 +349,7 @@ public class ProvisionModelSupport {
|
||||||
rs.setOtherTitles(getOtherTitles(r.getTitle()));
|
rs.setOtherTitles(getOtherTitles(r.getTitle()));
|
||||||
rs.setDescription(mapFieldList(r.getDescription()));
|
rs.setDescription(mapFieldList(r.getDescription()));
|
||||||
rs.setSubject(asSubject(r.getSubject()));
|
rs.setSubject(asSubject(r.getSubject()));
|
||||||
|
rs.setLanguage(asLanguage(r.getLanguage()));
|
||||||
rs.setPublicationdate(mapField(r.getDateofacceptance()));
|
rs.setPublicationdate(mapField(r.getDateofacceptance()));
|
||||||
rs.setPublisher(mapField(r.getPublisher()));
|
rs.setPublisher(mapField(r.getPublisher()));
|
||||||
rs.setEmbargoenddate(mapField(r.getEmbargoenddate()));
|
rs.setEmbargoenddate(mapField(r.getEmbargoenddate()));
|
||||||
|
@ -341,14 +365,14 @@ public class ProvisionModelSupport {
|
||||||
rs.setCountry(asCountry(r.getCountry()));
|
rs.setCountry(asCountry(r.getCountry()));
|
||||||
rs.setEoscifguidelines(asEOSCIF(r.getEoscifguidelines()));
|
rs.setEoscifguidelines(asEOSCIF(r.getEoscifguidelines()));
|
||||||
|
|
||||||
rs.setGreen(r.getIsGreen());
|
rs.setIsGreen(r.getIsGreen());
|
||||||
rs
|
rs
|
||||||
.setOpenAccessColor(
|
.setOpenAccessColor(
|
||||||
Optional
|
Optional
|
||||||
.ofNullable(r.getOpenAccessColor())
|
.ofNullable(r.getOpenAccessColor())
|
||||||
.map(color -> OpenAccessColor.valueOf(color.toString()))
|
.map(color -> OpenAccessColor.valueOf(color.toString()))
|
||||||
.orElse(null));
|
.orElse(null));
|
||||||
rs.setInDiamondJournal(r.getIsInDiamondJournal());
|
rs.setIsInDiamondJournal(r.getIsInDiamondJournal());
|
||||||
rs.setPubliclyFunded(r.getPubliclyFunded());
|
rs.setPubliclyFunded(r.getPubliclyFunded());
|
||||||
rs.setTransformativeAgreement(r.getTransformativeAgreement());
|
rs.setTransformativeAgreement(r.getTransformativeAgreement());
|
||||||
|
|
||||||
|
@ -375,6 +399,13 @@ public class ProvisionModelSupport {
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Language asLanguage(Qualifier lang) {
|
||||||
|
return Optional
|
||||||
|
.ofNullable(lang)
|
||||||
|
.map(q -> Language.newInstance(q.getClassid(), q.getClassname()))
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static List<String> getOtherTitles(List<StructuredProperty> titleList) {
|
private static List<String> getOtherTitles(List<StructuredProperty> titleList) {
|
||||||
return Optional
|
return Optional
|
||||||
|
@ -422,7 +453,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()));
|
||||||
|
@ -453,7 +484,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()))
|
||||||
|
@ -508,7 +540,25 @@ public class ProvisionModelSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Provenance asProvenance(KeyValue keyValue) {
|
private static Provenance asProvenance(KeyValue keyValue) {
|
||||||
return Optional.ofNullable(keyValue).map(cf -> Provenance.newInstance(cf.getKey(), cf.getValue())).orElse(null);
|
return Optional
|
||||||
|
.ofNullable(keyValue)
|
||||||
|
.map(
|
||||||
|
kv -> Provenance
|
||||||
|
.newInstance(
|
||||||
|
StringUtils.substringAfter(kv.getKey(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
||||||
|
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,
|
||||||
|
@ -581,7 +631,14 @@ public class ProvisionModelSupport {
|
||||||
.map(
|
.map(
|
||||||
pids -> pids
|
pids -> pids
|
||||||
.stream()
|
.stream()
|
||||||
.map(p -> Pid.newInstance(p.getQualifier().getClassname(), p.getValue()))
|
.filter(p -> Objects.nonNull(p.getQualifier()))
|
||||||
|
.filter(p -> Objects.nonNull(p.getQualifier().getClassid()))
|
||||||
|
.map(
|
||||||
|
p -> Pid
|
||||||
|
.newInstance(
|
||||||
|
p.getValue(),
|
||||||
|
p.getQualifier().getClassid(),
|
||||||
|
p.getQualifier().getClassname()))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -607,7 +664,9 @@ public class ProvisionModelSupport {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(s -> Objects.nonNull(s.getQualifier()))
|
.filter(s -> Objects.nonNull(s.getQualifier()))
|
||||||
.filter(s -> Objects.nonNull(s.getQualifier().getClassname()))
|
.filter(s -> Objects.nonNull(s.getQualifier().getClassname()))
|
||||||
.map(s -> Subject.newInstance(s.getValue(), s.getQualifier().getClassname()))
|
.map(
|
||||||
|
s -> Subject
|
||||||
|
.newInstance(s.getValue(), s.getQualifier().getClassid(), s.getQualifier().getClassname()))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -620,7 +679,9 @@ public class ProvisionModelSupport {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(s -> Objects.nonNull(s.getQualifier()))
|
.filter(s -> Objects.nonNull(s.getQualifier()))
|
||||||
.filter(s -> Objects.nonNull(s.getQualifier().getClassname()))
|
.filter(s -> Objects.nonNull(s.getQualifier().getClassname()))
|
||||||
.map(s -> Subject.newInstance(s.getValue(), s.getQualifier().getClassname()))
|
.map(
|
||||||
|
s -> Subject
|
||||||
|
.newInstance(s.getValue(), s.getQualifier().getClassid(), s.getQualifier().getClassname()))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +750,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue