dion        02/05/10 04:31:40

  Modified:    src/dvsl/xdocs site.dvsl
               src/java/org/apache/maven MavenTool.java
               src/templates/build build-docs.xml
               xdocs/ref properties.xml
  Added:       src/dvsl/xdocs file-activity.dvsl
  Log:
  no message
  
  Revision  Changes    Path
  1.41      +3 -2      jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl
  
  Index: site.dvsl
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/dvsl/xdocs/site.dvsl,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- site.dvsl 10 May 2002 02:32:14 -0000      1.40
  +++ site.dvsl 10 May 2002 11:31:40 -0000      1.41
  @@ -188,13 +188,14 @@
                   </div>
                   <div>
                     <small><a href="$relativePath/maven-reports.html">Maven 
Reports</a></small>
  -                  #if ($currentDir == "." && ($infilename == "maven-reports.xml" || 
$infilename == "tasks.xml" || $infilename == "changelog.xml" || $infilename == 
"junit-report.xml" || $infilename == "jdepend-report.xml" || $infilename == 
"checkstyle-report.xml" || $infilename == "activity-log.xml"))
  +                  #if ($currentDir == "." && ($infilename == "maven-reports.xml" || 
$infilename == "tasks.xml" || $infilename == "changelog.xml" || $infilename == 
"junit-report.xml" || $infilename == "jdepend-report.xml" || $infilename == 
"checkstyle-report.xml" || $infilename == "activity-log.xml" || $infilename == 
"file-activity-report.xml"))
                       #if 
($context.toolbox.fileutil.file("$context.toolbox.docSrc/tasks.xml").exists())
                       <div><small><a 
href="$relativePath/tasks.html">Tasks</a></small></div>
                       #end
                       #if ($pom.cvsModule)
                       <div><small><a href="$relativePath/changelog.html">Change 
Log</a></small></div>
  -                    <div><small><a href="$relativePath/activity-log.html">Activity 
Log</a></small></div>
  +                    <div><small><a href="$relativePath/activity-log.html">Developer 
Activity</a></small></div>
  +                    <div><small><a 
href="$relativePath/file-activity-report.html">File Activity</a></small></div>
                       #end
                       #if ($context.toolbox.testSrcPresent == "true")
                       <div><small><a href="$relativePath/junit-report.html">Unit 
