1
|
package eu.dnetlib.data.mapreduce.hbase.broker.model;
|
2
|
|
3
|
import java.util.Map;
|
4
|
|
5
|
import com.google.gson.Gson;
|
6
|
|
7
|
/**
|
8
|
* Created by claudio on 08/07/16.
|
9
|
*/
|
10
|
|
11
|
// This class represents the Event message as required by the Original API
|
12
|
// (rabbitMQ)
|
13
|
public class EventMessage {
|
14
|
|
15
|
public static final int TTH_INFINITE = -1;
|
16
|
|
17
|
private String producerId;
|
18
|
private String topic;
|
19
|
private String payload;
|
20
|
private int tthDays = TTH_INFINITE;
|
21
|
private Map<String, MapValue> map;
|
22
|
|
23
|
public EventMessage() {
|
24
|
}
|
25
|
|
26
|
public EventMessage(final String producerId, final Topic topic, final String payload, final int tthDays,
|
27
|
final Map<String, MapValue> map) {
|
28
|
this.producerId = producerId;
|
29
|
this.topic = topic.getValue();
|
30
|
this.payload = payload;
|
31
|
this.tthDays = tthDays;
|
32
|
this.map = map;
|
33
|
}
|
34
|
|
35
|
public String getProducerId() {
|
36
|
return this.producerId;
|
37
|
}
|
38
|
|
39
|
public void setProducerId(final String producerId) {
|
40
|
this.producerId = producerId;
|
41
|
}
|
42
|
|
43
|
public String getTopic() {
|
44
|
return this.topic;
|
45
|
}
|
46
|
|
47
|
public void setTopic(final String topic) {
|
48
|
this.topic = topic;
|
49
|
}
|
50
|
|
51
|
public String getPayload() {
|
52
|
return this.payload;
|
53
|
}
|
54
|
|
55
|
public void setPayload(final String payload) {
|
56
|
this.payload = payload;
|
57
|
}
|
58
|
|
59
|
public Map<String, MapValue> getMap() {
|
60
|
return this.map;
|
61
|
}
|
62
|
|
63
|
public void setMap(final Map<String, MapValue> map) {
|
64
|
this.map = map;
|
65
|
}
|
66
|
|
67
|
public boolean hasNulls() {
|
68
|
return (this.producerId == null) || (this.topic == null) || (this.payload == null) || (this.map == null);
|
69
|
}
|
70
|
|
71
|
public int getTthDays() {
|
72
|
return this.tthDays;
|
73
|
}
|
74
|
|
75
|
public void setTthDays(final int tthDays) {
|
76
|
this.tthDays = tthDays;
|
77
|
}
|
78
|
|
79
|
@Override
|
80
|
public String toString() {
|
81
|
return new Gson().toJson(this);
|
82
|
}
|
83
|
}
|