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.logging.Log;
19  import org.apache.commons.logging.LogFactory;
20  import org.apache.maven.artifact.versioning.ArtifactVersion;
21  
22  import de.smartics.maven.issues.VersionType;
23  
24  /**
25   * Aribiter to determine if a version should be skipped from or included in a
26   * report.
27   *
28   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
29   * @version $Revision:591 $
30   */
31  public class ReleasePlanVersionSkipper extends AbstractVersionSkipper
32  {
33    // ********************************* Fields *********************************
34  
35    // --- constants ------------------------------------------------------------
36  
37    /**
38     * Reference to the logger for this class.
39     */
40    private static final Log LOG = LogFactory
41        .getLog(ReleasePlanVersionSkipper.class);
42  
43    // --- members --------------------------------------------------------------
44  
45    // ****************************** Initializer *******************************
46  
47    // ****************************** Constructors ******************************
48  
49    /**
50     * Default constructor.
51     *
52     * @param versionType the version type to be accepted.
53     */
54    public ReleasePlanVersionSkipper(final VersionType versionType)
55    {
56      super(versionType);
57    }
58  
59    // ****************************** Inner Classes *****************************
60  
61    // ********************************* Methods ********************************
62  
63    // --- init -----------------------------------------------------------------
64  
65    // --- get&set --------------------------------------------------------------
66  
67    // --- business -------------------------------------------------------------
68  
69    /**
70     * Checks if the <code>version</code> should be skipped so that issues
71     * associated with this version are not rendered in the report.
72     *
73     * @impl Subclasses should implement their specific logic.
74     * @param releaseVersion the version of the release.
75     * @param version the version to check for skipping its issues.
76     * @return <code>true</code> if the issues should be skipped and not rendered
77     *         in the report, <code>false</code> otherwise.
78     */
79    @SuppressWarnings("unchecked")
80    public boolean skipVersion(final ArtifactVersion releaseVersion,
81        final ArtifactVersion version)
82    {
83      final boolean isPriorVersionThanRelease =
84          releaseVersion.compareTo(version) > 0;
85      final boolean isAllowedAsCurrentSnapshot =
86          isReleaseSnapshotOfVersion(releaseVersion, version);
87      final boolean skip =
88          !isAllowedAsCurrentSnapshot && isPriorVersionThanRelease;
89      if (LOG.isTraceEnabled())
90      {
91        LOG.trace("release=" + releaseVersion + ", version=" + version
92                  + ", isPriorVersionThanRelease=" + isPriorVersionThanRelease
93                  + ", isAllowedAsCurrentSnapshot=" + isAllowedAsCurrentSnapshot
94                  + ", skip=" + skip);
95      }
96      return (skip);
97    }
98  
99    // --- object basics --------------------------------------------------------
100 
101 }