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