1
|
package eu.dnetlib.data.mapreduce.hbase.broker.mapping;
|
2
|
|
3
|
import java.util.Collection;
|
4
|
import java.util.List;
|
5
|
|
6
|
import com.google.common.collect.Lists;
|
7
|
import eu.dnetlib.broker.objects.OpenAireEventPayload;
|
8
|
import eu.dnetlib.data.proto.FieldTypeProtos;
|
9
|
import eu.dnetlib.data.proto.FieldTypeProtos.StringField;
|
10
|
import eu.dnetlib.data.proto.FieldTypeProtos.StructuredProperty;
|
11
|
import eu.dnetlib.data.proto.OafProtos.OafEntity;
|
12
|
import eu.dnetlib.data.proto.ResultProtos.Result.Instance;
|
13
|
|
14
|
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.*;
|
15
|
|
16
|
/**
|
17
|
* Created by alessia on 21/07/16.
|
18
|
*/
|
19
|
public class HighlightFactory extends ProtoMapping {
|
20
|
|
21
|
public static OpenAireEventPayload highlightEnrichOa(final OpenAireEventPayload p, final Collection<Instance> instances) {
|
22
|
p.getHighlight().setInstances(mapInstances(instances));
|
23
|
return p;
|
24
|
}
|
25
|
|
26
|
public static OpenAireEventPayload highlightEnrichPid(final OpenAireEventPayload p, final List<StructuredProperty> pids) {
|
27
|
p.getHighlight().setPids(mapPids(pids));
|
28
|
return p;
|
29
|
}
|
30
|
|
31
|
public static OpenAireEventPayload highlightEnrichPublicationDate(final OpenAireEventPayload p, final StringField date) {
|
32
|
p.getHighlight().setPublicationdate(getValue(date));
|
33
|
return p;
|
34
|
}
|
35
|
|
36
|
public static OpenAireEventPayload highlightEnrichAbstract(final OpenAireEventPayload p, final List<StringField> descriptionList) {
|
37
|
p.getHighlight().setAbstracts(listValues(descriptionList));
|
38
|
return p;
|
39
|
}
|
40
|
|
41
|
public static OpenAireEventPayload highlightEnrichOrcidAuthor(final OpenAireEventPayload p, final FieldTypeProtos.Author author) {
|
42
|
p.getHighlight().getCreators().add(mapValue(author));
|
43
|
return p;
|
44
|
}
|
45
|
|
46
|
public static OpenAireEventPayload highlightEnrichSubject(final OpenAireEventPayload p, final List<StructuredProperty> subjects) {
|
47
|
p.getHighlight().setSubjects(listValues(subjects));
|
48
|
return p;
|
49
|
}
|
50
|
|
51
|
// TODO: highlight for the following reasons
|
52
|
public static OpenAireEventPayload highlightEnrichProject(final OpenAireEventPayload p, final OafEntity project, final String provenance) {
|
53
|
// TODO: this can wait. Think about generating the openaire string for project links: it will be easier for subscribers to integrate
|
54
|
// it back to their records!
|
55
|
|
56
|
p.getHighlight().setProjects(Lists.newArrayList(mapRelatedProject(project.getProject())));
|
57
|
|
58
|
return p;
|
59
|
}
|
60
|
|
61
|
public static OpenAireEventPayload highlightEnrichSoftware(final OpenAireEventPayload p, final OafEntity software, final String provenance) {
|
62
|
// TODO: this can wait. Think about generating the openaire string for project links: it will be easier for subscribers to integrate
|
63
|
// it back to their records!
|
64
|
|
65
|
p.getHighlight().setSoftwares(Lists.newArrayList(mapRelatedSoftware(software.getResult())));
|
66
|
|
67
|
return p;
|
68
|
}
|
69
|
|
70
|
public static OpenAireEventPayload highlightEnrichDataset(final OpenAireEventPayload p) {
|
71
|
// TODO: this can wait
|
72
|
return p;
|
73
|
}
|
74
|
|
75
|
public static OpenAireEventPayload highlightEnrichAuthorPid(final OpenAireEventPayload p) {
|
76
|
// TODO: this can wait
|
77
|
return p;
|
78
|
}
|
79
|
|
80
|
// Commenting highlights for addition events: the record is new for the subscriber!
|
81
|
/*
|
82
|
* public static OpenAireEventPayload highlightAddByAffiliation(final OpenAireEventPayload p){ return p; }
|
83
|
*
|
84
|
* public static OpenAireEventPayload highlightAddByReference(final OpenAireEventPayload p){ return p; }
|
85
|
*
|
86
|
* public static OpenAireEventPayload highlightAddByProject(final OpenAireEventPayload p){ //TODO: this cannot wait return p; }
|
87
|
*/
|
88
|
|
89
|
}
|