From 0d88f9a6a48f483325ceb9116512c0fe1c8444e5 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 24 Oct 2019 17:43:42 +0200 Subject: [PATCH] added mapping for projects --- .../eu/dnetlib/dhp/schema/oaf/Project.java | 78 ++++++++++++------- .../eu/dnetlib/dhp/graph/ProtoConverter.java | 43 +++++++++- pom.xml | 2 +- 3 files changed, 93 insertions(+), 30 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java index 65f22da37d..5efe1526f6 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java @@ -61,207 +61,233 @@ public class Project extends OafEntity implements Serializable { return websiteurl; } - public void setWebsiteurl(Field websiteurl) { + public Project setWebsiteurl(Field websiteurl) { this.websiteurl = websiteurl; + return this; } public Field getCode() { return code; } - public void setCode(Field code) { + public Project setCode(Field code) { this.code = code; + return this; } public Field getAcronym() { return acronym; } - public void setAcronym(Field acronym) { + public Project setAcronym(Field acronym) { this.acronym = acronym; + return this; } public Field getTitle() { return title; } - public void setTitle(Field title) { + public Project setTitle(Field title) { this.title = title; + return this; } public Field getStartdate() { return startdate; } - public void setStartdate(Field startdate) { + public Project setStartdate(Field startdate) { this.startdate = startdate; + return this; } public Field getEnddate() { return enddate; } - public void setEnddate(Field enddate) { + public Project setEnddate(Field enddate) { this.enddate = enddate; + return this; } public Field getCallidentifier() { return callidentifier; } - public void setCallidentifier(Field callidentifier) { + public Project setCallidentifier(Field callidentifier) { this.callidentifier = callidentifier; + return this; } public Field getKeywords() { return keywords; } - public void setKeywords(Field keywords) { + public Project setKeywords(Field keywords) { this.keywords = keywords; + return this; } public Field getDuration() { return duration; } - public void setDuration(Field duration) { + public Project setDuration(Field duration) { this.duration = duration; + return this; } public Field getEcsc39() { return ecsc39; } - public void setEcsc39(Field ecsc39) { + public Project setEcsc39(Field ecsc39) { this.ecsc39 = ecsc39; + return this; } public Field getOamandatepublications() { return oamandatepublications; } - public void setOamandatepublications(Field oamandatepublications) { + public Project setOamandatepublications(Field oamandatepublications) { this.oamandatepublications = oamandatepublications; + return this; } public Field getEcarticle29_3() { return ecarticle29_3; } - public void setEcarticle29_3(Field ecarticle29_3) { + public Project setEcarticle29_3(Field ecarticle29_3) { this.ecarticle29_3 = ecarticle29_3; + return this; } public List getSubjects() { return subjects; } - public void setSubjects(List subjects) { + public Project setSubjects(List subjects) { this.subjects = subjects; + return this; } public List> getFundingtree() { return fundingtree; } - public void setFundingtree(List> fundingtree) { + public Project setFundingtree(List> fundingtree) { this.fundingtree = fundingtree; + return this; } public Qualifier getContracttype() { return contracttype; } - public void setContracttype(Qualifier contracttype) { + public Project setContracttype(Qualifier contracttype) { this.contracttype = contracttype; + return this; } public Field getOptional1() { return optional1; } - public void setOptional1(Field optional1) { + public Project setOptional1(Field optional1) { this.optional1 = optional1; + return this; } public Field getOptional2() { return optional2; } - public void setOptional2(Field optional2) { + public Project setOptional2(Field optional2) { this.optional2 = optional2; + return this; } public Field getJsonextrainfo() { return jsonextrainfo; } - public void setJsonextrainfo(Field jsonextrainfo) { + public Project setJsonextrainfo(Field jsonextrainfo) { this.jsonextrainfo = jsonextrainfo; + return this; } public Field getContactfullname() { return contactfullname; } - public void setContactfullname(Field contactfullname) { + public Project setContactfullname(Field contactfullname) { this.contactfullname = contactfullname; + return this; } public Field getContactfax() { return contactfax; } - public void setContactfax(Field contactfax) { + public Project setContactfax(Field contactfax) { this.contactfax = contactfax; + return this; } public Field getContactphone() { return contactphone; } - public void setContactphone(Field contactphone) { + public Project setContactphone(Field contactphone) { this.contactphone = contactphone; + return this; } public Field getContactemail() { return contactemail; } - public void setContactemail(Field contactemail) { + public Project setContactemail(Field contactemail) { this.contactemail = contactemail; + return this; } public Field getSummary() { return summary; } - public void setSummary(Field summary) { + public Project setSummary(Field summary) { this.summary = summary; + return this; } public Field getCurrency() { return currency; } - public void setCurrency(Field currency) { + public Project setCurrency(Field currency) { this.currency = currency; + return this; } public Float getTotalcost() { return totalcost; } - public void setTotalcost(Float totalcost) { + public Project setTotalcost(Float totalcost) { this.totalcost = totalcost; + return this; } public Float getFundedamount() { return fundedamount; } - public void setFundedamount(Float fundedamount) { + public Project setFundedamount(Float fundedamount) { this.fundedamount = fundedamount; + return this; } } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoConverter.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoConverter.java index 40b15a6a13..679d37375c 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoConverter.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoConverter.java @@ -2,13 +2,13 @@ package eu.dnetlib.dhp.graph; import eu.dnetlib.data.proto.KindProtos; import eu.dnetlib.data.proto.OafProtos; +import eu.dnetlib.data.proto.ProjectProtos; import eu.dnetlib.dhp.schema.oaf.*; import java.io.Serializable; import java.util.stream.Collectors; -import static eu.dnetlib.dhp.graph.ProtoUtils.mapDataInfo; -import static eu.dnetlib.dhp.graph.ProtoUtils.mapKV; +import static eu.dnetlib.dhp.graph.ProtoUtils.*; public class ProtoConverter implements Serializable { @@ -88,11 +88,48 @@ public class ProtoConverter implements Serializable { } private static Project convertProject(OafProtos.Oaf oaf) { - return new Project(); + final ProjectProtos.Project.Metadata m = oaf.getEntity().getProject().getMetadata(); + final Project project = new Project(); + project.setDataInfo(mapDataInfo(oaf.getDataInfo())); + project.setLastupdatetimestamp(oaf.getLastupdatetimestamp()); + return project + .setAcronym(mapStringField(m.getAcronym())) + .setCallidentifier(mapStringField(m.getCallidentifier())) + .setCode(mapStringField(m.getCode())) + .setContactemail(mapStringField(m.getContactemail())) + .setContactfax(mapStringField(m.getContactfax())) + .setContactfullname(mapStringField(m.getContactfullname())) + .setContactphone(mapStringField(m.getContactphone())) + .setContracttype(mapQualifier(m.getContracttype())) + .setCurrency(mapStringField(m.getCurrency())) + .setDuration(mapStringField(m.getDuration())) + .setEcarticle29_3(mapStringField(m.getEcarticle293())) + .setEcsc39(mapStringField(m.getEcsc39())) + .setOamandatepublications(mapStringField(m.getOamandatepublications())) + .setStartdate(mapStringField(m.getStartdate())) + .setEnddate(mapStringField(m.getEnddate())) + .setFundedamount(m.getFundedamount()) + .setTotalcost(m.getTotalcost()) + .setKeywords(mapStringField(m.getKeywords())) + .setSubjects(m.getSubjectsCount() > 0 ? + m.getSubjectsList().stream() + .map(sp -> mapStructuredProperty(sp)) + .collect(Collectors.toList()) : null) + .setTitle(mapStringField(m.getTitle())) + .setWebsiteurl(mapStringField(m.getWebsiteurl())) + .setFundingtree(m.getFundingtreeCount() > 0 ? + m.getFundingtreeList().stream() + .map(f -> mapStringField(f)) + .collect(Collectors.toList()) : null) + .setJsonextrainfo(mapStringField(m.getJsonextrainfo())) + .setSummary(mapStringField(m.getSummary())) + .setOptional1(mapStringField(m.getOptional1())) + .setOptional2(mapStringField(m.getOptional2())); } private static Result convertResult(OafProtos.Oaf oaf) { switch (oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()) { + case "dataset": return createDataset(oaf); case "publication": diff --git a/pom.xml b/pom.xml index 5e00ada157..f37a58f2a2 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ eu.dnetlib dnet-openaire-data-protos - 3.9.4 + 3.9.5