Coverage Report - org.apache.maven.report.projectinfo.IssueTrackingReport
 
Classes in this File Line Coverage Branch Coverage Complexity
IssueTrackingReport
100%
7/7
N/A
2.429
IssueTrackingReport$IssueTrackingRenderer
56%
22/39
25%
4/16
2.429
 
 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.codehaus.plexus.i18n.I18N;
 26  
 import org.codehaus.plexus.util.StringUtils;
 27  
 
 28  
 import java.util.Locale;
 29  
 
 30  
 /**
 31  
  * Generates the Project Issue Tracking report.
 32  
  *
 33  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
 34  
  * @version $Id: IssueTrackingReport.java 940663 2010-05-03 22:58:15Z hboutemy $
 35  
  * @since 2.0
 36  
  * @goal issue-tracking
 37  
  */
 38  1
 public class IssueTrackingReport
 39  
     extends AbstractProjectInfoReport
 40  
 {
 41  
     // ----------------------------------------------------------------------
 42  
     // Public methods
 43  
     // ----------------------------------------------------------------------
 44  
 
 45  
     /** {@inheritDoc} */
 46  
     public void executeReport( Locale locale )
 47  
     {
 48  1
         IssueTrackingRenderer r = new IssueTrackingRenderer( getSink(), getProject().getModel(), i18n, locale );
 49  
 
 50  1
         r.render();
 51  1
     }
 52  
 
 53  
     /** {@inheritDoc} */
 54  
     public String getOutputName()
 55  
     {
 56  2
         return "issue-tracking";
 57  
     }
 58  
 
 59  
     protected String getI18Nsection()
 60  
     {
 61  1
         return "issuetracking";
 62  
     }
 63  
 
 64  
     // ----------------------------------------------------------------------
 65  
     // Private
 66  
     // ----------------------------------------------------------------------
 67  
 
 68  
     /**
 69  
      * Internal renderer class
 70  
      */
 71  1
     private static class IssueTrackingRenderer
 72  
         extends AbstractProjectInfoRenderer
 73  
     {
 74  
         private Model model;
 75  
 
 76  
         IssueTrackingRenderer( Sink sink, Model model, I18N i18n, Locale locale )
 77  
         {
 78  1
             super( sink, i18n, locale );
 79  
 
 80  1
             this.model = model;
 81  1
         }
 82  
 
 83  
         protected String getI18Nsection()
 84  
         {
 85  5
             return "issuetracking";
 86  
         }
 87  
 
 88  
         /** {@inheritDoc} */
 89  
         public void renderBody()
 90  
         {
 91  1
             IssueManagement issueManagement = model.getIssueManagement();
 92  1
             if ( issueManagement == null )
 93  
             {
 94  0
                 startSection( getTitle() );
 95  
 
 96  0
                 paragraph( getI18nString( "noissueManagement" ) );
 97  
 
 98  0
                 endSection();
 99  
 
 100  0
                 return;
 101  
             }
 102  
 
 103  1
             String system = issueManagement.getSystem();
 104  1
             String url = issueManagement.getUrl();
 105  
 
 106  
             // Overview
 107  1
             startSection( getI18nString( "overview.title" ) );
 108  
 
 109  1
             if ( isIssueManagementSystem( system, "jira" ) )
 110  
             {
 111  1
                 sink.paragraph();
 112  1
                 linkPatternedText( getI18nString( "jira.intro" ) );
 113  1
                 sink.paragraph_();
 114  
             }
 115  0
             else if ( isIssueManagementSystem( system, "bugzilla" ) )
 116  
             {
 117  0
                 sink.paragraph();
 118  0
                 linkPatternedText( getI18nString( "bugzilla.intro" ) );
 119  0
                 sink.paragraph_();
 120  
             }
 121  0
             else if ( isIssueManagementSystem( system, "scarab" ) )
 122  
             {
 123  0
                 sink.paragraph();
 124  0
                 linkPatternedText( getI18nString( "scarab.intro" ) );
 125  0
                 sink.paragraph_();
 126  
             }
 127  0
             else if ( system == null || "".equals( system.trim() ) )
 128  
             {
 129  0
                 paragraph( getI18nString( "general.intro" ) );
 130  
             }
 131  
             else
 132  
             {
 133  0
                 paragraph( getI18nString( "custom.intro" ).replaceFirst( "%issueManagementSystem%", system ) );
 134  
             }
 135  
 
 136  1
             endSection();
 137  
 
 138  
             // Connection
 139  1
             startSection( getTitle() );
 140  
 
 141  1
             paragraph( getI18nString( "intro" ) );
 142  
 
 143  1
             verbatimLink( url, url );
 144  
 
 145  1
             endSection();
 146  1
         }
 147  
 
 148  
         /**
 149  
          * Checks if a issue management system is Jira, bugzilla...
 150  
          *
 151  
          * @param system
 152  
          * @param im
 153  
          * @return true if the issue management system is Jira, bugzilla, false otherwise.
 154  
          */
 155  
         private boolean isIssueManagementSystem( String system, String im )
 156  
         {
 157  1
             if ( StringUtils.isEmpty( system ) )
 158  
             {
 159  0
                 return false;
 160  
             }
 161  
 
 162  1
             if ( StringUtils.isEmpty( im ) )
 163  
             {
 164  0
                 return false;
 165  
             }
 166  
 
 167  1
             return system.toLowerCase( Locale.ENGLISH ).startsWith( im.toLowerCase( Locale.ENGLISH ) );
 168  
         }
 169  
     }
 170  
 }