You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by de...@apache.org on 2008/01/22 00:18:21 UTC
svn commit: r614045 - in
/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira:
AbstractJiraDownloader.java JiraMojo.java
Author: dennisl
Date: Mon Jan 21 15:18:19 2008
New Revision: 614045
URL: http://svn.apache.org/viewvc?rev=614045&view=rev
Log:
[MCHANGES-94] Add option to configure the sort order of the JIRA report
Submitted by: Niall Pemberton
Reviewed by: Dennis Lundberg
Patch applied with modifications:
- Log errors if configuration is wrong, instead of using default values.
- Change column names to "Updated" and "Created" to match the column headers in the JIRA issue navigator.
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java?rev=614045&r1=614044&r2=614045&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/AbstractJiraDownloader.java Mon Jan 21 15:18:19 2008
@@ -75,6 +75,8 @@
private String component;
/** Ids of types to show, as comma separated string. */
private String typeIds;
+ /** Column names to sort by, as comma separated string. */
+ private String sortColumnNames;
/** The username to log into JIRA. */
private String jiraUser;
/** The password to log into JIRA. */
@@ -203,10 +205,100 @@
}
}
- // add default sorting (by priority and then creation date)
- String sort = "&sorter/field=created&sorter/order=DESC" + "&sorter/field=priority&sorter/order=DESC";
+ // get the Sort order
+ int validSortColumnNames = 0;
+ if ( sortColumnNames != null )
+ {
+ String[] sortColumnNamesArray = sortColumnNames.split( "," );
+ // N.B. Add in reverse order (it's the way JIRA likes it!!)
+ for ( int i = sortColumnNamesArray.length - 1; i >= 0; i-- )
+ {
+ String lowerColumnName = sortColumnNamesArray[i].trim().toLowerCase();
+ boolean descending = false;
+ String fieldName = null;
+ if ( lowerColumnName.endsWith( "desc" ) )
+ {
+ descending = true;
+ lowerColumnName = lowerColumnName.substring(0, lowerColumnName.length() - 4).trim();
+ }
- return localFilter + sort;
+ if ( "key".equals( lowerColumnName ) )
+ {
+ fieldName = "issuekey";
+ }
+ else if ("summary".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("status".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("resolution".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("assignee".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("reporter".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("type".equals( lowerColumnName ) )
+ {
+ fieldName = "issuetype";
+ }
+ else if ("priority".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("version".equals( lowerColumnName ) )
+ {
+ fieldName = "versions";
+ }
+ else if ("fix version".equals( lowerColumnName ) )
+ {
+ fieldName = "fixVersions";
+ }
+ else if ("component".equals( lowerColumnName ) )
+ {
+ fieldName = "components";
+ }
+ else if ("created".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ else if ("updated".equals( lowerColumnName ) )
+ {
+ fieldName = lowerColumnName;
+ }
+ if ( fieldName != null )
+ {
+ localFilter.append( "&sorter/field=" );
+ localFilter.append( fieldName );
+ localFilter.append( "&sorter/order=" );
+ localFilter.append( descending ? "DESC" : "ASC" );
+ validSortColumnNames++;
+ }
+ else {
+ // Error in the configuration
+ getLog().error(
+ "maven-changes-plugin: The configured value '" + lowerColumnName
+ + "' for sortColumnNames is not correct." );
+ }
+ }
+ }
+ if ( validSortColumnNames == 0 )
+ {
+ // Error in the configuration
+ getLog().error(
+ "maven-changes-plugin: None of the configured sortColumnNames '" + sortColumnNames + "' are correct." );
+ }
+
+
+ return localFilter.toString();
}
/**
@@ -664,6 +756,16 @@
public void setResolutionIds( String thisResolutionIds )
{
resolutionIds = thisResolutionIds;
+ }
+
+ /**
+ * Sets the sort column names.
+ *
+ * @param thisSortColumnNames The column names to sort by
+ */
+ public void setSortColumnNames( String thisSortColumnNames )
+ {
+ sortColumnNames = thisSortColumnNames;
}
/**
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=614045&r1=614044&r2=614045&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 21 15:18:19 2008
@@ -178,6 +178,27 @@
private String columnNames;
/**
+ * Sets the column names that you want to sort the report by. Add
+ * <code>DESC</code> following the column name
+ * to specify <i>descending</i> sequence. For
+ * example <code>Fix Version DESC, Type</code> sorts first by
+ * the Fix Version in descending order and then by Type in
+ * ascending order.
+ * <p>
+ * Valid columns are: <code>Key</code>, <code>Summary</code>,
+ * <code>Status</code>, <code>Resolution</code>, <code>Assignee</code>,
+ * <code>Reporter</code>, <code>Type</code>, <code>Priority</code>,
+ * <code>Version</code>, <code>Fix Version</code>,
+ * <code>Component</code>, <code>Created</code> and
+ * <code>Updated</code>.
+ * </p>
+ *
+ * @parameter default-value="Priority DESC, Created DESC"
+ * @since 2.0-beta-4
+ */
+ private String sortColumnNames;
+
+ /**
* Defines the JIRA username for authentication into a private JIRA installation.
*
* @parameter default-value=""
@@ -305,6 +326,8 @@
jira.setResolutionIds( resolutionIds );
jira.setPriorityIds( priorityIds );
+
+ jira.setSortColumnNames( sortColumnNames );
jira.setFilter( filter );