View Javadoc

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