1
0
Fork 0

more proto 2 graph model mappings

This commit is contained in:
Claudio Atzori 2019-10-25 09:25:36 +02:00
parent d46371ceab
commit c929c1dfac
6 changed files with 231 additions and 106 deletions

View File

@ -65,7 +65,7 @@ public class Datasource extends OafEntity implements Serializable {
private Field<String> databaseaccessrestriction; private Field<String> databaseaccessrestriction;
// {feeRequired, registration, other} // {feeRequired, registration, other}
private Field<String> datauploadrestriction9; private Field<String> datauploadrestriction;
private Field<Boolean> versioning; private Field<Boolean> versioning;
@ -86,279 +86,314 @@ public class Datasource extends OafEntity implements Serializable {
return datasourcetype; return datasourcetype;
} }
public void setDatasourcetype(Qualifier datasourcetype) { public Datasource setDatasourcetype(Qualifier datasourcetype) {
this.datasourcetype = datasourcetype; this.datasourcetype = datasourcetype;
return this;
} }
public Qualifier getOpenairecompatibility() { public Qualifier getOpenairecompatibility() {
return openairecompatibility; return openairecompatibility;
} }
public void setOpenairecompatibility(Qualifier openairecompatibility) { public Datasource setOpenairecompatibility(Qualifier openairecompatibility) {
this.openairecompatibility = openairecompatibility; this.openairecompatibility = openairecompatibility;
return this;
} }
public Field<String> getOfficialname() { public Field<String> getOfficialname() {
return officialname; return officialname;
} }
public void setOfficialname(Field<String> officialname) { public Datasource setOfficialname(Field<String> officialname) {
this.officialname = officialname; this.officialname = officialname;
return this;
} }
public Field<String> getEnglishname() { public Field<String> getEnglishname() {
return englishname; return englishname;
} }
public void setEnglishname(Field<String> englishname) { public Datasource setEnglishname(Field<String> englishname) {
this.englishname = englishname; this.englishname = englishname;
return this;
} }
public Field<String> getWebsiteurl() { public Field<String> getWebsiteurl() {
return websiteurl; return websiteurl;
} }
public void setWebsiteurl(Field<String> websiteurl) { public Datasource setWebsiteurl(Field<String> websiteurl) {
this.websiteurl = websiteurl; this.websiteurl = websiteurl;
return this;
} }
public Field<String> getLogourl() { public Field<String> getLogourl() {
return logourl; return logourl;
} }
public void setLogourl(Field<String> logourl) { public Datasource setLogourl(Field<String> logourl) {
this.logourl = logourl; this.logourl = logourl;
return this;
} }
public Field<String> getContactemail() { public Field<String> getContactemail() {
return contactemail; return contactemail;
} }
public void setContactemail(Field<String> contactemail) { public Datasource setContactemail(Field<String> contactemail) {
this.contactemail = contactemail; this.contactemail = contactemail;
return this;
} }
public Field<String> getNamespaceprefix() { public Field<String> getNamespaceprefix() {
return namespaceprefix; return namespaceprefix;
} }
public void setNamespaceprefix(Field<String> namespaceprefix) { public Datasource setNamespaceprefix(Field<String> namespaceprefix) {
this.namespaceprefix = namespaceprefix; this.namespaceprefix = namespaceprefix;
return this;
} }
public Field<String> getLatitude() { public Field<String> getLatitude() {
return latitude; return latitude;
} }
public void setLatitude(Field<String> latitude) { public Datasource setLatitude(Field<String> latitude) {
this.latitude = latitude; this.latitude = latitude;
return this;
} }
public Field<String> getLongitude() { public Field<String> getLongitude() {
return longitude; return longitude;
} }
public void setLongitude(Field<String> longitude) { public Datasource setLongitude(Field<String> longitude) {
this.longitude = longitude; this.longitude = longitude;
return this;
} }
public Field<String> getDateofvalidation() { public Field<String> getDateofvalidation() {
return dateofvalidation; return dateofvalidation;
} }
public void setDateofvalidation(Field<String> dateofvalidation) { public Datasource setDateofvalidation(Field<String> dateofvalidation) {
this.dateofvalidation = dateofvalidation; this.dateofvalidation = dateofvalidation;
return this;
} }
public Field<String> getDescription() { public Field<String> getDescription() {
return description; return description;
} }
public void setDescription(Field<String> description) { public Datasource setDescription(Field<String> description) {
this.description = description; this.description = description;
return this;
} }
public List<StructuredProperty> getSubjects() { public List<StructuredProperty> getSubjects() {
return subjects; return subjects;
} }
public void setSubjects(List<StructuredProperty> subjects) { public Datasource setSubjects(List<StructuredProperty> subjects) {
this.subjects = subjects; this.subjects = subjects;
return this;
} }
public Field<String> getOdnumberofitems() { public Field<String> getOdnumberofitems() {
return odnumberofitems; return odnumberofitems;
} }
public void setOdnumberofitems(Field<String> odnumberofitems) { public Datasource setOdnumberofitems(Field<String> odnumberofitems) {
this.odnumberofitems = odnumberofitems; this.odnumberofitems = odnumberofitems;
return this;
} }
public Field<String> getOdnumberofitemsdate() { public Field<String> getOdnumberofitemsdate() {
return odnumberofitemsdate; return odnumberofitemsdate;
} }
public void setOdnumberofitemsdate(Field<String> odnumberofitemsdate) { public Datasource setOdnumberofitemsdate(Field<String> odnumberofitemsdate) {
this.odnumberofitemsdate = odnumberofitemsdate; this.odnumberofitemsdate = odnumberofitemsdate;
return this;
} }
public Field<String> getOdpolicies() { public Field<String> getOdpolicies() {
return odpolicies; return odpolicies;
} }
public void setOdpolicies(Field<String> odpolicies) { public Datasource setOdpolicies(Field<String> odpolicies) {
this.odpolicies = odpolicies; this.odpolicies = odpolicies;
return this;
} }
public List<Field<String>> getOdlanguages() { public List<Field<String>> getOdlanguages() {
return odlanguages; return odlanguages;
} }
public void setOdlanguages(List<Field<String>> odlanguages) { public Datasource setOdlanguages(List<Field<String>> odlanguages) {
this.odlanguages = odlanguages; this.odlanguages = odlanguages;
return this;
} }
public List<Field<String>> getOdcontenttypes() { public List<Field<String>> getOdcontenttypes() {
return odcontenttypes; return odcontenttypes;
} }
public void setOdcontenttypes(List<Field<String>> odcontenttypes) { public Datasource setOdcontenttypes(List<Field<String>> odcontenttypes) {
this.odcontenttypes = odcontenttypes; this.odcontenttypes = odcontenttypes;
return this;
} }
public List<Field<String>> getAccessinfopackage() { public List<Field<String>> getAccessinfopackage() {
return accessinfopackage; return accessinfopackage;
} }
public void setAccessinfopackage(List<Field<String>> accessinfopackage) { public Datasource setAccessinfopackage(List<Field<String>> accessinfopackage) {
this.accessinfopackage = accessinfopackage; this.accessinfopackage = accessinfopackage;
return this;
} }
public Field<String> getReleasestartdate() { public Field<String> getReleasestartdate() {
return releasestartdate; return releasestartdate;
} }
public void setReleasestartdate(Field<String> releasestartdate) { public Datasource setReleasestartdate(Field<String> releasestartdate) {
this.releasestartdate = releasestartdate; this.releasestartdate = releasestartdate;
return this;
} }
public Field<String> getReleaseenddate() { public Field<String> getReleaseenddate() {
return releaseenddate; return releaseenddate;
} }
public void setReleaseenddate(Field<String> releaseenddate) { public Datasource setReleaseenddate(Field<String> releaseenddate) {
this.releaseenddate = releaseenddate; this.releaseenddate = releaseenddate;
return this;
} }
public Field<String> getMissionstatementurl() { public Field<String> getMissionstatementurl() {
return missionstatementurl; return missionstatementurl;
} }
public void setMissionstatementurl(Field<String> missionstatementurl) { public Datasource setMissionstatementurl(Field<String> missionstatementurl) {
this.missionstatementurl = missionstatementurl; this.missionstatementurl = missionstatementurl;
return this;
} }
public Field<Boolean> getDataprovider() { public Field<Boolean> getDataprovider() {
return dataprovider; return dataprovider;
} }
public void setDataprovider(Field<Boolean> dataprovider) { public Datasource setDataprovider(Field<Boolean> dataprovider) {
this.dataprovider = dataprovider; this.dataprovider = dataprovider;
return this;
} }
public Field<Boolean> getServiceprovider() { public Field<Boolean> getServiceprovider() {
return serviceprovider; return serviceprovider;
} }
public void setServiceprovider(Field<Boolean> serviceprovider) { public Datasource setServiceprovider(Field<Boolean> serviceprovider) {
this.serviceprovider = serviceprovider; this.serviceprovider = serviceprovider;
return this;
} }
public Field<String> getDatabaseaccesstype() { public Field<String> getDatabaseaccesstype() {
return databaseaccesstype; return databaseaccesstype;
} }
public void setDatabaseaccesstype(Field<String> databaseaccesstype) { public Datasource setDatabaseaccesstype(Field<String> databaseaccesstype) {
this.databaseaccesstype = databaseaccesstype; this.databaseaccesstype = databaseaccesstype;
return this;
} }
public Field<String> getDatauploadtype() { public Field<String> getDatauploadtype() {
return datauploadtype; return datauploadtype;
} }
public void setDatauploadtype(Field<String> datauploadtype) { public Datasource setDatauploadtype(Field<String> datauploadtype) {
this.datauploadtype = datauploadtype; this.datauploadtype = datauploadtype;
return this;
} }
public Field<String> getDatabaseaccessrestriction() { public Field<String> getDatabaseaccessrestriction() {
return databaseaccessrestriction; return databaseaccessrestriction;
} }
public void setDatabaseaccessrestriction(Field<String> databaseaccessrestriction) { public Datasource setDatabaseaccessrestriction(Field<String> databaseaccessrestriction) {
this.databaseaccessrestriction = databaseaccessrestriction; this.databaseaccessrestriction = databaseaccessrestriction;
return this;
} }
public Field<String> getDatauploadrestriction9() { public Field<String> getDatauploadrestriction() {
return datauploadrestriction9; return datauploadrestriction;
} }
public void setDatauploadrestriction9(Field<String> datauploadrestriction9) { public Datasource setDatauploadrestriction(Field<String> datauploadrestriction) {
this.datauploadrestriction9 = datauploadrestriction9; this.datauploadrestriction = datauploadrestriction;
return this;
} }
public Field<Boolean> getVersioning() { public Field<Boolean> getVersioning() {
return versioning; return versioning;
} }
public void setVersioning(Field<Boolean> versioning) { public Datasource setVersioning(Field<Boolean> versioning) {
this.versioning = versioning; this.versioning = versioning;
return this;
} }
public Field<String> getCitationguidelineurl() { public Field<String> getCitationguidelineurl() {
return citationguidelineurl; return citationguidelineurl;
} }
public void setCitationguidelineurl(Field<String> citationguidelineurl) { public Datasource setCitationguidelineurl(Field<String> citationguidelineurl) {
this.citationguidelineurl = citationguidelineurl; this.citationguidelineurl = citationguidelineurl;
return this;
} }
public Field<String> getQualitymanagementkind() { public Field<String> getQualitymanagementkind() {
return qualitymanagementkind; return qualitymanagementkind;
} }
public void setQualitymanagementkind(Field<String> qualitymanagementkind) { public Datasource setQualitymanagementkind(Field<String> qualitymanagementkind) {
this.qualitymanagementkind = qualitymanagementkind; this.qualitymanagementkind = qualitymanagementkind;
return this;
} }
public Field<String> getPidsystems() { public Field<String> getPidsystems() {
return pidsystems; return pidsystems;
} }
public void setPidsystems(Field<String> pidsystems) { public Datasource setPidsystems(Field<String> pidsystems) {
this.pidsystems = pidsystems; this.pidsystems = pidsystems;
return this;
} }
public Field<String> getCertificates() { public Field<String> getCertificates() {
return certificates; return certificates;
} }
public void setCertificates(Field<String> certificates) { public Datasource setCertificates(Field<String> certificates) {
this.certificates = certificates; this.certificates = certificates;
return this;
} }
public List<KeyValue> getPolicies() { public List<KeyValue> getPolicies() {
return policies; return policies;
} }
public void setPolicies(List<KeyValue> policies) { public Datasource setPolicies(List<KeyValue> policies) {
this.policies = policies; this.policies = policies;
return this;
} }
public Journal getJournal() { public Journal getJournal() {
return journal; return journal;
} }
public void setJournal(Journal journal) { public Datasource setJournal(Journal journal) {
this.journal = journal; this.journal = journal;
return this;
} }
} }

