Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.apache.maven.plugin.changelog;
  
  /*
   * Licensed to the Apache Software Foundation (ASF) under one
   * or more contributor license agreements.  See the NOTICE file
   * distributed with this work for additional information
   * regarding copyright ownership.  The ASF licenses this file
   * to you under the Apache License, Version 2.0 (the
   * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
  */
 
 
 import java.util.List;
 import java.util.Map;
Generate a file activity report.

Version:
$Id: FileActivityReport.java 1517983 2013-08-27 20:57:20Z krosenvold $
 
 @Mojo(name = "file-activity")
 public class FileActivityReport
     extends ChangeLogReport
 {
    
 
     public String getDescriptionLocale locale )
     {
         return getBundlelocale ).getString"report.file-activity.description" );
     }

    
 
     public String getNameLocale locale )
     {
         return getBundlelocale ).getString"report.file-activity.name" );
     }

    
 
     public String getOutputName()
     {
         return "file-activity";
     }

    
 
     protected void doGenerateEmptyReportResourceBundle bundleSink sink )
     {
         sink.head();
         sink.title();
         sink.textbundle.getString"report.file-activity.header" ) );
         sink.title_();
         sink.head_();
 
         sink.body();
         sink.section1();
 
         sink.sectionTitle1();
         sink.textbundle.getString"report.file-activity.mainTitle" ) );
         sink.sectionTitle1_();
 
         sink.paragraph();
         sink.text"No sources found to create a report." );
         sink.paragraph_();
 
         sink.section1_();
 
         sink.body_();
         sink.flush();
         sink.close();
     }

    
    protected void doGenerateReportList<ChangeLogSetchangeLogSetsResourceBundle bundleSink sink )
    {
        sink.head();
        sink.title();
        sink.textbundle.getString"report.file-activity.header" ) );
        sink.title_();
        sink.head_();
        sink.body();
        sink.section1();
        sink.sectionTitle1();
        sink.textbundle.getString"report.file-activity.mainTitle" ) );
        sink.sectionTitle1_();
        for ( ChangeLogSet set : changeLogSets )
        {
            doChangedSetssetbundlesink );
        }
        sink.section1_();
        sink.body_();
        sink.flush();
        sink.close();
    }

    
generates a section of the report referring to a changeset

Parameters:
set the current ChangeSet to generate this section of the report
bundle the resource bundle to retrieve report phrases from
sink the report formatting tool
    private void doChangedSetsChangeLogSet setResourceBundle bundleSink sink )
    {
        sink.section2();
        doChangeSetTitlesetbundlesink );
        doSummarysetbundlesink );
        sink.table();
        sink.tableRow();
        sink.tableHeaderCell();
        sink.textbundle.getString"report.file-activity.filename" ) );
        sink.tableHeaderCell_();
        sink.tableHeaderCell();
        sink.textbundle.getString"report.file-activity.timesChanged" ) );
        sink.tableHeaderCell_();
        sink.tableRow_();
        doRowssetsink );
        sink.table_();
        sink.section2_();
    }

    
generates the row details for the file activity report

Parameters:
set the changelog set to generate a report with
sink the report formatting tool
    private void doRowsChangeLogSet setSink sink )
    {
        List<List<ChangeFile>> list = getOrderedFileListset.getChangeSets() );
        initReportUrls();
        for ( List<ChangeFilerevision : list )
        {
            ChangeFile file = revision.get( 0 );
            sink.tableRow();
            sink.tableCell();
            try
            {
                generateLinksgetConnection(), file.getName(), sink );
            }
            catch ( Exception e )
            {
                if ( getLog().isDebugEnabled() )
                {
                    getLog().errore.getMessage(), e );
                }
                else
                {
                    getLog().errore.getMessage() );
                }
                sink.textfile.getName() );
            }
            sink.tableCell_();
            sink.tableCell();
            sink.text"" + revision.size() );
            sink.tableCell_();
            sink.tableRow_();
        }
    }

    
reads the change log entries and generates a list of files changed order by the number of times edited. This used the FileActivityComparator Object to sort the list

Parameters:
entries the changelog entries to generate the report
Returns:
list of changed files within the SCM with the number of times changed in descending order
    private List<List<ChangeFile>> getOrderedFileListCollection<ChangeSetentries )
    {
        List<List<ChangeFile>> list = new LinkedList<List<ChangeFile>>();
        Map<StringList<ChangeFile>> map = new HashMap<StringList<ChangeFile>>();
        for ( ChangeSet entry : entries )
        {
            for ( ChangeFile file : entry.getFiles() )
            {
                List<ChangeFilerevisions = map.getfile.getName() );
                if ( revisions == null )
                {
                    revisions = new LinkedList<ChangeFile>();
                    map.putfile.getName(), revisions );
                }
                revisions.addfile );
            }
        }
        list.addAllmap.values() );
        Collections.sortlistnew FileActivityComparator() );
        return list;
    }
New to GrepCode? Check out our FAQ X