Project

General

Profile

« Previous | Next » 

Revision 52765

Fixed the generation of eventIds

View differences:

SubjectEventFactory.java
1 1
package eu.dnetlib.data.mapreduce.hbase.broker;
2 2

  
3
import static eu.dnetlib.data.mapreduce.hbase.broker.mapping.EventFactory.asEvent;
4

  
3 5
import java.io.IOException;
4 6
import java.util.List;
7
import java.util.stream.Collectors;
5 8

  
9
import org.apache.commons.lang.StringUtils;
10
import org.apache.hadoop.mapreduce.Reducer.Context;
11
import org.dom4j.DocumentException;
12

  
6 13
import com.google.common.collect.Lists;
14

  
7 15
import eu.dnetlib.broker.objects.OpenAireEventPayload;
8 16
import eu.dnetlib.data.mapreduce.hbase.broker.mapping.HighlightFactory;
9 17
import eu.dnetlib.data.mapreduce.hbase.broker.mapping.OpenAireEventPayloadFactory;
......
12 20
import eu.dnetlib.data.proto.OafProtos.Oaf;
13 21
import eu.dnetlib.data.proto.OafProtos.OafEntity;
14 22
import eu.dnetlib.data.proto.ResultProtos.Result.Metadata;
15
import org.apache.commons.lang.StringUtils;
16
import org.apache.hadoop.mapreduce.Reducer.Context;
17
import org.dom4j.DocumentException;
18 23

  
19
import static eu.dnetlib.data.mapreduce.hbase.broker.mapping.EventFactory.asEvent;
20

  
21 24
/**
22 25
 * Created by claudio on 16/11/2016.
23 26
 */
......
40 43
			for (final StructuredProperty subject : mCurrent.getSubjectList()) {
41 44

  
42 45
				if (subject.hasDataInfo() && subject.getDataInfo().getInferred()) {
43
					events.add(doProcessSubject(context, current, null, subject, getSubjectTopic(subject, true), Float.valueOf(subject.getDataInfo().getTrust())));
46
					events.add(
47
							doProcessSubject(context, current, null, subject, getSubjectTopic(subject, true), Float.valueOf(subject.getDataInfo().getTrust())));
44 48
				}
45 49
			}
46 50
		}
47 51
		return events;
48 52
	}
49 53

  
50
	private List<EventWrapper> processSubjectPair(final Context context, final Oaf current, final Oaf other, final Float trust) throws IOException, InterruptedException {
54
	private List<EventWrapper> processSubjectPair(final Context context, final Oaf current, final Oaf other, final Float trust)
55
			throws IOException, InterruptedException {
51 56

  
52 57
		final Metadata mCurrent = current.getEntity().getResult().getMetadata();
53 58
		final Metadata mOther = other.getEntity().getResult().getMetadata();
......
95 100
						Lists.newArrayList(subjectOther));
96 101
		return EventWrapper.newInstance(
97 102
				asEvent(oaf.getEntity(), topic, payload, eventEntity, adjustedTrust),
103
				payload.getHighlight().getSubjects().stream().filter(StringUtils::isNotBlank).sorted().collect(Collectors.joining(", ")),
98 104
				topic.getValue());
99 105
	}
100 106

  
101
	private Topic getSubjectTopic(final StructuredProperty subject, boolean missingOrMore) {
107
	private Topic getSubjectTopic(final StructuredProperty subject, final boolean missingOrMore) {
102 108
		switch (subject.getQualifier().getClassid()) {
103
		case "mesheuropmc" :
109
		case "mesheuropmc":
104 110
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_MESHEUROPMC : Topic.ENRICH_MORE_SUBJECT_MESHEUROPMC;
105
		case "arxiv" :
111
		case "arxiv":
106 112
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_ARXIV : Topic.ENRICH_MORE_SUBJECT_ARXIV;
107
		case "jel" :
113
		case "jel":
108 114
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_JEL : Topic.ENRICH_MORE_SUBJECT_JEL;
109
		case "ddc" :
115
		case "ddc":
110 116
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_DDC : Topic.ENRICH_MORE_SUBJECT_DDC;
111
		case "acm" :
117
		case "acm":
112 118
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_ACM : Topic.ENRICH_MORE_SUBJECT_ACM;
113
		case "rvk" :
119
		case "rvk":
114 120
			return missingOrMore ? Topic.ENRICH_MISSING_SUBJECT_RVK : Topic.ENRICH_MORE_SUBJECT_RVK;
115 121
		default:
116 122
			return null;

Also available in: Unified diff