View File

@ -32,95 +32,107 @@ public class Journal implements Serializable {
return name; return name;
} }
public void setName(String name) { public Journal setName(String name) {
this.name = name; this.name = name;
return this;
} }
public String getIssnPrinted() { public String getIssnPrinted() {
return issnPrinted; return issnPrinted;
} }
public void setIssnPrinted(String issnPrinted) { public Journal setIssnPrinted(String issnPrinted) {
this.issnPrinted = issnPrinted; this.issnPrinted = issnPrinted;
return this;
} }
public String getIssnOnline() { public String getIssnOnline() {
return issnOnline; return issnOnline;
} }
public void setIssnOnline(String issnOnline) { public Journal setIssnOnline(String issnOnline) {
this.issnOnline = issnOnline; this.issnOnline = issnOnline;
return this;
} }
public String getIssnLinking() { public String getIssnLinking() {
return issnLinking; return issnLinking;
} }
public void setIssnLinking(String issnLinking) { public Journal setIssnLinking(String issnLinking) {
this.issnLinking = issnLinking; this.issnLinking = issnLinking;
return this;
} }
public String getEp() { public String getEp() {
return ep; return ep;
} }
public void setEp(String ep) { public Journal setEp(String ep) {
this.ep = ep; this.ep = ep;
return this;
} }
public String getIss() { public String getIss() {
return iss; return iss;
} }
public void setIss(String iss) { public Journal setIss(String iss) {
this.iss = iss; this.iss = iss;
return this;
} }
public String getSp() { public String getSp() {
return sp; return sp;
} }
public void setSp(String sp) { public Journal setSp(String sp) {
this.sp = sp; this.sp = sp;
return this;
} }
public String getVol() { public String getVol() {
return vol; return vol;
} }
public void setVol(String vol) { public Journal setVol(String vol) {
this.vol = vol; this.vol = vol;
return this;
} }
public String getEdition() { public String getEdition() {
return edition; return edition;
} }
public void setEdition(String edition) { public Journal setEdition(String edition) {
this.edition = edition; this.edition = edition;
return this;
} }
public String getConferenceplace() { public String getConferenceplace() {
return conferenceplace; return conferenceplace;
} }
public void setConferenceplace(String conferenceplace) { public Journal setConferenceplace(String conferenceplace) {
this.conferenceplace = conferenceplace; this.conferenceplace = conferenceplace;
return this;
} }
public String getConferencedate() { public String getConferencedate() {
return conferencedate; return conferencedate;
} }
public void setConferencedate(String conferencedate) { public Journal setConferencedate(String conferencedate) {
this.conferencedate = conferencedate; this.conferencedate = conferencedate;
return this;
} }
public DataInfo getDataInfo() { public DataInfo getDataInfo() {
return dataInfo; return dataInfo;
} }
public void setDataInfo(DataInfo dataInfo) { public Journal setDataInfo(DataInfo dataInfo) {
this.dataInfo = dataInfo; this.dataInfo = dataInfo;
return this;
} }
} }

