Project

General

Profile

1
package eu.dnetlib.data.mapreduce.hbase.dataexport;
2

    
3
import com.google.common.collect.Lists;
4
import com.googlecode.protobuf.format.JsonFormat;
5
import eu.dnetlib.data.proto.*;
6
import eu.dnetlib.dhp.schema.oaf.*;
7

    
8
import java.io.Serializable;
9
import java.util.List;
10
import java.util.stream.Collectors;
11

    
12
public class ProtoConverter implements Serializable {
13

    
14
    public static Oaf convert(OafProtos.Oaf oaf) {
15
        try {
16
            switch (oaf.getKind()) {
17
                case entity:
18
                    return convertEntity(oaf);
19
                case relation:
20
                    return convertRelation(oaf);
21
                default:
22
                    throw new IllegalArgumentException("invalid kind " + oaf.getKind());
23
            }
24
        } catch (Throwable e) {
25
            throw new RuntimeException("error on getting " + JsonFormat.printToString(oaf), e);
26
        }
27
    }
28

    
29
    private static Relation convertRelation(OafProtos.Oaf oaf) {
30
        final OafProtos.OafRel r = oaf.getRel();
31
        final Relation rel = new Relation();
32
        rel.setDataInfo(mapDataInfo(oaf.getDataInfo()));
33
        rel.setLastupdatetimestamp(oaf.getLastupdatetimestamp());
34
        rel.setSource(r.getSource());
35
        rel.setTarget(r.getTarget());
36
        rel.setRelType(r.getRelType().toString());
37
        rel.setSubRelType(r.getSubRelType().toString());
38
        rel.setRelClass(r.getRelClass());
39
        rel.setCollectedFrom(r.getCollectedfromCount() > 0 ?
40
                r.getCollectedfromList().stream()
41
                        .map(kv -> mapKV(kv))
42
                        .collect(Collectors.toList()) : null);
43
        return rel;
44
    }
45

    
46
    private static OafEntity convertEntity(OafProtos.Oaf oaf) {
47

    
48
        switch (oaf.getEntity().getType()) {
49
            case result:
50
                final Result r = convertResult(oaf);
51
                r.setInstance(convertInstances(oaf));
52
                return r;
53
            case project:
54
                return convertProject(oaf);
55
            case datasource:
56
                return convertDataSource(oaf);
57
            case organization:
58
                return convertOrganization(oaf);
59
            default:
60
                throw new RuntimeException("received unknown type");
61
        }
62
    }
63

    
64
    private static List<Instance> convertInstances(OafProtos.Oaf oaf) {
65

    
66
        final ResultProtos.Result r = oaf.getEntity().getResult();
67
        if (r.getInstanceCount() > 0) {
68
            return r.getInstanceList()
69
                    .stream()
70
                    .map(i -> convertInstance(i))
71
                    .collect(Collectors.toList());
72
        }
73
        return Lists.newArrayList();
74
    }
75

    
76
    private static Instance convertInstance(ResultProtos.Result.Instance ri) {
77
        final Instance i = new Instance();
78
        i.setAccessright(mapQualifier(ri.getAccessright()));
79
        i.setCollectedfrom(mapKV(ri.getCollectedfrom()));
80
        i.setDateofacceptance(mapStringField(ri.getDateofacceptance()));
81
        i.setDistributionlocation(ri.getDistributionlocation());
82
        i.setHostedby(mapKV(ri.getHostedby()));
83
        i.setInstancetype(mapQualifier(ri.getInstancetype()));
84
        i.setLicense(mapStringField(ri.getLicense()));
85
        i.setUrl(ri.getUrlList());
86
        //TODO: uncomment after model update
87
        //i.setRefereed(ri.getRefereed());
88
        return i;
89
    }
90

    
91
    private static Organization convertOrganization(OafProtos.Oaf oaf) {
92
        final OrganizationProtos.Organization.Metadata m = oaf.getEntity().getOrganization().getMetadata();
93
        final Organization org = setOaf(new Organization(), oaf);
94
        setEntity(org, oaf);
95
        org.setLegalshortname(mapStringField(m.getLegalshortname()));
96
        org.setLegalname(mapStringField(m.getLegalname()));
97
        org.setAlternativeNames(m.getAlternativeNamesList().
98
                stream()
99
                .map(ProtoConverter::mapStringField)
100
                .collect(Collectors.toList()));
101
        org.setWebsiteurl(mapStringField(m.getWebsiteurl()));
102
        org.setLogourl(mapStringField(m.getLogourl()));
103
        org.setEclegalbody(mapStringField(m.getEclegalbody()));
104
        org.setEclegalperson(mapStringField(m.getEclegalperson()));
105
        org.setEcnonprofit(mapStringField(m.getEcnonprofit()));
106
        org.setEcresearchorganization(mapStringField(m.getEcresearchorganization()));
107
        org.setEchighereducation(mapStringField(m.getEchighereducation()));
108
        org.setEcinternationalorganizationeurinterests(mapStringField(m.getEcinternationalorganizationeurinterests()));
109
        org.setEcinternationalorganization(mapStringField(m.getEcinternationalorganization()));
110
        org.setEcenterprise(mapStringField(m.getEcenterprise()));
111
        org.setEcsmevalidated(mapStringField(m.getEcsmevalidated()));
112
        org.setEcnutscode(mapStringField(m.getEcnutscode()));
113
        org.setCountry(mapQualifier(m.getCountry()));
114

    
115
        return org;
116
    }
117

    
118
    private static Datasource convertDataSource(OafProtos.Oaf oaf) {
119
        final DatasourceProtos.Datasource.Metadata m = oaf.getEntity().getDatasource().getMetadata();
120
        final Datasource datasource = setOaf(new Datasource(), oaf);
121
        setEntity(datasource, oaf);
122
        datasource.setAccessinfopackage(m.getAccessinfopackageList()
123
                .stream()
124
                .map(ProtoConverter::mapStringField)
125
                .collect(Collectors.toList()));
126
        datasource.setCertificates(mapStringField(m.getCertificates()));
127
        datasource.setCitationguidelineurl(mapStringField(m.getCitationguidelineurl()));
128
        datasource.setContactemail(mapStringField(m.getContactemail()));
129
        datasource.setDatabaseaccessrestriction(mapStringField(m.getDatabaseaccessrestriction()));
130
        datasource.setDatabaseaccesstype(mapStringField(m.getDatabaseaccesstype()));
131
        datasource.setDataprovider(mapBoolField(m.getDataprovider()));
132
        datasource.setDatasourcetype(mapQualifier(m.getDatasourcetype()));
133
        datasource.setDatauploadrestriction(mapStringField(m.getDatauploadrestriction()));
134
        datasource.setCitationguidelineurl(mapStringField(m.getCitationguidelineurl()));
135
        datasource.setDatauploadtype(mapStringField(m.getDatauploadtype()));
136
        datasource.setDateofvalidation(mapStringField(m.getDateofvalidation()));
137
        datasource.setDescription(mapStringField(m.getDescription()));
138
        datasource.setEnglishname(mapStringField(m.getEnglishname()));
139
        datasource.setLatitude(mapStringField(m.getLatitude()));
140
        datasource.setLongitude(mapStringField(m.getLongitude()));
141
        datasource.setLogourl(mapStringField(m.getLogourl()));
142
        datasource.setMissionstatementurl(mapStringField(m.getMissionstatementurl()));
143
        datasource.setNamespaceprefix(mapStringField(m.getNamespaceprefix()));
144
        datasource.setOdcontenttypes(m.getOdcontenttypesList()
145
                .stream()
146
                .map(ProtoConverter::mapStringField)
147
                .collect(Collectors.toList()));
148
        datasource.setOdlanguages(m.getOdlanguagesList()
149
                .stream()
150
                .map(ProtoConverter::mapStringField)
151
                .collect(Collectors.toList()));
152
        datasource.setOdnumberofitems(mapStringField(m.getOdnumberofitems()));
153
        datasource.setOdnumberofitemsdate(mapStringField(m.getOdnumberofitemsdate()));
154
        datasource.setOdpolicies(mapStringField(m.getOdpolicies()));
155
        datasource.setOfficialname(mapStringField(m.getOfficialname()));
156
        datasource.setOpenairecompatibility(mapQualifier(m.getOpenairecompatibility()));
157
        datasource.setPidsystems(mapStringField(m.getPidsystems()));
158
        datasource.setPolicies(m.getPoliciesList()
159
                .stream()
160
                .map(ProtoConverter::mapKV)
161
                .collect(Collectors.toList()));
162
        datasource.setQualitymanagementkind(mapStringField(m.getQualitymanagementkind()));
163
        datasource.setReleaseenddate(mapStringField(m.getReleaseenddate()));
164
        datasource.setServiceprovider(mapBoolField(m.getServiceprovider()));
165
        datasource.setReleasestartdate(mapStringField(m.getReleasestartdate()));
166
        datasource.setSubjects(m.getSubjectsList()
167
                .stream()
168
                .map(ProtoConverter::mapStructuredProperty)
169
                .collect(Collectors.toList()));
170
        datasource.setVersioning(mapBoolField(m.getVersioning()));
171
        datasource.setWebsiteurl(mapStringField(m.getWebsiteurl()));
172
        datasource.setJournal(mapJournal(m.getJournal()));
173

    
174

    
175
        return datasource;
176
    }
177

    
178
    private static Project convertProject(OafProtos.Oaf oaf) {
179
        final ProjectProtos.Project.Metadata m = oaf.getEntity().getProject().getMetadata();
180
        final Project project = setOaf(new Project(), oaf);
181
        setEntity(project, oaf);
182
        project.setAcronym(mapStringField(m.getAcronym()));
183
        project.setCallidentifier(mapStringField(m.getCallidentifier()));
184
        project.setCode(mapStringField(m.getCode()));
185
        project.setContactemail(mapStringField(m.getContactemail()));
186
        project.setContactfax(mapStringField(m.getContactfax()));
187
        project.setContactfullname(mapStringField(m.getContactfullname()));
188
        project.setContactphone(mapStringField(m.getContactphone()));
189
        project.setContracttype(mapQualifier(m.getContracttype()));
190
        project.setCurrency(mapStringField(m.getCurrency()));
191
        project.setDuration(mapStringField(m.getDuration()));
192
        project.setEcarticle29_3(mapStringField(m.getEcarticle293()));
193
        project.setEcsc39(mapStringField(m.getEcsc39()));
194
        project.setOamandatepublications(mapStringField(m.getOamandatepublications()));
195
        project.setStartdate(mapStringField(m.getStartdate()));
196
        project.setEnddate(mapStringField(m.getEnddate()));
197
        project.setFundedamount(m.getFundedamount());
198
        project.setTotalcost(m.getTotalcost());
199
        project.setKeywords(mapStringField(m.getKeywords()));
200
        project.setSubjects(m.getSubjectsList().stream()
201
                .map(sp -> mapStructuredProperty(sp))
202
                .collect(Collectors.toList()));
203
        project.setTitle(mapStringField(m.getTitle()));
204
        project.setWebsiteurl(mapStringField(m.getWebsiteurl()));
205
        project.setFundingtree(m.getFundingtreeList().stream()
206
                .map(f -> mapStringField(f))
207
                .collect(Collectors.toList()));
208
        project.setJsonextrainfo(mapStringField(m.getJsonextrainfo()));
209
        project.setSummary(mapStringField(m.getSummary()));
210
        project.setOptional1(mapStringField(m.getOptional1()));
211
        project.setOptional2(mapStringField(m.getOptional2()));
212
        return project;
213
    }
214

    
215
    private static Result convertResult(OafProtos.Oaf oaf) {
216
        switch (oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()) {
217

    
218
            case "dataset":
219
                return createDataset(oaf);
220
            case "publication":
221
                return createPublication(oaf);
222
            case "software":
223
                return createSoftware(oaf);
224
            case "other":
225
                return createORP(oaf);
226
            default:
227
                throw new RuntimeException("received unknown type: " + oaf.getEntity().getResult().getMetadata().getResulttype().getClassid());
228
        }
229
    }
230

    
231
    private static Software createSoftware(OafProtos.Oaf oaf) {
232
        ResultProtos.Result.Metadata m = oaf.getEntity().getResult().getMetadata();
233
        Software software = setOaf(new Software(), oaf);
234
        setEntity(software, oaf);
235
        setResult(software, oaf);
236

    
237
        software.setDocumentationUrl(m.getDocumentationUrlList()
238
                .stream()
239
                .map(ProtoConverter::mapStringField)
240
                .collect(Collectors.toList()));
241
        software.setLicense(m.getLicenseList()
242
                .stream()
243
                .map(ProtoConverter::mapStructuredProperty)
244
                .collect(Collectors.toList()));
245
        software.setCodeRepositoryUrl(mapStringField(m.getCodeRepositoryUrl()));
246
        software.setProgrammingLanguage(mapQualifier(m.getProgrammingLanguage()));
247
        return software;
248
    }
249

    
250
    private static OtherResearchProduct createORP(OafProtos.Oaf oaf) {
251
        ResultProtos.Result.Metadata m = oaf.getEntity().getResult().getMetadata();
252
        OtherResearchProduct otherResearchProducts = setOaf(new OtherResearchProduct(), oaf);
253
        setEntity(otherResearchProducts, oaf);
254
        setResult(otherResearchProducts, oaf);
255
        otherResearchProducts.setContactperson(m.getContactpersonList()
256
                .stream()
257
                .map(ProtoConverter::mapStringField)
258
                .collect(Collectors.toList()));
259
        otherResearchProducts.setContactgroup(m.getContactgroupList()
260
                .stream()
261
                .map(ProtoConverter::mapStringField)
262
                .collect(Collectors.toList()));
263
        otherResearchProducts.setTool(m.getToolList()
264
                .stream()
265
                .map(ProtoConverter::mapStringField)
266
                .collect(Collectors.toList()));
267

    
268
        return otherResearchProducts;
269
    }
270

    
271
    private static Publication createPublication(OafProtos.Oaf oaf) {
272

    
273
        ResultProtos.Result.Metadata m = oaf.getEntity().getResult().getMetadata();
274
        Publication publication = setOaf(new Publication(), oaf);
275
        setEntity(publication, oaf);
276
        setResult(publication, oaf);
277
        publication.setJournal(mapJournal(m.getJournal()));
278
        return publication;
279
    }
280

    
281
    private static Dataset createDataset(OafProtos.Oaf oaf) {
282

    
283
        ResultProtos.Result.Metadata m = oaf.getEntity().getResult().getMetadata();
284
        Dataset dataset = setOaf(new Dataset(), oaf);
285
        setEntity(dataset, oaf);
286
        setResult(dataset, oaf);
287
        dataset.setStoragedate(mapStringField(m.getStoragedate()));
288
        dataset.setDevice(mapStringField(m.getDevice()));
289
        dataset.setSize(mapStringField(m.getSize()));
290
        dataset.setVersion(mapStringField(m.getVersion()));
291
        dataset.setLastmetadataupdate(mapStringField(m.getLastmetadataupdate()));
292
        dataset.setMetadataversionnumber(mapStringField(m.getMetadataversionnumber()));
293
        dataset.setGeolocation(m.getGeolocationList()
294
                .stream()
295
                .map(ProtoConverter::mapGeolocation)
296
                .collect(Collectors.toList()));
297
        return dataset;
298

    
299
    }
300

    
301
    public static <T extends Oaf> T setOaf(T oaf, OafProtos.Oaf o) {
302
        oaf.setDataInfo(mapDataInfo(o.getDataInfo()));
303
        oaf.setLastupdatetimestamp(o.getLastupdatetimestamp());
304
        return oaf;
305
    }
306

    
307
    public static <T extends OafEntity> T setEntity(T entity, OafProtos.Oaf oaf) {
308
        //setting Entity fields
309
        final OafProtos.OafEntity e = oaf.getEntity();
310
        entity.setId(e.getId());
311
        entity.setOriginalId(e.getOriginalIdList());
312
        entity.setCollectedfrom(e.getCollectedfromList()
313
                .stream()
314
                .map(ProtoConverter::mapKV)
315
                .collect(Collectors.toList()));
316
        entity.setPid(e.getPidList().stream()
317
                .map(ProtoConverter::mapStructuredProperty)
318
                .collect(Collectors.toList()));
319
        entity.setDateofcollection(e.getDateofcollection());
320
        entity.setDateoftransformation(e.getDateoftransformation());
321
        entity.setExtraInfo(e.getExtraInfoList()
322
                .stream()
323
                .map(ProtoConverter::mapExtraInfo)
324
                .collect(Collectors.toList()));
325
        return entity;
326
    }
327

    
328
    public static <T extends Result> T setResult(T entity, OafProtos.Oaf oaf) {
329
        //setting Entity fields
330
        final ResultProtos.Result.Metadata m = oaf.getEntity().getResult().getMetadata();
331
        entity.setAuthor(m.getAuthorList()
332
                .stream()
333
                .map(ProtoConverter::mapAuthor)
334
                .collect(Collectors.toList()));
335
        entity.setResulttype(mapQualifier(m.getResulttype()));
336
        entity.setLanguage(mapQualifier(m.getLanguage()));
337
        entity.setCountry(m.getCountryList()
338
                .stream()
339
                .map(ProtoConverter::mapQualifier)
340
                .collect(Collectors.toList()));
341
        entity.setSubject(m.getSubjectList()
342
                .stream()
343
                .map(ProtoConverter::mapStructuredProperty)
344
                .collect(Collectors.toList()));
345
        entity.setTitle(m.getTitleList()
346
                .stream()
347
                .map(ProtoConverter::mapStructuredProperty)
348
                .collect(Collectors.toList()));
349
        entity.setRelevantdate(m.getRelevantdateList()
350
                .stream()
351
                .map(ProtoConverter::mapStructuredProperty)
352
                .collect(Collectors.toList()));
353
        entity.setDescription(m.getDescriptionList()
354
                .stream()
355
                .map(ProtoConverter::mapStringField)
356
                .collect(Collectors.toList()));
357
        entity.setDateofacceptance(mapStringField(m.getDateofacceptance()));
358
        entity.setPublisher(mapStringField(m.getPublisher()));
359
        entity.setEmbargoenddate(mapStringField(m.getEmbargoenddate()));
360
        entity.setSource(m.getSourceList()
361
                .stream()
362
                .map(ProtoConverter::mapStringField)
363
                .collect(Collectors.toList()));
364
        entity.setFulltext(m.getFulltextList()
365
                .stream()
366
                .map(ProtoConverter::mapStringField)
367
                .collect(Collectors.toList()));
368
        entity.setFormat(m.getFormatList()
369
                .stream()
370
                .map(ProtoConverter::mapStringField)
371
                .collect(Collectors.toList()));
372
        entity.setContributor(m.getContributorList()
373
                .stream()
374
                .map(ProtoConverter::mapStringField)
375
                .collect(Collectors.toList()));
376
        entity.setResourcetype(mapQualifier(m.getResourcetype()));
377
        entity.setCoverage(m.getCoverageList()
378
                .stream()
379
                .map(ProtoConverter::mapStringField)
380
                .collect(Collectors.toList()));
381
        entity.setContext(m.getContextList()
382
                .stream()
383
                .map(ProtoConverter::mapContext)
384
                .collect(Collectors.toList()));
385

    
386
        return entity;
387
    }
388

    
389
    private static Context mapContext(ResultProtos.Result.Context context) {
390

    
391
        final Context entity = new Context();
392
        entity.setId(context.getId());
393
        entity.setDataInfo(context.getDataInfoList()
394
                .stream()
395
                .map(ProtoConverter::mapDataInfo)
396
                .collect(Collectors.toList()));
397
        return entity;
398
    }
399

    
400

    
401
    public static KeyValue mapKV(FieldTypeProtos.KeyValue kv) {
402
        final KeyValue keyValue = new KeyValue();
403
        keyValue.setKey(kv.getKey());
404
        keyValue.setValue(kv.getValue());
405
        keyValue.setDataInfo(mapDataInfo(kv.getDataInfo()));
406
        return keyValue;
407
    }
408

    
409
    public static DataInfo mapDataInfo(FieldTypeProtos.DataInfo d) {
410
        final DataInfo dataInfo = new DataInfo();
411
        dataInfo.setDeletedbyinference(d.getDeletedbyinference());
412
        dataInfo.setInferenceprovenance(d.getInferenceprovenance());
413
        dataInfo.setInferred(d.getInferred());
414
        dataInfo.setInvisible(d.getInvisible());
415
        dataInfo.setProvenanceaction(mapQualifier(d.getProvenanceaction()));
416
        dataInfo.setTrust(d.getTrust());
417
        return dataInfo;
418
    }
419

    
420
    public static Qualifier mapQualifier(FieldTypeProtos.Qualifier q) {
421
        final Qualifier qualifier = new Qualifier();
422
        qualifier.setClassid(q.getClassid());
423
        qualifier.setClassname(q.getClassname());
424
        qualifier.setSchemeid(q.getSchemeid());
425
        qualifier.setSchemename(q.getSchemename());
426
        return qualifier;
427
    }
428

    
429
    public static StructuredProperty mapStructuredProperty(FieldTypeProtos.StructuredProperty sp) {
430
        final StructuredProperty structuredProperty = new StructuredProperty();
431
        structuredProperty.setValue(sp.getValue());
432
        structuredProperty.setQualifier(mapQualifier(sp.getQualifier()));
433
        structuredProperty.setDataInfo(mapDataInfo(sp.getDataInfo()));
434
        return structuredProperty;
435
    }
436

    
437
    public static ExtraInfo mapExtraInfo(FieldTypeProtos.ExtraInfo extraInfo) {
438
        final ExtraInfo entity = new ExtraInfo();
439
        entity.setName(extraInfo.getName());
440
        entity.setTypology(extraInfo.getTypology());
441
        entity.setProvenance(extraInfo.getProvenance());
442
        entity.setTrust(extraInfo.getTrust());
443
        entity.setValue(extraInfo.getValue());
444
        return entity;
445
    }
446

    
447
    public static OAIProvenance mapOAIProvenance(FieldTypeProtos.OAIProvenance oaiProvenance) {
448
        final OAIProvenance entity = new OAIProvenance();
449
        entity.setOriginDescription(mapOriginalDescription(oaiProvenance.getOriginDescription()));
450
        return entity;
451
    }
452

    
453
    public static OriginDescription mapOriginalDescription(FieldTypeProtos.OAIProvenance.OriginDescription originDescription) {
454
        final OriginDescription originDescriptionResult = new OriginDescription();
455
        originDescriptionResult.setHarvestDate(originDescription.getHarvestDate());
456
        originDescriptionResult.setAltered(originDescription.getAltered());
457
        originDescriptionResult.setBaseURL(originDescription.getBaseURL());
458
        originDescriptionResult.setIdentifier(originDescription.getIdentifier());
459
        originDescriptionResult.setDatestamp(originDescription.getDatestamp());
460
        originDescriptionResult.setMetadataNamespace(originDescription.getMetadataNamespace());
461
        return originDescriptionResult;
462
    }
463

    
464
    public static Field<String> mapStringField(FieldTypeProtos.StringField s) {
465
        final Field<String> stringField = new Field<>();
466
        stringField.setValue(s.getValue());
467
        stringField.setDataInfo(mapDataInfo(s.getDataInfo()));
468
        return stringField;
469
    }
470

    
471
    public static Field<Boolean> mapBoolField(FieldTypeProtos.BoolField b) {
472
        final Field<Boolean> booleanField = new Field<>();
473
        booleanField.setValue(b.getValue());
474
        booleanField.setDataInfo(mapDataInfo(b.getDataInfo()));
475
        return booleanField;
476
    }
477

    
478
    public static Field<Integer> mapIntField(FieldTypeProtos.IntField b) {
479
        final Field<Integer> entity = new Field<>();
480
        entity.setValue(b.getValue());
481
        entity.setDataInfo(mapDataInfo(b.getDataInfo()));
482
        return entity;
483
    }
484

    
485
    public static Journal mapJournal(FieldTypeProtos.Journal j) {
486
        final Journal journal = new Journal();
487
        journal.setConferencedate(j.getConferencedate());
488
        journal.setConferenceplace(j.getConferenceplace());
489
        journal.setEdition(j.getEdition());
490
        journal.setEp(j.getEp());
491
        journal.setIss(j.getIss());
492
        journal.setIssnLinking(j.getIssnLinking());
493
        journal.setIssnOnline(j.getIssnOnline());
494
        journal.setIssnPrinted(j.getIssnPrinted());
495
        journal.setName(j.getName());
496
        journal.setSp(j.getSp());
497
        journal.setVol(j.getVol());
498
        journal.setDataInfo(mapDataInfo(j.getDataInfo()));
499
        return journal;
500
    }
501

    
502
    public static Author mapAuthor(FieldTypeProtos.Author author) {
503
        final Author entity = new Author();
504
        entity.setFullname(author.getFullname());
505
        entity.setName(author.getName());
506
        entity.setSurname(author.getSurname());
507
        entity.setRank(author.getRank());
508
        entity.setPid(author.getPidList()
509
                .stream()
510
                .map(kv -> {
511
                    final StructuredProperty sp = new StructuredProperty();
512
                    sp.setValue(kv.getValue());
513
                    final Qualifier q = new Qualifier();
514
                    q.setClassid(kv.getKey());
515
                    q.setClassname(kv.getKey());
516
                    sp.setQualifier(q);
517
                    return sp;
518
                })
519
                .collect(Collectors.toList()));
520
        entity.setAffiliation(author.getAffiliationList()
521
                .stream()
522
                .map(ProtoConverter::mapStringField)
523
                .collect(Collectors.toList()));
524
        return entity;
525

    
526
    }
527

    
528
    public static GeoLocation mapGeolocation(ResultProtos.Result.GeoLocation geoLocation) {
529
        final GeoLocation entity = new GeoLocation();
530
        entity.setPoint(geoLocation.getPoint());
531
        entity.setBox(geoLocation.getBox());
532
        entity.setPlace(geoLocation.getPlace());
533
        return entity;
534
    }
535
}
(9-9/10)