1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.eventstream.internal

File DefaultEvent.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

16
53
37
1
345
243
45
0.85
1.43
37
1.22

Classes

Class Line # Actions
DefaultEvent 40 53 0% 45 12
0.886792588.7%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.eventstream.internal;
21   
22    import java.net.URL;
23    import java.text.MessageFormat;
24    import java.util.Collections;
25    import java.util.Date;
26    import java.util.HashMap;
27    import java.util.Map;
28   
29    import org.xwiki.eventstream.Event;
30    import org.xwiki.model.reference.DocumentReference;
31    import org.xwiki.model.reference.EntityReference;
32    import org.xwiki.model.reference.SpaceReference;
33    import org.xwiki.model.reference.WikiReference;
34   
35    /**
36    * A recorded event that occurred at some point in the wiki.
37    *
38    * @version $Id: df500ea5e7773f92ab6c95a061b0cde88ba2a28d $
39    */
 
40    public class DefaultEvent implements Event
41    {
42    /** The format of the {@link #toString()} result. */
43    private static final MessageFormat STRING_FORMAT =
44    new MessageFormat("{0} at {1,time,yyyy-MM-dd HH:mm:ss} by {2} on {3}");
45   
46    /** @see #getId() */
47    private String id;
48   
49    /** @see #getGroupId() */
50    private String groupId;
51   
52    /** @see #getType() */
53    private String type;
54   
55    /** @see #getDate() */
56    private Date date;
57   
58    /** @see #getImportance() */
59    private Importance importance = Importance.MEDIUM;
60   
61    /** @see #getApplication() */
62    private String application;
63   
64    /** @see #getStream() */
65    private String stream;
66   
67    /** @see #getWiki() */
68    private WikiReference wiki;
69   
70    /** @see #getSpace() */
71    private SpaceReference space;
72   
73    /** @see #getDocument() */
74    private DocumentReference document;
75   
76    /** @see #getRelatedEntity() */
77    private EntityReference relatedEntity;
78   
79    /** @see #getDocumentVersion() */
80    private String documentVersion;
81   
82    /** @see #getDocumentTitle() */
83    private String documentTitle;
84   
85    /** @see #getUser() */
86    private DocumentReference user;
87   
88    /** @see #getUrl() */
89    private URL url;
90   
91    /** @see #getTitle() */
92    private String title;
93   
94    /** @see #getBody() */
95    private String body;
96   
97    /** @see #getParameters() */
98    private Map<String, String> parameters;
99   
 
100  18 toggle @Override
101    public String getId()
102    {
103  18 return this.id;
104    }
105   
 
106  34 toggle @Override
107    public void setId(String id)
108    {
109  34 this.id = id;
110    }
111   
 
112  7 toggle @Override
113    public String getGroupId()
114    {
115  7 return this.groupId;
116    }
117   
 
118  21 toggle @Override
119    public void setGroupId(String id)
120    {
121  21 this.groupId = id;
122    }
123   
 
124  9 toggle @Override
125    public String getType()
126    {
127  9 return this.type;
128    }
129   
 
130  16 toggle @Override
131    public void setType(String type)
132    {
133  16 this.type = type;
134    }
135   
 
136  6 toggle @Override
137    public Date getDate()
138    {
139  6 return this.date;
140    }
141   
 
142  21 toggle @Override
143    public void setDate(Date date)
144    {
145  21 this.date = date;
146    }
147   
 
148  29 toggle @Override
149    public Importance getImportance()
150    {
151  29 return this.importance;
152    }
153   
 
154  15 toggle @Override
155    public void setImportance(Importance importance)
156    {
157  15 if (importance == null) {
158  1 this.importance = Importance.MEDIUM;
159    } else {
160  14 this.importance = importance;
161    }
162    }
163   
 
164  5 toggle @Override
165    public String getApplication()
166    {
167  5 return this.application;
168    }
169   
 
170  16 toggle @Override
171    public void setApplication(String application)
172    {
173  16 this.application = application;
174    }
175   
 
176  7 toggle @Override
177    public String getStream()
178    {
179  7 return this.stream;
180    }
181   
 
182  16 toggle @Override
183    public void setStream(String stream)
184    {
185  16 this.stream = stream;
186    }
187   
 
188  11 toggle @Override
189    public WikiReference getWiki()
190    {
191  11 WikiReference result = null;
192  11 if (this.wiki != null) {
193  2 result = this.wiki;
194  9 } else if (this.space != null) {
195  3 result = (WikiReference) this.space.getRoot();
196  6 } else if (this.document != null) {
197  3 result = this.document.getWikiReference();
198    }
199  11 return result;
200    }
201   
 
202  2 toggle @Override
203    public void setWiki(WikiReference wiki)
204    {
205  2 this.wiki = wiki;
206    }
207   
 
208  8 toggle @Override
209    public SpaceReference getSpace()
210    {
211  8 SpaceReference result = null;
212  8 if (this.space != null) {
213  2 result = this.space;
214  6 } else if (this.document != null) {
215  3 result = this.document.getLastSpaceReference();
216    }
217  8 return result;
218    }
219   
 
220  4 toggle @Override
221    public void setSpace(SpaceReference space)
222    {
223  4 this.space = space;
224    }
225   
 
226  5 toggle @Override
227    public DocumentReference getDocument()
228    {
229  5 return this.document;
230    }
231   
 
232  20 toggle @Override
233    public void setDocument(DocumentReference document)
234    {
235  20 this.document = document;
236    }
237   
 
238  4 toggle @Override
239    public String getDocumentVersion()
240    {
241  4 return this.documentVersion;
242    }
243   
 
244  2 toggle @Override
245    public void setDocumentVersion(String version)
246    {
247  2 this.documentVersion = version;
248    }
249   
 
250  8 toggle @Override
251    public EntityReference getRelatedEntity()
252    {
253  8 return this.relatedEntity;
254    }
255   
 
256  15 toggle @Override
257    public void setRelatedEntity(EntityReference entity)
258    {
259  15 this.relatedEntity = entity;
260    }
261   
 
262  6 toggle @Override
263    public DocumentReference getUser()
264    {
265  6 return this.user;
266    }
267   
 
268  21 toggle @Override
269    public void setUser(DocumentReference user)
270    {
271  21 this.user = user;
272    }
273   
 
274  4 toggle @Override
275    public URL getUrl()
276    {
277  4 return this.url;
278    }
279   
 
280  2 toggle @Override
281    public void setUrl(URL url)
282    {
283  2 this.url = url;
284    }
285   
 
286  4 toggle @Override
287    public String getTitle()
288    {
289  4 return this.title;
290    }
291   
 
292  2 toggle @Override
293    public void setTitle(String title)
294    {
295  2 this.title = title;
296    }
297   
 
298  17 toggle @Override
299    public String getBody()
300    {
301  17 return this.body;
302    }
303   
 
304  15 toggle @Override
305    public void setBody(String body)
306    {
307  15 this.body = body;
308    }
309   
 
310  4 toggle @Override
311    public String getDocumentTitle()
312    {
313  4 return this.documentTitle;
314    }
315   
 
316  2 toggle @Override
317    public void setDocumentTitle(String title)
318    {
319  2 this.documentTitle = title;
320    }
321   
 
322  0 toggle @Override
323    public Map<String, String> getParameters()
324    {
325  0 return this.parameters == null ? Collections.<String, String> emptyMap()
326    : Collections.unmodifiableMap(this.parameters);
327    }
328   
 
329  0 toggle @Override
330    public void setParameters(Map<String, String> parameters)
331    {
332  0 if (parameters != null) {
333  0 this.parameters = new HashMap<String, String>(parameters);
334    } else {
335    // Fallback to empty parameters map.
336  0 this.parameters = new HashMap<String, String>();
337    }
338    }
339   
 
340  0 toggle @Override
341    public String toString()
342    {
343  0 return STRING_FORMAT.format(new Object[] {getType(), getDate(), getUser(), getDocument()});
344    }
345    }