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