[DUMP INDICATORS ] added code to serialize the indicators
This commit is contained in:
parent
e222c2c4d7
commit
bdd1cfc1e0
|
@ -1,6 +1,8 @@
|
|||
|
||||
package eu.dnetlib.dhp.oa.graph.dump;
|
||||
|
||||
import static eu.dnetlib.dhp.oa.graph.dump.Constants.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -223,35 +225,30 @@ public class ResultMapper implements Serializable {
|
|||
.ofNullable(input.getSubject())
|
||||
.ifPresent(
|
||||
value -> value
|
||||
.stream().filter(s -> !((s.getQualifier().getClassid().equalsIgnoreCase("fos") &&
|
||||
Optional.ofNullable(s.getDataInfo()).isPresent() && Optional.ofNullable(s.getDataInfo().getProvenanceaction()).isPresent()&&
|
||||
s.getDataInfo().getProvenanceaction().getClassid().equalsIgnoreCase("subject:fos")) ||
|
||||
(s.getQualifier().getClassid().equalsIgnoreCase("sdg") &&
|
||||
Optional.ofNullable(s.getDataInfo()).isPresent() && Optional.ofNullable(s.getDataInfo().getProvenanceaction()).isPresent()&&
|
||||
s.getDataInfo().getProvenanceaction().getClassid().equalsIgnoreCase("subject:sdg"))))
|
||||
.stream()
|
||||
.filter(
|
||||
s -> !((s.getQualifier().getClassid().equalsIgnoreCase("fos") &&
|
||||
Optional.ofNullable(s.getDataInfo()).isPresent()
|
||||
&& Optional.ofNullable(s.getDataInfo().getProvenanceaction()).isPresent() &&
|
||||
s.getDataInfo().getProvenanceaction().getClassid().equalsIgnoreCase("subject:fos"))
|
||||
||
|
||||
(s.getQualifier().getClassid().equalsIgnoreCase("sdg") &&
|
||||
Optional.ofNullable(s.getDataInfo()).isPresent()
|
||||
&& Optional.ofNullable(s.getDataInfo().getProvenanceaction()).isPresent() &&
|
||||
s
|
||||
.getDataInfo()
|
||||
.getProvenanceaction()
|
||||
.getClassid()
|
||||
.equalsIgnoreCase("subject:sdg"))))
|
||||
.forEach(s -> subjectList.add(getSubject(s))));
|
||||
|
||||
out.setSubjects(subjectList);
|
||||
|
||||
out.setType(input.getResulttype().getClassid());
|
||||
|
||||
if (Optional.ofNullable(input.getMeasures()).isPresent() && input.getMeasures().size() > 0
|
||||
) {
|
||||
List<Indicator> indicators = new ArrayList<>();
|
||||
input
|
||||
.getMeasures()
|
||||
.forEach(
|
||||
m -> indicators
|
||||
.add(
|
||||
Indicator
|
||||
.newInstance(
|
||||
m.getId(),
|
||||
m
|
||||
.getUnit()
|
||||
.stream()
|
||||
.map(u -> Measure.newInstance(u.getKey(), u.getValue()))
|
||||
.collect(Collectors.toList()))));
|
||||
out.setIndicators(indicators);
|
||||
if (Optional.ofNullable(input.getMeasures()).isPresent() && input.getMeasures().size() > 0) {
|
||||
|
||||
out.setIndicators(getIndicator(input.getMeasures()));
|
||||
}
|
||||
|
||||
if (!Constants.DUMPTYPE.COMPLETE.getType().equals(dumpType)) {
|
||||
|
@ -335,6 +332,79 @@ public class ResultMapper implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
private static Indicator getIndicator(List<eu.dnetlib.dhp.schema.oaf.Measure> measures) {
|
||||
UsageCounts uc = null;
|
||||
ImpactMeasures im = null;
|
||||
Indicator i = new Indicator();
|
||||
for (eu.dnetlib.dhp.schema.oaf.Measure m : measures) {
|
||||
switch (m.getId()) {
|
||||
case USAGE_COUNT_DOWNLOADS:
|
||||
if (uc == null) {
|
||||
uc = new UsageCounts();
|
||||
i.setUsageCounts(uc);
|
||||
}
|
||||
uc.setDownloads(m.getUnit().get(0).getValue());
|
||||
break;
|
||||
case USAGE_COUNT_VIEWS:
|
||||
if (uc == null) {
|
||||
uc = new UsageCounts();
|
||||
i.setUsageCounts(uc);
|
||||
}
|
||||
uc.setViews(m.getUnit().get(0).getValue());
|
||||
break;
|
||||
case IMPACT_POPULARITY:
|
||||
if (im == null) {
|
||||
im = new ImpactMeasures();
|
||||
i.setImpactMeasures(im);
|
||||
}
|
||||
im.setPopularity(getScore(m.getUnit()));
|
||||
break;
|
||||
case IMPACT_POPULARITY_ALT:
|
||||
if (im == null) {
|
||||
im = new ImpactMeasures();
|
||||
i.setImpactMeasures(im);
|
||||
}
|
||||
im.setPopularity_alt(getScore(m.getUnit()));
|
||||
break;
|
||||
case IMPACT_IMPULSE:
|
||||
if (im == null) {
|
||||
im = new ImpactMeasures();
|
||||
i.setImpactMeasures(im);
|
||||
}
|
||||
im.setImpulse(getScore(m.getUnit()));
|
||||
break;
|
||||
case IMPACT_INFLUENCE:
|
||||
if (im == null) {
|
||||
im = new ImpactMeasures();
|
||||
i.setImpactMeasures(im);
|
||||
}
|
||||
im.setInfluence(getScore(m.getUnit()));
|
||||
break;
|
||||
case IMPACT_INFLUENCE_ALT:
|
||||
if (im == null) {
|
||||
im = new ImpactMeasures();
|
||||
i.setImpactMeasures(im);
|
||||
}
|
||||
im.setInfluence_alt(getScore(m.getUnit()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static Score getScore(List<KeyValue> unit) {
|
||||
Score s = new Score();
|
||||
for (KeyValue u : unit) {
|
||||
if (u.getKey().equals("score")) {
|
||||
s.setScore(u.getValue());
|
||||
} else {
|
||||
s.setClazz(u.getValue());
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private static void addTypeSpecificInformation(Result out, eu.dnetlib.dhp.schema.oaf.Result input,
|
||||
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> ort) throws NoAvailableEntityTypeException {
|
||||
switch (ort.get().getClassid()) {
|
||||
|
@ -480,21 +550,21 @@ public class ResultMapper implements Serializable {
|
|||
|
||||
Optional<List<eu.dnetlib.dhp.schema.oaf.Measure>> mes = Optional.ofNullable(i.getMeasures());
|
||||
if (mes.isPresent()) {
|
||||
List<Indicator> indicators = new ArrayList<>();
|
||||
mes
|
||||
.get()
|
||||
.forEach(
|
||||
m -> indicators
|
||||
.add(
|
||||
Indicator
|
||||
.newInstance(
|
||||
m.getId(),
|
||||
m
|
||||
.getUnit()
|
||||
.stream()
|
||||
.map(u -> Measure.newInstance(u.getKey(), u.getValue()))
|
||||
.collect(Collectors.toList()))));
|
||||
instance.setIndicators(indicators);
|
||||
// List<Indicator> indicators = new ArrayList<>();
|
||||
// mes
|
||||
// .get()
|
||||
// .forEach(
|
||||
// m -> indicators
|
||||
// .add(
|
||||
// Indicator
|
||||
// .newInstance(
|
||||
// m.getId(),
|
||||
// m
|
||||
// .getUnit()
|
||||
// .stream()
|
||||
// .map(u -> Measure.newInstance(u.getKey(), u.getValue()))
|
||||
// .collect(Collectors.toList()))));
|
||||
instance.setIndicators(getIndicator(mes.get()));
|
||||
}
|
||||
|
||||
if (opAr.get().getOpenAccessRoute() != null) {
|
||||
|
|
Loading…
Reference in New Issue