forked from D-Net/dnet-hadoop
Using the updated Solr JSON payload model classes
This commit is contained in:
parent
c858c02111
commit
786c217085
|
@ -5,7 +5,6 @@ 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;
|
||||||
|
@ -33,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;
|
||||||
|
@ -109,12 +109,13 @@ public class ProvisionModelSupport {
|
||||||
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
|
final String relationProvenance = Optional
|
||||||
.ofNullable(relation.getDataInfo())
|
.ofNullable(relation.getDataInfo())
|
||||||
.map(d -> Optional
|
.map(
|
||||||
.ofNullable(d.getProvenanceaction())
|
d -> Optional
|
||||||
.map(Qualifier::getClassid)
|
.ofNullable(d.getProvenanceaction())
|
||||||
.orElse(null))
|
.map(Qualifier::getClassid)
|
||||||
.orElse(null);
|
.orElse(null))
|
||||||
|
.orElse(null);
|
||||||
rr
|
rr
|
||||||
.setHeader(
|
.setHeader(
|
||||||
RelatedRecordHeader
|
RelatedRecordHeader
|
||||||
|
@ -151,7 +152,8 @@ public class ProvisionModelSupport {
|
||||||
if (relation.getValidated() == null) {
|
if (relation.getValidated() == null) {
|
||||||
relation.setValidated(false);
|
relation.setValidated(false);
|
||||||
}
|
}
|
||||||
if (ModelConstants.OUTCOME.equals(relation.getSubRelType()) && StringUtils.isNotBlank(relation.getValidationDate())) {
|
if (ModelConstants.OUTCOME.equals(relation.getSubRelType())
|
||||||
|
&& StringUtils.isNotBlank(relation.getValidationDate())) {
|
||||||
rr.setValidationDate(relation.getValidationDate());
|
rr.setValidationDate(relation.getValidationDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,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());
|
||||||
|
|
||||||
|
@ -398,9 +400,10 @@ public class ProvisionModelSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Language asLanguage(Qualifier lang) {
|
private static Language asLanguage(Qualifier lang) {
|
||||||
return Optional.ofNullable(lang)
|
return Optional
|
||||||
.map(q -> Language.newInstance(q.getClassid(), q.getClassname()))
|
.ofNullable(lang)
|
||||||
.orElse(null);
|
.map(q -> Language.newInstance(q.getClassid(), q.getClassname()))
|
||||||
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -537,18 +540,25 @@ public class ProvisionModelSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Provenance asProvenance(KeyValue keyValue) {
|
private static Provenance asProvenance(KeyValue keyValue) {
|
||||||
return Optional.ofNullable(keyValue).map(kv ->
|
return Optional
|
||||||
Provenance.newInstance(
|
.ofNullable(keyValue)
|
||||||
StringUtils.substringAfter(kv.getKey(), IdentifierFactory.ID_PREFIX_SEPARATOR),
|
.map(
|
||||||
kv.getValue())).orElse(null);
|
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) {
|
private static List<Measure> mapMeasures(List<eu.dnetlib.dhp.schema.oaf.Measure> measures) {
|
||||||
return Optional.ofNullable(measures)
|
return Optional
|
||||||
.map(ml -> ml.stream()
|
.ofNullable(measures)
|
||||||
.map(m -> Measure.newInstance(m.getId(), mapCodeLabelKV(m.getUnit())))
|
.map(
|
||||||
.collect(Collectors.toList()))
|
ml -> ml
|
||||||
.orElse(null);
|
.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,
|
||||||
|
@ -623,10 +633,12 @@ public class ProvisionModelSupport {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(p -> Objects.nonNull(p.getQualifier()))
|
.filter(p -> Objects.nonNull(p.getQualifier()))
|
||||||
.filter(p -> Objects.nonNull(p.getQualifier().getClassid()))
|
.filter(p -> Objects.nonNull(p.getQualifier().getClassid()))
|
||||||
.map(p -> Pid.newInstance(
|
.map(
|
||||||
p.getValue(),
|
p -> Pid
|
||||||
p.getQualifier().getClassid(),
|
.newInstance(
|
||||||
p.getQualifier().getClassname()))
|
p.getValue(),
|
||||||
|
p.getQualifier().getClassid(),
|
||||||
|
p.getQualifier().getClassname()))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
@ -652,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().getClassid(), 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);
|
||||||
}
|
}
|
||||||
|
@ -665,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().getClassid(), 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue