View Javadoc

1   /*
2    * Copyright 2008-2010 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package de.smartics.maven.issues.bugzilla;
18  
19  import org.apache.commons.lang.StringUtils;
20  
21  import de.smartics.maven.issues.AbstractIssuesReportMojo;
22  import de.smartics.maven.issues.ArtifactVersionRange;
23  import de.smartics.maven.issues.VersionType;
24  
25  /**
26   * The base implementation of all bugzilla reports.
27   *
28   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
29   * @version $Revision:591 $
30   */
31  public abstract class AbstractBugzillaReportMojo extends
32      AbstractIssuesReportMojo
33  {
34    // ********************************* Fields *********************************
35  
36    // --- constants ------------------------------------------------------------
37  
38    /**
39     * Defines the selector to mean "all values without restriction". This is
40     * often the same as specifying no value but allows inherited configurations
41     * to be overridden.
42     * <p>
43     * The value of this constant is {@value}.
44     * </p>
45     */
46    public static final String ALL_VALUES_SELECTOR = "_ALL_";
47  
48    // --- members --------------------------------------------------------------
49  
50    /**
51     * Defines the filter parameters to restrict which issues are retrieved from
52     * Bugzilla. The filter parameter must use the same format of url parameters
53     * that is used in a Bugzilla search.
54     *
55     * @parameter default-value=""
56     * @since 1.0
57     */
58    private String filter;
59  
60    /**
61     * Sets the status(es) that you want to limit your report to include. Valid
62     * statuses are: UNCONFIRMED, NEW, ASSIGNED, REOPENED, RESOLVED, VERIFIED, and
63     * CLOSED. Multiple values can be separated by commas.
64     *
65     * @parameter default-value="CLOSED"
66     * @since 1.0
67     */
68    private String status;
69  
70    /**
71     * Sets the resolution(s) that you want to limit your report to include. Valid
72     * statuses are: FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE,
73     * WORKSFORME, and MOVED. Multiple values can be separated by commas.
74     *
75     * @parameter default-value=""
76     * @since 1.0
77     */
78    private String resolution;
79  
80    /**
81     * Sets the keywords that you want to limit your report to include.
82     *
83     * @parameter default-value=""
84     * @since 1.0
85     */
86    private String keywords;
87  
88    /**
89     * Sets the handling of the keywords. May have any value but Bugzilla supports
90     * currently <code>allwords</code>, <code>nowords</code>,
91     * <code>anywords</code>.
92     *
93     * @parameter default-value="anywords"
94     * @since 1.0
95     */
96    private String keywordsType;
97  
98    /**
99     * Sets the component(s) that you want to limit your report to include.
100    * Multiple components can be separated by commas. If this is set to empty or
101    * <code>_ALL_</code> all components are queried.
102    *
103    * @parameter default-value=""
104    * @since 1.0
105    */
106   private String component;
107 
108   /**
109    * Sets the product(s) that you want to limit your report to include. Multiple
110    * products can be separated by commas. If this is set to empty - that means
111    * all products.
112    *
113    * @parameter default-value=""
114    * @since 1.0
115    */
116   private String product;
117 
118   /**
119    * Sets the order of the bugs returned.
120    *
121    * @parameter default-value="Bug Number"
122    * @since 1.0
123    */
124   private String order;
125 
126   /**
127    * The name of the query to execute. If the query name is specified none of
128    * the other query properties is taken into account.
129    *
130    * @parameter
131    * @since 1.0
132    */
133   private String queryName;
134 
135   /**
136    * The type of the command executed. This property is currently only relevant
137    * is <code>queryName</code> is set.
138    *
139    * @parameter default-value="runnamed"
140    * @since 1.0
141    */
142   private String commandType;
143 
144   /**
145    * On the same page all of the given version type are rendered. For instance
146    * if this value refers to the major version, all versions having the same
147    * major version are rendered. A value of micro implies that only the current
148    * version is to be rendered.
149    * <p>
150    * Valid values are major, minor, micro (only the exact version), all (allow
151    * all versions).
152    * </p>
153    *
154    * @parameter default-value="major"
155    * @required
156    * @since 1.0
157    */
158   protected String includeOnSamePageAllOfVersion;
159 
160   // ****************************** Initializer *******************************
161 
162   // ****************************** Constructors ******************************
163 
164   // ****************************** Inner Classes *****************************
165 
166   // ********************************* Methods ********************************
167 
168   // --- init -----------------------------------------------------------------
169 
170   // --- get&set --------------------------------------------------------------
171 
172   /**
173    * Returns the value for status.
174    * <p>
175    * Sets the status(es) that you want to limit your report to include. Valid
176    * statuses are: UNCONFIRMED, NEW, ASSIGNED, REOPENED, RESOLVED, VERIFIED, and
177    * CLOSED. Multiple values can be separated by commas.
178    *
179    * @return the value for status.
180    */
181   public String getStatus()
182   {
183     return status;
184   }
185 
186   /**
187    * Returns the value for filter.
188    * <p>
189    * Defines the filter parameters to restrict which issues are retrieved from
190    * Bugzilla. The filter parameter must use the same format of url parameters
191    * that is used in a Bugzilla search.
192    *
193    * @return the value for filter.
194    */
195   public String getFilter()
196   {
197     return filter;
198   }
199 
200   /**
201    * Returns the value for resolution.
202    * <p>
203    * Sets the resolution(s) that you want to limit your report to include. Valid
204    * statuses are: FIXED, INVALID, WONTFIX, LATER, REMIND, DUPLICATE,
205    * WORKSFORME, and MOVED. Multiple values can be separated by commas.
206    *
207    * @return the value for resolution.
208    */
209   public String getResolution()
210   {
211     return resolution;
212   }
213 
214   /**
215    * Returns the value for keywords.
216    * <p>
217    * Sets the keywords that you want to limit your report to include.
218    *
219    * @return the value for keywords.
220    */
221   public String getKeywords()
222   {
223     return keywords;
224   }
225 
226   /**
227    * Returns the value for keywordsType.
228    * <p>
229    * Sets the handling of the keywords. May have any value but Bugzilla supports
230    * currently <code>allwords</code>, <code>nowords</code>,
231    * <code>anywords</code>.
232    *
233    * @return the value for keywordsType.
234    */
235   public String getKeywordsType()
236   {
237     return keywordsType;
238   }
239 
240   /**
241    * Returns the value for component.
242    * <p>
243    * Sets the component(s) that you want to limit your report to include.
244    * Multiple components can be separated by commas. If this is set to empty -
245    * that means all components.
246    *
247    * @return the value for component.
248    */
249   public String getComponent()
250   {
251     if (ALL_VALUES_SELECTOR.equals(component))
252     {
253       return StringUtils.EMPTY;
254     }
255     return component;
256   }
257 
258   /**
259    * Returns the value for product.
260    * <p>
261    * Sets the product(s) that you want to limit your report to include. Multiple
262    * products can be separated by commas. If this is set to empty - that means
263    * all products.
264    *
265    * @return the value for product.
266    */
267   public String getProduct()
268   {
269     return product;
270   }
271 
272   /**
273    * Returns the value for order.
274    * <p>
275    * Sets the order of the bugs returned.
276    *
277    * @return the value for order.
278    */
279   public String getOrder()
280   {
281     return order;
282   }
283 
284   /**
285    * Returns the name of the query to execute. If the query name is specified
286    * none of the other query properties is taken into account.
287    *
288    * @return the name of the query to execute.
289    */
290   public String getQueryName()
291   {
292     return queryName;
293   }
294 
295   /**
296    * Returns the type of the command executed. This property is currently only
297    * relevant is <code>queryName</code> is set.
298    *
299    * @return the type of the command executed.
300    */
301   public String getCommandType()
302   {
303     return commandType;
304   }
305 
306   /**
307    * {@inheritDoc}
308    *
309    * @see de.smartics.maven.issues.AbstractIssuesReportMojo#getIncludeOnSamePageAllOfVersion()
310    */
311   @Override
312   public VersionType getIncludeOnSamePageAllOfVersion()
313   {
314     return VersionType.fromName(includeOnSamePageAllOfVersion);
315   }
316 
317   // --- business -------------------------------------------------------------
318 
319   /**
320    * {@inheritDoc}
321    */
322   protected BugzillaQueryData createQueryData(final ArtifactVersionRange versionRange)
323   {
324     final BugzillaQueryData queryData = new BugzillaQueryData();
325     queryData.setComponent(getComponent());
326     queryData.setFilter(getFilter());
327     queryData.setProduct(getProduct());
328     queryData.setResolution(getResolution());
329     queryData.setStatus(getStatus());
330     queryData.setKeywords(getKeywords());
331     queryData.setKeywordsType(getKeywordsType());
332     queryData.setOrder(getOrder());
333     queryData.setQueryName(getQueryName());
334     queryData.setCommandType(getCommandType());
335     queryData.setVersionRange(versionRange);
336     return queryData;
337   }
338 
339   // --- object basics --------------------------------------------------------
340 
341 }