Coverage Report - org.apache.maven.report.projectinfo.ProjectSummaryReport
 
Classes in this File Line Coverage Branch Coverage Complexity
ProjectSummaryReport
100%
6/6
N/A
2.286
ProjectSummaryReport$ProjectSummaryRenderer
79%
48/61
45%
9/20
2.286
 
 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.Organization;
 24  
 import org.apache.maven.reporting.MavenReportException;
 25  
 import org.codehaus.plexus.util.StringUtils;
 26  
 
 27  
 import java.util.Locale;
 28  
 
 29  
 /**
 30  
  * Generates the project information reports summary.
 31  
  *
 32  
  * @author Edwin Punzalan
 33  
  * @version $Id: ProjectSummaryReport.java 940663 2010-05-03 22:58:15Z hboutemy $
 34  
  * @since 2.0
 35  
  * @goal summary
 36  
  * @plexus.component
 37  
  */
 38  1
 public class ProjectSummaryReport
 39  
     extends AbstractProjectInfoReport
 40  
 {
 41  
     // ----------------------------------------------------------------------
 42  
     // Public methods
 43  
     // ----------------------------------------------------------------------
 44  
 
 45  
     /** {@inheritDoc} */
 46  
     protected void executeReport( Locale locale )
 47  
         throws MavenReportException
 48  
     {
 49  1
         new ProjectSummaryRenderer( getSink(), locale ).render();
 50  1
     }
 51  
 
 52  
     /** {@inheritDoc} */
 53  
     public String getOutputName()
 54  
     {
 55  2
         return "project-summary";
 56  
     }
 57  
 
 58  
     protected String getI18Nsection()
 59  
     {
 60  1
         return "summary";
 61  
     }
 62  
 
 63  
     // ----------------------------------------------------------------------
 64  
     // Private
 65  
     // ----------------------------------------------------------------------
 66  
 
 67  
     /**
 68  
      * Internal renderer class
 69  
      */
 70  1
     private class ProjectSummaryRenderer
 71  
         extends AbstractProjectInfoRenderer
 72  
     {
 73  
         ProjectSummaryRenderer( Sink sink, Locale locale )
 74  1
         {
 75  1
             super( sink, i18n, locale );
 76  1
         }
 77  
 
 78  
         protected String getI18Nsection()
 79  
         {
 80  17
             return "summary";
 81  
         }
 82  
 
 83  
         /** {@inheritDoc} */
 84  
         protected void renderBody()
 85  
         {
 86  1
             startSection( getTitle() );
 87  
 
 88  
             //general information sub-section
 89  1
             String name = project.getName();
 90  1
             if ( name == null )
 91  
             {
 92  0
                 name = "";
 93  
             }
 94  1
             String description = project.getDescription();
 95  1
             if ( description == null )
 96  
             {
 97  1
                 description = "";
 98  
             }
 99  1
             String homepage = project.getUrl();
 100  1
             if ( homepage == null )
 101  
             {
 102  1
                 homepage = "";
 103  
             }
 104  
 
 105  1
             startSection( getI18nString( "general.title" ) );
 106  1
             startTable();
 107  1
             tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
 108  1
             tableRow( new String[]{getI18nString( "general.name" ), name} );
 109  1
             tableRow( new String[]{getI18nString( "general.description" ), description} );
 110  1
             tableRowWithLink( new String[]{getI18nString( "general.homepage" ), homepage} );
 111  1
             endTable();
 112  1
             endSection();
 113  
 
 114  
             //organization sub-section
 115  1
             startSection( getI18nString( "organization.title" ) );
 116  1
             Organization organization = project.getOrganization();
 117  1
             if ( organization == null )
 118  
             {
 119  1
                 paragraph( getI18nString( "noorganization" ) );
 120  
             }
 121  
             else
 122  
             {
 123  0
                 if ( organization.getName() == null )
 124  
                 {
 125  0
                     organization.setName( "" );
 126  
                 }
 127  0
                 if ( organization.getUrl() == null )
 128  
                 {
 129  0
                     organization.setUrl( "" );
 130  
                 }
 131  
 
 132  0
                 startTable();
 133  0
                 tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
 134  0
                 tableRow( new String[] { getI18nString( "organization.name" ), organization.getName() } );
 135  0
                 tableRowWithLink( new String[]{getI18nString( "organization.url" ), organization.getUrl()} );
 136  0
                 endTable();
 137  
             }
 138  1
             endSection();
 139  
 
 140  
             //build section
 141  1
             startSection( getI18nString( "build.title" ) );
 142  1
             startTable();
 143  1
             tableHeader( new String[]{getI18nString( "field" ), getI18nString( "value" )} );
 144  1
             tableRow( new String[]{getI18nString( "build.groupid" ), project.getGroupId()} );
 145  1
             tableRow( new String[]{getI18nString( "build.artifactid" ), project.getArtifactId()} );
 146  1
             tableRow( new String[]{getI18nString( "build.version" ), project.getVersion()} );
 147  1
             tableRow( new String[]{getI18nString( "build.type" ), project.getPackaging()} );
 148  1
             endTable();
 149  1
             endSection();
 150  
 
 151  1
             endSection();
 152  1
         }
 153  
 
 154  
 
 155  
         private void tableRowWithLink( String[] content )
 156  
         {
 157  1
             sink.tableRow();
 158  
 
 159  3
             for ( int ctr = 0; ctr < content.length; ctr++ )
 160  
             {
 161  2
                 String cell = content[ctr];
 162  
 
 163  2
                 sink.tableCell();
 164  
 
 165  2
                 if ( StringUtils.isEmpty( cell ) )
 166  
                 {
 167  1
                     sink.text( "-" );
 168  
                 }
 169  
                 else
 170  
                 {
 171  1
                     if ( ctr == content.length - 1 && cell.length() > 0 )
 172  
                     {
 173  0
                         sink.link( cell );
 174  0
                         sink.text( cell );
 175  0
                         sink.link_();
 176  
                     }
 177  
                     else
 178  
                     {
 179  1
                         sink.text( cell );
 180  
                     }
 181  
                 }
 182  2
                 sink.tableCell_();
 183  
             }
 184  
 
 185  1
             sink.tableRow_();
 186  1
         }
 187  
     }
 188  
 }