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
        return i;
87
    }
88

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

    
113
        return org;
114
    }
115

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

    
172

    
173
        return datasource;
174
    }
175

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

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

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

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

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

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

    
266
        return otherResearchProducts;
267
    }
268

    
269
    private static Publication createPublication(OafProtos.Oaf oaf) {
270

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

    
279
    private static Dataset createDataset(OafProtos.Oaf oaf) {
280

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

    
297
    }
298

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

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

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

    
385
        return entity;
386
    }
387

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

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

    
399

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

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

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

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

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

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

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

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

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

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

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

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

    
525
    }
526

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