Revision 48145
Added by Claudio Atzori almost 7 years ago
HighlightFactory.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.data.mapreduce.hbase.broker.mapping; |
2 | 2 |
|
3 |
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.getValue; |
|
4 |
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.listValues; |
|
5 |
|
|
6 | 3 |
import java.util.List; |
7 | 4 |
|
8 |
import com.google.common.base.Function; |
|
9 |
import com.google.common.base.Joiner; |
|
10 |
import com.google.common.collect.Iterables; |
|
11 |
|
|
5 |
import com.google.common.collect.Lists; |
|
12 | 6 |
import eu.dnetlib.broker.objects.OpenAireEventPayload; |
13 | 7 |
import eu.dnetlib.data.proto.FieldTypeProtos.StringField; |
14 | 8 |
import eu.dnetlib.data.proto.FieldTypeProtos.StructuredProperty; |
15 | 9 |
import eu.dnetlib.data.proto.OafProtos.OafEntity; |
16 |
import eu.dnetlib.data.proto.ProjectProtos.Project; |
|
17 |
import eu.dnetlib.data.proto.ProjectProtos.Project.Metadata; |
|
18 | 10 |
import eu.dnetlib.data.proto.ResultProtos.Result.Instance; |
19 | 11 |
|
12 |
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.getValue; |
|
13 |
import static eu.dnetlib.data.mapreduce.util.OafHbaseUtils.listValues; |
|
14 |
|
|
20 | 15 |
/** |
21 | 16 |
* Created by alessia on 21/07/16. |
22 | 17 |
*/ |
... | ... | |
48 | 43 |
} |
49 | 44 |
|
50 | 45 |
// TODO: highlight for the following reasons |
51 |
public static OpenAireEventPayload highlightEnrichProject(final OpenAireEventPayload p, final OafEntity projectEntity, final String provenance) {
|
|
46 |
public static OpenAireEventPayload highlightEnrichProject(final OpenAireEventPayload p, final OafEntity project, final String provenance) { |
|
52 | 47 |
// TODO: this can wait. Think about generating the openaire string for project links: it will be easier for subscribers to integrate |
53 | 48 |
// it back to their records! |
54 |
final Project project = projectEntity.getProject(); |
|
55 |
final Metadata projectMetadata = project.getMetadata(); |
|
56 |
final StringField acro = projectMetadata.getAcronym(); |
|
57 |
final StringField title = projectMetadata.getTitle(); |
|
58 |
final StringField code = projectMetadata.getCode(); |
|
59 |
final List<StringField> fundingtree = projectMetadata.getFundingtreeList(); |
|
60 |
final String fundingTrees = "<fundings>" + Joiner.on(" ").join(Iterables.transform(fundingtree, new Function<StringField, String>() { |
|
61 | 49 |
|
62 |
@Override |
|
63 |
public String apply(final StringField v) { |
|
64 |
return v.getValue(); |
|
65 |
} |
|
66 |
} |
|
50 |
p.getHighlight().setProjects(Lists.newArrayList(mapRelatedProject(project.getProject()))); |
|
67 | 51 |
|
68 |
)) + "</fundings>"; |
|
69 | 52 |
return p; |
70 | 53 |
} |
71 | 54 |
|
... | ... | |
82 | 65 |
// Commenting highlights for addition events: the record is new for the subscriber! |
83 | 66 |
/* |
84 | 67 |
* public static OpenAireEventPayload highlightAddByAffiliation(final OpenAireEventPayload p){ return p; } |
85 |
*
|
|
68 |
* |
|
86 | 69 |
* public static OpenAireEventPayload highlightAddByReference(final OpenAireEventPayload p){ return p; } |
87 |
*
|
|
70 |
* |
|
88 | 71 |
* public static OpenAireEventPayload highlightAddByProject(final OpenAireEventPayload p){ //TODO: this cannot wait return p; } |
89 | 72 |
*/ |
90 | 73 |
|
Also available in: Unified diff
integrated latest changes from dnet40