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