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.util.Set;
21   
22   import javax.xml.bind.annotation.XmlAccessOrder;
23   import javax.xml.bind.annotation.XmlAccessType;
24   import javax.xml.bind.annotation.XmlAccessorOrder;
25   import javax.xml.bind.annotation.XmlAccessorType;
26   import javax.xml.bind.annotation.XmlElement;
27   import javax.xml.bind.annotation.XmlElementWrapper;
28   import javax.xml.bind.annotation.XmlRootElement;
29   
30   import org.torweg.pulse.configuration.XSLHandleConfiguration;
31   import org.torweg.pulse.util.adminui.AbstractBaseConfiguration;
32   import org.torweg.pulse.util.time.Period;
33   import org.torweg.pulse.util.xml.transform.XSLHandle;
34   
35   /**
36    * Abstract base-class to derive {@code Configuration}s for the
37    * {@code AbstractStatisticsViewController}s from.
38    * 
39    * @author Daniel Dietz
40    * @version $Revision: 1568 $
41    */
42   @XmlRootElement(name = "abstract-statistics-view-controller-configuration")
43   @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
44   @XmlAccessorType(XmlAccessType.FIELD)
45   public abstract class AbstractStatisticsViewControllerConfiguration extends
46           AbstractBaseConfiguration {
47   
48       /**
49        * The serialVersionUID.
50        */
51       private static final long serialVersionUID = 809978823218389930L;
52   
53       /**
54        * The default statistical view period.
55        */
56       @XmlElement(name = "default-statistical-view-period")
57       private Period defaultStatisticalViewPeriod;
58   
59       /**
60        * The default statistical data resolution period.
61        */
62       @XmlElement(name = "default-statistical-data-resolution-period")
63       private Period defaultStatisticalDataResolutionPeriod;
64   
65       /**
66        * The default statistical data resolution period.
67        */
68       @XmlElementWrapper(name = "available-statistical-data-resolution-periods")
69       @XmlElement(name = "statistical-data-resolution-period")
70       private Set<Period> availableStatisticalDataResolutionPeriods;
71   
72       /**
73        * The {@code XSLHandleConfiguration} to fetch the (main)
74        * {@code XSLHandle} for the creation of the PDF report.
75        */
76       @XmlElement(name = "report-pdf-XSL")
77       private XSLHandleConfiguration reportPDFXSLHandle;
78   
79       /**
80        * The prefix to be used for naming the created report PDF.
81        * <p>
82        * <strong>default:</strong> "StatisticsReport"
83        * </p>
84        */
85       @XmlElement(name = "report-pdf-prefix")
86       private String reportPDFPrefix = "StatisticsReport";
87   
88       /**
89        * Returns the default {@code Period}.
90        * 
91        * @return the default {@code Period}
92        */
93       public final Period getDefaultStatisticalViewPeriod() {
94           return this.defaultStatisticalViewPeriod;
95       }
96   
97       /**
98        * Sets the default {@code Period}.
99        * 
100       * @param period
101       *            the <tt>Period</tt>
102       */
103      protected final void setDefaultStatisticalViewPeriod(final Period period) {
104          this.defaultStatisticalViewPeriod = period;
105      }
106  
107      /**
108       * Returns the default data resolution {@code Period}.
109       * 
110       * @return the default data resolution {@code Period}
111       */
112      public final Period getDefaultStatisticalDataResolutionPeriod() {
113          return this.defaultStatisticalDataResolutionPeriod;
114      }
115  
116      /**
117       * Sets the default data resolution {@code Period}.
118       * 
119       * @param period
120       *            the <tt>Period</tt>
121       */
122      protected final void setDefaultStatisticalDataResolutionPeriod(
123              final Period period) {
124          this.defaultStatisticalDataResolutionPeriod = period;
125      }
126  
127      /**
128       * Returns the available data resolution {@code Period} s.
129       * 
130       * @return the available data resolution {@code Period}s
131       */
132      public final Set<Period> getAvailableStatisticalDataResolutionPeriods() {
133          return this.availableStatisticalDataResolutionPeriods;
134      }
135  
136      /**
137       * Sets the available data resolution {@code Period}.
138       * 
139       * @param periods
140       *            the <tt>Period</tt>s
141       */
142      protected final void setAvailableStatisticalDataResolutionPeriods(
143              final Set<Period> periods) {
144          this.availableStatisticalDataResolutionPeriods = periods;
145      }
146  
147      /**
148       * Returns the (main) {@code XSLHandle} to fetch the (main)
149       * {@code XSLHandle} for the creation of the PDF report.
150       * 
151       * @return an {@code XSLHandle}
152       */
153      public final XSLHandle getReportPDFXSLHandle() {
154          return this.reportPDFXSLHandle.getXSLHandle();
155      }
156  
157      /**
158       * FOR TESTING ONLY.
159       * 
160       * @param handle
161       *            the <tt>reportPDFXSLHandle</tt> to set
162       */
163      protected final void setReportPDFXSLHandle(
164              final XSLHandleConfiguration handle) {
165          this.reportPDFXSLHandle = handle;
166      }
167  
168      /**
169       * Returns the prefix to be used for naming the created report PDF.
170       * 
171       * @return the reportPDFPrefix
172       */
173      public final String getReportPDFPrefix() {
174          return this.reportPDFPrefix;
175      }
176  
177      /**
178       * FOR TESTING ONLY.
179       * 
180       * @param prefix
181       *            the report PDF prefix to set
182       */
183      protected final void setReportPDFPrefix(final String prefix) {
184          this.reportPDFPrefix = prefix;
185      }
186  
187  }
188