Tests</a></small></div>
  
  
  
  1.1                  jakarta-turbine-maven/src/dvsl/xdocs/file-activity.dvsl
  
  Index: file-activity.dvsl
  ===================================================================
  #######################################################################
  ## Developer Activity  D V S L    S T Y L E S H E E T                ##
  #######################################################################
  
  ## This stylesheet is used to transform the output of ChangeLog's xml
  ## generator.  The XML is transformed into a standard xdoc that can
  ## then be transformed (yet again) using whatever stylesheet is used
  ## to format one's site.
  ##
  ##
  ## Version: $Id: file-activity.dvsl,v 1.1 2002/05/10 11:31:40 dion Exp $
  ## Author:  dIon Gillard
  
  #######################################################################
  ## V E L O C I T Y    M A C R O S                                    ##
  #######################################################################
  
  ## Convert a string that represents a number using the specified
  ## pattern.  
  ##
  #macro (cvsWebLink $pom $file)
      <a href="$pom.cvsWebUrl.toString().trim()$file">$file</a>
  #end
  
  
  #######################################################################
  ## T E M P L A T E    D E F I N I T I O N S                          ## 
  ####################################################################### 
  
  ## Matches the first data element of the ChangeLog XML report.
  ##
  #match ("changelog")
  <?xml version="1.0"?>
    ## Grab a reference to the project descriptor here so we can pull
    ## info from it such as the cvs web url, etc ...
    #set( $pomFilename = "$context.toolbox.basedir/project.xml")
    #set( $pom = $node.selectSingleNode("document('$pomFilename')/project"))
    $context.applyTemplates()
  
  <document>
  
    <properties>
      <title>File Activity Analysis</title>
    </properties>
    <body>
      <section name="Activity by File">
      <p>
        Timeframe: $context.toolbox.range days, 
        Total Commits: $node.valueOf("count(./changelog-entry"),
        Total Number of Files Changed: $node.valueOf("count(./changelog-entry/file")
      </p>
      <table>
          <tr>
          <th>File Name</th><th>Number of times changed</th>
          </tr>
          #set ($fileList = $context.toolbox.maven.CountDescending)
          #foreach ($key in $fileList.keySet())
              #foreach ($name in $fileList.get($key))
          <tr>
              <td>#cvsWebLink ($pom $name)</td>
              <td>$key</td>
          </tr>
              #end
          #end
      </table>
      </section>
    </body></document>
  #end
  
  #match("file")
      #set ($dummy = $context.toolbox.maven.addToCount("$node.name.value()"))
  #end
  
  
  1.6       +147 -0    jakarta-turbine-maven/src/java/org/apache/maven/MavenTool.java
  
  Index: MavenTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/MavenTool.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MavenTool.java    28 Apr 2002 17:35:00 -0000      1.5
  +++ MavenTool.java    10 May 2002 11:31:40 -0000      1.6
  @@ -55,6 +55,15 @@
    */
   
   import java.io.File;
  +import java.util.ArrayList;
  +import java.util.Collections;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
  +import java.util.TreeSet;
  +import java.util.TreeMap;
   
   import org.apache.tools.ant.types.Path;
   
  @@ -67,7 +76,15 @@
    */
   public class MavenTool
   {
  +    /** The maven project the tool is processing */
       private Project project;
  +    /** list of items to be counted. Key is the object, value is a list
  +        of objects that have been added that are equal */
  +    private Map counted = new HashMap();
  +    /** the counted items in ascending order of number of times counted */
  +    private Map countedItems = null;
  +    /** the counted items in descending order of number of times counted */
  +    private Map countedItemsReversed = null;
   
       /**
        * Creates a new instance.
  @@ -137,5 +154,135 @@
                                  " using a base diretory of " + baseDir);
           }
           return path;
  +    }
  +    
  +    /**
  +     * Clear the counter so that there are zero items
  +     */
  +    public void resetCount()
  +    {
  +        getCounted().clear();
  +    }
  +    
  +    /**
  +     * Add an object to the list of counted items.
  +     * @param object the item to be added.
  +     */
  +    public void addToCount(Object object)
  +    {
  +        List list = null;
  +        if (getCounted().get(object) == null)
  +        {
  +            list = new ArrayList();
  +        }
  +        else
  +        {
  +            list = (List)getCounted().get(object);
  +        }
  +        list.add(object);
  +        getCounted().put(object, list);
  +        if (getCountedItems() != null)
  +        {
  +            setCountedItems(null);
  +            setCountedItemsReversed(null);
  +        }
  +    }
  +    
  +    /** Fill the provided sorting map of items from the counted items
  +     * @param map a map that will sort the objects added to it
  +     */
  +    private void fillSortingMap(Map map)
  +    {
  +        List list = null;
  +        Object key = null;
  +        for (Iterator index = counted.keySet().iterator(); index.hasNext(); )
  +        {
  +            key = index.next();
  +            list = (List)counted.get(key);
  +            Integer count = new Integer(list.size());
  +            Set items = null;
  +            if (!map.containsKey(count))
  +            {
  +                items = new TreeSet();
  +            }
  +            else
  +            {
  +                items = (Set)map.get(count);
  +            }
  +            items.add(key);
  +            map.put(count, items);
  +        }
  +    }
  +    
  +    /**
  +     * get a list of counted items with the key being the number of times
  +     * counted (in descending order) and the value any arbitrary item that was 
counted
  +     * @return a sorted map of #times counted -> list of objects
  +     */
  +    public Map getCountDescending()
  +    {
  +        if (getCountedItemsReversed() == null)
  +        {
  +            setCountedItemsReversed(new TreeMap(Collections.reverseOrder()));
  +            fillSortingMap(getCountedItemsReversed());
  +        }
  +        return getCountedItemsReversed();
  +    }
  +    
  +    /**
  +     * get a list of counted items with the key being the number of times
  +     * counted and the value any arbitrary item that was counted
  +     * @return a sorted map of #times counted -> list of objects
  +     */
  +    public Map getCount()
  +    {
  +        if (getCountedItems() == null)
  +        {
  +            setCountedItems(new TreeMap());
  +            fillSortingMap(getCountedItems());
  +        }
  +        return getCountedItems();
  +    }
  +    
  +    /** Getter for property counted.
  +     * @return Value of property counted.
  +     */
  +    private Map getCounted() {
  +        return counted;
  +    }
  +    
  +    /** Setter for property counted.
  +     * @param counted New value of property counted.
  +     */
  +    private void setCounted(Map counted) {
  +        this.counted = counted;
  +    }
  +    
  +    /** Getter for property countedItems.
  +     * @return Value of property countedItems.
  +     */
  +    private Map getCountedItems() {
  +        return countedItems;
  +    }
  +    
  +    /** Setter for property countedItems.
  +     * @param countedItems New value of property countedItems.
  +     */
  +    private void setCountedItems(Map countedItems) {
  +        this.countedItems = countedItems;
  +    }
  +    
  +    /** Getter for property countedItemsReversed.
  +     * @return Value of property countedItemsReversed.
  +     */
  +    private Map getCountedItemsReversed() {
  +        return countedItemsReversed;
  +    }
  +    
  +    /** Setter for property countedItemsReverse.
  +     * @param countedItemsRevers New value of property countedItemsReverse.
  +     */
  +    private void setCountedItemsReversed(Map countedItemsReversed) {
  +        this.countedItemsReversed = countedItemsReversed;
       }
   }
  
  
  
  1.69      +25 -2     jakarta-turbine-maven/src/templates/build/build-docs.xml
  
  Index: build-docs.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-docs.xml,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- build-docs.xml    10 May 2002 03:23:13 -0000      1.68
  +++ build-docs.xml    10 May 2002 11:31:40 -0000      1.69
  @@ -162,7 +162,7 @@
       </taskdef>
   
   
  -    <!-- Transform the auto-generated xdocs first -->
  +    <!-- Transform the activity log into developer activity first -->
       <dvsl
         basedir="${maven.build.dir}"
         destdir="${maven.gen.docs}/"
  @@ -174,15 +174,38 @@
         <!--excludes="**/project.xml,**/template.xml"-->
         <!-- Need to add the maven jar to load the toolbox -->
         <classpath refid="maven-classpath"/>
  -      <tool name="toolbox.string.basedir" value="${basedir}"/>
  +<!--      <tool name="toolbox.string.basedir" value="${basedir}"/>
         <tool name="toolbox.string.docSrc" value="${maven.docs.src}"/>
         <tool name="toolbox.string.srcDir" value="${maven.src.dir}"/>
         <tool name="toolbox.string.srcPresent" value="${maven.sourcesPresent}"/>
         <tool name="toolbox.string.testSrcPresent" 