View File

@ -12,15 +12,17 @@ public abstract class Oaf implements Serializable {
return dataInfo; return dataInfo;
} }
public void setDataInfo(DataInfo dataInfo) { public Oaf setDataInfo(DataInfo dataInfo) {
this.dataInfo = dataInfo; this.dataInfo = dataInfo;
return this;
} }
public Long getLastupdatetimestamp() { public Long getLastupdatetimestamp() {
return lastupdatetimestamp; return lastupdatetimestamp;
} }
public void setLastupdatetimestamp(Long lastupdatetimestamp) { public Oaf setLastupdatetimestamp(Long lastupdatetimestamp) {
this.lastupdatetimestamp = lastupdatetimestamp; this.lastupdatetimestamp = lastupdatetimestamp;
return this;
} }
} }

View File

@ -29,71 +29,80 @@ public abstract class OafEntity extends Oaf implements Serializable {
return id; return id;
} }
public void setId(String id) { public OafEntity setId(String id) {
this.id = id; this.id = id;
return this;
} }
public List<String> getOriginalId() { public List<String> getOriginalId() {
return originalId; return originalId;
} }
public void setOriginalId(List<String> originalId) { public OafEntity setOriginalId(List<String> originalId) {
this.originalId = originalId; this.originalId = originalId;
return this;
} }
public List<KeyValue> getCollectedfrom() { public List<KeyValue> getCollectedfrom() {
return collectedfrom; return collectedfrom;
} }
public void setCollectedfrom(List<KeyValue> collectedfrom) { public OafEntity setCollectedfrom(List<KeyValue> collectedfrom) {
this.collectedfrom = collectedfrom; this.collectedfrom = collectedfrom;
return this;
} }
public List<StructuredProperty> getPid() { public List<StructuredProperty> getPid() {
return pid; return pid;
} }
public void setPid(List<StructuredProperty> pid) { public OafEntity setPid(List<StructuredProperty> pid) {
this.pid = pid; this.pid = pid;
return this;
} }
public String getDateofcollection() { public String getDateofcollection() {
return dateofcollection; return dateofcollection;
} }
public void setDateofcollection(String dateofcollection) { public OafEntity setDateofcollection(String dateofcollection) {
this.dateofcollection = dateofcollection; this.dateofcollection = dateofcollection;
return this;
} }
public String getDateoftransformation() { public String getDateoftransformation() {
return dateoftransformation; return dateoftransformation;
} }
public void setDateoftransformation(String dateoftransformation) { public OafEntity setDateoftransformation(String dateoftransformation) {
this.dateoftransformation = dateoftransformation; this.dateoftransformation = dateoftransformation;
return this;
} }
public List<OafEntity> getChildren() { public List<OafEntity> getChildren() {
return children; return children;
} }
public void setChildren(List<OafEntity> children) { public OafEntity setChildren(List<OafEntity> children) {
this.children = children; this.children = children;
return this;
} }
public List<ExtraInfo> getExtraInfo() { public List<ExtraInfo> getExtraInfo() {
return extraInfo; return extraInfo;
} }
public void setExtraInfo(List<ExtraInfo> extraInfo) { public OafEntity setExtraInfo(List<ExtraInfo> extraInfo) {
this.extraInfo = extraInfo; this.extraInfo = extraInfo;
return this;
} }
public OAIProvenance getOaiprovenance() { public OAIProvenance getOaiprovenance() {
return oaiprovenance; return oaiprovenance;
} }
public void setOaiprovenance(OAIProvenance oaiprovenance) { public OafEntity setOaiprovenance(OAIProvenance oaiprovenance) {
this.oaiprovenance = oaiprovenance; this.oaiprovenance = oaiprovenance;
return this;
} }
} }

