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
public class Event {
10

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

    
13
	private String eventId;
14

    
15
	private String producerId;
16

    
17
	private String topic;
18

    
19
	private String payload;
20

    
21
	private Date creationDate;
22

    
23
	private Date expiryDate;
24

    
25
	private boolean instantMessage;
26

    
27
	private Map<String, Object> map;
28

    
29
	public Event() {}
30

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

    
44
	public String getProducerId() {
45
		return this.producerId;
46
	}
47

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

    
52
	public String getEventId() {
53
		return this.eventId;
54
	}
55

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

    
60
	public String getTopic() {
61
		return this.topic;
62
	}
63

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

    
68
	public String getPayload() {
69
		return this.payload;
70
	}
71

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

    
76
	public Date getCreationDate() {
77
		return this.creationDate;
78
	}
79

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

    
84
	public Date getExpiryDate() {
85
		return this.expiryDate;
86
	}
87

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

    
92
	public boolean isInstantMessage() {
93
		return this.instantMessage;
94
	}
95

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

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

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

    
108
	public String toJson() {
109

    
110
		final Gson gson = new GsonBuilder()
111
				.setDateFormat(DATE_FORMAT).create();
112

    
113
		return gson.toJson(this);
114
	}
115
}
(1-1/5)