From 2dd9572f41280b32ade9c5f6af966d9d8cd7cfcf Mon Sep 17 00:00:00 2001 From: "sandro.labruzzo" Date: Thu, 24 Oct 2019 17:36:44 +0200 Subject: [PATCH 1/6] added Mapping of OriginalDescription --- .../dnetlib/dhp/schema/oaf/OAIProvenance.java | 3 ++- .../dhp/schema/oaf/OriginDescription.java | 21 ++++++++++++------- .../java/eu/dnetlib/dhp/graph/ProtoUtils.java | 20 ++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java index bb97654b98..8990009a47 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java @@ -10,7 +10,8 @@ public class OAIProvenance implements Serializable { return originDescription; } - public void setOriginDescription(OriginDescription originDescription) { + public OAIProvenance setOriginDescription(OriginDescription originDescription) { this.originDescription = originDescription; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java index 898c162100..e593330e4a 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java @@ -22,55 +22,62 @@ public class OriginDescription implements Serializable { return harvestDate; } - public void setHarvestDate(String harvestDate) { + public OriginDescription setHarvestDate(String harvestDate) { this.harvestDate = harvestDate; + return this; } public Boolean getAltered() { return altered; } - public void setAltered(Boolean altered) { + public OriginDescription setAltered(Boolean altered) { this.altered = altered; + return this; } public String getBaseURL() { return baseURL; } - public void setBaseURL(String baseURL) { + public OriginDescription setBaseURL(String baseURL) { this.baseURL = baseURL; + return this; } public String getIdentifier() { return identifier; } - public void setIdentifier(String identifier) { + public OriginDescription setIdentifier(String identifier) { this.identifier = identifier; + return this; } public String getDatestamp() { return datestamp; } - public void setDatestamp(String datestamp) { + public OriginDescription setDatestamp(String datestamp) { this.datestamp = datestamp; + return this; } public String getMetadataNamespace() { return metadataNamespace; } - public void setMetadataNamespace(String metadataNamespace) { + public OriginDescription setMetadataNamespace(String metadataNamespace) { this.metadataNamespace = metadataNamespace; + return this; } public OriginDescription getOriginDescription() { return originDescription; } - public void setOriginDescription(OriginDescription originDescription) { + public OriginDescription setOriginDescription(OriginDescription originDescription) { this.originDescription = originDescription; + return this; } } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java index 91e33b0883..97b9c32973 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java @@ -54,6 +54,26 @@ public class ProtoUtils { .setValue(extraInfo.getValue()); } + + public static OAIProvenance mapOAIProvenance(FieldTypeProtos.OAIProvenance oaiProvenance) { + return new OAIProvenance().setOriginDescription(mapOriginalDescription(oaiProvenance.getOriginDescription())); + } + + + public static OriginDescription mapOriginalDescription(FieldTypeProtos.OAIProvenance.OriginDescription originDescription) { + final OriginDescription originDescriptionResult = new OriginDescription() + .setHarvestDate(originDescription.getHarvestDate()) + .setAltered(originDescription.getAltered()) + .setBaseURL(originDescription.getBaseURL()) + .setIdentifier(originDescription.getIdentifier()) + .setDatestamp(originDescription.getDatestamp()) + .setMetadataNamespace(originDescription.getMetadataNamespace()); + if (originDescription.hasOriginDescription()) + originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription())); + return originDescriptionResult; + + } + public static Field mapStringField(FieldTypeProtos.StringField s) { return new Field() .setValue(s.getValue()) From 0d88f9a6a48f483325ceb9116512c0fe1c8444e5 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 24 Oct 2019 17:43:42 +0200 Subject: [PATCH 2/6] 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 From 3a8bb11695a9d6a2b5e64e369f3b19bccb597162 Mon Sep 17 00:00:00 2001 From: "sandro.labruzzo" Date: Thu, 24 Oct 2019 17:55:40 +0200 Subject: [PATCH 3/6] mapped first part --- .../eu/dnetlib/dhp/graph/ProtoConverter.java | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) 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 0fa83a51a2..04da0d10c7 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 @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.graph; +import eu.dnetlib.data.proto.DatasourceProtos; import eu.dnetlib.data.proto.KindProtos; import eu.dnetlib.data.proto.OafProtos; import eu.dnetlib.dhp.schema.oaf.*; @@ -7,8 +8,7 @@ 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 { @@ -99,6 +99,57 @@ public class ProtoConverter implements Serializable { .map(ProtoUtils::mapExtraInfo) .collect(Collectors.toList())); + result.setOaiprovenance(mapOAIProvenance(entity.getOaiprovenance())); + + //Setting Datasource fields + final DatasourceProtos.Datasource.Metadata datasource = entity.getDatasource().getMetadata(); + + result.setDatasourcetype(mapQualifier(datasource.getDatasourcetype())); + result.setOpenairecompatibility(mapQualifier(datasource.getOpenairecompatibility())); + + result.setOfficialname(mapStringField(datasource.getOfficialname())); + result.setEnglishname(mapStringField(datasource.getEnglishname())); + result.setWebsiteurl(mapStringField(datasource.getWebsiteurl())); + result.setLogourl(mapStringField(datasource.getLogourl())); + result.setContactemail(mapStringField(datasource.getContactemail())); + result.setNamespaceprefix(mapStringField(datasource.getNamespaceprefix())); + + result.setLatitude(mapStringField(datasource.getLatitude())); + result.setLongitude(mapStringField(datasource.getLongitude())); + result.setDateofvalidation(mapStringField(datasource.getDateofvalidation())); + result.setDescription(mapStringField(datasource.getDescription())); + + result.setSubjects(datasource.getSubjectsList() + .stream() + .map(ProtoUtils::mapStructuredProperty) + .collect(Collectors.toList()) + ); + + result.setOdnumberofitems(mapStringField(datasource.getOdnumberofitems())); + result.setOdnumberofitemsdate(mapStringField(datasource.getOdnumberofitemsdate())); + result.setOdpolicies(mapStringField(datasource.getOdpolicies())); + + result.setOdlanguages(datasource + .getOdlanguagesList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) + ); + + result.setOdcontenttypes(datasource.getOdcontenttypesList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) + ); + + result.setAccessinfopackage(datasource.getAccessinfopackageList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) + ); + + //TODO r3data fields + return result; } From 09ffda03a25a7dcd0d4961af2554e8619a7f4097 Mon Sep 17 00:00:00 2001 From: "sandro.labruzzo" Date: Fri, 25 Oct 2019 09:24:18 +0200 Subject: [PATCH 4/6] removed circular dependencies --- .../eu/dnetlib/dhp/schema/oaf/Datasource.java | 10 ++--- .../eu/dnetlib/dhp/schema/oaf/Journal.java | 36 ++++++++++++------ .../eu/dnetlib/dhp/schema/oaf/OafEntity.java | 16 ++++---- .../dhp/schema/oaf/OriginDescription.java | 18 ++++----- .../eu/dnetlib/dhp/schema/oaf/Qualifier.java | 18 ++++----- .../eu/dnetlib/dhp/graph/ProtoConverter.java | 38 +++++++++++++++---- .../java/eu/dnetlib/dhp/graph/ProtoUtils.java | 28 ++++++++++++-- .../dhp/graph/SparkGraphImporterJob.java | 23 +++++++---- .../dnetlib/dhp/graph/ProtoConverterTest.java | 4 ++ 9 files changed, 128 insertions(+), 63 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java index 354045ba70..21408a5ec0 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java @@ -65,7 +65,7 @@ public class Datasource extends OafEntity implements Serializable { private Field databaseaccessrestriction; // {feeRequired, registration, other} - private Field datauploadrestriction9; + private Field datauploadrestriction; private Field versioning; @@ -298,12 +298,12 @@ public class Datasource extends OafEntity implements Serializable { this.databaseaccessrestriction = databaseaccessrestriction; } - public Field getDatauploadrestriction9() { - return datauploadrestriction9; + public Field getDatauploadrestriction() { + return datauploadrestriction; } - public void setDatauploadrestriction9(Field datauploadrestriction9) { - this.datauploadrestriction9 = datauploadrestriction9; + public void setDatauploadrestriction(Field datauploadrestriction) { + this.datauploadrestriction = datauploadrestriction; } public Field getVersioning() { diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java index 06e5ca7dc1..b0a53e5c49 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java @@ -32,95 +32,107 @@ public class Journal implements Serializable { return name; } - public void setName(String name) { + public Journal setName(String name) { this.name = name; + return this; } public String getIssnPrinted() { return issnPrinted; } - public void setIssnPrinted(String issnPrinted) { + public Journal setIssnPrinted(String issnPrinted) { this.issnPrinted = issnPrinted; + return this; } public String getIssnOnline() { return issnOnline; } - public void setIssnOnline(String issnOnline) { + public Journal setIssnOnline(String issnOnline) { this.issnOnline = issnOnline; + return this; } public String getIssnLinking() { return issnLinking; } - public void setIssnLinking(String issnLinking) { + public Journal setIssnLinking(String issnLinking) { this.issnLinking = issnLinking; + return this; } public String getEp() { return ep; } - public void setEp(String ep) { + public Journal setEp(String ep) { this.ep = ep; + return this; } public String getIss() { return iss; } - public void setIss(String iss) { + public Journal setIss(String iss) { this.iss = iss; + return this; } public String getSp() { return sp; } - public void setSp(String sp) { + public Journal setSp(String sp) { this.sp = sp; + return this; } public String getVol() { return vol; } - public void setVol(String vol) { + public Journal setVol(String vol) { this.vol = vol; + return this; } public String getEdition() { return edition; } - public void setEdition(String edition) { + public Journal setEdition(String edition) { this.edition = edition; + return this; } public String getConferenceplace() { return conferenceplace; } - public void setConferenceplace(String conferenceplace) { + public Journal setConferenceplace(String conferenceplace) { this.conferenceplace = conferenceplace; + return this; } public String getConferencedate() { return conferencedate; } - public void setConferencedate(String conferencedate) { + public Journal setConferencedate(String conferencedate) { this.conferencedate = conferencedate; + return this; } public DataInfo getDataInfo() { return dataInfo; } - public void setDataInfo(DataInfo dataInfo) { + public Journal setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java index 98f435fab4..e5d07539fa 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java @@ -18,7 +18,7 @@ public abstract class OafEntity extends Oaf implements Serializable { private String dateoftransformation; //TODO remove this field - private List children; +// private List children; private List extraInfo; @@ -73,13 +73,13 @@ public abstract class OafEntity extends Oaf implements Serializable { this.dateoftransformation = dateoftransformation; } - public List getChildren() { - return children; - } - - public void setChildren(List children) { - this.children = children; - } +// public List getChildren() { +// return children; +// } +// +// public void setChildren(List children) { +// this.children = children; +// } public List getExtraInfo() { return extraInfo; diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java index e593330e4a..cba4011743 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java @@ -16,7 +16,7 @@ public class OriginDescription implements Serializable { private String metadataNamespace; - private OriginDescription originDescription; + //private OriginDescription originDescription; public String getHarvestDate() { return harvestDate; @@ -72,12 +72,12 @@ public class OriginDescription implements Serializable { return this; } - public OriginDescription getOriginDescription() { - return originDescription; - } - - public OriginDescription setOriginDescription(OriginDescription originDescription) { - this.originDescription = originDescription; - return this; - } +// public OriginDescription getOriginDescription() { +// return originDescription; +// } +// +// public OriginDescription setOriginDescription(OriginDescription originDescription) { +// this.originDescription = originDescription; +// return this; +// } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java index b586855a1f..0320798f0f 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java @@ -9,7 +9,7 @@ public class Qualifier implements Serializable { private String schemeid; private String schemename; - private DataInfo dataInfo; +// private DataInfo dataInfo; public String getClassid() { return classid; @@ -47,12 +47,12 @@ public class Qualifier implements Serializable { return this; } - public DataInfo getDataInfo() { - return dataInfo; - } - - public Qualifier setDataInfo(DataInfo dataInfo) { - this.dataInfo = dataInfo; - return this; - } +// public DataInfo getDataInfo() { +// return dataInfo; +// } +// +// public Qualifier setDataInfo(DataInfo dataInfo) { +// this.dataInfo = dataInfo; +// 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 10473f6d91..f0fde32f34 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 @@ -20,7 +20,7 @@ public class ProtoConverter implements Serializable { if (oaf.getKind() == KindProtos.Kind.entity) return convertEntity(oaf); else { - return convertRelation(oaf); + return convertRelation(oaf); } } catch (Throwable e) { throw new RuntimeException(e); @@ -40,8 +40,8 @@ public class ProtoConverter implements Serializable { .setRelClass(r.getRelClass()) .setCollectedFrom(r.getCollectedfromCount() > 0 ? r.getCollectedfromList().stream() - .map(kv -> mapKV(kv)) - .collect(Collectors.toList()) : null); + .map(kv -> mapKV(kv)) + .collect(Collectors.toList()) : null); } private static OafEntity convertEntity(OafProtos.Oaf oaf) { @@ -151,6 +151,28 @@ public class ProtoConverter implements Serializable { //TODO r3data fields + result.setReleasestartdate(mapStringField(datasource.getReleasestartdate())); + result.setReleaseenddate(mapStringField(datasource.getReleaseenddate())); + result.setMissionstatementurl(mapStringField(datasource.getMissionstatementurl())); + result.setDataprovider(mapBoolField(datasource.getDataprovider())); + result.setServiceprovider(mapBoolField(datasource.getServiceprovider())); + result.setDatabaseaccesstype(mapStringField(datasource.getDatabaseaccesstype())); + result.setDatauploadtype(mapStringField(datasource.getDatauploadtype())); + result.setDatabaseaccessrestriction(mapStringField(datasource.getDatabaseaccessrestriction())); + result.setDatauploadrestriction(mapStringField(datasource.getDatauploadrestriction())); + result.setVersioning(mapBoolField(datasource.getVersioning())); + result.setCitationguidelineurl(mapStringField(datasource.getCitationguidelineurl())); + result.setQualitymanagementkind(mapStringField(datasource.getQualitymanagementkind())); + result.setPidsystems(mapStringField(datasource.getPidsystems())); + result.setCertificates(mapStringField(datasource.getCertificates())); + result.setPolicies(datasource.getPoliciesList() + .stream() + .map(ProtoUtils::mapKV) + .collect(Collectors.toList()) + ); + + result.setJournal(mapJournal(datasource.getJournal())); + return result; } @@ -180,14 +202,14 @@ public class ProtoConverter implements Serializable { .setKeywords(mapStringField(m.getKeywords())) .setSubjects(m.getSubjectsCount() > 0 ? m.getSubjectsList().stream() - .map(sp -> mapStructuredProperty(sp)) - .collect(Collectors.toList()) : null) + .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) + .map(f -> mapStringField(f)) + .collect(Collectors.toList()) : null) .setJsonextrainfo(mapStringField(m.getJsonextrainfo())) .setSummary(mapStringField(m.getSummary())) .setOptional1(mapStringField(m.getOptional1())) @@ -206,7 +228,7 @@ public class ProtoConverter implements Serializable { case "orp": return createORP(oaf); default: - throw new RuntimeException("received unknown type :"+oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()); + throw new RuntimeException("received unknown type :" + oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()); } } diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java index 97b9c32973..90c590b667 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java @@ -34,8 +34,8 @@ public class ProtoUtils { .setClassid(q.getClassid()) .setClassname(q.getClassname()) .setSchemeid(q.getSchemeid()) - .setSchemename(q.getSchemename()) - .setDataInfo(q.hasDataInfo() ? mapDataInfo(q.getDataInfo()) : null); + .setSchemename(q.getSchemename()); + //.setDataInfo(q.hasDataInfo() ? mapDataInfo(q.getDataInfo()) : null); } public static StructuredProperty mapStructuredProperty(FieldTypeProtos.StructuredProperty sp) { @@ -68,10 +68,30 @@ public class ProtoUtils { .setIdentifier(originDescription.getIdentifier()) .setDatestamp(originDescription.getDatestamp()) .setMetadataNamespace(originDescription.getMetadataNamespace()); - if (originDescription.hasOriginDescription()) - originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription())); +// if (originDescription.hasOriginDescription()) +// originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription())); return originDescriptionResult; + } + + public static Journal mapJournal(FieldTypeProtos.Journal journal) { + return new Journal() + .setName(journal.getName()) + .setIssnPrinted(journal.getIssnPrinted()) + .setIssnOnline(journal.getIssnOnline()) + .setIssnLinking(journal.getIssnLinking()) + .setEp(journal.getEp()) + .setIss(journal.getIss()) + .setSp(journal.getSp()) + .setVol(journal.getVol()) + .setEdition(journal.getEdition()) + .setConferenceplace(journal.getConferenceplace()) + .setConferencedate(journal.getConferencedate()) + .setDataInfo(mapDataInfo(journal.getDataInfo())) + ; + + + } public static Field mapStringField(FieldTypeProtos.StringField s) { diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/SparkGraphImporterJob.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/SparkGraphImporterJob.java index a73ed8d754..804ecbd7b1 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/SparkGraphImporterJob.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/SparkGraphImporterJob.java @@ -1,15 +1,21 @@ package eu.dnetlib.dhp.graph; +import eu.dnetlib.dhp.schema.oaf.Datasource; import eu.dnetlib.dhp.schema.oaf.Oaf; import eu.dnetlib.dhp.schema.oaf.Publication; import org.apache.hadoop.io.Text; import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaSparkContext; import org.apache.spark.api.java.function.PairFunction; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Encoder; +import org.apache.spark.sql.Encoders; import org.apache.spark.sql.SparkSession; import scala.Tuple2; +import javax.xml.crypto.Data; + public class SparkGraphImporterJob { @@ -32,18 +38,19 @@ public class SparkGraphImporterJob { final JavaRDD> inputRDD = sc.sequenceFile("file:///home/sandro/part-m-00000", Text.class, Text.class).map(item -> new Tuple2<>(item._1.toString(), item._2.toString())); - Tuple2 item = inputRDD + final JavaRDD datasources = inputRDD .filter(s -> s._1().split("@")[2].equalsIgnoreCase("body")) - .first(); - System.out.println(item._1()); - System.out.println(item._2()); + .map(Tuple2::_2) + .map(ProtoConverter::convert) + .filter(s-> s instanceof Datasource) + .map(s->(Datasource)s); + final Encoder encoder = Encoders.bean(Datasource.class); + final Dataset mdstore = spark.createDataset(datasources.rdd(), encoder); -// .map(Tuple2::_2) -// .map(ProtoConverter::convert) -// .mapToPair((PairFunction) s-> new Tuple2(s.getClass().getName(),1)) -// .reduceByKey(Integer::sum).collect().forEach(System.out::println); + System.out.println(mdstore.count()); + // // // .filter(s -> s instanceof Publication) diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/graph/ProtoConverterTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/graph/ProtoConverterTest.java index 3640cb9965..fd0edf5733 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/graph/ProtoConverterTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/graph/ProtoConverterTest.java @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.graph; +import com.fasterxml.jackson.databind.ObjectMapper; import eu.dnetlib.dhp.schema.oaf.Datasource; import eu.dnetlib.dhp.schema.oaf.Oaf; import org.apache.commons.io.IOUtils; @@ -23,6 +24,9 @@ public class ProtoConverterTest { System.out.println(ds.getId()); + ObjectMapper mapper = new ObjectMapper(); + System.out.println(mapper.writeValueAsString(result)); + } From c929c1dface2381845f526574103b20588bdfd5c Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Fri, 25 Oct 2019 09:25:36 +0200 Subject: [PATCH 5/6] more proto 2 graph model mappings --- .../eu/dnetlib/dhp/schema/oaf/Datasource.java | 113 ++++++++++++------ .../eu/dnetlib/dhp/schema/oaf/Journal.java | 36 ++++-- .../java/eu/dnetlib/dhp/schema/oaf/Oaf.java | 6 +- .../eu/dnetlib/dhp/schema/oaf/OafEntity.java | 27 +++-- .../eu/dnetlib/dhp/graph/ProtoConverter.java | 107 ++++++++++------- .../java/eu/dnetlib/dhp/graph/ProtoUtils.java | 48 +++++++- 6 files changed, 231 insertions(+), 106 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java index 354045ba70..33e994d4a1 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java @@ -65,7 +65,7 @@ public class Datasource extends OafEntity implements Serializable { private Field databaseaccessrestriction; // {feeRequired, registration, other} - private Field datauploadrestriction9; + private Field datauploadrestriction; private Field versioning; @@ -86,279 +86,314 @@ public class Datasource extends OafEntity implements Serializable { return datasourcetype; } - public void setDatasourcetype(Qualifier datasourcetype) { + public Datasource setDatasourcetype(Qualifier datasourcetype) { this.datasourcetype = datasourcetype; + return this; } public Qualifier getOpenairecompatibility() { return openairecompatibility; } - public void setOpenairecompatibility(Qualifier openairecompatibility) { + public Datasource setOpenairecompatibility(Qualifier openairecompatibility) { this.openairecompatibility = openairecompatibility; + return this; } public Field getOfficialname() { return officialname; } - public void setOfficialname(Field officialname) { + public Datasource setOfficialname(Field officialname) { this.officialname = officialname; + return this; } public Field getEnglishname() { return englishname; } - public void setEnglishname(Field englishname) { + public Datasource setEnglishname(Field englishname) { this.englishname = englishname; + return this; } public Field getWebsiteurl() { return websiteurl; } - public void setWebsiteurl(Field websiteurl) { + public Datasource setWebsiteurl(Field websiteurl) { this.websiteurl = websiteurl; + return this; } public Field getLogourl() { return logourl; } - public void setLogourl(Field logourl) { + public Datasource setLogourl(Field logourl) { this.logourl = logourl; + return this; } public Field getContactemail() { return contactemail; } - public void setContactemail(Field contactemail) { + public Datasource setContactemail(Field contactemail) { this.contactemail = contactemail; + return this; } public Field getNamespaceprefix() { return namespaceprefix; } - public void setNamespaceprefix(Field namespaceprefix) { + public Datasource setNamespaceprefix(Field namespaceprefix) { this.namespaceprefix = namespaceprefix; + return this; } public Field getLatitude() { return latitude; } - public void setLatitude(Field latitude) { + public Datasource setLatitude(Field latitude) { this.latitude = latitude; + return this; } public Field getLongitude() { return longitude; } - public void setLongitude(Field longitude) { + public Datasource setLongitude(Field longitude) { this.longitude = longitude; + return this; } public Field getDateofvalidation() { return dateofvalidation; } - public void setDateofvalidation(Field dateofvalidation) { + public Datasource setDateofvalidation(Field dateofvalidation) { this.dateofvalidation = dateofvalidation; + return this; } public Field getDescription() { return description; } - public void setDescription(Field description) { + public Datasource setDescription(Field description) { this.description = description; + return this; } public List getSubjects() { return subjects; } - public void setSubjects(List subjects) { + public Datasource setSubjects(List subjects) { this.subjects = subjects; + return this; } public Field getOdnumberofitems() { return odnumberofitems; } - public void setOdnumberofitems(Field odnumberofitems) { + public Datasource setOdnumberofitems(Field odnumberofitems) { this.odnumberofitems = odnumberofitems; + return this; } public Field getOdnumberofitemsdate() { return odnumberofitemsdate; } - public void setOdnumberofitemsdate(Field odnumberofitemsdate) { + public Datasource setOdnumberofitemsdate(Field odnumberofitemsdate) { this.odnumberofitemsdate = odnumberofitemsdate; + return this; } public Field getOdpolicies() { return odpolicies; } - public void setOdpolicies(Field odpolicies) { + public Datasource setOdpolicies(Field odpolicies) { this.odpolicies = odpolicies; + return this; } public List> getOdlanguages() { return odlanguages; } - public void setOdlanguages(List> odlanguages) { + public Datasource setOdlanguages(List> odlanguages) { this.odlanguages = odlanguages; + return this; } public List> getOdcontenttypes() { return odcontenttypes; } - public void setOdcontenttypes(List> odcontenttypes) { + public Datasource setOdcontenttypes(List> odcontenttypes) { this.odcontenttypes = odcontenttypes; + return this; } public List> getAccessinfopackage() { return accessinfopackage; } - public void setAccessinfopackage(List> accessinfopackage) { + public Datasource setAccessinfopackage(List> accessinfopackage) { this.accessinfopackage = accessinfopackage; + return this; } public Field getReleasestartdate() { return releasestartdate; } - public void setReleasestartdate(Field releasestartdate) { + public Datasource setReleasestartdate(Field releasestartdate) { this.releasestartdate = releasestartdate; + return this; } public Field getReleaseenddate() { return releaseenddate; } - public void setReleaseenddate(Field releaseenddate) { + public Datasource setReleaseenddate(Field releaseenddate) { this.releaseenddate = releaseenddate; + return this; } public Field getMissionstatementurl() { return missionstatementurl; } - public void setMissionstatementurl(Field missionstatementurl) { + public Datasource setMissionstatementurl(Field missionstatementurl) { this.missionstatementurl = missionstatementurl; + return this; } public Field getDataprovider() { return dataprovider; } - public void setDataprovider(Field dataprovider) { + public Datasource setDataprovider(Field dataprovider) { this.dataprovider = dataprovider; + return this; } public Field getServiceprovider() { return serviceprovider; } - public void setServiceprovider(Field serviceprovider) { + public Datasource setServiceprovider(Field serviceprovider) { this.serviceprovider = serviceprovider; + return this; } public Field getDatabaseaccesstype() { return databaseaccesstype; } - public void setDatabaseaccesstype(Field databaseaccesstype) { + public Datasource setDatabaseaccesstype(Field databaseaccesstype) { this.databaseaccesstype = databaseaccesstype; + return this; } public Field getDatauploadtype() { return datauploadtype; } - public void setDatauploadtype(Field datauploadtype) { + public Datasource setDatauploadtype(Field datauploadtype) { this.datauploadtype = datauploadtype; + return this; } public Field getDatabaseaccessrestriction() { return databaseaccessrestriction; } - public void setDatabaseaccessrestriction(Field databaseaccessrestriction) { + public Datasource setDatabaseaccessrestriction(Field databaseaccessrestriction) { this.databaseaccessrestriction = databaseaccessrestriction; + return this; } - public Field getDatauploadrestriction9() { - return datauploadrestriction9; + public Field getDatauploadrestriction() { + return datauploadrestriction; } - public void setDatauploadrestriction9(Field datauploadrestriction9) { - this.datauploadrestriction9 = datauploadrestriction9; + public Datasource setDatauploadrestriction(Field datauploadrestriction) { + this.datauploadrestriction = datauploadrestriction; + return this; } public Field getVersioning() { return versioning; } - public void setVersioning(Field versioning) { + public Datasource setVersioning(Field versioning) { this.versioning = versioning; + return this; } public Field getCitationguidelineurl() { return citationguidelineurl; } - public void setCitationguidelineurl(Field citationguidelineurl) { + public Datasource setCitationguidelineurl(Field citationguidelineurl) { this.citationguidelineurl = citationguidelineurl; + return this; } public Field getQualitymanagementkind() { return qualitymanagementkind; } - public void setQualitymanagementkind(Field qualitymanagementkind) { + public Datasource setQualitymanagementkind(Field qualitymanagementkind) { this.qualitymanagementkind = qualitymanagementkind; + return this; } public Field getPidsystems() { return pidsystems; } - public void setPidsystems(Field pidsystems) { + public Datasource setPidsystems(Field pidsystems) { this.pidsystems = pidsystems; + return this; } public Field getCertificates() { return certificates; } - public void setCertificates(Field certificates) { + public Datasource setCertificates(Field certificates) { this.certificates = certificates; + return this; } public List getPolicies() { return policies; } - public void setPolicies(List policies) { + public Datasource setPolicies(List policies) { this.policies = policies; + return this; } public Journal getJournal() { return journal; } - public void setJournal(Journal journal) { + public Datasource setJournal(Journal journal) { this.journal = journal; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java index 06e5ca7dc1..b0a53e5c49 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java @@ -32,95 +32,107 @@ public class Journal implements Serializable { return name; } - public void setName(String name) { + public Journal setName(String name) { this.name = name; + return this; } public String getIssnPrinted() { return issnPrinted; } - public void setIssnPrinted(String issnPrinted) { + public Journal setIssnPrinted(String issnPrinted) { this.issnPrinted = issnPrinted; + return this; } public String getIssnOnline() { return issnOnline; } - public void setIssnOnline(String issnOnline) { + public Journal setIssnOnline(String issnOnline) { this.issnOnline = issnOnline; + return this; } public String getIssnLinking() { return issnLinking; } - public void setIssnLinking(String issnLinking) { + public Journal setIssnLinking(String issnLinking) { this.issnLinking = issnLinking; + return this; } public String getEp() { return ep; } - public void setEp(String ep) { + public Journal setEp(String ep) { this.ep = ep; + return this; } public String getIss() { return iss; } - public void setIss(String iss) { + public Journal setIss(String iss) { this.iss = iss; + return this; } public String getSp() { return sp; } - public void setSp(String sp) { + public Journal setSp(String sp) { this.sp = sp; + return this; } public String getVol() { return vol; } - public void setVol(String vol) { + public Journal setVol(String vol) { this.vol = vol; + return this; } public String getEdition() { return edition; } - public void setEdition(String edition) { + public Journal setEdition(String edition) { this.edition = edition; + return this; } public String getConferenceplace() { return conferenceplace; } - public void setConferenceplace(String conferenceplace) { + public Journal setConferenceplace(String conferenceplace) { this.conferenceplace = conferenceplace; + return this; } public String getConferencedate() { return conferencedate; } - public void setConferencedate(String conferencedate) { + public Journal setConferencedate(String conferencedate) { this.conferencedate = conferencedate; + return this; } public DataInfo getDataInfo() { return dataInfo; } - public void setDataInfo(DataInfo dataInfo) { + public Journal setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java index 352ebbc6e3..2924deaba3 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java @@ -12,15 +12,17 @@ public abstract class Oaf implements Serializable { return dataInfo; } - public void setDataInfo(DataInfo dataInfo) { + public Oaf setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; + return this; } public Long getLastupdatetimestamp() { return lastupdatetimestamp; } - public void setLastupdatetimestamp(Long lastupdatetimestamp) { + public Oaf setLastupdatetimestamp(Long lastupdatetimestamp) { this.lastupdatetimestamp = lastupdatetimestamp; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java index 98f435fab4..ef9d330cde 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java @@ -29,71 +29,80 @@ public abstract class OafEntity extends Oaf implements Serializable { return id; } - public void setId(String id) { + public OafEntity setId(String id) { this.id = id; + return this; } public List getOriginalId() { return originalId; } - public void setOriginalId(List originalId) { + public OafEntity setOriginalId(List originalId) { this.originalId = originalId; + return this; } public List getCollectedfrom() { return collectedfrom; } - public void setCollectedfrom(List collectedfrom) { + public OafEntity setCollectedfrom(List collectedfrom) { this.collectedfrom = collectedfrom; + return this; } public List getPid() { return pid; } - public void setPid(List pid) { + public OafEntity setPid(List pid) { this.pid = pid; + return this; } public String getDateofcollection() { return dateofcollection; } - public void setDateofcollection(String dateofcollection) { + public OafEntity setDateofcollection(String dateofcollection) { this.dateofcollection = dateofcollection; + return this; } public String getDateoftransformation() { return dateoftransformation; } - public void setDateoftransformation(String dateoftransformation) { + public OafEntity setDateoftransformation(String dateoftransformation) { this.dateoftransformation = dateoftransformation; + return this; } public List getChildren() { return children; } - public void setChildren(List children) { + public OafEntity setChildren(List children) { this.children = children; + return this; } public List getExtraInfo() { return extraInfo; } - public void setExtraInfo(List extraInfo) { + public OafEntity setExtraInfo(List extraInfo) { this.extraInfo = extraInfo; + return this; } public OAIProvenance getOaiprovenance() { return oaiprovenance; } - public void setOaiprovenance(OAIProvenance oaiprovenance) { + public OafEntity setOaiprovenance(OAIProvenance oaiprovenance) { this.oaiprovenance = oaiprovenance; + 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 b801aaae7a..0e09ac172f 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 @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.graph; +import eu.dnetlib.data.proto.DatasourceProtos; import eu.dnetlib.data.proto.KindProtos; import eu.dnetlib.data.proto.OafProtos; import eu.dnetlib.data.proto.ProjectProtos; @@ -60,54 +61,78 @@ public class ProtoConverter implements Serializable { } private static Organization convertOrganization(OafProtos.Oaf oaf) { - return new Organization(); + final DatasourceProtos.Datasource.Metadata m = oaf.getEntity().getDatasource().getMetadata(); + final Organization org = setOaf(new Organization(), oaf); + return setEntity(org, oaf); + //TODO set org fields } - private static Datasource convertDataSource(OafProtos.Oaf oaf) { - final Datasource result = new Datasource(); - - - //Set Oaf Fields - result.setDataInfo(ProtoUtils.mapDataInfo(oaf.getDataInfo())); - - result.setLastupdatetimestamp(oaf.getLastupdatetimestamp()); - - //setting Entity fields - final OafProtos.OafEntity entity = oaf.getEntity(); - - result.setId(entity.getId()); - - result.setOriginalId(entity.getOriginalIdList()); - - result.setCollectedfrom(entity.getCollectedfromList() - .stream() - .map(ProtoUtils::mapKV) - .collect(Collectors.toList())); - - result.setPid(entity.getPidList() - .stream() - .map(ProtoUtils::mapStructuredProperty) - .collect(Collectors.toList())); - - result.setDateofcollection(entity.getDateofcollection()); - - result.setDateoftransformation(entity.getDateoftransformation()); - - result.setExtraInfo(entity.getExtraInfoList() - .stream() - .map(ProtoUtils::mapExtraInfo) - .collect(Collectors.toList())); - - return result; + final DatasourceProtos.Datasource.Metadata m = oaf.getEntity().getDatasource().getMetadata(); + final Datasource datasource = setOaf(new Datasource(), oaf); + return setEntity(datasource, oaf) + .setAccessinfopackage(m.getAccessinfopackageCount() > 0 ? + m.getAccessinfopackageList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) : null) + .setCertificates(mapStringField(m.getCertificates())) + .setCitationguidelineurl(mapStringField(m.getCitationguidelineurl())) + .setContactemail(mapStringField(m.getContactemail())) + .setDatabaseaccessrestriction(mapStringField(m.getDatabaseaccessrestriction())) + .setDatabaseaccesstype(mapStringField(m.getDatabaseaccesstype())) + .setDataprovider(mapBoolField(m.getDataprovider())) + .setDatasourcetype(mapQualifier(m.getDatasourcetype())) + .setDatauploadrestriction(mapStringField(m.getDatauploadrestriction())) + .setCitationguidelineurl(mapStringField(m.getCitationguidelineurl())) + .setDatauploadtype(mapStringField(m.getDatauploadtype())) + .setDateofvalidation(mapStringField(m.getDateofvalidation())) + .setDescription(mapStringField(m.getDescription())) + .setEnglishname(mapStringField(m.getEnglishname())) + .setLatitude(mapStringField(m.getLatitude())) + .setLongitude(mapStringField(m.getLongitude())) + .setLogourl(mapStringField(m.getLogourl())) + .setMissionstatementurl(mapStringField(m.getMissionstatementurl())) + .setNamespaceprefix(mapStringField(m.getNamespaceprefix())) + .setOdcontenttypes(m.getOdcontenttypesCount() > 0 ? + m.getOdcontenttypesList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) : null) + .setOdlanguages(m.getOdlanguagesCount() > 0 ? + m.getOdlanguagesList() + .stream() + .map(ProtoUtils::mapStringField) + .collect(Collectors.toList()) : null) + .setOdnumberofitems(mapStringField(m.getOdnumberofitems())) + .setOdnumberofitemsdate(mapStringField(m.getOdnumberofitemsdate())) + .setOdpolicies(mapStringField(m.getOdpolicies())) + .setOfficialname(mapStringField(m.getOfficialname())) + .setOpenairecompatibility(mapQualifier(m.getOpenairecompatibility())) + .setPidsystems(mapStringField(m.getPidsystems())) + .setPolicies(m.getPoliciesCount() > 0 ? + m.getPoliciesList() + .stream() + .map(ProtoUtils::mapKV) + .collect(Collectors.toList()) : null) + .setQualitymanagementkind(mapStringField(m.getQualitymanagementkind())) + .setReleaseenddate(mapStringField(m.getReleaseenddate())) + .setServiceprovider(mapBoolField(m.getServiceprovider())) + .setReleasestartdate(mapStringField(m.getReleasestartdate())) + .setSubjects(m.getSubjectsCount() > 0 ? + m.getSubjectsList() + .stream() + .map(ProtoUtils::mapStructuredProperty) + .collect(Collectors.toList()) : null) + .setVersioning(mapBoolField(m.getVersioning())) + .setWebsiteurl(mapStringField(m.getWebsiteurl())) + .setJournal(mapJournal(m.getJournal())); } private static Project convertProject(OafProtos.Oaf oaf) { 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 + final Project project = setOaf(new Project(), oaf); + return setEntity(project, oaf) .setAcronym(mapStringField(m.getAcronym())) .setCallidentifier(mapStringField(m.getCallidentifier())) .setCode(mapStringField(m.getCode())) diff --git a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java index 97b9c32973..c0a4ae74e3 100644 --- a/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java +++ b/dhp-workflows/dhp-graph-mapper/src/main/java/eu/dnetlib/dhp/graph/ProtoUtils.java @@ -5,6 +5,8 @@ import eu.dnetlib.data.proto.FieldTypeProtos; import eu.dnetlib.data.proto.OafProtos; import eu.dnetlib.dhp.schema.oaf.*; +import java.util.stream.Collectors; + public class ProtoUtils { public static OafProtos.Oaf parse(String json) throws JsonFormat.ParseException { @@ -13,6 +15,33 @@ public class ProtoUtils { return builder.build(); } + public static T setOaf(T oaf, OafProtos.Oaf o) { + oaf.setDataInfo(mapDataInfo(o.getDataInfo())).setLastupdatetimestamp(o.getLastupdatetimestamp()); + return oaf; + } + + public static T setEntity(T entity, OafProtos.Oaf oaf) { + //setting Entity fields + final OafProtos.OafEntity e = oaf.getEntity(); + entity + .setId(e.getId()) + .setOriginalId(e.getOriginalIdList()) + .setCollectedfrom(e.getCollectedfromList() + .stream() + .map(ProtoUtils::mapKV) + .collect(Collectors.toList())) + .setPid(e.getPidList().stream() + .map(ProtoUtils::mapStructuredProperty) + .collect(Collectors.toList())) + .setDateofcollection(entity.getDateofcollection()) + .setDateoftransformation(entity.getDateoftransformation()) + .setExtraInfo(e.getExtraInfoList() + .stream() + .map(ProtoUtils::mapExtraInfo) + .collect(Collectors.toList())); + return entity; + } + public static KeyValue mapKV(FieldTypeProtos.KeyValue kv) { return new KeyValue() .setKey(kv.getKey()) @@ -54,12 +83,10 @@ public class ProtoUtils { .setValue(extraInfo.getValue()); } - public static OAIProvenance mapOAIProvenance(FieldTypeProtos.OAIProvenance oaiProvenance) { return new OAIProvenance().setOriginDescription(mapOriginalDescription(oaiProvenance.getOriginDescription())); } - public static OriginDescription mapOriginalDescription(FieldTypeProtos.OAIProvenance.OriginDescription originDescription) { final OriginDescription originDescriptionResult = new OriginDescription() .setHarvestDate(originDescription.getHarvestDate()) @@ -71,7 +98,6 @@ public class ProtoUtils { if (originDescription.hasOriginDescription()) originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription())); return originDescriptionResult; - } public static Field mapStringField(FieldTypeProtos.StringField s) { @@ -92,4 +118,20 @@ public class ProtoUtils { .setDataInfo(b.hasDataInfo() ? mapDataInfo(b.getDataInfo()) : null); } + public static Journal mapJournal(FieldTypeProtos.Journal j) { + return new Journal() + .setConferencedate(j.getConferencedate()) + .setConferenceplace(j.getConferenceplace()) + .setEdition(j.getEdition()) + .setEp(j.getEp()) + .setIss(j.getIss()) + .setIssnLinking(j.getIssnLinking()) + .setIssnOnline(j.getIssnOnline()) + .setIssnPrinted(j.getIssnPrinted()) + .setName(j.getName()) + .setSp(j.getSp()) + .setVol(j.getVol()) + .setDataInfo(mapDataInfo(j.getDataInfo())); + } + } From b0aa7cd7fbfa6899b35122b8d4ddeaf9a59f6eed Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Fri, 25 Oct 2019 09:53:08 +0200 Subject: [PATCH 6/6] fluent setters --- .../eu/dnetlib/dhp/schema/oaf/Author.java | 15 +++-- .../eu/dnetlib/dhp/schema/oaf/Context.java | 6 +- .../eu/dnetlib/dhp/schema/oaf/Dataset.java | 21 ++++-- .../dhp/schema/oaf/ExternalReference.java | 24 ++++--- .../dnetlib/dhp/schema/oaf/GeoLocation.java | 9 ++- .../eu/dnetlib/dhp/schema/oaf/Instance.java | 24 ++++--- .../dnetlib/dhp/schema/oaf/Organization.java | 49 +++++++++----- .../dhp/schema/oaf/OriginDescription.java | 10 --- .../dhp/schema/oaf/OtherResearchProducts.java | 10 ++- .../dnetlib/dhp/schema/oaf/Publication.java | 3 +- .../eu/dnetlib/dhp/schema/oaf/Qualifier.java | 10 --- .../eu/dnetlib/dhp/schema/oaf/Result.java | 64 ++++++++++++------- .../eu/dnetlib/dhp/schema/oaf/Software.java | 12 ++-- 13 files changed, 157 insertions(+), 100 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java index ab66d68249..436bc1b6e2 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java @@ -19,39 +19,44 @@ public class Author implements Serializable { return name; } - public void setName(String name) { + public Author setName(String name) { this.name = name; + return this; } public String getTypology() { return typology; } - public void setTypology(String typology) { + public Author setTypology(String typology) { this.typology = typology; + return this; } public String getProvenance() { return provenance; } - public void setProvenance(String provenance) { + public Author setProvenance(String provenance) { this.provenance = provenance; + return this; } public String getTrust() { return trust; } - public void setTrust(String trust) { + public Author setTrust(String trust) { this.trust = trust; + return this; } public String getValue() { return value; } - public void setValue(String value) { + public Author setValue(String value) { this.value = value; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Context.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Context.java index 64e23088e0..2c3c22d047 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Context.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Context.java @@ -12,15 +12,17 @@ public class Context implements Serializable { return id; } - public void setId(String id) { + public Context setId(String id) { this.id = id; + return this; } public List getDataInfo() { return dataInfo; } - public void setDataInfo(List dataInfo) { + public Context setDataInfo(List dataInfo) { this.dataInfo = dataInfo; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java index 44d5226e9b..25fd7e5d57 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java @@ -23,55 +23,62 @@ public class Dataset extends Result implements Serializable { return storagedate; } - public void setStoragedate(Field storagedate) { + public Dataset setStoragedate(Field storagedate) { this.storagedate = storagedate; + return this; } public Field getDevice() { return device; } - public void setDevice(Field device) { + public Dataset setDevice(Field device) { this.device = device; + return this; } public Field getSize() { return size; } - public void setSize(Field size) { + public Dataset setSize(Field size) { this.size = size; + return this; } public Field getVersion() { return version; } - public void setVersion(Field version) { + public Dataset setVersion(Field version) { this.version = version; + return this; } public Field getLastmetadataupdate() { return lastmetadataupdate; } - public void setLastmetadataupdate(Field lastmetadataupdate) { + public Dataset setLastmetadataupdate(Field lastmetadataupdate) { this.lastmetadataupdate = lastmetadataupdate; + return this; } public Field getMetadataversionnumber() { return metadataversionnumber; } - public void setMetadataversionnumber(Field metadataversionnumber) { + public Dataset setMetadataversionnumber(Field metadataversionnumber) { this.metadataversionnumber = metadataversionnumber; + return this; } public List getGeolocation() { return geolocation; } - public void setGeolocation(List geolocation) { + public Dataset setGeolocation(List geolocation) { this.geolocation = geolocation; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java index 006658133c..523d7c87e6 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java @@ -31,63 +31,71 @@ public class ExternalReference implements Serializable { return sitename; } - public void setSitename(String sitename) { + public ExternalReference setSitename(String sitename) { this.sitename = sitename; + return this; } public String getLabel() { return label; } - public void setLabel(String label) { + public ExternalReference setLabel(String label) { this.label = label; + return this; } public String getUrl() { return url; } - public void setUrl(String url) { + public ExternalReference setUrl(String url) { this.url = url; + return this; } public String getDescription() { return description; } - public void setDescription(String description) { + public ExternalReference setDescription(String description) { this.description = description; + return this; } public Qualifier getQualifier() { return qualifier; } - public void setQualifier(Qualifier qualifier) { + public ExternalReference setQualifier(Qualifier qualifier) { this.qualifier = qualifier; + return this; } public String getRefidentifier() { return refidentifier; } - public void setRefidentifier(String refidentifier) { + public ExternalReference setRefidentifier(String refidentifier) { this.refidentifier = refidentifier; + return this; } public String getQuery() { return query; } - public void setQuery(String query) { + public ExternalReference setQuery(String query) { this.query = query; + return this; } public DataInfo getDataInfo() { return dataInfo; } - public void setDataInfo(DataInfo dataInfo) { + public ExternalReference setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/GeoLocation.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/GeoLocation.java index 567254a238..104a591f13 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/GeoLocation.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/GeoLocation.java @@ -14,23 +14,26 @@ public class GeoLocation implements Serializable { return point; } - public void setPoint(String point) { + public GeoLocation setPoint(String point) { this.point = point; + return this; } public String getBox() { return box; } - public void setBox(String box) { + public GeoLocation setBox(String box) { this.box = box; + return this; } public String getPlace() { return place; } - public void setPlace(String place) { + public GeoLocation setPlace(String place) { this.place = place; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java index f27704c5ce..4fef24e467 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java @@ -25,63 +25,71 @@ public class Instance implements Serializable { return license; } - public void setLicense(Field license) { + public Instance setLicense(Field license) { this.license = license; + return this; } public Qualifier getAccessright() { return accessright; } - public void setAccessright(Qualifier accessright) { + public Instance setAccessright(Qualifier accessright) { this.accessright = accessright; + return this; } public Qualifier getInstancetype() { return instancetype; } - public void setInstancetype(Qualifier instancetype) { + public Instance setInstancetype(Qualifier instancetype) { this.instancetype = instancetype; + return this; } public KeyValue getHostedby() { return hostedby; } - public void setHostedby(KeyValue hostedby) { + public Instance setHostedby(KeyValue hostedby) { this.hostedby = hostedby; + return this; } public String getUrl() { return url; } - public void setUrl(String url) { + public Instance setUrl(String url) { this.url = url; + return this; } public String getDistributionlocation() { return distributionlocation; } - public void setDistributionlocation(String distributionlocation) { + public Instance setDistributionlocation(String distributionlocation) { this.distributionlocation = distributionlocation; + return this; } public KeyValue getCollectedfrom() { return collectedfrom; } - public void setCollectedfrom(KeyValue collectedfrom) { + public Instance setCollectedfrom(KeyValue collectedfrom) { this.collectedfrom = collectedfrom; + return this; } public Field getDateofacceptance() { return dateofacceptance; } - public void setDateofacceptance(Field dateofacceptance) { + public Instance setDateofacceptance(Field dateofacceptance) { this.dateofacceptance = dateofacceptance; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java index dd966deb51..260fc22b65 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java @@ -37,132 +37,147 @@ public class Organization extends OafEntity implements Serializable { private Qualifier country; - public Field getLegalshortname() { return legalshortname; } - public void setLegalshortname(Field legalshortname) { + public Organization setLegalshortname(Field legalshortname) { this.legalshortname = legalshortname; + return this; } public Field getLegalname() { return legalname; } - public void setLegalname(Field legalname) { + public Organization setLegalname(Field legalname) { this.legalname = legalname; + return this; } public List> getAlternativeNames() { return alternativeNames; } - public void setAlternativeNames(List> alternativeNames) { + public Organization setAlternativeNames(List> alternativeNames) { this.alternativeNames = alternativeNames; + return this; } public Field getWebsiteurl() { return websiteurl; } - public void setWebsiteurl(Field websiteurl) { + public Organization setWebsiteurl(Field websiteurl) { this.websiteurl = websiteurl; + return this; } public Field getLogourl() { return logourl; } - public void setLogourl(Field logourl) { + public Organization setLogourl(Field logourl) { this.logourl = logourl; + return this; } public Field getEclegalbody() { return eclegalbody; } - public void setEclegalbody(Field eclegalbody) { + public Organization setEclegalbody(Field eclegalbody) { this.eclegalbody = eclegalbody; + return this; } public Field getEclegalperson() { return eclegalperson; } - public void setEclegalperson(Field eclegalperson) { + public Organization setEclegalperson(Field eclegalperson) { this.eclegalperson = eclegalperson; + return this; } public Field getEcnonprofit() { return ecnonprofit; } - public void setEcnonprofit(Field ecnonprofit) { + public Organization setEcnonprofit(Field ecnonprofit) { this.ecnonprofit = ecnonprofit; + return this; } public Field getEcresearchorganization() { return ecresearchorganization; } - public void setEcresearchorganization(Field ecresearchorganization) { + public Organization setEcresearchorganization(Field ecresearchorganization) { this.ecresearchorganization = ecresearchorganization; + return this; } public Field getEchighereducation() { return echighereducation; } - public void setEchighereducation(Field echighereducation) { + public Organization setEchighereducation(Field echighereducation) { this.echighereducation = echighereducation; + return this; } public Field getEcinternationalorganizationeurinterests() { return ecinternationalorganizationeurinterests; } - public void setEcinternationalorganizationeurinterests(Field ecinternationalorganizationeurinterests) { + public Organization setEcinternationalorganizationeurinterests(Field ecinternationalorganizationeurinterests) { this.ecinternationalorganizationeurinterests = ecinternationalorganizationeurinterests; + return this; } public Field getEcinternationalorganization() { return ecinternationalorganization; } - public void setEcinternationalorganization(Field ecinternationalorganization) { + public Organization setEcinternationalorganization(Field ecinternationalorganization) { this.ecinternationalorganization = ecinternationalorganization; + return this; } public Field getEcenterprise() { return ecenterprise; } - public void setEcenterprise(Field ecenterprise) { + public Organization setEcenterprise(Field ecenterprise) { this.ecenterprise = ecenterprise; + return this; } public Field getEcsmevalidated() { return ecsmevalidated; } - public void setEcsmevalidated(Field ecsmevalidated) { + public Organization setEcsmevalidated(Field ecsmevalidated) { this.ecsmevalidated = ecsmevalidated; + return this; } public Field getEcnutscode() { return ecnutscode; } - public void setEcnutscode(Field ecnutscode) { + public Organization setEcnutscode(Field ecnutscode) { this.ecnutscode = ecnutscode; + return this; } public Qualifier getCountry() { return country; } - public void setCountry(Qualifier country) { + public Organization setCountry(Qualifier country) { this.country = country; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java index cba4011743..1c803a2857 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java @@ -16,8 +16,6 @@ public class OriginDescription implements Serializable { private String metadataNamespace; - //private OriginDescription originDescription; - public String getHarvestDate() { return harvestDate; } @@ -72,12 +70,4 @@ public class OriginDescription implements Serializable { return this; } -// public OriginDescription getOriginDescription() { -// return originDescription; -// } -// -// public OriginDescription setOriginDescription(OriginDescription originDescription) { -// this.originDescription = originDescription; -// return this; -// } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProducts.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProducts.java index 12b578904f..3ca231587c 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProducts.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProducts.java @@ -4,6 +4,7 @@ import java.io.Serializable; import java.util.List; public class OtherResearchProducts extends Result implements Serializable { + private List> contactperson; private List> contactgroup; @@ -14,23 +15,26 @@ public class OtherResearchProducts extends Result implements Serializable { return contactperson; } - public void setContactperson(List> contactperson) { + public OtherResearchProducts setContactperson(List> contactperson) { this.contactperson = contactperson; + return this; } public List> getContactgroup() { return contactgroup; } - public void setContactgroup(List> contactgroup) { + public OtherResearchProducts setContactgroup(List> contactgroup) { this.contactgroup = contactgroup; + return this; } public List> getTool() { return tool; } - public void setTool(List> tool) { + public OtherResearchProducts setTool(List> tool) { this.tool = tool; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java index 9ca9cd3d64..bf4eab93c6 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java @@ -11,7 +11,8 @@ public class Publication extends Result implements Serializable { return journal; } - public void setJournal(Journal journal) { + public Publication setJournal(Journal journal) { this.journal = journal; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java index 0320798f0f..55d0427aa7 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Qualifier.java @@ -9,8 +9,6 @@ public class Qualifier implements Serializable { private String schemeid; private String schemename; -// private DataInfo dataInfo; - public String getClassid() { return classid; } @@ -47,12 +45,4 @@ public class Qualifier implements Serializable { return this; } -// public DataInfo getDataInfo() { -// return dataInfo; -// } -// -// public Qualifier setDataInfo(DataInfo dataInfo) { -// this.dataInfo = dataInfo; -// return this; -// } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java index 1a0f74aac2..b0630825a8 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java @@ -49,172 +49,192 @@ public abstract class Result extends OafEntity implements Serializable { private List instance; - public List getAuthor() { return author; } - public void setAuthor(List author) { + public Result setAuthor(List author) { this.author = author; + return this; } public Qualifier getResulttype() { return resulttype; } - public void setResulttype(Qualifier resulttype) { + public Result setResulttype(Qualifier resulttype) { this.resulttype = resulttype; + return this; } public Qualifier getLanguage() { return language; } - public void setLanguage(Qualifier language) { + public Result setLanguage(Qualifier language) { this.language = language; + return this; } public List getCountry() { return country; } - public void setCountry(List country) { + public Result setCountry(List country) { this.country = country; + return this; } public List getSubject() { return subject; } - public void setSubject(List subject) { + public Result setSubject(List subject) { this.subject = subject; + return this; } public List getTitle() { return title; } - public void setTitle(List title) { + public Result setTitle(List title) { this.title = title; + return this; } public List getRelevantdate() { return relevantdate; } - public void setRelevantdate(List relevantdate) { + public Result setRelevantdate(List relevantdate) { this.relevantdate = relevantdate; + return this; } public List> getDescription() { return description; } - public void setDescription(List> description) { + public Result setDescription(List> description) { this.description = description; + return this; } public Field getDateofacceptance() { return dateofacceptance; } - public void setDateofacceptance(Field dateofacceptance) { + public Result setDateofacceptance(Field dateofacceptance) { this.dateofacceptance = dateofacceptance; + return this; } public Field getPublisher() { return publisher; } - public void setPublisher(Field publisher) { + public Result setPublisher(Field publisher) { this.publisher = publisher; + return this; } public Field getEmbargoenddate() { return embargoenddate; } - public void setEmbargoenddate(Field embargoenddate) { + public Result setEmbargoenddate(Field embargoenddate) { this.embargoenddate = embargoenddate; + return this; } public List> getSource() { return source; } - public void setSource(List> source) { + public Result setSource(List> source) { this.source = source; + return this; } public List> getFulltext() { return fulltext; } - public void setFulltext(List> fulltext) { + public Result setFulltext(List> fulltext) { this.fulltext = fulltext; + return this; } public List> getFormat() { return format; } - public void setFormat(List> format) { + public Result setFormat(List> format) { this.format = format; + return this; } public List> getContributor() { return contributor; } - public void setContributor(List> contributor) { + public Result setContributor(List> contributor) { this.contributor = contributor; + return this; } public Qualifier getResourcetype() { return resourcetype; } - public void setResourcetype(Qualifier resourcetype) { + public Result setResourcetype(Qualifier resourcetype) { this.resourcetype = resourcetype; + return this; } public List> getCoverage() { return coverage; } - public void setCoverage(List> coverage) { + public Result setCoverage(List> coverage) { this.coverage = coverage; + return this; } public Field getRefereed() { return refereed; } - public void setRefereed(Field refereed) { + public Result setRefereed(Field refereed) { this.refereed = refereed; + return this; } public List getContext() { return context; } - public void setContext(List context) { + public Result setContext(List context) { this.context = context; + return this; } public List getExternalReference() { return externalReference; } - public void setExternalReference(List externalReference) { + public Result setExternalReference(List externalReference) { this.externalReference = externalReference; + return this; } public List getInstance() { return instance; } - public void setInstance(List instance) { + public Result setInstance(List instance) { this.instance = instance; + return this; } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java index e696cdb520..451efb99af 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java @@ -17,31 +17,35 @@ public class Software extends Result implements Serializable { return documentationUrl; } - public void setDocumentationUrl(List> documentationUrl) { + public Software setDocumentationUrl(List> documentationUrl) { this.documentationUrl = documentationUrl; + return this; } public List getLicense() { return license; } - public void setLicense(List license) { + public Software setLicense(List license) { this.license = license; + return this; } public Field getCodeRepositoryUrl() { return codeRepositoryUrl; } - public void setCodeRepositoryUrl(Field codeRepositoryUrl) { + public Software setCodeRepositoryUrl(Field codeRepositoryUrl) { this.codeRepositoryUrl = codeRepositoryUrl; + return this; } public Qualifier getProgrammingLanguage() { return programmingLanguage; } - public void setProgrammingLanguage(Qualifier programmingLanguage) { + public Software setProgrammingLanguage(Qualifier programmingLanguage) { this.programmingLanguage = programmingLanguage; + return this; } }