Revision 58095
Added by Claudio Atzori about 4 years ago
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/dataexport/ProtoConverter.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import com.google.common.collect.Lists; |
4 | 4 |
import com.googlecode.protobuf.format.JsonFormat; |
5 |
import eu.dnetlib.data.mapreduce.util.LicenseComparator; |
|
5 | 6 |
import eu.dnetlib.data.proto.*; |
6 | 7 |
import eu.dnetlib.dhp.schema.oaf.*; |
7 | 8 |
|
... | ... | |
83 | 84 |
i.setInstancetype(mapQualifier(ri.getInstancetype())); |
84 | 85 |
i.setLicense(mapStringField(ri.getLicense())); |
85 | 86 |
i.setUrl(ri.getUrlList()); |
86 |
//TODO: uncomment after model update |
|
87 |
//i.setRefereed(ri.getRefereed()); |
|
87 |
i.setRefereed(mapStringField(ri.getRefereed())); |
|
88 |
i.setProcessingchargeamount(mapStringField(ri.getProcessingchargeamount())); |
|
89 |
i.setProcessingchargecurrency(mapStringField(ri.getProcessingchargecurrency())); |
|
88 | 90 |
return i; |
89 | 91 |
} |
90 | 92 |
|
... | ... | |
214 | 216 |
|
215 | 217 |
private static Result convertResult(OafProtos.Oaf oaf) { |
216 | 218 |
switch (oaf.getEntity().getResult().getMetadata().getResulttype().getClassid()) { |
217 |
|
|
218 | 219 |
case "dataset": |
219 | 220 |
return createDataset(oaf); |
220 | 221 |
case "publication": |
... | ... | |
336 | 337 |
entity.setLanguage(mapQualifier(m.getLanguage())); |
337 | 338 |
entity.setCountry(m.getCountryList() |
338 | 339 |
.stream() |
339 |
.map(ProtoConverter::mapQualifier) |
|
340 |
.map(ProtoConverter::mapQualifierAsCountry)
|
|
340 | 341 |
.collect(Collectors.toList())); |
341 | 342 |
entity.setSubject(m.getSubjectList() |
342 | 343 |
.stream() |
... | ... | |
383 | 384 |
.map(ProtoConverter::mapContext) |
384 | 385 |
.collect(Collectors.toList())); |
385 | 386 |
|
387 |
entity.setBestaccessright(getBestAccessRights(oaf.getEntity().getResult().getInstanceList())); |
|
388 |
|
|
386 | 389 |
return entity; |
387 | 390 |
} |
388 | 391 |
|
392 |
private static Qualifier getBestAccessRights(List<ResultProtos.Result.Instance> instanceList) { |
|
393 |
if (instanceList != null) { |
|
394 |
return mapQualifier(instanceList.stream() |
|
395 |
.map(i -> i.getAccessright()) |
|
396 |
.sorted(new LicenseComparator()) |
|
397 |
.findFirst() |
|
398 |
.get()); |
|
399 |
} |
|
400 |
return null; |
|
401 |
} |
|
402 |
|
|
389 | 403 |
private static Context mapContext(ResultProtos.Result.Context context) { |
390 | 404 |
|
391 | 405 |
final Context entity = new Context(); |
... | ... | |
426 | 440 |
return qualifier; |
427 | 441 |
} |
428 | 442 |
|
443 |
public static Country mapQualifierAsCountry(FieldTypeProtos.Qualifier q) { |
|
444 |
final Country c = new Country(); |
|
445 |
c.setClassid(q.getClassid()); |
|
446 |
c.setClassname(q.getClassname()); |
|
447 |
c.setSchemeid(q.getSchemeid()); |
|
448 |
c.setSchemename(q.getSchemename()); |
|
449 |
c.setDataInfo(mapDataInfo(q.getDataInfo())); |
|
450 |
return c; |
|
451 |
} |
|
452 |
|
|
429 | 453 |
public static StructuredProperty mapStructuredProperty(FieldTypeProtos.StructuredProperty sp) { |
430 | 454 |
final StructuredProperty structuredProperty = new StructuredProperty(); |
431 | 455 |
structuredProperty.setValue(sp.getValue()); |
Also available in: Unified diff
protobuf to dhp model mapping aligned with dhp-schema:1.1.5