first attempt at changing the measure element
This commit is contained in:
parent
5b32bf1482
commit
e7eb17f73e
|
@ -0,0 +1,39 @@
|
|||
|
||||
package eu.dnetlib.dhp.oa.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
|
||||
|
||||
public class Indicator implements Serializable {
|
||||
@JsonSchema(description = "The indicator (i.e. popularity)")
|
||||
private String id;
|
||||
|
||||
@JsonSchema(description = "The measures for that indicator")
|
||||
private List<Measure> measure;
|
||||
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<Measure> getMeasure() {
|
||||
return measure;
|
||||
}
|
||||
|
||||
public void setMeasure(List<Measure> measure) {
|
||||
this.measure = measure;
|
||||
}
|
||||
|
||||
public static Indicator newInstance(String id, List<Measure> measure){
|
||||
Indicator indicator = new Indicator();
|
||||
indicator.id = id;
|
||||
indicator.measure = measure;
|
||||
return indicator;
|
||||
}
|
||||
}
|
|
@ -25,8 +25,8 @@ import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
|
|||
*/
|
||||
public class Instance implements Serializable {
|
||||
|
||||
@JsonSchema(description = "Measures computed for this instance, for example Bip!Finder ones")
|
||||
private List<Measure> measures;
|
||||
@JsonSchema(description = "Indicators computed for this instance, for example Bip!Finder ones")
|
||||
private List<Indicator> indicators;
|
||||
|
||||
private List<ResultPid> pid;
|
||||
|
||||
|
@ -131,11 +131,11 @@ public class Instance implements Serializable {
|
|||
this.alternateIdentifier = alternateIdentifier;
|
||||
}
|
||||
|
||||
public List<Measure> getMeasures() {
|
||||
return measures;
|
||||
public List<Indicator> getIndicators() {
|
||||
return indicators;
|
||||
}
|
||||
|
||||
public void setMeasures(List<Measure> measures) {
|
||||
this.measures = measures;
|
||||
public void setIndicators(List<Indicator> indicators) {
|
||||
this.indicators = indicators;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,46 +1,47 @@
|
|||
|
||||
package eu.dnetlib.dhp.oa.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author miriam.baglioni
|
||||
* @Date 03/08/22
|
||||
*/
|
||||
public class Measure implements Serializable {
|
||||
@JsonSchema(description = "The measure (i.e. popularity)")
|
||||
private String key;
|
||||
@JsonSchema(description = "The measure (i.e. class)")
|
||||
private String key;
|
||||
|
||||
@JsonSchema(description = "The value for that measure")
|
||||
private String value;
|
||||
@JsonSchema(description = "The value for that measure")
|
||||
private String value;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Measure newInstance(String key, String value) {
|
||||
Measure inst = new Measure();
|
||||
inst.key = key;
|
||||
inst.value = value;
|
||||
return inst;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isBlank() {
|
||||
return StringUtils.isBlank(key) && StringUtils.isBlank(value);
|
||||
}
|
||||
public static Measure newInstance(String key, String value) {
|
||||
Measure mes = new Measure();
|
||||
mes.key = key;
|
||||
mes.value = value;
|
||||
return mes;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isBlank() {
|
||||
return StringUtils.isBlank(key) && StringUtils.isBlank(value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.io.Serializable;
|
|||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.dnetlib.dhp.oa.model.Measure;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import eu.dnetlib.dhp.eosc.model.EoscInteroperabilityFramework;
|
||||
|
@ -16,7 +17,7 @@ import eu.dnetlib.dhp.oa.model.AccessRight;
|
|||
import eu.dnetlib.dhp.oa.model.Author;
|
||||
import eu.dnetlib.dhp.oa.model.GeoLocation;
|
||||
import eu.dnetlib.dhp.oa.model.Instance;
|
||||
import eu.dnetlib.dhp.oa.model.Measure;
|
||||
import eu.dnetlib.dhp.oa.model.Indicator;
|
||||
import eu.dnetlib.dhp.oa.model.OpenAccessRoute;
|
||||
import eu.dnetlib.dhp.oa.model.Result;
|
||||
import eu.dnetlib.dhp.oa.model.community.CfHbKeyValue;
|
||||
|
@ -471,12 +472,15 @@ public class ResultMapper implements Serializable {
|
|||
|
||||
Optional<List<eu.dnetlib.dhp.schema.oaf.Measure>> mes = Optional.ofNullable(i.getMeasures());
|
||||
if (mes.isPresent()) {
|
||||
List<Measure> measure = new ArrayList<>();
|
||||
List<Indicator> indicators = new ArrayList<>();
|
||||
mes
|
||||
.get()
|
||||
.forEach(
|
||||
m -> m.getUnit().forEach(u -> measure.add(Measure.newInstance(m.getId(), u.getValue()))));
|
||||
instance.setMeasures(measure);
|
||||
m -> indicators.add(Indicator.newInstance(m.getId(),
|
||||
m.getUnit().stream()
|
||||
.map(u -> Measure.newInstance(u.getKey(),u.getValue()))
|
||||
.collect(Collectors.toList()))));
|
||||
instance.setIndicators(indicators);
|
||||
}
|
||||
|
||||
if (opAr.get().getOpenAccessRoute() != null) {
|
||||
|
@ -549,6 +553,8 @@ public class ResultMapper implements Serializable {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static List<Provenance> getUniqueProvenance(List<Provenance> provenance)
|
||||
throws NoAvailableEntityTypeException {
|
||||
Provenance iProv = new Provenance();
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue