1
|
package eu.dnetlib.data.mapreduce.hbase.broker.mapping;
|
2
|
|
3
|
import java.util.List;
|
4
|
|
5
|
import com.google.common.base.Function;
|
6
|
import com.google.common.base.Joiner;
|
7
|
import com.google.common.collect.Iterables;
|
8
|
import eu.dnetlib.data.broker.model.openaire.OpenAireEventPayload;
|
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.ProjectProtos.Project;
|
13
|
import eu.dnetlib.data.proto.ProjectProtos.Project.Metadata;
|
14
|
import eu.dnetlib.data.proto.ResultProtos.Result.Instance;
|
15
|
|
16
|
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.getValue;
|
17
|
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.hashSetValues;
|
18
|
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.listValues;
|
19
|
|
20
|
/**
|
21
|
* Created by alessia on 21/07/16.
|
22
|
*/
|
23
|
public class HighlightFactory extends ProtoMapping {
|
24
|
|
25
|
public static OpenAireEventPayload highlightEnrichOa(final OpenAireEventPayload p, List<Instance> instances) {
|
26
|
p.getHighlight().setInstances(mapInstances(instances));
|
27
|
return p;
|
28
|
}
|
29
|
|
30
|
public static OpenAireEventPayload highlightEnrichPid(final OpenAireEventPayload p, final List<StructuredProperty> pids) {
|
31
|
p.getHighlight().setPids(mapPids(pids));
|
32
|
return p;
|
33
|
}
|
34
|
|
35
|
public static OpenAireEventPayload highlightEnrichPublicationDate(final OpenAireEventPayload p, final StringField date) {
|
36
|
p.getHighlight().setPublicationdate(getValue(date));
|
37
|
return p;
|
38
|
}
|
39
|
|
40
|
public static OpenAireEventPayload highlightEnrichAbstract(final OpenAireEventPayload p, List<StringField> descriptionList){
|
41
|
p.getHighlight().setAbstracts(hashSetValues(descriptionList));
|
42
|
return p;
|
43
|
}
|
44
|
|
45
|
public static OpenAireEventPayload highlightEnrichSubject(final OpenAireEventPayload p, final List<StructuredProperty> subjects){
|
46
|
p.getHighlight().setSubjects(hashSetValues(subjects));
|
47
|
return p;
|
48
|
}
|
49
|
|
50
|
//TODO: highlight for the following reasons
|
51
|
public static OpenAireEventPayload highlightEnrichProject(final OpenAireEventPayload p, final OafEntity projectEntity, boolean inferredLink){
|
52
|
//TODO: this can wait. Think about generating the openaire string for project links: it will be easier for subscribers to integrate it back to their records!
|
53
|
Project project = projectEntity.getProject();
|
54
|
Metadata projectMetadata = project.getMetadata();
|
55
|
StringField acro = projectMetadata.getAcronym();
|
56
|
StringField title = projectMetadata.getTitle();
|
57
|
StringField code = projectMetadata.getCode();
|
58
|
List<StringField> fundingtree = projectMetadata.getFundingtreeList();
|
59
|
String fundingTrees = "<fundings>"+Joiner.on(" ").join(Iterables.transform(fundingtree, new Function<StringField, String>() {
|
60
|
@Override
|
61
|
public String apply(final StringField v) {
|
62
|
return v.getValue();
|
63
|
}
|
64
|
}
|
65
|
|
66
|
)) + "</fundings>";
|
67
|
return p;
|
68
|
}
|
69
|
|
70
|
|
71
|
public static OpenAireEventPayload highlightEnrichDataset(final OpenAireEventPayload p){
|
72
|
//TODO: this can wait
|
73
|
return p;
|
74
|
}
|
75
|
|
76
|
public static OpenAireEventPayload highlightEnrichAuthorPid(final OpenAireEventPayload p){
|
77
|
//TODO: this can wait
|
78
|
return p;
|
79
|
}
|
80
|
|
81
|
// Commenting highlights for addition events: the record is new for the subscriber!
|
82
|
/*public static OpenAireEventPayload highlightAddByAffiliation(final OpenAireEventPayload p){
|
83
|
return p;
|
84
|
}
|
85
|
|
86
|
public static OpenAireEventPayload highlightAddByReference(final OpenAireEventPayload p){
|
87
|
return p;
|
88
|
}
|
89
|
|
90
|
public static OpenAireEventPayload highlightAddByProject(final OpenAireEventPayload p){
|
91
|
//TODO: this cannot wait
|
92
|
return p;
|
93
|
}*/
|
94
|
|
95
|
|
96
|
|
97
|
}
|