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