maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1054791 - in /maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin: issues/IssuesReportGenerator.java issues/IssuesReportHelper.java jira/JiraMojo.java trac/TracMojo.java
Date Mon, 03 Jan 2011 22:04:58 GMT
Author: dennisl
Date: Mon Jan  3 22:04:57 2011
New Revision: 1054791

URL: http://svn.apache.org/viewvc?rev=1054791&view=rev
Log:
o Refactoring: Move shared code to helper class.

Modified:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportHelper.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java?rev=1054791&r1=1054790&r2=1054791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
Mon Jan  3 22:04:57 2011
@@ -20,9 +20,7 @@ package org.apache.maven.plugin.issues;
  */
 
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.plugin.jira.JiraMojo;
 import org.apache.maven.reporting.MavenReportException;
-import org.codehaus.plexus.util.StringUtils;
 
 import java.text.SimpleDateFormat;
 import java.util.List;
@@ -92,59 +90,59 @@ public class IssuesReportGenerator
         {
             switch ( columns[columnIndex] )
             {
-                case JiraMojo.COLUMN_ASSIGNEE:
+                case IssuesReportHelper.COLUMN_ASSIGNEE:
                     sinkHeader( sink, bundle.getString( "report.issues.label.by" ) );
                     break;
 
-                case JiraMojo.COLUMN_CHANGED:
+                case IssuesReportHelper.COLUMN_CHANGED:
                     sinkHeader( sink, bundle.getString( "report.issues.label.changed" ) );
                     break;
 
-                case JiraMojo.COLUMN_COMPONENT:
+                case IssuesReportHelper.COLUMN_COMPONENT:
                     sinkHeader( sink, bundle.getString( "report.issues.label.component" )
);
                     break;
 
-                case JiraMojo.COLUMN_CREATED:
+                case IssuesReportHelper.COLUMN_CREATED:
                     sinkHeader( sink, bundle.getString( "report.issues.label.created" ) );
                     break;
 
-                case JiraMojo.COLUMN_FIX_VERSION:
+                case IssuesReportHelper.COLUMN_FIX_VERSION:
                     sinkHeader( sink, bundle.getString( "report.issues.label.fixVersion"
) );
                     break;
 
-                case JiraMojo.COLUMN_ID:
+                case IssuesReportHelper.COLUMN_ID:
                     sinkHeader( sink, bundle.getString( "report.issues.label.id" ) );
                     break;
 
-                case JiraMojo.COLUMN_KEY:
+                case IssuesReportHelper.COLUMN_KEY:
                     sinkHeader( sink, bundle.getString( "report.issues.label.key" ) );
                     break;
 
-                case JiraMojo.COLUMN_PRIORITY:
+                case IssuesReportHelper.COLUMN_PRIORITY:
                     sinkHeader( sink, bundle.getString( "report.issues.label.priority" )
);
                     break;
 
-                case JiraMojo.COLUMN_REPORTER:
+                case IssuesReportHelper.COLUMN_REPORTER:
                     sinkHeader( sink, bundle.getString( "report.issues.label.reporter" )
);
                     break;
 
-                case JiraMojo.COLUMN_RESOLUTION:
+                case IssuesReportHelper.COLUMN_RESOLUTION:
                     sinkHeader( sink, bundle.getString( "report.issues.label.resolution"
) );
                     break;
 
-                case JiraMojo.COLUMN_STATUS:
+                case IssuesReportHelper.COLUMN_STATUS:
                     sinkHeader( sink, bundle.getString( "report.issues.label.status" ) );
                     break;
 
-                case JiraMojo.COLUMN_SUMMARY:
+                case IssuesReportHelper.COLUMN_SUMMARY:
                     sinkHeader( sink, bundle.getString( "report.issues.label.summary" ) );
                     break;
 
-                case JiraMojo.COLUMN_TYPE:
+                case IssuesReportHelper.COLUMN_TYPE:
                     sinkHeader( sink, bundle.getString( "report.issues.label.type" ) );
                     break;
 
-                case JiraMojo.COLUMN_VERSION:
+                case IssuesReportHelper.COLUMN_VERSION:
                     sinkHeader( sink, bundle.getString( "report.issues.label.version" ) );
                     break;
 
@@ -184,27 +182,27 @@ public class IssuesReportGenerator
             {
                 switch ( columns[columnIndex] )
                 {
-                    case JiraMojo.COLUMN_ASSIGNEE:
+                    case IssuesReportHelper.COLUMN_ASSIGNEE:
                         sinkCell( sink, issue.getAssignee() );
                         break;
 
-                    case JiraMojo.COLUMN_CHANGED:
+                    case IssuesReportHelper.COLUMN_CHANGED:
                         sinkCell( sink, sdf.format( issue.getUpdated() ) );
                         break;
 
-                    case JiraMojo.COLUMN_COMPONENT:
+                    case IssuesReportHelper.COLUMN_COMPONENT:
                         sinkCell( sink, IssuesReportHelper.printValues( issue.getComponents()
) );
                         break;
 
-                    case JiraMojo.COLUMN_CREATED:
+                    case IssuesReportHelper.COLUMN_CREATED:
                         sinkCell( sink, sdf.format( issue.getCreated() ) );
                         break;
 
-                    case JiraMojo.COLUMN_FIX_VERSION:
+                    case IssuesReportHelper.COLUMN_FIX_VERSION:
                         sinkCell( sink, IssuesReportHelper.printValues( issue.getFixVersions()
) );
                         break;
 
-                    case JiraMojo.COLUMN_ID:
+                    case IssuesReportHelper.COLUMN_ID:
                         sink.tableCell();
                         sink.link( issue.getLink() );
                         sink.text( issue.getId() );
@@ -212,7 +210,7 @@ public class IssuesReportGenerator
                         sink.tableCell_();
                         break;
 
-                    case JiraMojo.COLUMN_KEY:
+                    case IssuesReportHelper.COLUMN_KEY:
                         sink.tableCell();
                         sink.link( issue.getLink() );
                         sink.text( issue.getKey() );
@@ -220,31 +218,31 @@ public class IssuesReportGenerator
                         sink.tableCell_();
                         break;
 
-                    case JiraMojo.COLUMN_PRIORITY:
+                    case IssuesReportHelper.COLUMN_PRIORITY:
                         sinkCell( sink, issue.getPriority() );
                         break;
 
-                    case JiraMojo.COLUMN_REPORTER:
+                    case IssuesReportHelper.COLUMN_REPORTER:
                         sinkCell( sink, issue.getReporter() );
                         break;
 
-                    case JiraMojo.COLUMN_RESOLUTION:
+                    case IssuesReportHelper.COLUMN_RESOLUTION:
                         sinkCell( sink, issue.getResolution() );
                         break;
 
-                    case JiraMojo.COLUMN_STATUS:
+                    case IssuesReportHelper.COLUMN_STATUS:
                         sinkCell( sink, issue.getStatus() );
                         break;
 
-                    case JiraMojo.COLUMN_SUMMARY:
+                    case IssuesReportHelper.COLUMN_SUMMARY:
                         sinkCell( sink, issue.getSummary() );
                         break;
 
-                    case JiraMojo.COLUMN_TYPE:
+                    case IssuesReportHelper.COLUMN_TYPE:
                         sinkCell( sink, issue.getType() );
                         break;
 
-                    case JiraMojo.COLUMN_VERSION:
+                    case IssuesReportHelper.COLUMN_VERSION:
                         sinkCell( sink, issue.getVersion() );
                         break;
 

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportHelper.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportHelper.java?rev=1054791&r1=1054790&r2=1054791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportHelper.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportHelper.java
Mon Jan  3 22:04:57 2011
@@ -19,8 +19,10 @@ package org.apache.maven.plugin.issues;
  * under the License.
  */
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 /**
  * A helper class for generation of reports based on issues.
@@ -30,6 +32,57 @@ import java.util.List;
  */
 public class IssuesReportHelper
 {
+    public static final int COLUMN_KEY = 0;
+
+    public static final int COLUMN_SUMMARY = 1;
+
+    public static final int COLUMN_STATUS = 2;
+
+    public static final int COLUMN_RESOLUTION = 3;
+
+    public static final int COLUMN_ASSIGNEE = 4;
+
+    public static final int COLUMN_REPORTER = 5;
+
+    public static final int COLUMN_TYPE = 6;
+
+    public static final int COLUMN_PRIORITY = 7;
+
+    public static final int COLUMN_VERSION = 8;
+
+    public static final int COLUMN_FIX_VERSION = 9;
+
+    public static final int COLUMN_COMPONENT = 10;
+
+    public static final int COLUMN_ID = 11;
+
+    public static final int COLUMN_CREATED = 12;
+
+    public static final int COLUMN_CHANGED = 13;
+
+    /**
+     * Get a list of id:s for the columns that are to be included in the report.
+     *
+     * @param columnNames The names of the columns
+     * @param allColumns A mapping from column name to column id
+     * @return A List of column id:s
+     */
+    public static List getColumnIds( String columnNames, Map allColumns )
+    {
+        List columnIds = new ArrayList();
+        String[] columnNamesArray = columnNames.split( "," );
+        // Loop through the names of the columns, to validate each of them and add their
id to the list
+        for ( int i = 0; i < columnNamesArray.length; i++ )
+        {
+            String columnName = columnNamesArray[i].trim();
+            if ( allColumns.containsKey( columnName ) )
+            {
+                columnIds.add( (Integer) allColumns.get( columnName ) );
+            }
+        }
+        return columnIds;
+    }
+
     /**
      * Print a list of values separated by commas.
      *
@@ -54,4 +107,20 @@ public class IssuesReportHelper
         }
         return sb.toString();
     }
+
+    /**
+     * Convert a List of Integers to an int array.
+     *
+     * @param list The List to convert
+     * @return An in array
+     */
+    public static int[] toIntArray( List list )
+    {
+        int[] intArray = new int[list.size()];
+        for ( int j = 0; j < intArray.length; j++ )
+        {
+            intArray[j] = ( (Integer) list.get( j ) ).intValue();
+        }
+        return intArray;
+    }
 }

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java?rev=1054791&r1=1054790&r2=1054791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
Mon Jan  3 22:04:57 2011
@@ -20,7 +20,6 @@ package org.apache.maven.plugin.jira;
  */
 
 import java.io.File;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -30,6 +29,7 @@ import java.util.ResourceBundle;
 import org.apache.maven.plugin.changes.AbstractChangesReport;
 import org.apache.maven.plugin.changes.ProjectUtils;
 import org.apache.maven.plugin.issues.IssuesReportGenerator;
+import org.apache.maven.plugin.issues.IssuesReportHelper;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.maven.settings.Settings;
 
@@ -43,22 +43,6 @@ import org.apache.maven.settings.Setting
 public class JiraMojo
     extends AbstractChangesReport
 {
-    //@todo Move to utility class
-    public static final int COLUMN_KEY = 0;
-    public static final int COLUMN_SUMMARY = 1;
-    public static final int COLUMN_STATUS = 2;
-    public static final int COLUMN_RESOLUTION = 3;
-    public static final int COLUMN_ASSIGNEE = 4;
-    public static final int COLUMN_REPORTER = 5;
-    public static final int COLUMN_TYPE = 6;
-    public static final int COLUMN_PRIORITY = 7;
-    public static final int COLUMN_VERSION = 8;
-    public static final int COLUMN_FIX_VERSION = 9;
-    public static final int COLUMN_COMPONENT = 10;
-    public static final int COLUMN_ID = 11;
-    public static final int COLUMN_CREATED = 12;
-    public static final int COLUMN_CHANGED = 13;
-
     /**
      * Valid JIRA columns.
      */
@@ -66,17 +50,17 @@ public class JiraMojo
 
     static
     {
-        JIRA_COLUMNS.put( "Key", new Integer( COLUMN_KEY ) );
-        JIRA_COLUMNS.put( "Summary", new Integer( COLUMN_SUMMARY ) );
-        JIRA_COLUMNS.put( "Status", new Integer( COLUMN_STATUS ) );
-        JIRA_COLUMNS.put( "Resolution", new Integer( COLUMN_RESOLUTION ) );
-        JIRA_COLUMNS.put( "Assignee", new Integer( COLUMN_ASSIGNEE ) );
-        JIRA_COLUMNS.put( "Reporter", new Integer( COLUMN_REPORTER ) );
-        JIRA_COLUMNS.put( "Type", new Integer( COLUMN_TYPE ) );
-        JIRA_COLUMNS.put( "Priority", new Integer( COLUMN_PRIORITY ) );
-        JIRA_COLUMNS.put( "Version", new Integer( COLUMN_VERSION ) );
-        JIRA_COLUMNS.put( "Fix Version", new Integer( COLUMN_FIX_VERSION ) );
-        JIRA_COLUMNS.put( "Component", new Integer( COLUMN_COMPONENT ) );
+        JIRA_COLUMNS.put( "Key", new Integer( IssuesReportHelper.COLUMN_KEY ) );
+        JIRA_COLUMNS.put( "Summary", new Integer( IssuesReportHelper.COLUMN_SUMMARY ) );
+        JIRA_COLUMNS.put( "Status", new Integer( IssuesReportHelper.COLUMN_STATUS ) );
+        JIRA_COLUMNS.put( "Resolution", new Integer( IssuesReportHelper.COLUMN_RESOLUTION
) );
+        JIRA_COLUMNS.put( "Assignee", new Integer( IssuesReportHelper.COLUMN_ASSIGNEE ) );
+        JIRA_COLUMNS.put( "Reporter", new Integer( IssuesReportHelper.COLUMN_REPORTER ) );
+        JIRA_COLUMNS.put( "Type", new Integer( IssuesReportHelper.COLUMN_TYPE ) );
+        JIRA_COLUMNS.put( "Priority", new Integer( IssuesReportHelper.COLUMN_PRIORITY ) );
+        JIRA_COLUMNS.put( "Version", new Integer( IssuesReportHelper.COLUMN_VERSION ) );
+        JIRA_COLUMNS.put( "Fix Version", new Integer( IssuesReportHelper.COLUMN_FIX_VERSION
) );
+        JIRA_COLUMNS.put( "Component", new Integer( IssuesReportHelper.COLUMN_COMPONENT )
);
     }
 
     /**
@@ -300,14 +284,14 @@ public class JiraMojo
                 JiraXML jira = new JiraXML( jiraXmlPath, jiraXmlEncoding );
                 List issueList = jira.getIssueList();
 
-                List columnIds = getColumnIds( columnNames, JIRA_COLUMNS );
+                List columnIds = IssuesReportHelper.getColumnIds( columnNames, JIRA_COLUMNS
);
                 if ( columnIds.size() == 0 )
                 {
                     // This can happen if the user has configured column names and they are
all invalid
                     throw new MavenReportException(
                         "maven-changes-plugin: None of the configured columnNames '" + columnNames
+ "' are valid." );
                 }
-                report = new IssuesReportGenerator( toIntArray( columnIds ) );
+                report = new IssuesReportGenerator( IssuesReportHelper.toIntArray( columnIds
) );
 
                 if ( onlyCurrentVersion )
                 {
@@ -336,47 +320,6 @@ public class JiraMojo
         }
     }
 
-    /**
-     * Get a list of id:s for the columns that are to be included in the report.
-     *
-     * @param columnNames The names of the columns
-     * @param allColumns A mapping from column name to column id
-     * @return A List of column id:s
-     * @todo Move to helper class
-     */
-    public static List getColumnIds( String columnNames, Map allColumns )
-    {
-        List columnIds = new ArrayList();
-        String[] columnNamesArray = columnNames.split( "," );
-        // Loop through the names of the columns, to validate each of them and add their
id to the list
-        for ( int i = 0; i < columnNamesArray.length; i++ )
-        {
-            String columnName = columnNamesArray[i].trim();
-            if ( allColumns.containsKey( columnName ) )
-            {
-                columnIds.add( (Integer) allColumns.get( columnName ) );
-            }
-        }
-        return columnIds;
-    }
-
-    /**
-     * Convert a List of Integers to an int array.
-     *
-     * @param list The List to convert
-     * @return An in array
-     * @todo Move to helper class
-     */
-    public static int[] toIntArray( List list )
-    {
-        int[] intArray = new int[list.size()];
-        for ( int j = 0; j < intArray.length; j++ )
-        {
-            intArray[j] = ( (Integer) list.get( j ) ).intValue();
-        }
-        return intArray;
-    }
-
     public String getName( Locale locale )
     {
         return getBundle( locale ).getString( "report.issues.name" );

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java?rev=1054791&r1=1054790&r2=1054791&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/trac/TracMojo.java
Mon Jan  3 22:04:57 2011
@@ -30,7 +30,7 @@ import org.apache.maven.doxia.siterender
 import org.apache.maven.plugin.changes.AbstractChangesReport;
 import org.apache.maven.plugin.changes.ProjectUtils;
 import org.apache.maven.plugin.issues.IssuesReportGenerator;
-import org.apache.maven.plugin.jira.JiraMojo;
+import org.apache.maven.plugin.issues.IssuesReportHelper;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.reporting.MavenReportException;
 import org.apache.xmlrpc.XmlRpcException;
@@ -54,18 +54,18 @@ public class TracMojo
 
     static
     {
-        TRAC_COLUMNS.put( "id", new Integer( JiraMojo.COLUMN_ID ) );
-        TRAC_COLUMNS.put( "type", new Integer( JiraMojo.COLUMN_TYPE ) );
-        TRAC_COLUMNS.put( "summary", new Integer( JiraMojo.COLUMN_SUMMARY ) );
-        TRAC_COLUMNS.put( "status", new Integer( JiraMojo.COLUMN_STATUS ) );
-        TRAC_COLUMNS.put( "resolution", new Integer( JiraMojo.COLUMN_RESOLUTION ) );
-        TRAC_COLUMNS.put( "milestone", new Integer( JiraMojo.COLUMN_FIX_VERSION ) );
-        TRAC_COLUMNS.put( "owner", new Integer( JiraMojo.COLUMN_ASSIGNEE ) );
-        TRAC_COLUMNS.put( "priority", new Integer( JiraMojo.COLUMN_PRIORITY ) );
-        TRAC_COLUMNS.put( "reporter", new Integer( JiraMojo.COLUMN_REPORTER ) );
-        TRAC_COLUMNS.put( "component", new Integer( JiraMojo.COLUMN_COMPONENT ) );
-        TRAC_COLUMNS.put( "created", new Integer( JiraMojo.COLUMN_CREATED ) );
-        TRAC_COLUMNS.put( "changed", new Integer( JiraMojo.COLUMN_CHANGED ) );
+        TRAC_COLUMNS.put( "id", new Integer( IssuesReportHelper.COLUMN_ID ) );
+        TRAC_COLUMNS.put( "type", new Integer( IssuesReportHelper.COLUMN_TYPE ) );
+        TRAC_COLUMNS.put( "summary", new Integer( IssuesReportHelper.COLUMN_SUMMARY ) );
+        TRAC_COLUMNS.put( "status", new Integer( IssuesReportHelper.COLUMN_STATUS ) );
+        TRAC_COLUMNS.put( "resolution", new Integer( IssuesReportHelper.COLUMN_RESOLUTION
) );
+        TRAC_COLUMNS.put( "milestone", new Integer( IssuesReportHelper.COLUMN_FIX_VERSION
) );
+        TRAC_COLUMNS.put( "owner", new Integer( IssuesReportHelper.COLUMN_ASSIGNEE ) );
+        TRAC_COLUMNS.put( "priority", new Integer( IssuesReportHelper.COLUMN_PRIORITY ) );
+        TRAC_COLUMNS.put( "reporter", new Integer( IssuesReportHelper.COLUMN_REPORTER ) );
+        TRAC_COLUMNS.put( "component", new Integer( IssuesReportHelper.COLUMN_COMPONENT )
);
+        TRAC_COLUMNS.put( "created", new Integer( IssuesReportHelper.COLUMN_CREATED ) );
+        TRAC_COLUMNS.put( "changed", new Integer( IssuesReportHelper.COLUMN_CHANGED ) );
     }
 
     /**
@@ -137,7 +137,7 @@ public class TracMojo
         {
             List issueList = issueDownloader.getIssueList();
 
-            List columnIds = JiraMojo.getColumnIds( columnNames, TRAC_COLUMNS );
+            List columnIds = IssuesReportHelper.getColumnIds( columnNames, TRAC_COLUMNS );
             if ( columnIds.size() == 0 )
             {
                 // This can happen if the user has configured column names and they are all
invalid
@@ -146,7 +146,7 @@ public class TracMojo
             }
 
             // Generate the report
-            IssuesReportGenerator report = new IssuesReportGenerator( JiraMojo.toIntArray(
columnIds ) );
+            IssuesReportGenerator report = new IssuesReportGenerator( IssuesReportHelper.toIntArray(
columnIds ) );
 
             if ( issueList.isEmpty() )
             {



Mime
View raw message