Project

General

Profile

1
package eu.dnetlib.data.mapreduce.hbase.broker.model;
2

    
3
import java.util.Date;
4
import java.util.Map;
5

    
6
import com.google.gson.Gson;
7
import com.google.gson.GsonBuilder;
8

    
9
// This class represents the ElasticSearch Entity
10
public class Event {
11

    
12
	public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
13

    
14
	private String eventId;
15

    
16
	private String producerId;
17

    
18
	private String topic;
19

    
20
	private String payload;
21

    
22
	private Date creationDate;
23

    
24
	private Date expiryDate;
25

    
26
	private boolean instantMessage;
27

    
28
	private Map<String, Object> map;
29

    
30
	public Event() {
31
	}
32

    
33
	public Event(final String producerId, final String eventId, final String topic, final String payload,
34
			final Date creationDate, final Date expiryDate, final boolean instantMessage,
35
			final Map<String, Object> map) {
36
		this.producerId = producerId;
37
		this.eventId = eventId;
38
		this.topic = topic;
39
		this.payload = payload;
40
		this.creationDate = creationDate;
41
		this.expiryDate = expiryDate;
42
		this.instantMessage = instantMessage;
43
		this.map = map;
44
	}
45

    
46
	public String getProducerId() {
47
		return this.producerId;
48
	}
49

    
50
	public void setProducerId(final String producerId) {
51
		this.producerId = producerId;
52
	}
53

    
54
	public String getEventId() {
55
		return this.eventId;
56
	}
57

    
58
	public void setEventId(final String eventId) {
59
		this.eventId = eventId;
60
	}
61

    
62
	public String getTopic() {
63
		return this.topic;
64
	}
65

    
66
	public void setTopic(final String topic) {
67
		this.topic = topic;
68
	}
69

    
70
	public String getPayload() {
71
		return this.payload;
72
	}
73

    
74
	public void setPayload(final String payload) {
75
		this.payload = payload;
76
	}
77

    
78
	public Date getCreationDate() {
79
		return this.creationDate;
80
	}
81

    
82
	public void setCreationDate(final Date creationDate) {
83
		this.creationDate = creationDate;
84
	}
85

    
86
	public Date getExpiryDate() {
87
		return this.expiryDate;
88
	}
89

    
90
	public void setExpiryDate(final Date expiryDate) {
91
		this.expiryDate = expiryDate;
92
	}
93

    
94
	public boolean isInstantMessage() {
95
		return this.instantMessage;
96
	}
97

    
98
	public void setInstantMessage(final boolean instantMessage) {
99
		this.instantMessage = instantMessage;
100
	}
101

    
102
	public Map<String, Object> getMap() {
103
		return this.map;
104
	}
105

    
106
	public void setMap(final Map<String, Object> map) {
107
		this.map = map;
108
	}
109

    
110
	public String asJson() {
111
		final Gson gson = new GsonBuilder().setDateFormat(DATE_FORMAT).create();
112
		return gson.toJson(this);
113
	}
114
}
(1-1/6)