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