1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.stats.impl

File DocumentStats.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart0.png
83% of files have more coverage

Code metrics

0
13
10
2
142
55
10
0.77
1.3
5
1

Classes

Class Line # Actions
DocumentStats 31 13 0% 10 23
0.00%
DocumentStats.Property 38 0 - 0 0
-1.0 -
 

Contributing tests

No tests hitting this source file were found.

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.stats.impl;
21   
22    import java.util.Date;
23   
24    import com.xpn.xwiki.stats.impl.StatsUtil.PeriodType;
25   
26    /**
27    * The document statistics database object.
28    *
29    * @version $Id: 50bffaf3d32cf1ea546ee6fda828302febd0b858 $
30    */
 
31    public class DocumentStats extends XWikiStats
32    {
33    /**
34    * The properties of document statistics object.
35    *
36    * @version $Id: 50bffaf3d32cf1ea546ee6fda828302febd0b858 $
37    */
 
38    public enum Property
39    {
40    /**
41    * The action made on the document ("view", "save", ...).
42    */
43    action,
44   
45    /**
46    * The number of unique visitors.
47    */
48    uniqueVisitors,
49   
50    /**
51    * The number of visits.
52    */
53    visits
54    }
55   
56    /**
57    * Default {@link DocumentStats} constructor.
58    */
 
59  0 toggle public DocumentStats()
60    {
61    }
62   
63    /**
64    * @param docName the name of the wiki/space/document.
65    * @param action the action made on the document ("view", "save", ...).
66    * @param periodDate the date of the period.
67    * @param periodType the type of the period.
68    */
 
69  0 toggle public DocumentStats(String docName, String action, Date periodDate, PeriodType periodType)
70    {
71  0 super(periodDate, periodType);
72   
73  0 setName(docName);
74  0 String nb = action + getPeriod();
75  0 setNumber(nb.hashCode());
76  0 setAction(action);
77    }
78   
79    /**
80    * @return the action made on the document ("view", "save", ...).
81    */
 
82  0 toggle public String getAction()
83    {
84  0 return getStringValue(Property.action.toString());
85    }
86   
87    /**
88    * @param action the action made on the document ("view", "save", ...).
89    */
 
90  0 toggle public void setAction(String action)
91    {
92  0 setStringValue(Property.action.toString(), action);
93    }
94   
95    /**
96    * @return the number of unique visitors.
97    */
 
98  0 toggle public int getUniqueVisitors()
99    {
100  0 return getIntValue(Property.uniqueVisitors.toString());
101    }
102   
103    /**
104    * @param uniqueVisitors the number of unique visitors.
105    */
 
106  0 toggle public void setUniqueVisitors(int uniqueVisitors)
107    {
108  0 setIntValue(Property.uniqueVisitors.toString(), uniqueVisitors);
109    }
110   
111    /**
112    * Add 1 to the number of unique visitors.
113    */
 
114  0 toggle public void incUniqueVisitors()
115    {
116  0 setIntValue(Property.uniqueVisitors.toString(), getUniqueVisitors() + 1);
117    }
118   
119    /**
120    * @return the number of visits.
121    */
 
122  0 toggle public int getVisits()
123    {
124  0 return getIntValue(Property.visits.toString());
125    }
126   
127    /**
128    * @param visits the number of visits.
129    */
 
130  0 toggle public void setVisits(int visits)
131    {
132  0 setIntValue(Property.visits.toString(), visits);
133    }
134   
135    /**
136    * Add 1 to the number of visits.
137    */
 
138  0 toggle public void incVisits()
139    {
140  0 setIntValue(Property.visits.toString(), getVisits() + 1);
141    }
142    }