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;
19   
20   import java.util.Collections;
21   import java.util.Set;
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.XmlElementWrapper;
29   import javax.xml.bind.annotation.XmlRootElement;
30   
31   import org.torweg.pulse.configuration.Configuration;
32   import org.torweg.pulse.configuration.EmailConfiguration;
33   import org.torweg.pulse.util.time.TimeSpan;
34   
35   /**
36    * The {@code Configuration} of the {@code DataAggregationJoblet}.
37    * 
38    * @author Daniel Dietz
39    * @version $Revision: 1538 $
40    * 
41    */
42   @XmlRootElement(name = "data-aggregation-joblet-configuration")
43   @XmlAccessorOrder(XmlAccessOrder.UNDEFINED)
44   @XmlAccessorType(XmlAccessType.FIELD)
45   public class DataAggregationJobletConfiguration extends Configuration {
46   
47       /**
48        * The serialVersionUID.
49        */
50       private static final long serialVersionUID = 8424477915024621264L;
51   
52       /**
53        * A time span specifying the maximum idle time of a session. If this time
54        * span is exceeded a new visit will be generated for the session. This
55        * value does not necessarily have to correlate with the actual value from
56        * the servlet-container.
57        */
58       @XmlElement(name = "max-session-idle-time")
59       private TimeSpan maxSessionIdleTime;
60   
61       /**
62        * A time span specifying an assumed time for the last page impression of a
63        * {@code Visit}.
64        */
65       @XmlElement(name = "assumed-time-for-last-page-impression")
66       private TimeSpan assumedTimeForLastPageImpression;
67   
68       /**
69        * The {@code AbstractBaseAggregator}s (fqn's) to be processed by the
70        * {@code DataAggregationJoblet} as configured.
71        */
72       @XmlElementWrapper(name = "aggregators")
73       @XmlElement(name = "aggregator")
74       private Set<String> aggregatorClassNames;
75   
76       /**
77        * The {@code IPreRunAndOrPostRunTask}s (fqn's) to be processed by the
78        * {@code DataAggregationJoblet} just after the
79        * {@code DataAggregationJoblet} has been configured and right
80        * <strong>before</strong> the {@code DataAggregationJoblet} is being
81        * executed.
82        */
83       @XmlElementWrapper(name = "pre-tasks")
84       @XmlElement(name = "task")
85       private Set<String> preTaskClassNames;
86   
87       /**
88        * The {@code IPreRunAndOrPostRunTask}s (fqn's) to be processed by the
89        * {@code DataAggregationJoblet} right <strong>after</strong> the
90        * {@code DataAggregationJoblet} has been executed.
91        */
92       @XmlElementWrapper(name = "post-tasks")
93       @XmlElement(name = "task")
94       private Set<String> postTaskClassNames;
95   
96       /**
97        * The {@code IPreAggregationAndOrPostAggregationTask}s (fqn's) to be
98        * processed by the {@code DataAggregationJoblet} right
99        * <strong>before</strong> the
100       * {@code DataAggregationJoblet.AggregationExecutor} is being executed.
101       */
102      @XmlElementWrapper(name = "pre-aggregation-tasks")
103      @XmlElement(name = "aggregation-task")
104      private Set<String> preAggregationTaskClassNames;
105  
106      /**
107       * The {@code IPreAggregationAndOrPostAggregationTask}s (fqn's) to be
108       * processed by the {@code DataAggregationJoblet} right
109       * <strong>after</strong> the
110       * {@code DataAggregationJoblet.AggregationExecutor} has been executed.
111       */
112      @XmlElementWrapper(name = "post-aggregation-tasks")
113      @XmlElement(name = "aggregation-task")
114      private Set<String> postAggregationTaskClassNames;
115  
116      /**
117       * The {@code PIRecord} processing limit.
118       * <p>
119       * This is the maximum number of {@code PIRecord}s being processed in a
120       * single {@code DataAggregationJoblet} run.
121       * </p>
122       */
123      @XmlElement(name = "pi-record-processing-limit")
124      private Integer piRecordProcessingLimit;
125  
126      /**
127       * An {@code EmailConfiguration} to be use for mailing notifications
128       * about {@code Exception}s which might occur during the execution of
129       * the {@code DataAggregationJoblet}.
130       */
131      @XmlElement(name = "exception-email-configuration")
132      private EmailConfiguration exceptionEmailConfiguration;
133  
134      /**
135       * Returns the {@code TimeSpan} representing the maximum idle time of a
136       * session - for the statistics.
137       * 
138       * @return the <tt>maxSessionIdleTime</tt>
139       */
140      public final TimeSpan getMaxSessionIdleTime() {
141          return new TimeSpan(this.maxSessionIdleTime);
142      }
143  
144      /**
145       * Returns the {@code TimeSpan} representing the assumed time for the
146       * last page impression of a {@code Visit}.
147       * 
148       * @return the <tt>assumedTimeForLastPageImpression</tt>
149       */
150      public final TimeSpan getAssumedTimeForLastPageImpression() {
151          return new TimeSpan(this.assumedTimeForLastPageImpression);
152      }
153  
154      /**
155       * Returns the list with fqn of the {@code AbstractBaseAggregator}s to
156       * be processed.
157       * 
158       * @return an unmodifiable view of the <tt>aggregatorClassNames</tt>
159       */
160      public final Set<String> getAggregatorClassNames() {
161          return Collections.unmodifiableSet(this.aggregatorClassNames);
162      }
163  
164      /**
165       * Returns the list with fqn of the {@code IPreRunAndOrPostRunTask} s
166       * to be processed.
167       * 
168       * @return an unmodifiable view of the <tt>preTaskClassNames</tt>
169       */
170      public final Set<String> getPreTaskClassNames() {
171          return Collections.unmodifiableSet(this.preTaskClassNames);
172      }
173  
174      /**
175       * Returns the list with fqn of the {@code IPreRunAndOrPostRunTask} s
176       * to be processed.
177       * 
178       * @return an unmodifiable view of the <tt>postTaskClassNames</tt>
179       */
180      public final Set<String> getPostTaskClassNames() {
181          return Collections.unmodifiableSet(this.postTaskClassNames);
182      }
183  
184      /**
185       * Returns the list with fqn of the
186       * {@code IPreAggregationAndOrPostAggregationTask} s to be processed.
187       * 
188       * @return an unmodifiable view of the <tt>preAggregationTaskClassNames</tt>
189       */
190      public final Set<String> getPreAggregationTaskClassNames() {
191          return Collections.unmodifiableSet(this.preAggregationTaskClassNames);
192      }
193  
194      /**
195       * Returns the list with fqn of the
196       * {@code IPreAggregationAndOrPostAggregationTask} s to be processed.
197       * 
198       * @return an unmodifiable view of the
199       *         <tt>postAggregationTaskClassNames</tt>
200       */
201      public final Set<String> getPostAggregationTaskClassNames() {
202          return Collections.unmodifiableSet(this.postAggregationTaskClassNames);
203      }
204  
205      /**
206       * Returns the processing limit for the {@code PIRecord}s.
207       * <p>
208       * If not configured: 150000 (150-thousand)
209       * </p>
210       * 
211       * @return the processing limit for the {@code PIRecord}s
212       */
213      public final int getPIRecordProcessingLimit() {
214          if (this.piRecordProcessingLimit == null) {
215              return 150000;
216          }
217          return this.piRecordProcessingLimit;
218      }
219  
220      /**
221       * Returns the {@code EmailConfiguration} for email notifications about
222       * exceptions during the execution of the {@code DataAggregationJoblet}
223       * .
224       * 
225       * @return the exception-{@code EmailConfiguration} or
226       *         {@code null} if not configured
227       */
228      public final EmailConfiguration getExceptionEmailConfiguration() {
229          return this.exceptionEmailConfiguration;
230      }
231  
232  }
233