[Graph Dump] fixed tests

This commit is contained in:
Miriam Baglioni 2021-12-06 15:06:32 +01:00
parent f430688ff7
commit 96a7d46278
3 changed files with 432 additions and 432 deletions

View File

@ -1,413 +1,413 @@
//
package eu.dnetlib.dhp.common; //package eu.dnetlib.dhp.common;
//
import java.io.Serializable; //import java.io.Serializable;
import java.util.*; //import java.util.*;
import java.util.stream.Collectors; //import java.util.stream.Collectors;
//
import eu.dnetlib.dhp.schema.common.ModelConstants; //import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.dump.oaf.*; //import eu.dnetlib.dhp.schema.dump.oaf.*;
import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityInstance; //import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityInstance;
import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult; //import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult;
import eu.dnetlib.dhp.schema.oaf.DataInfo; //import eu.dnetlib.dhp.schema.oaf.DataInfo;
import eu.dnetlib.dhp.schema.oaf.Field; //import eu.dnetlib.dhp.schema.oaf.Field;
import eu.dnetlib.dhp.schema.oaf.Journal; //import eu.dnetlib.dhp.schema.oaf.Journal;
import eu.dnetlib.dhp.schema.oaf.StructuredProperty; //import eu.dnetlib.dhp.schema.oaf.StructuredProperty;
//
public class GraphResultMapper implements Serializable { //public class GraphResultMapper implements Serializable {
//
public static <E extends eu.dnetlib.dhp.schema.oaf.OafEntity> Result map( // public static <E extends eu.dnetlib.dhp.schema.oaf.OafEntity> Result map(
E in) { // E in) {
//
CommunityResult out = new CommunityResult(); // CommunityResult out = new CommunityResult();
//
eu.dnetlib.dhp.schema.oaf.Result input = (eu.dnetlib.dhp.schema.oaf.Result) in; // eu.dnetlib.dhp.schema.oaf.Result input = (eu.dnetlib.dhp.schema.oaf.Result) in;
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> ort = Optional.ofNullable(input.getResulttype()); // Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> ort = Optional.ofNullable(input.getResulttype());
if (ort.isPresent()) { // if (ort.isPresent()) {
switch (ort.get().getClassid()) { // switch (ort.get().getClassid()) {
case "publication": // case "publication":
Optional<Journal> journal = Optional // Optional<Journal> journal = Optional
.ofNullable(((eu.dnetlib.dhp.schema.oaf.Publication) input).getJournal()); // .ofNullable(((eu.dnetlib.dhp.schema.oaf.Publication) input).getJournal());
if (journal.isPresent()) { // if (journal.isPresent()) {
Journal j = journal.get(); // Journal j = journal.get();
Container c = new Container(); // Container c = new Container();
c.setConferencedate(j.getConferencedate()); // c.setConferencedate(j.getConferencedate());
c.setConferenceplace(j.getConferenceplace()); // c.setConferenceplace(j.getConferenceplace());
c.setEdition(j.getEdition()); // c.setEdition(j.getEdition());
c.setEp(j.getEp()); // c.setEp(j.getEp());
c.setIss(j.getIss()); // c.setIss(j.getIss());
c.setIssnLinking(j.getIssnLinking()); // c.setIssnLinking(j.getIssnLinking());
c.setIssnOnline(j.getIssnOnline()); // c.setIssnOnline(j.getIssnOnline());
c.setIssnPrinted(j.getIssnPrinted()); // c.setIssnPrinted(j.getIssnPrinted());
c.setName(j.getName()); // c.setName(j.getName());
c.setSp(j.getSp()); // c.setSp(j.getSp());
c.setVol(j.getVol()); // c.setVol(j.getVol());
out.setContainer(c); // out.setContainer(c);
out.setType(ModelConstants.PUBLICATION_DEFAULT_RESULTTYPE.getClassname()); // out.setType(ModelConstants.PUBLICATION_DEFAULT_RESULTTYPE.getClassname());
} // }
break; // break;
case "dataset": // case "dataset":
eu.dnetlib.dhp.schema.oaf.Dataset id = (eu.dnetlib.dhp.schema.oaf.Dataset) input; // eu.dnetlib.dhp.schema.oaf.Dataset id = (eu.dnetlib.dhp.schema.oaf.Dataset) input;
Optional.ofNullable(id.getSize()).ifPresent(v -> out.setSize(v.getValue())); // Optional.ofNullable(id.getSize()).ifPresent(v -> out.setSize(v.getValue()));
Optional.ofNullable(id.getVersion()).ifPresent(v -> out.setVersion(v.getValue())); // Optional.ofNullable(id.getVersion()).ifPresent(v -> out.setVersion(v.getValue()));
//
out // out
.setGeolocation( // .setGeolocation(
Optional // Optional
.ofNullable(id.getGeolocation()) // .ofNullable(id.getGeolocation())
.map( // .map(
igl -> igl // igl -> igl
.stream() // .stream()
.filter(Objects::nonNull) // .filter(Objects::nonNull)
.map(gli -> { // .map(gli -> {
GeoLocation gl = new GeoLocation(); // GeoLocation gl = new GeoLocation();
gl.setBox(gli.getBox()); // gl.setBox(gli.getBox());
gl.setPlace(gli.getPlace()); // gl.setPlace(gli.getPlace());
gl.setPoint(gli.getPoint()); // gl.setPoint(gli.getPoint());
return gl; // return gl;
}) // })
.collect(Collectors.toList())) // .collect(Collectors.toList()))
.orElse(null)); // .orElse(null));
//
out.setType(ModelConstants.DATASET_DEFAULT_RESULTTYPE.getClassname()); // out.setType(ModelConstants.DATASET_DEFAULT_RESULTTYPE.getClassname());
break; // break;
case "software": // case "software":
//
eu.dnetlib.dhp.schema.oaf.Software is = (eu.dnetlib.dhp.schema.oaf.Software) input; // eu.dnetlib.dhp.schema.oaf.Software is = (eu.dnetlib.dhp.schema.oaf.Software) input;
Optional // Optional
.ofNullable(is.getCodeRepositoryUrl()) // .ofNullable(is.getCodeRepositoryUrl())
.ifPresent(value -> out.setCodeRepositoryUrl(value.getValue())); // .ifPresent(value -> out.setCodeRepositoryUrl(value.getValue()));
Optional // Optional
.ofNullable(is.getDocumentationUrl()) // .ofNullable(is.getDocumentationUrl())
.ifPresent( // .ifPresent(
value -> out // value -> out
.setDocumentationUrl( // .setDocumentationUrl(
value // value
.stream() // .stream()
.map(Field::getValue) // .map(Field::getValue)
.collect(Collectors.toList()))); // .collect(Collectors.toList())));
//
Optional // Optional
.ofNullable(is.getProgrammingLanguage()) // .ofNullable(is.getProgrammingLanguage())
.ifPresent(value -> out.setProgrammingLanguage(value.getClassid())); // .ifPresent(value -> out.setProgrammingLanguage(value.getClassid()));
//
out.setType(ModelConstants.SOFTWARE_DEFAULT_RESULTTYPE.getClassname()); // out.setType(ModelConstants.SOFTWARE_DEFAULT_RESULTTYPE.getClassname());
break; // break;
case "other": // case "other":
//
eu.dnetlib.dhp.schema.oaf.OtherResearchProduct ir = (eu.dnetlib.dhp.schema.oaf.OtherResearchProduct) input; // eu.dnetlib.dhp.schema.oaf.OtherResearchProduct ir = (eu.dnetlib.dhp.schema.oaf.OtherResearchProduct) input;
out // out
.setContactgroup( // .setContactgroup(
Optional // Optional
.ofNullable(ir.getContactgroup()) // .ofNullable(ir.getContactgroup())
.map(value -> value.stream().map(Field::getValue).collect(Collectors.toList())) // .map(value -> value.stream().map(Field::getValue).collect(Collectors.toList()))
.orElse(null)); // .orElse(null));
//
out // out
.setContactperson( // .setContactperson(
Optional // Optional
.ofNullable(ir.getContactperson()) // .ofNullable(ir.getContactperson())
.map(value -> value.stream().map(Field::getValue).collect(Collectors.toList())) // .map(value -> value.stream().map(Field::getValue).collect(Collectors.toList()))
.orElse(null)); // .orElse(null));
out // out
.setTool( // .setTool(
Optional // Optional
.ofNullable(ir.getTool()) // .ofNullable(ir.getTool())
.map(value -> value.stream().map(Field::getValue).collect(Collectors.toList())) // .map(value -> value.stream().map(Field::getValue).collect(Collectors.toList()))
.orElse(null)); // .orElse(null));
//
out.setType(ModelConstants.ORP_DEFAULT_RESULTTYPE.getClassname()); // out.setType(ModelConstants.ORP_DEFAULT_RESULTTYPE.getClassname());
//
break; // break;
} // }
//
Optional // Optional
.ofNullable(input.getAuthor()) // .ofNullable(input.getAuthor())
.ifPresent( // .ifPresent(
ats -> out.setAuthor(ats.stream().map(GraphResultMapper::getAuthor).collect(Collectors.toList()))); // ats -> out.setAuthor(ats.stream().map(GraphResultMapper::getAuthor).collect(Collectors.toList())));
//
// I do not map Access Right UNKNOWN or OTHER // // I do not map Access Right UNKNOWN or OTHER
//
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oar = Optional.ofNullable(input.getBestaccessright()); // Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oar = Optional.ofNullable(input.getBestaccessright());
if (oar.isPresent()) { // if (oar.isPresent()) {
if (Constants.accessRightsCoarMap.containsKey(oar.get().getClassid())) { // if (Constants.accessRightsCoarMap.containsKey(oar.get().getClassid())) {
String code = Constants.accessRightsCoarMap.get(oar.get().getClassid()); // String code = Constants.accessRightsCoarMap.get(oar.get().getClassid());
out // out
.setBestaccessright( // .setBestaccessright(
AccessRight // AccessRight
.newInstance( // .newInstance(
code, // code,
Constants.coarCodeLabelMap.get(code), // Constants.coarCodeLabelMap.get(code),
Constants.COAR_ACCESS_RIGHT_SCHEMA)); // Constants.COAR_ACCESS_RIGHT_SCHEMA));
} // }
} // }
//
final List<String> contributorList = new ArrayList<>(); // final List<String> contributorList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getContributor()) // .ofNullable(input.getContributor())
.ifPresent(value -> value.stream().forEach(c -> contributorList.add(c.getValue()))); // .ifPresent(value -> value.stream().forEach(c -> contributorList.add(c.getValue())));
out.setContributor(contributorList); // out.setContributor(contributorList);
//
Optional // Optional
.ofNullable(input.getCountry()) // .ofNullable(input.getCountry())
.ifPresent( // .ifPresent(
value -> out // value -> out
.setCountry( // .setCountry(
value // value
.stream() // .stream()
.map( // .map(
c -> { // c -> {
if (c.getClassid().equals((ModelConstants.UNKNOWN))) { // if (c.getClassid().equals((ModelConstants.UNKNOWN))) {
return null; // return null;
} // }
Country country = new Country(); // Country country = new Country();
country.setCode(c.getClassid()); // country.setCode(c.getClassid());
country.setLabel(c.getClassname()); // country.setLabel(c.getClassname());
Optional // Optional
.ofNullable(c.getDataInfo()) // .ofNullable(c.getDataInfo())
.ifPresent( // .ifPresent(
provenance -> country // provenance -> country
.setProvenance( // .setProvenance(
Provenance // Provenance
.newInstance( // .newInstance(
provenance // provenance
.getProvenanceaction() // .getProvenanceaction()
.getClassname(), // .getClassname(),
c.getDataInfo().getTrust()))); // c.getDataInfo().getTrust())));
return country; // return country;
}) // })
.filter(Objects::nonNull) // .filter(Objects::nonNull)
.collect(Collectors.toList()))); // .collect(Collectors.toList())));
//
final List<String> coverageList = new ArrayList<>(); // final List<String> coverageList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getCoverage()) // .ofNullable(input.getCoverage())
.ifPresent(value -> value.stream().forEach(c -> coverageList.add(c.getValue()))); // .ifPresent(value -> value.stream().forEach(c -> coverageList.add(c.getValue())));
out.setCoverage(coverageList); // out.setCoverage(coverageList);
//
out.setDateofcollection(input.getDateofcollection()); // out.setDateofcollection(input.getDateofcollection());
//
final List<String> descriptionList = new ArrayList<>(); // final List<String> descriptionList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getDescription()) // .ofNullable(input.getDescription())
.ifPresent(value -> value.forEach(d -> descriptionList.add(d.getValue()))); // .ifPresent(value -> value.forEach(d -> descriptionList.add(d.getValue())));
out.setDescription(descriptionList); // out.setDescription(descriptionList);
Optional<Field<String>> oStr = Optional.ofNullable(input.getEmbargoenddate()); // Optional<Field<String>> oStr = Optional.ofNullable(input.getEmbargoenddate());
if (oStr.isPresent()) { // if (oStr.isPresent()) {
out.setEmbargoenddate(oStr.get().getValue()); // out.setEmbargoenddate(oStr.get().getValue());
} // }
//
final List<String> formatList = new ArrayList<>(); // final List<String> formatList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getFormat()) // .ofNullable(input.getFormat())
.ifPresent(value -> value.stream().forEach(f -> formatList.add(f.getValue()))); // .ifPresent(value -> value.stream().forEach(f -> formatList.add(f.getValue())));
out.setFormat(formatList); // out.setFormat(formatList);
out.setId(input.getId()); // out.setId(input.getId());
out.setOriginalId(input.getOriginalId()); // out.setOriginalId(input.getOriginalId());
//
Optional<List<eu.dnetlib.dhp.schema.oaf.Instance>> oInst = Optional // Optional<List<eu.dnetlib.dhp.schema.oaf.Instance>> oInst = Optional
.ofNullable(input.getInstance()); // .ofNullable(input.getInstance());
//
if (oInst.isPresent()) { // if (oInst.isPresent()) {
out // out
.setInstance( // .setInstance(
oInst.get().stream().map(GraphResultMapper::getInstance).collect(Collectors.toList())); // oInst.get().stream().map(GraphResultMapper::getInstance).collect(Collectors.toList()));
//
} // }
//
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oL = Optional.ofNullable(input.getLanguage()); // Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> oL = Optional.ofNullable(input.getLanguage());
if (oL.isPresent()) { // if (oL.isPresent()) {
eu.dnetlib.dhp.schema.oaf.Qualifier language = oL.get(); // eu.dnetlib.dhp.schema.oaf.Qualifier language = oL.get();
out.setLanguage(Qualifier.newInstance(language.getClassid(), language.getClassname())); // out.setLanguage(Qualifier.newInstance(language.getClassid(), language.getClassname()));
} // }
Optional<Long> oLong = Optional.ofNullable(input.getLastupdatetimestamp()); // Optional<Long> oLong = Optional.ofNullable(input.getLastupdatetimestamp());
if (oLong.isPresent()) { // if (oLong.isPresent()) {
out.setLastupdatetimestamp(oLong.get()); // out.setLastupdatetimestamp(oLong.get());
} // }
Optional<List<StructuredProperty>> otitle = Optional.ofNullable(input.getTitle()); // Optional<List<StructuredProperty>> otitle = Optional.ofNullable(input.getTitle());
if (otitle.isPresent()) { // if (otitle.isPresent()) {
List<StructuredProperty> iTitle = otitle // List<StructuredProperty> iTitle = otitle
.get() // .get()
.stream() // .stream()
.filter(t -> t.getQualifier().getClassid().equalsIgnoreCase("main title")) // .filter(t -> t.getQualifier().getClassid().equalsIgnoreCase("main title"))
.collect(Collectors.toList()); // .collect(Collectors.toList());
if (!iTitle.isEmpty()) { // if (!iTitle.isEmpty()) {
out.setMaintitle(iTitle.get(0).getValue()); // out.setMaintitle(iTitle.get(0).getValue());
} // }
//
iTitle = otitle // iTitle = otitle
.get() // .get()
.stream() // .stream()
.filter(t -> t.getQualifier().getClassid().equalsIgnoreCase("subtitle")) // .filter(t -> t.getQualifier().getClassid().equalsIgnoreCase("subtitle"))
.collect(Collectors.toList()); // .collect(Collectors.toList());
if (!iTitle.isEmpty()) { // if (!iTitle.isEmpty()) {
out.setSubtitle(iTitle.get(0).getValue()); // out.setSubtitle(iTitle.get(0).getValue());
} // }
//
} // }
//
List<ControlledField> pids = new ArrayList<>(); // List<ControlledField> pids = new ArrayList<>();
Optional // Optional
.ofNullable(input.getPid()) // .ofNullable(input.getPid())
.ifPresent( // .ifPresent(
value -> value // value -> value
.stream() // .stream()
.forEach( // .forEach(
p -> pids // p -> pids
.add( // .add(
ControlledField // ControlledField
.newInstance(p.getQualifier().getClassid(), p.getValue())))); // .newInstance(p.getQualifier().getClassid(), p.getValue()))));
out.setPid(pids); // out.setPid(pids);
oStr = Optional.ofNullable(input.getDateofacceptance()); // oStr = Optional.ofNullable(input.getDateofacceptance());
if (oStr.isPresent()) { // if (oStr.isPresent()) {
out.setPublicationdate(oStr.get().getValue()); // out.setPublicationdate(oStr.get().getValue());
} // }
oStr = Optional.ofNullable(input.getPublisher()); // oStr = Optional.ofNullable(input.getPublisher());
if (oStr.isPresent()) { // if (oStr.isPresent()) {
out.setPublisher(oStr.get().getValue()); // out.setPublisher(oStr.get().getValue());
} // }
//
List<String> sourceList = new ArrayList<>(); // List<String> sourceList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getSource()) // .ofNullable(input.getSource())
.ifPresent(value -> value.stream().forEach(s -> sourceList.add(s.getValue()))); // .ifPresent(value -> value.stream().forEach(s -> sourceList.add(s.getValue())));
// out.setSource(input.getSource().stream().map(s -> s.getValue()).collect(Collectors.toList())); // // out.setSource(input.getSource().stream().map(s -> s.getValue()).collect(Collectors.toList()));
List<Subject> subjectList = new ArrayList<>(); // List<Subject> subjectList = new ArrayList<>();
Optional // Optional
.ofNullable(input.getSubject()) // .ofNullable(input.getSubject())
.ifPresent( // .ifPresent(
value -> value // value -> value
.forEach(s -> subjectList.add(getSubject(s)))); // .forEach(s -> subjectList.add(getSubject(s))));
//
out.setSubjects(subjectList); // out.setSubjects(subjectList);
//
out.setType(input.getResulttype().getClassid()); // out.setType(input.getResulttype().getClassid());
} // }
//
out // out
.setCollectedfrom( // .setCollectedfrom(
input // input
.getCollectedfrom() // .getCollectedfrom()
.stream() // .stream()
.map(cf -> KeyValue.newInstance(cf.getKey(), cf.getValue())) // .map(cf -> KeyValue.newInstance(cf.getKey(), cf.getValue()))
.collect(Collectors.toList())); // .collect(Collectors.toList()));
//
return out; // return out;
//
} // }
//
private static CommunityInstance getInstance(eu.dnetlib.dhp.schema.oaf.Instance i) { // private static CommunityInstance getInstance(eu.dnetlib.dhp.schema.oaf.Instance i) {
CommunityInstance instance = new CommunityInstance(); // CommunityInstance instance = new CommunityInstance();
//
setCommonValue(i, instance); // setCommonValue(i, instance);
//
instance // instance
.setCollectedfrom( // .setCollectedfrom(
KeyValue // KeyValue
.newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue())); // .newInstance(i.getCollectedfrom().getKey(), i.getCollectedfrom().getValue()));
//
instance // instance
.setHostedby( // .setHostedby(
KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue())); // KeyValue.newInstance(i.getHostedby().getKey(), i.getHostedby().getValue()));
//
return instance; // return instance;
//
} // }
//
private static <I extends Instance> void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) { // private static <I extends Instance> void setCommonValue(eu.dnetlib.dhp.schema.oaf.Instance i, I instance) {
Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> opAr = Optional // Optional<eu.dnetlib.dhp.schema.oaf.Qualifier> opAr = Optional
.ofNullable(i.getAccessright()); // .ofNullable(i.getAccessright());
if (opAr.isPresent()) { // if (opAr.isPresent()) {
if (Constants.accessRightsCoarMap.containsKey(opAr.get().getClassid())) { // if (Constants.accessRightsCoarMap.containsKey(opAr.get().getClassid())) {
String code = Constants.accessRightsCoarMap.get(opAr.get().getClassid()); // String code = Constants.accessRightsCoarMap.get(opAr.get().getClassid());
instance // instance
.setAccessright( // .setAccessright(
AccessRight // AccessRight
.newInstance( // .newInstance(
code, // code,
Constants.coarCodeLabelMap.get(code), // Constants.coarCodeLabelMap.get(code),
Constants.COAR_ACCESS_RIGHT_SCHEMA)); // Constants.COAR_ACCESS_RIGHT_SCHEMA));
} // }
} // }
//
Optional // Optional
.ofNullable(i.getLicense()) // .ofNullable(i.getLicense())
.ifPresent(value -> instance.setLicense(value.getValue())); // .ifPresent(value -> instance.setLicense(value.getValue()));
Optional // Optional
.ofNullable(i.getDateofacceptance()) // .ofNullable(i.getDateofacceptance())
.ifPresent(value -> instance.setPublicationdate(value.getValue())); // .ifPresent(value -> instance.setPublicationdate(value.getValue()));
Optional // Optional
.ofNullable(i.getRefereed()) // .ofNullable(i.getRefereed())
.ifPresent(value -> instance.setRefereed(value.getClassname())); // .ifPresent(value -> instance.setRefereed(value.getClassname()));
Optional // Optional
.ofNullable(i.getInstancetype()) // .ofNullable(i.getInstancetype())
.ifPresent(value -> instance.setType(value.getClassname())); // .ifPresent(value -> instance.setType(value.getClassname()));
Optional.ofNullable(i.getUrl()).ifPresent(value -> instance.setUrl(value)); // Optional.ofNullable(i.getUrl()).ifPresent(value -> instance.setUrl(value));
//
} // }
//
private static Subject getSubject(StructuredProperty s) { // private static Subject getSubject(StructuredProperty s) {
Subject subject = new Subject(); // Subject subject = new Subject();
subject.setSubject(ControlledField.newInstance(s.getQualifier().getClassid(), s.getValue())); // subject.setSubject(ControlledField.newInstance(s.getQualifier().getClassid(), s.getValue()));
Optional<DataInfo> di = Optional.ofNullable(s.getDataInfo()); // Optional<DataInfo> di = Optional.ofNullable(s.getDataInfo());
if (di.isPresent()) { // if (di.isPresent()) {
Provenance p = new Provenance(); // Provenance p = new Provenance();
p.setProvenance(di.get().getProvenanceaction().getClassname()); // p.setProvenance(di.get().getProvenanceaction().getClassname());
p.setTrust(di.get().getTrust()); // p.setTrust(di.get().getTrust());
subject.setProvenance(p); // subject.setProvenance(p);
} // }
//
return subject; // return subject;
} // }
//
private static Author getAuthor(eu.dnetlib.dhp.schema.oaf.Author oa) { // private static Author getAuthor(eu.dnetlib.dhp.schema.oaf.Author oa) {
Author a = new Author(); // Author a = new Author();
a.setFullname(oa.getFullname()); // a.setFullname(oa.getFullname());
a.setName(oa.getName()); // a.setName(oa.getName());
a.setSurname(oa.getSurname()); // a.setSurname(oa.getSurname());
a.setRank(oa.getRank()); // a.setRank(oa.getRank());
//
Optional<List<StructuredProperty>> oPids = Optional // Optional<List<StructuredProperty>> oPids = Optional
.ofNullable(oa.getPid()); // .ofNullable(oa.getPid());
if (oPids.isPresent()) { // if (oPids.isPresent()) {
Pid pid = getOrcid(oPids.get()); // Pid pid = getOrcid(oPids.get());
if (pid != null) { // if (pid != null) {
a.setPid(pid); // a.setPid(pid);
} // }
} // }
//
return a; // return a;
} // }
//
private static Pid getOrcid(List<StructuredProperty> p) { // private static Pid getOrcid(List<StructuredProperty> p) {
for (StructuredProperty pid : p) { // for (StructuredProperty pid : p) {
if (pid.getQualifier().getClassid().equals(ModelConstants.ORCID)) { // if (pid.getQualifier().getClassid().equals(ModelConstants.ORCID)) {
Optional<DataInfo> di = Optional.ofNullable(pid.getDataInfo()); // Optional<DataInfo> di = Optional.ofNullable(pid.getDataInfo());
if (di.isPresent()) { // if (di.isPresent()) {
return Pid // return Pid
.newInstance( // .newInstance(
ControlledField // ControlledField
.newInstance( // .newInstance(
pid.getQualifier().getClassid(), // pid.getQualifier().getClassid(),
pid.getValue()), // pid.getValue()),
Provenance // Provenance
.newInstance( // .newInstance(
di.get().getProvenanceaction().getClassname(), // di.get().getProvenanceaction().getClassname(),
di.get().getTrust())); // di.get().getTrust()));
} else { // } else {
return Pid // return Pid
.newInstance( // .newInstance(
ControlledField // ControlledField
.newInstance( // .newInstance(
pid.getQualifier().getClassid(), // pid.getQualifier().getClassid(),
pid.getValue()) // pid.getValue())
//
); // );
} // }
//
} // }
} // }
return null; // return null;
} // }
//
} //}

View File

@ -171,23 +171,23 @@ public class DumpJobTest {
GraphResult gr = verificationDataset.first(); GraphResult gr = verificationDataset.first();
Assertions.assertEquals(2, gr.getMeasures().size()); // Assertions.assertEquals(2, gr.getMeasures().size());
Assertions // Assertions
.assertTrue( // .assertTrue(
gr // gr
.getMeasures() // .getMeasures()
.stream() // .stream()
.anyMatch( // .anyMatch(
m -> m.getKey().equals("influence") // m -> m.getKey().equals("influence")
&& m.getValue().equals("1.62759106106e-08"))); // && m.getValue().equals("1.62759106106e-08")));
Assertions // Assertions
.assertTrue( // .assertTrue(
gr // gr
.getMeasures() // .getMeasures()
.stream() // .stream()
.anyMatch( // .anyMatch(
m -> m.getKey().equals("popularity") // m -> m.getKey().equals("popularity")
&& m.getValue().equals("0.22519296"))); // && m.getValue().equals("0.22519296")));
Assertions.assertEquals(6, gr.getAuthor().size()); Assertions.assertEquals(6, gr.getAuthor().size());
Assertions Assertions