1    /*
2     * Copyright 2009 :torweg free software group
3     *
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program is distributed in the hope that it will be useful,
10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.component.statistics.view;
19   
20   import java.io.Serializable;
21   import java.util.List;
22   
23   import javax.xml.bind.annotation.XmlAccessOrder;
24   import javax.xml.bind.annotation.XmlAccessType;
25   import javax.xml.bind.annotation.XmlAccessorOrder;
26   import javax.xml.bind.annotation.XmlAccessorType;
27   import javax.xml.bind.annotation.XmlElement;
28   import javax.xml.bind.annotation.XmlRootElement;
29   import javax.xml.bind.annotation.XmlTransient;
30   
31   import org.slf4j.Logger;
32   import org.slf4j.LoggerFactory;
33   import org.torweg.pulse.component.statistics.model.StatisticsServer;
34   import org.torweg.pulse.component.statistics.model.aggregation.AverageTimePerVisitAggregation;
35   import org.torweg.pulse.component.statistics.model.aggregation.CountryPerVisitAggregation;
36   import org.torweg.pulse.component.statistics.model.aggregation.OperatingSystemPerVisitAggregation;
37   import org.torweg.pulse.component.statistics.model.aggregation.PIRecordCountAggregation;
38   import org.torweg.pulse.component.statistics.model.aggregation.RefererTreeAggregation;
39   import org.torweg.pulse.component.statistics.model.aggregation.ScreenResolutionPerVisitAggregation;
40   import org.torweg.pulse.component.statistics.model.aggregation.UserAgentPerVisitAggregation;
41   import org.torweg.pulse.component.statistics.model.aggregation.VisitCountAggregation;
42   import org.torweg.pulse.util.time.Duration;
43   import org.torweg.pulse.util.time.Period;
44   
45   /**
46    * An abstract base-class to be used for extending representing statistical
47    * aggregated data for usage in results.
48    * 
49    * @author Daniel Dietz
50    * @version $Revision: 1585 $
51    */
52   @XmlRootElement(name = "abstract-statistics-view-controller-result-data")
53   @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
54   @XmlAccessorType(XmlAccessType.FIELD)
55   public abstract class AbstractStatisticsViewControllerResultData implements
56           Serializable {
57   
58       /**
59        * The serialVersionUID.
60        */
61       private static final long serialVersionUID = -7755440931530097041L;
62   
63       /**
64        * The logger.
65        */
66       protected static final Logger LOGGER = LoggerFactory
67               .getLogger(AbstractStatisticsViewControllerResultData.class);
68   
69       /**
70        * The {@code Duration}.
71        */
72       @XmlElement(name = "duration")
73       private Duration duration;
74   
75       /**
76        * The {@code Period} "data resolution".
77        */
78       @XmlElement(name = "data-resolution")
79       private Period dataResolution;
80   
81       /**
82        * The {@code StatisticsServer}.
83        */
84       @XmlElement(name = "statistics-server")
85       private StatisticsServer server;
86   
87       /**
88        * The {@code AverageTimePerVisitAggregation}s.
89        */
90       @XmlTransient
91       private List<AverageTimePerVisitAggregation> averageTimePerVisitAggregations;
92   
93       /**
94        * The {@code CountryPerVisitAggregation}s.
95        */
96       @XmlTransient
97       private List<CountryPerVisitAggregation> countryPerVisitAggregations;
98   
99       /**
100       * The {@code PIRecordCountAggregation}s.
101       */
102      @XmlTransient
103      private List<PIRecordCountAggregation> piRecordCountAggregations;
104  
105      /**
106       * The {@code VisitCountAggregation}s.
107       */
108      @XmlTransient
109      private List<VisitCountAggregation> visitCountAggregations;
110  
111      /**
112       * The {@code OperatingSystemPerVisitAggregation}s.
113       */
114      @XmlTransient
115      private List<OperatingSystemPerVisitAggregation> operatingSystemPerVisitAggregations;
116  
117      /**
118       * The {@code UserAgentPerVisitAggregation}s.
119       */
120      @XmlTransient
121      private List<UserAgentPerVisitAggregation> userAgentPerVisitAggregations;
122  
123      /**
124       * The {@code ScreenResolutionPerVisitAggregation}s.
125       */
126      @XmlTransient
127      private List<ScreenResolutionPerVisitAggregation> screenResolutionPerVisitAggregations;
128  
129      /**
130       * The {@code RefererPerVisitAggregation}s.
131       */
132      @XmlTransient
133      private List<RefererTreeAggregation> refererTreeAggregations;
134  
135      /**
136       * Returns the {@code Duration}.
137       * 
138       * @return the <tt>duration</tt>
139       */
140      public final Duration getDuration() {
141          return this.duration;
142      }
143  
144      /**
145       * Sets the {@code Duration}.
146       * 
147       * @param dur
148       *            the {@code Duration}
149       * 
150       * @throws NullPointerException
151       *             if the given {@code Duration} is {@code null}
152       */
153      protected final void setDuration(final Duration dur) {
154          if (dur == null) {
155              throw new NullPointerException("Given Duration must not be null.");
156          }
157          this.duration = dur;
158      }
159  
160      /**
161       * Returns the {@code Period} used as "data resolution".
162       * 
163       * @return the <tt>dataResolution</tt>
164       */
165      public final Period getDataResolution() {
166          return this.dataResolution;
167      }
168  
169      /**
170       * Sets the {@code Period} to be used as "data resolution".
171       * 
172       * @param resolution
173       *            the {@code Period}
174       * 
175       * @throws NullPointerException
176       *             if the given {@code Period} is {@code null}
177       */
178      protected final void setDataResolution(final Period resolution) {
179          if (resolution == null) {
180              throw new NullPointerException("Given Period must not be null.");
181          }
182          this.dataResolution = resolution;
183      }
184  
185      /**
186       * Returns the {@code StatisticsServer}.
187       * 
188       * @return the <tt>server</tt>
189       */
190      public final StatisticsServer getStatisticsServer() {
191          return this.server;
192      }
193  
194      /**
195       * Sets the {@code StatisticsServer}.
196       * 
197       * @param ser
198       *            the {@code StatisticsServer}
199       * 
200       * @throws NullPointerException
201       *             if the given {@code StatisticsServer} is
202       *             {@code null}
203       */
204      protected final void setStatisticsServer(final StatisticsServer ser) {
205          if (ser == null) {
206              throw new NullPointerException(
207                      "Given StatisticsServer must not be null.");
208          }
209          this.server = ser;
210      }
211  
212      /**
213       * Returns the {@code AverageTimePerVisitAggregation}s.
214       * 
215       * @return the <tt>averageTimePerVisitAggregations</tt>
216       */
217      @XmlTransient
218      public final List<AverageTimePerVisitAggregation> getAverageTimePerVisitAggregations() {
219          return this.averageTimePerVisitAggregations;
220      }
221  
222      /**
223       * Sets the {@code AverageTimePerVisitAggregation}s.
224       * 
225       * @param aggregations
226       *            the {@code AverageTimePerVisitAggregation}s
227       */
228      protected void setAverageTimePerVisitAggregations(
229              final List<AverageTimePerVisitAggregation> aggregations) {
230          this.averageTimePerVisitAggregations = aggregations;
231      }
232  
233      /**
234       * Returns the {@code CountryPerVisitAggregation}s.
235       * 
236       * @return the <tt>countryPerVisitAggregations</tt>
237       */
238      @XmlTransient
239      public final List<CountryPerVisitAggregation> getCountryPerVisitAggregations() {
240          return this.countryPerVisitAggregations;
241      }
242  
243      /**
244       * Sets the {@code CountryPerVisitAggregation}s.
245       * 
246       * @param aggregations
247       *            the {@code CountryPerVisitAggregation}s
248       */
249      protected void setCountryPerVisitAggregations(
250              final List<CountryPerVisitAggregation> aggregations) {
251          this.countryPerVisitAggregations = aggregations;
252      }
253  
254      /**
255       * Returns the {@code PIRecordCountAggregation}s.
256       * 
257       * @return the <tt>piRecordCountAggregations</tt>
258       */
259      @XmlTransient
260      public final List<PIRecordCountAggregation> getPIRecordCountAggregations() {
261          return this.piRecordCountAggregations;
262      }
263  
264      /**
265       * Sets the {@code PIRecordCountAggregation}s.
266       * 
267       * @param aggregations
268       *            the {@code PIRecordCountAggregation}s
269       */
270      protected void setPIRecordCountAggregations(
271              final List<PIRecordCountAggregation> aggregations) {
272          this.piRecordCountAggregations = aggregations;
273      }
274  
275      /**
276       * Returns the {@code VisitCountAggregation}s.
277       * 
278       * @return the <tt>visitCountAggregations</tt>
279       */
280      @XmlTransient
281      public final List<VisitCountAggregation> getVisitCountAggregations() {
282          return this.visitCountAggregations;
283      }
284  
285      /**
286       * Sets the {@code VisitCountAggregation}s.
287       * 
288       * @param aggregations
289       *            the {@code VisitCountAggregation}s
290       */
291      protected void setVisitCountAggregations(
292              final List<VisitCountAggregation> aggregations) {
293          this.visitCountAggregations = aggregations;
294      }
295  
296      /**
297       * Returns the {@code OperatingSystemPerVisitAggregation}s.
298       * 
299       * @return the <tt>operatingSystemPerVisitAggregations</tt>
300       */
301      @XmlTransient
302      public final List<OperatingSystemPerVisitAggregation> getOperatingSystemPerVisitAggregations() {
303          return this.operatingSystemPerVisitAggregations;
304      }
305  
306      /**
307       * Sets the {@code OperatingSystemPerVisitAggregation}s.
308       * 
309       * @param aggregations
310       *            the {@code OperatingSystemPerVisitAggregation}s
311       */
312      protected void setOperatingSystemPerVisitAggregations(
313              final List<OperatingSystemPerVisitAggregation> aggregations) {
314          this.operatingSystemPerVisitAggregations = aggregations;
315      }
316  
317      /**
318       * Returns the {@code UserAgentPerVisitAggregation}s.
319       * 
320       * @return the <tt>userAgentPerVisitAggregations</tt>
321       */
322      @XmlTransient
323      public final List<UserAgentPerVisitAggregation> getUserAgentPerVisitAggregations() {
324          return this.userAgentPerVisitAggregations;
325      }
326  
327      /**
328       * Sets the {@code UserAgentPerVisitAggregation}s.
329       * 
330       * @param aggregations
331       *            the {@code UserAgentPerVisitAggregation}s
332       */
333      protected void setUserAgentPerVisitAggregations(
334              final List<UserAgentPerVisitAggregation> aggregations) {
335          this.userAgentPerVisitAggregations = aggregations;
336      }
337  
338      /**
339       * Returns the {@code ScreenResolutionPerVisitAggregation}s.
340       * 
341       * @return the <tt>screenResolutionPerVisitAggregations</tt>
342       */
343      @XmlTransient
344      public final List<ScreenResolutionPerVisitAggregation> getScreenResolutionPerVisitAggregations() {
345          return this.screenResolutionPerVisitAggregations;
346      }
347  
348      /**
349       * Sets the {@code ScreenResolutionPerVisitAggregation}s.
350       * 
351       * @param aggregations
352       *            the {@code ScreenResolutionPerVisitAggregation}s
353       */
354      protected void setScreenResolutionPerVisitAggregations(
355              final List<ScreenResolutionPerVisitAggregation> aggregations) {
356          this.screenResolutionPerVisitAggregations = aggregations;
357      }
358  
359      /**
360       * Returns the {@code RefererTreeAggregation}s.
361       * 
362       * @return the <tt>refererTreeAggregations</tt>
363       */
364      @XmlTransient
365      public final List<RefererTreeAggregation> getRefererTreeAggregations() {
366          return this.refererTreeAggregations;
367      }
368  
369      /**
370       * Sets the {@code RefererTreeAggregation}s.
371       * 
372       * @param aggregations
373       *            the {@code RefererTreeAggregation}s
374       */
375      protected void setRefererTreeAggregations(
376              final List<RefererTreeAggregation> aggregations) {
377          this.refererTreeAggregations = aggregations;
378      }
379  
380  }
381