1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package com.xpn.xwiki.plugin.activitystream.impl

File ActivityEventImpl.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart8.png
56% of files have more coverage

Code metrics

16
70
52
1
492
317
60
0.86
1.35
52
1.15

Classes

Class Line # Actions
ActivityEventImpl 34 70 0% 60 30
0.782608778.3%
 

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 com.xpn.xwiki.plugin.activitystream.impl;
21   
22    import java.util.ArrayList;
23    import java.util.Date;
24    import java.util.List;
25    import java.util.Map;
26    import java.util.Set;
27   
28    import com.xpn.xwiki.XWikiContext;
29    import com.xpn.xwiki.plugin.activitystream.api.ActivityEvent;
30   
31    /**
32    * @version $Id: 18ba8bdccf575696ce59937bfc9a9e433a9e848f $
33    */
 
34    public class ActivityEventImpl implements ActivityEvent
35    {
36    /**
37    * ID.
38    */
39    protected String eventId;
40   
41    /**
42    * Request ID.
43    */
44    protected String requestId;
45   
46    /**
47    * Priority.
48    */
49    protected int priority;
50   
51    /**
52    * Date the event occured.
53    */
54    protected Date date;
55   
56    /**
57    * Stream the event belongs to.
58    */
59    protected String stream;
60   
61    /**
62    * Application which fired the event (as of august 2009 this application is always "xwiki").
63    */
64    protected String application;
65   
66    /**
67    * Type of the event, see {@link com.xpn.xwiki.plugin.activitystream.api.ActivityEventType ActivityEventType}.
68    */
69    protected String type;
70   
71    /**
72    * Context user at the time the event has been fired.
73    */
74    protected String user;
75   
76    /**
77    * Wiki in which the event occured, example: "xwiki".
78    */
79    protected String wiki;
80   
81    /**
82    * Space (local serialized reference) in which the event occurred, example: "Main", "A.B", "A.B.C", etc.
83    */
84    protected String space;
85   
86    /**
87    * Name of the document which fired the event, example: "Main.WebHome".
88    */
89    protected String page;
90   
91    /**
92    * URL of the document which fired the event, example: "/xwiki/bin/view/Main/WebHome".
93    */
94    protected String url;
95   
96    /**
97    * Title of the event.
98    */
99    protected String title;
100   
101    /**
102    * Body message of the event.
103    */
104    protected String body = "";
105   
106    /**
107    * Version of the document at the time the event occured.
108    */
109    protected String version = "";
110   
111    /**
112    * Free param 1.
113    */
114    protected String param1 = "";
115   
116    /**
117    * Free param 2.
118    */
119    protected String param2 = "";
120   
121    /**
122    * Free param 3.
123    */
124    protected String param3 = "";
125   
126    /**
127    * Free param 4.
128    */
129    protected String param4 = "";
130   
131    /**
132    * Free param 5.
133    */
134    protected String param5 = "";
135   
136    /**
137    * True if the page which fired the event is marked as hidden, false otherwise.
138    */
139    protected boolean hidden;
140   
141    /**
142    * Named parameters.
143    */
144    protected Map<String, String> parameters;
145   
146    protected Set<String> target;
147   
 
148  0 toggle @Override
149    public String getDisplayTitle(XWikiContext context)
150    {
151  0 return context.getMessageTool().get(this.title, getParams());
152    }
153   
 
154  0 toggle @Override
155    public String getDisplayBody(XWikiContext context)
156    {
157  0 return context.getMessageTool().get(this.body, getParams());
158    }
159   
 
160  0 toggle @Override
161    public String getDisplayDate(XWikiContext context)
162    {
163  0 return context.getWiki().formatDate(this.date, null, context);
164    }
165   
 
166  0 toggle @Override
167    public String getDisplayUser(XWikiContext context)
168    {
169  0 return context.getWiki().getUserName(this.user, context);
170    }
171   
 
172  56 toggle @Override
173    public void setParams(List<String> params)
174    {
175  56 if (params != null) {
176  56 if (params.size() > 0) {
177  56 setParam1(params.get(0));
178    }
179  56 if (params.size() > 1) {
180  0 setParam2(params.get(1));
181    }
182  56 if (params.size() > 2) {
183  0 setParam3(params.get(2));
184    }
185  56 if (params.size() > 3) {
186  0 setParam4(params.get(3));
187    }
188  56 if (params.size() > 4) {
189  0 setParam5(params.get(4));
190    }
191    }
192    }
193   
194    /**
195    * @return the parameters of the event
196    */
 
197  0 toggle public List<String> getParams()
198    {
199  0 List<String> params = new ArrayList<String>();
200  0 params.add(getParam1());
201  0 params.add(getParam2());
202  0 params.add(getParam3());
203  0 params.add(getParam4());
204  0 params.add(getParam5());
205  0 return params;
206    }
207   
 
208  224 toggle @Override
209    public String getEventId()
210    {
211  224 return this.eventId;
212    }
213   
 
214  135 toggle @Override
215    public void setEventId(String eventId)
216    {
217  135 this.eventId = eventId;
218    }
219   
 
220  224 toggle @Override
221    public String getRequestId()
222    {
223  224 return this.requestId;
224    }
225   
 
226  79 toggle @Override
227    public void setRequestId(String requestId)
228    {
229  79 this.requestId = requestId;
230    }
231   
 
232  224 toggle @Override
233    public int getPriority()
234    {
235  224 return this.priority;
236    }
237   
 
238  79 toggle @Override
239    public void setPriority(int priority)
240    {
241  79 this.priority = priority;
242    }
243   
 
244  280 toggle @Override
245    public String getApplication()
246    {
247  280 return this.application;
248    }
249   
 
250  79 toggle @Override
251    public void setStream(String stream)
252    {
253  79 this.stream = stream;
254    }
255   
 
256  193 toggle @Override
257    public String getVersion()
258    {
259  193 return this.version;
260    }
261   
 
262  80 toggle @Override
263    public void setVersion(String version)
264    {
265  80 if (version != null) {
266  80 this.version = version;
267    }
268    }
269   
 
270  168 toggle @Override
271    public String getParam1()
272    {
273  168 return this.param1;
274    }
275   
 
276  79 toggle @Override
277    public void setParam1(String param1)
278    {
279  79 this.param1 = param1;
280    }
281   
 
282  168 toggle @Override
283    public String getParam2()
284    {
285  168 return this.param2;
286    }
287   
 
288  23 toggle @Override
289    public void setParam2(String param2)
290    {
291  23 this.param2 = param2;
292    }
293   
 
294  112 toggle @Override
295    public String getParam3()
296    {
297  112 return this.param3;
298    }
299   
 
300  23 toggle @Override
301    public void setParam3(String param3)
302    {
303  23 this.param3 = param3;
304    }
305   
 
306  112 toggle @Override
307    public String getParam4()
308    {
309  112 return this.param4;
310    }
311   
 
312  23 toggle @Override
313    public void setParam4(String param4)
314    {
315  23 this.param4 = param4;
316    }
317   
 
318  112 toggle @Override
319    public String getParam5()
320    {
321  112 return this.param5;
322    }
323   
 
324  23 toggle @Override
325    public void setParam5(String param5)
326    {
327  23 this.param5 = param5;
328    }
329   
 
330  330 toggle @Override
331    public String getWiki()
332    {
333  330 return this.wiki;
334    }
335   
 
336  80 toggle @Override
337    public void setWiki(String wiki)
338    {
339  80 this.wiki = wiki;
340    }
341   
 
342  249 toggle @Override
343    public String getType()
344    {
345  249 return this.type;
346    }
347   
 
348  80 toggle @Override
349    public void setType(String type)
350    {
351  80 this.type = type;
352    }
353   
 
354  273 toggle @Override
355    public String getUser()
356    {
357  273 return this.user;
358    }
359   
 
360  80 toggle @Override
361    public void setUser(String user)
362    {
363  80 this.user = user;
364    }
365   
 
366  168 toggle @Override
367    public String getSpace()
368    {
369  168 return this.space;
370    }
371   
 
372  79 toggle @Override
373    public void setSpace(String space)
374    {
375  79 this.space = space;
376    }
377   
 
378  305 toggle @Override
379    public String getPage()
380    {
381  305 return this.page;
382    }
383   
 
384  80 toggle @Override
385    public void setPage(String page)
386    {
387  80 this.page = page;
388    }
389   
 
390  277 toggle @Override
391    public String getUrl()
392    {
393  277 return this.url;
394    }
395   
 
396  76 toggle @Override
397    public void setUrl(String url)
398    {
399  76 this.url = url;
400    }
401   
 
402  168 toggle @Override
403    public String getTitle()
404    {
405  168 return this.title;
406    }
407   
 
408  79 toggle @Override
409    public void setTitle(String title)
410    {
411  79 this.title = title;
412    }
413   
 
414  168 toggle @Override
415    public String getBody()
416    {
417  168 return this.body;
418    }
419   
 
420  79 toggle @Override
421    public void setBody(String body)
422    {
423  79 this.body = body;
424    }
425   
 
426  305 toggle @Override
427    public Date getDate()
428    {
429  305 return this.date;
430    }
431   
 
432  80 toggle @Override
433    public void setDate(Date date)
434    {
435  80 this.date = date;
436    }
437   
 
438  280 toggle @Override
439    public String getStream()
440    {
441  280 return this.stream;
442    }
443   
 
444  79 toggle @Override
445    public void setApplication(String application)
446    {
447  79 this.application = application;
448    }
449   
 
450  0 toggle @Override
451    public void setParameters(Map<String, String> parameters)
452    {
453  0 this.parameters = parameters;
454    }
455   
 
456  56 toggle @Override
457    public Map<String, String> getParameters()
458    {
459  56 return this.parameters;
460    }
461   
462    /**
463    * @return True if the event has been triggered by an action performed on a document marked as hidden.
464    */
 
465  112 toggle public boolean isHidden()
466    {
467  112 return this.hidden;
468    }
469   
470    /**
471    * @param hidden the event hidden flag.
472    * @see #isHidden()
473    */
 
474  79 toggle public void setHidden(Boolean hidden)
475    {
476  79 if (hidden != null) {
477  79 this.hidden = hidden;
478    }
479    }
480   
 
481  23 toggle @Override
482    public void setTarget(Set<String> target)
483    {
484  23 this.target = target;
485    }
486   
 
487  168 toggle @Override
488    public Set<String> getTarget()
489    {
490  168 return target;
491    }
492    }