From 6c32d418acb5a1ecee17210e817f1e2378eaa165 Mon Sep 17 00:00:00 2001 From: "sandro.labruzzo" Date: Thu, 24 Oct 2019 17:26:55 +0200 Subject: [PATCH] added conversion of ExtraInfo --- .../eu/dnetlib/dhp/schema/oaf/ExtraInfo.java | 15 ++-- .../eu/dnetlib/dhp/graph/ProtoConverter.java | 31 ++++++-- .../java/eu/dnetlib/dhp/graph/ProtoUtils.java | 9 +++ .../eu/dnetlib/dhp/graph/organization.json | 74 ++++++++++++++++++- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java index 028b812a5..cf41926dc 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java @@ -18,39 +18,44 @@ public class ExtraInfo implements Serializable { return name; } - public void setName(String name) { + public ExtraInfo setName(String name) { this.name = name; + return this; } public String getTypology() { return typology; } - public void setTypology(String typology) { + public ExtraInfo setTypology(String typology) { this.typology = typology; + return this; } public String getProvenance() { return provenance; } - public void setProvenance(String provenance) { + public ExtraInfo setProvenance(String provenance) { this.provenance = provenance; + return this; } public String getTrust() { return trust; } - public void setTrust(String trust) { + public ExtraInfo setTrust(String trust) { this.trust = trust; + return this; } public String getValue() { return value; } - public void setValue(String value) { + public ExtraInfo setValue(String value) { this.value = value; + 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 40b15a6a1..0fa83a51a 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 @@ -67,22 +67,37 @@ public class ProtoConverter implements Serializable { private static Datasource convertDataSource(OafProtos.Oaf oaf) { final Datasource result = new Datasource(); - //setting oaf field - //TODO waiting claudio for this method - //result.setDataInfo(DataInfo.fromOaf(oaf.getDataInfo())); + + //Set Oaf Fields + result.setDataInfo(ProtoUtils.mapDataInfo(oaf.getDataInfo())); + result.setLastupdatetimestamp(oaf.getLastupdatetimestamp()); //setting Entity fields - result.setId(oaf.getEntity().getId()); - result.setOriginalId(oaf.getEntity().getOriginalIdList()); + final OafProtos.OafEntity entity = oaf.getEntity(); - //TODO waiting claudio for this method - result.setCollectedfrom(oaf.getEntity().getCollectedfromList() + result.setId(entity.getId()); + + result.setOriginalId(entity.getOriginalIdList()); + + result.setCollectedfrom(entity.getCollectedfromList() .stream() - .map(s->new KeyValue()) + .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; } 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 c6baf8b41..91e33b088 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 @@ -45,6 +45,15 @@ public class ProtoUtils { .setDataInfo(sp.hasDataInfo() ? mapDataInfo(sp.getDataInfo()) : null); } + public static ExtraInfo mapExtraInfo(FieldTypeProtos.ExtraInfo extraInfo) { + return new ExtraInfo() + .setName(extraInfo.getName()) + .setTypology(extraInfo.getTypology()) + .setProvenance(extraInfo.getProvenance()) + .setTrust(extraInfo.getTrust()) + .setValue(extraInfo.getValue()); + } + public static Field mapStringField(FieldTypeProtos.StringField s) { return new Field() .setValue(s.getValue()) diff --git a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/graph/organization.json b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/graph/organization.json index e20e39b98..e2c382c0a 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/graph/organization.json +++ b/dhp-workflows/dhp-graph-mapper/src/test/resources/eu/dnetlib/dhp/graph/organization.json @@ -1 +1,73 @@ -{"kind": "entity","entity": {"type": "datasource","datasource": {"metadata": {"officialname": {"value": "CRIS UNS (Current Research Information System University of Novi Sad)"},"englishname": {"value": "CRIS UNS (Current Research Information System University of Novi Sad)"},"websiteurl": {"value": "https://cris.uns.ac.rs/"},"accessinfopackage": [{"value": "https://cris.uns.ac.rs/OAIHandlerOpenAIRECRIS"}],"namespaceprefix": {"value": "CrisUnsNoviS"},"datasourcetype": {"classid": "crissystem","classname": "CRIS System","schemeid": "dnet:datasource_typologies","schemename": "dnet:datasource_typologies"},"openairecompatibility": {"classid": "openaire-cris_1.1","classname": "OpenAIRE CRIS v1.1","schemeid": "dnet:datasourceCompatibilityLevel","schemename": "dnet:datasourceCompatibilityLevel"},"latitude": {"value": "0.0"},"longitude": {"value": "0.0"},"journal": {"issnPrinted": "","issnOnline": "","issnLinking": ""}}},"originalId": ["CRIS_UNS____::openaire"],"collectedfrom": [{"key": "","value": ""}],"dateofcollection": "2019-04-04","id": "10|CRIS_UNS____::f66f1bd369679b5b077dcdf006089556","dateoftransformation": ""},"dataInfo": {"inferred": false,"deletedbyinference": false,"trust": "0.9","provenanceaction": {"classid": "sysimport:crosswalk:entityregistry","classname": "sysimport:crosswalk:entityregistry","schemeid": "dnet:provenance_actions","schemename": "dnet:provenance_actions"}}} \ No newline at end of file +{ + "kind": "entity", + "entity": { + "type": "datasource", + "datasource": { + "metadata": { + "officialname": { + "value": "CRIS UNS (Current Research Information System University of Novi Sad)" + }, + "englishname": { + "value": "CRIS UNS (Current Research Information System University of Novi Sad)" + }, + "websiteurl": { + "value": "https://cris.uns.ac.rs/" + }, + "accessinfopackage": [ + { + "value": "https://cris.uns.ac.rs/OAIHandlerOpenAIRECRIS" + } + ], + "namespaceprefix": { + "value": "CrisUnsNoviS" + }, + "datasourcetype": { + "classid": "crissystem", + "classname": "CRIS System", + "schemeid": "dnet:datasource_typologies", + "schemename": "dnet:datasource_typologies" + }, + "openairecompatibility": { + "classid": "openaire-cris_1.1", + "classname": "OpenAIRE CRIS v1.1", + "schemeid": "dnet:datasourceCompatibilityLevel", + "schemename": "dnet:datasourceCompatibilityLevel" + }, + "latitude": { + "value": "0.0" + }, + "longitude": { + "value": "0.0" + }, + "journal": { + "issnPrinted": "", + "issnOnline": "", + "issnLinking": "" + } + } + }, + "originalId": [ + "CRIS_UNS____::openaire" + ], + "collectedfrom": [ + { + "key": "", + "value": "" + } + ], + "dateofcollection": "2019-04-04", + "id": "10|CRIS_UNS____::f66f1bd369679b5b077dcdf006089556", + "dateoftransformation": "" + }, + "dataInfo": { + "inferred": false, + "deletedbyinference": false, + "trust": "0.9", + "provenanceaction": { + "classid": "sysimport:crosswalk:entityregistry", + "classname": "sysimport:crosswalk:entityregistry", + "schemeid": "dnet:provenance_actions", + "schemename": "dnet:provenance_actions" + } + } +} \ No newline at end of file