value="${maven.unitTestSourcesPresent}"/>
         <tool name="toolbox.string.currentYear" value="${maven.current.year}"/>
  +-->
         <tool name="toolbox.string.range" value="${maven.activitylog.range}"/>
       </dvsl>
       
  +    <!-- Transform the activity log into file activity-->
  +    <dvsl
  +      extension=".xml"
  +      force="true"
  +      toolboxfile="${maven.home}/stylesheets/toolbox.props"
  +      style="${maven.home}/stylesheets/file-activity.dvsl"
  +      in="${maven.build.dir}/activity-log.xml"
  +      out="${maven.gen.docs}/file-activity-report.xml">
  +      <!-- Need to add the maven jar to load the toolbox -->
  +      <classpath refid="maven-classpath"/>
  +      <tool name="toolbox.string.basedir" value="${basedir}"/>
  +<!--
  +      <tool name="toolbox.string.docSrc" value="${maven.docs.src}"/>
  +      <tool name="toolbox.string.srcDir" value="${maven.src.dir}"/>
  +      <tool name="toolbox.string.srcPresent" value="${maven.sourcesPresent}"/>
  +      <tool name="toolbox.string.testSrcPresent" 
value="${maven.unitTestSourcesPresent}"/>
  +      <tool name="toolbox.string.currentYear" value="${maven.current.year}"/>
  +-->
  +      <tool name="toolbox.string.range" value="${maven.activitylog.range}"/>
  +    </dvsl>
  +
  +        
     </target>
     <!-- ================================================================== -->
     <!-- P R O J E C T  D O C U M E N T A T I O N                           -->
  
  
  
  1.12      +1 -1      jakarta-turbine-maven/xdocs/ref/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/ref/properties.xml,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- properties.xml    10 May 2002 03:23:13 -0000      1.11
  +++ properties.xml    10 May 2002 11:31:40 -0000      1.12
  @@ -1216,7 +1216,7 @@
             <td>Yes</td>
             <td>
               Specifies the range to use when generating the
  -            developer activity log.  This is used by the <a
  +            developer and file activity logs.  This is used by the <a
                 href="build-file.html#maven:activity-log">maven:activity-log</a>
               target.
               The default value is <code>30</code> days.
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to