Coverage Report - org.apache.maven.report.projectinfo.IssueTrackingReport
 
Classes in this File Line Coverage Branch Coverage Complexity
IssueTrackingReport
88%
7/8
N/A
2,25
IssueTrackingReport$IssueTrackingRenderer
63%
22/35
25%
4/16
2,25
 
 1  
 package org.apache.maven.report.projectinfo;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import org.apache.maven.doxia.sink.Sink;
 23  
 import org.apache.maven.model.IssueManagement;
 24  
 import org.apache.maven.model.Model;
 25  
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 26  
 import org.codehaus.plexus.i18n.I18N;
 27  
 import org.codehaus.plexus.util.StringUtils;
 28  
 
 29  
 import java.util.Locale;
 30  
 
 31  
 /**
 32  
  * Generates the Project Issue Tracking report.
 33  
  *
 34  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
 35  
  * @version $Id: IssueTrackingReport.java 728546 2008-12-21 22:56:51Z bentmann $
 36  
  * @since 2.0
 37  
  * @goal issue-tracking
 38  
  */
 39  1
 public class IssueTrackingReport
 40  
     extends AbstractProjectInfoReport
 41  
 {
 42  
     // ----------------------------------------------------------------------
 43  
     // Public methods
 44  
     // ----------------------------------------------------------------------
 45  
 
 46  
     /** {@inheritDoc} */
 47  
     public String getName( Locale locale )
 48  
     {
 49  1
         return i18n.getString( "project-info-report", locale, "report.issuetracking.name" );
 50  
     }
 51  
 
 52  
     /** {@inheritDoc} */
 53  
     public String getDescription( Locale locale )
 54  
     {
 55  0
         return i18n.getString( "project-info-report", locale, "report.issuetracking.description" );
 56  
     }
 57  
 
 58  
     /** {@inheritDoc} */
 59  
     public void executeReport( Locale locale )
 60  
     {
 61  1
         IssueTrackingRenderer r = new IssueTrackingRenderer( getSink(), getProject().getModel(), i18n, locale );
 62  
 
 63  1
         r.render();
 64  1
     }
 65  
 
 66  
     /** {@inheritDoc} */
 67  
     public String getOutputName()
 68  
     {
 69  3
         return "issue-tracking";
 70  
     }
 71  
 
 72  
     // ----------------------------------------------------------------------
 73  
     // Private
 74  
     // ----------------------------------------------------------------------
 75  
 
 76  
     /**
 77  
      * Internal renderer class
 78  
      */
 79  1
     private static class IssueTrackingRenderer
 80  
         extends AbstractMavenReportRenderer
 81  
     {
 82  
         private Model model;
 83  
 
 84  
         private I18N i18n;
 85  
 
 86  
         private Locale locale;
 87  
 
 88  
         IssueTrackingRenderer( Sink sink, Model model, I18N i18n, Locale locale )
 89  
         {
 90  1
             super( sink );
 91  
 
 92  1
             this.model = model;
 93  
 
 94  1
             this.i18n = i18n;
 95  
 
 96  1
             this.locale = locale;
 97  1
         }
 98  
 
 99  
         /** {@inheritDoc} */
 100  
         public String getTitle()
 101  
         {
 102  2
             return i18n.getString( "project-info-report", locale, "report.issuetracking.title" );
 103  
         }
 104  
 
 105  
         /** {@inheritDoc} */
 106  
         public void renderBody()
 107  
         {
 108  1
             IssueManagement issueManagement = model.getIssueManagement();
 109  1
             if ( issueManagement == null )
 110  
             {
 111  0
                 startSection( getTitle() );
 112  
 
 113  0
                 paragraph( i18n.getString( "project-info-report", locale, "report.issuetracking.noissueManagement" ) );
 114  
 
 115  0
                 endSection();
 116  
 
 117  0
                 return;
 118  
             }
 119  
 
 120  1
             String system = issueManagement.getSystem();
 121  1
             String url = issueManagement.getUrl();
 122  
 
 123  
             // Overview
 124  1
             startSection( i18n.getString( "project-info-report", locale, "report.issuetracking.overview.title" ) );
 125  
 
 126  1
             if ( isIssueManagementSystem( system, "jira" ) )
 127  
             {
 128  1
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.issuetracking.jira.intro" ) );
 129  
             }
 130  0
             else if ( isIssueManagementSystem( system, "bugzilla" ) )
 131  
             {
 132  0
                 linkPatternedText(
 133  
                     i18n.getString( "project-info-report", locale, "report.issuetracking.bugzilla.intro" ) );
 134  
             }
 135  0
             else if ( isIssueManagementSystem( system, "scarab" ) )
 136  
             {
 137  0
                 linkPatternedText(
 138  
                     i18n.getString( "project-info-report", locale, "report.issuetracking.scarab.intro" ) );
 139  
             }
 140  0
             else if ( system == null || "".equals( system.trim() ) )
 141  
             {
 142  0
                 paragraph( i18n.getString( "project-info-report", locale, "report.issuetracking.general.intro" ) );
 143  
             }
 144  
             else
 145  
             {
 146  0
                 paragraph(
 147  
                     i18n.getString( "project-info-report", locale, "report.issuetracking.custom.intro" ).replaceFirst(
 148  
                         "%issueManagementSystem%", system ) );
 149  
             }
 150  
 
 151  1
             endSection();
 152  
 
 153  
             // Connection
 154  1
             startSection( getTitle() );
 155  
 
 156  1
             paragraph( i18n.getString( "project-info-report", locale, "report.issuetracking.intro" ) );
 157  
 
 158  1
             verbatimLink( url, url );
 159  
 
 160  1
             endSection();
 161  1
         }
 162  
 
 163  
         /**
 164  
          * Checks if a issue management system is Jira, bugzilla...
 165  
          *
 166  
          * @param system
 167  
          * @param im
 168  
          * @return true if the issue management system is Jira, bugzilla, false otherwise.
 169  
          */
 170  
         private boolean isIssueManagementSystem( String system, String im )
 171  
         {
 172  1
             if ( StringUtils.isEmpty( system ) )
 173  
             {
 174  0
                 return false;
 175  
             }
 176  
 
 177  1
             if ( StringUtils.isEmpty( im ) )
 178  
             {
 179  0
                 return false;
 180  
             }
 181  
 
 182  1
             return system.toLowerCase( Locale.ENGLISH ).startsWith( im.toLowerCase( Locale.ENGLISH ) );
 183  
         }
 184  
     }
 185  
 }