View File

@ -1,5 +1,6 @@
package eu.dnetlib.dhp.graph; package eu.dnetlib.dhp.graph;
import eu.dnetlib.data.proto.DatasourceProtos;
import eu.dnetlib.data.proto.KindProtos; import eu.dnetlib.data.proto.KindProtos;
import eu.dnetlib.data.proto.OafProtos; import eu.dnetlib.data.proto.OafProtos;
import eu.dnetlib.data.proto.ProjectProtos; import eu.dnetlib.data.proto.ProjectProtos;
@ -60,54 +61,78 @@ public class ProtoConverter implements Serializable {
} }
private static Organization convertOrganization(OafProtos.Oaf oaf) { 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) { private static Datasource convertDataSource(OafProtos.Oaf oaf) {
final Datasource result = new Datasource(); final DatasourceProtos.Datasource.Metadata m = oaf.getEntity().getDatasource().getMetadata();
final Datasource datasource = setOaf(new Datasource(), oaf);
return setEntity(datasource, oaf)
//Set Oaf Fields .setAccessinfopackage(m.getAccessinfopackageCount() > 0 ?
result.setDataInfo(ProtoUtils.mapDataInfo(oaf.getDataInfo())); m.getAccessinfopackageList()
.stream()
result.setLastupdatetimestamp(oaf.getLastupdatetimestamp()); .map(ProtoUtils::mapStringField)
.collect(Collectors.toList()) : null)
//setting Entity fields .setCertificates(mapStringField(m.getCertificates()))
final OafProtos.OafEntity entity = oaf.getEntity(); .setCitationguidelineurl(mapStringField(m.getCitationguidelineurl()))
.setContactemail(mapStringField(m.getContactemail()))
result.setId(entity.getId()); .setDatabaseaccessrestriction(mapStringField(m.getDatabaseaccessrestriction()))
.setDatabaseaccesstype(mapStringField(m.getDatabaseaccesstype()))
result.setOriginalId(entity.getOriginalIdList()); .setDataprovider(mapBoolField(m.getDataprovider()))
.setDatasourcetype(mapQualifier(m.getDatasourcetype()))
result.setCollectedfrom(entity.getCollectedfromList() .setDatauploadrestriction(mapStringField(m.getDatauploadrestriction()))
.stream() .setCitationguidelineurl(mapStringField(m.getCitationguidelineurl()))
.map(ProtoUtils::mapKV) .setDatauploadtype(mapStringField(m.getDatauploadtype()))
.collect(Collectors.toList())); .setDateofvalidation(mapStringField(m.getDateofvalidation()))
.setDescription(mapStringField(m.getDescription()))
result.setPid(entity.getPidList() .setEnglishname(mapStringField(m.getEnglishname()))
.stream() .setLatitude(mapStringField(m.getLatitude()))
.map(ProtoUtils::mapStructuredProperty) .setLongitude(mapStringField(m.getLongitude()))
.collect(Collectors.toList())); .setLogourl(mapStringField(m.getLogourl()))
.setMissionstatementurl(mapStringField(m.getMissionstatementurl()))
result.setDateofcollection(entity.getDateofcollection()); .setNamespaceprefix(mapStringField(m.getNamespaceprefix()))
.setOdcontenttypes(m.getOdcontenttypesCount() > 0 ?
result.setDateoftransformation(entity.getDateoftransformation()); m.getOdcontenttypesList()
.stream()
result.setExtraInfo(entity.getExtraInfoList() .map(ProtoUtils::mapStringField)
.stream() .collect(Collectors.toList()) : null)
.map(ProtoUtils::mapExtraInfo) .setOdlanguages(m.getOdlanguagesCount() > 0 ?
.collect(Collectors.toList())); m.getOdlanguagesList()
.stream()
return result; .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) { private static Project convertProject(OafProtos.Oaf oaf) {
final ProjectProtos.Project.Metadata m = oaf.getEntity().getProject().getMetadata(); final ProjectProtos.Project.Metadata m = oaf.getEntity().getProject().getMetadata();
final Project project = new Project(); final Project project = setOaf(new Project(), oaf);
project.setDataInfo(mapDataInfo(oaf.getDataInfo())); return setEntity(project, oaf)
project.setLastupdatetimestamp(oaf.getLastupdatetimestamp());
return project
.setAcronym(mapStringField(m.getAcronym())) .setAcronym(mapStringField(m.getAcronym()))
.setCallidentifier(mapStringField(m.getCallidentifier())) .setCallidentifier(mapStringField(m.getCallidentifier()))
.setCode(mapStringField(m.getCode())) .setCode(mapStringField(m.getCode()))

View File

@ -5,6 +5,8 @@ import eu.dnetlib.data.proto.FieldTypeProtos;
import eu.dnetlib.data.proto.OafProtos; import eu.dnetlib.data.proto.OafProtos;
import eu.dnetlib.dhp.schema.oaf.*; import eu.dnetlib.dhp.schema.oaf.*;
import java.util.stream.Collectors;
public class ProtoUtils { public class ProtoUtils {
public static OafProtos.Oaf parse(String json) throws JsonFormat.ParseException { public static OafProtos.Oaf parse(String json) throws JsonFormat.ParseException {
@ -13,6 +15,33 @@ public class ProtoUtils {
return builder.build(); return builder.build();
} }
public static <T extends Oaf> T setOaf(T oaf, OafProtos.Oaf o) {
oaf.setDataInfo(mapDataInfo(o.getDataInfo())).setLastupdatetimestamp(o.getLastupdatetimestamp());
return oaf;
}
public static <T extends OafEntity> 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) { public static KeyValue mapKV(FieldTypeProtos.KeyValue kv) {
return new KeyValue() return new KeyValue()
.setKey(kv.getKey()) .setKey(kv.getKey())
@ -54,12 +83,10 @@ public class ProtoUtils {
.setValue(extraInfo.getValue()); .setValue(extraInfo.getValue());
} }
public static OAIProvenance mapOAIProvenance(FieldTypeProtos.OAIProvenance oaiProvenance) { public static OAIProvenance mapOAIProvenance(FieldTypeProtos.OAIProvenance oaiProvenance) {
return new OAIProvenance().setOriginDescription(mapOriginalDescription(oaiProvenance.getOriginDescription())); return new OAIProvenance().setOriginDescription(mapOriginalDescription(oaiProvenance.getOriginDescription()));
} }
public static OriginDescription mapOriginalDescription(FieldTypeProtos.OAIProvenance.OriginDescription originDescription) { public static OriginDescription mapOriginalDescription(FieldTypeProtos.OAIProvenance.OriginDescription originDescription) {
final OriginDescription originDescriptionResult = new OriginDescription() final OriginDescription originDescriptionResult = new OriginDescription()
.setHarvestDate(originDescription.getHarvestDate()) .setHarvestDate(originDescription.getHarvestDate())
@ -71,7 +98,6 @@ public class ProtoUtils {
if (originDescription.hasOriginDescription()) if (originDescription.hasOriginDescription())
originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription())); originDescriptionResult.setOriginDescription(mapOriginalDescription(originDescription.getOriginDescription()));
return originDescriptionResult; return originDescriptionResult;
} }
public static Field<String> mapStringField(FieldTypeProtos.StringField s) { public static Field<String> mapStringField(FieldTypeProtos.StringField s) {
@ -92,4 +118,20 @@ public class ProtoUtils {
.setDataInfo(b.hasDataInfo() ? mapDataInfo(b.getDataInfo()) : null); .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()));
}
} }