Coverage Report - org.apache.maven.report.projectinfo.CimReport
 
Classes in this File Line Coverage Branch Coverage Complexity
CimReport
88%
7/8
N/A
2,875
CimReport$CimRenderer
21%
12/58
4%
1/26
2,875
 
 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.CiManagement;
 24  
 import org.apache.maven.model.Model;
 25  
 import org.apache.maven.model.Notifier;
 26  
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 27  
 import org.codehaus.plexus.i18n.I18N;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 
 30  
 import java.util.Iterator;
 31  
 import java.util.List;
 32  
 import java.util.Locale;
 33  
 
 34  
 /**
 35  
  * Generates the Project Continuous Integration System report.
 36  
  *
 37  
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
 38  
  * @version $Id: CimReport.java 728546 2008-12-21 22:56:51Z bentmann $
 39  
  * @since 2.0
 40  
  * @goal cim
 41  
  */
 42  1
 public class CimReport
 43  
     extends AbstractProjectInfoReport
 44  
 {
 45  
     // ----------------------------------------------------------------------
 46  
     // Public methods
 47  
     // ----------------------------------------------------------------------
 48  
 
 49  
     /** {@inheritDoc} */
 50  
     public String getName( Locale locale )
 51  
     {
 52  1
         return i18n.getString( "project-info-report", locale, "report.cim.name" );
 53  
     }
 54  
 
 55  
     /** {@inheritDoc} */
 56  
     public String getDescription( Locale locale )
 57  
     {
 58  0
         return i18n.getString( "project-info-report", locale, "report.cim.description" );
 59  
     }
 60  
 
 61  
     /** {@inheritDoc} */
 62  
     public void executeReport( Locale locale )
 63  
     {
 64  1
         CimRenderer r = new CimRenderer( getSink(), getProject().getModel(), i18n, locale );
 65  
 
 66  1
         r.render();
 67  1
     }
 68  
 
 69  
     /** {@inheritDoc} */
 70  
     public String getOutputName()
 71  
     {
 72  3
         return "integration";
 73  
     }
 74  
 
 75  
     // ----------------------------------------------------------------------
 76  
     // Private
 77  
     // ----------------------------------------------------------------------
 78  
 
 79  
     /**
 80  
      * Internal renderer class
 81  
      */
 82  1
     private static class CimRenderer
 83  
         extends AbstractMavenReportRenderer
 84  
     {
 85  
         private Model model;
 86  
 
 87  
         private I18N i18n;
 88  
 
 89  
         private Locale locale;
 90  
 
 91  
         CimRenderer( Sink sink, Model model, I18N i18n, Locale locale )
 92  
         {
 93  1
             super( sink );
 94  
 
 95  1
             this.model = model;
 96  
 
 97  1
             this.i18n = i18n;
 98  
 
 99  1
             this.locale = locale;
 100  1
         }
 101  
 
 102  
         /** {@inheritDoc} */
 103  
         public String getTitle()
 104  
         {
 105  2
             return i18n.getString( "project-info-report", locale, "report.cim.title" );
 106  
         }
 107  
 
 108  
         /** {@inheritDoc} */
 109  
         public void renderBody()
 110  
         {
 111  1
             CiManagement cim = model.getCiManagement();
 112  1
             if ( cim == null )
 113  
             {
 114  1
                 startSection( getTitle() );
 115  
 
 116  1
                 paragraph( i18n.getString( "project-info-report", locale, "report.cim.nocim" ) );
 117  
 
 118  1
                 endSection();
 119  
 
 120  1
                 return;
 121  
             }
 122  
 
 123  0
             String system = cim.getSystem();
 124  0
             String url = cim.getUrl();
 125  0
             List notifiers = cim.getNotifiers();
 126  
 
 127  
             // Overview
 128  0
             startSection( i18n.getString( "project-info-report", locale, "report.cim.overview.title" ) );
 129  
 
 130  0
             if ( isCimSystem( system, "anthill" ) )
 131  
             {
 132  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.anthill.intro" ) );
 133  
             }
 134  0
             else if ( isCimSystem( system, "buildforge" ) )
 135  
             {
 136  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.buildforge.intro" ) );
 137  
             }
 138  0
             else if ( isCimSystem( system, "continuum" ) )
 139  
             {
 140  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.continuum.intro" ) );
 141  
             }
 142  0
             else if ( isCimSystem( system, "cruisecontrol" ) )
 143  
             {
 144  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.cruisecontrol.intro" ) );
 145  
             }
 146  0
             else if ( isCimSystem( system, "hudson" ) )
 147  
             {
 148  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.hudson.intro" ) );
 149  
             }
 150  0
             else if ( isCimSystem( system, "luntbuild" ) )
 151  
             {
 152  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.luntbuild.intro" ) );
 153  
             }
 154  
             else
 155  
             {
 156  0
                 linkPatternedText( i18n.getString( "project-info-report", locale, "report.cim.general.intro" ) );
 157  
             }
 158  
 
 159  0
             endSection();
 160  
 
 161  
             // Access
 162  0
             startSection( i18n.getString( "project-info-report", locale, "report.cim.access" ) );
 163  
 
 164  0
             if ( !StringUtils.isEmpty( url ) )
 165  
             {
 166  0
                 paragraph( i18n.getString( "project-info-report", locale, "report.cim.url" ) );
 167  
 
 168  0
                 verbatimLink( url, url );
 169  
             }
 170  
             else
 171  
             {
 172  0
                 paragraph( i18n.getString( "project-info-report", locale, "report.cim.nourl" ) );
 173  
             }
 174  
 
 175  0
             endSection();
 176  
 
 177  
             // Notifiers
 178  0
             startSection( i18n.getString( "project-info-report", locale, "report.cim.notifiers.title" ) );
 179  
 
 180  0
             if ( notifiers == null || notifiers.isEmpty() )
 181  
             {
 182  0
                 paragraph( i18n.getString( "project-info-report", locale, "report.cim.notifiers.nolist" ) );
 183  
             }
 184  
             else
 185  
             {
 186  0
                 sink.paragraph();
 187  0
                 sink.text( i18n.getString( "project-info-report", locale, "report.cim.notifiers.intro" ) );
 188  0
                 sink.paragraph_();
 189  
 
 190  0
                 startTable();
 191  
 
 192  0
                 String type = i18n.getString( "project-info-report", locale, "report.cim.notifiers.column.type" );
 193  0
                 String address = i18n.getString( "project-info-report", locale, "report.cim.notifiers.column.address" );
 194  0
                 String configuration =
 195  
                     i18n.getString( "project-info-report", locale, "report.cim.notifiers.column.configuration" );
 196  
 
 197  0
                 tableHeader( new String[]{type, address, configuration} );
 198  
 
 199  0
                 for ( Iterator i = notifiers.iterator(); i.hasNext(); )
 200  
                 {
 201  0
                     Notifier notifier = (Notifier) i.next();
 202  
 
 203  0
                     tableRow( new String[]{notifier.getType(),
 204  
                         createLinkPatternedText( notifier.getAddress(), notifier.getAddress() ),
 205  
                         propertiesToString( notifier.getConfiguration() )} );
 206  
                 }
 207  
 
 208  0
                 endTable();
 209  
             }
 210  
 
 211  0
             endSection();
 212  0
         }
 213  
 
 214  
         /**
 215  
          * Checks if a CIM system is bugzilla, continium...
 216  
          *
 217  
          * @param connection
 218  
          * @param cim
 219  
          * @return true if the CIM system is bugzilla, continium..., false otherwise.
 220  
          */
 221  
         private boolean isCimSystem( String connection, String cim )
 222  
         {
 223  0
             if ( StringUtils.isEmpty( connection ) )
 224  
             {
 225  0
                 return false;
 226  
             }
 227  
 
 228  0
             if ( StringUtils.isEmpty( cim ) )
 229  
             {
 230  0
                 return false;
 231  
             }
 232  
 
 233  0
             return connection.toLowerCase( Locale.ENGLISH ).startsWith( cim.toLowerCase( Locale.ENGLISH ) );
 234  
         }
 235  
     }
 236  
 }