Author: dennisl
Date: Sat Sep 1 23:29:13 2012
New Revision: 1379896
URL: http://svn.apache.org/viewvc?rev=1379896&view=rev
Log:
Sort methods and fields.
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JqlQueryBuilder.java
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JqlQueryBuilder.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JqlQueryBuilder.java?rev=1379896&r1=1379895&r2=1379896&view=diff
==============================================================================
---
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JqlQueryBuilder.java
(original)
+++
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JqlQueryBuilder.java
Sat Sep 1 23:29:13 2012
@@ -36,87 +36,106 @@ import org.apache.maven.plugin.logging.L
public class JqlQueryBuilder
implements JiraQueryBuilder
{
+ private String filter = "";
+
/**
* Log for debug output.
*/
private Log log;
- private StringBuilder query = new StringBuilder();
-
private StringBuilder orderBy = new StringBuilder();
- private String filter = "";
+ private StringBuilder query = new StringBuilder();
public JqlQueryBuilder( Log log )
{
this.log = log;
}
- public JiraQueryBuilder project( String project )
+ public String build()
{
- addSingleValue( "project", project );
- return this;
+ try
+ {
+ String jqlQuery;
+ // If the user has defined a filter - use that
+ if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
+ {
+ jqlQuery = filter;
+ }
+ else
+ {
+ jqlQuery = query.toString() + orderBy.toString();
+ }
+ getLog().debug( "Encoding JBL query " + jqlQuery );
+ String encodedQuery = URLEncoder.encode( jqlQuery, "UTF-8" );
+ getLog().debug( "Encoded JBL query " + encodedQuery );
+ return encodedQuery;
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ getLog().error( "Unable to encode JBL query with UTF-8", e );
+ throw new RuntimeException( e );
+ }
}
- /**
- * When both {@link #fixVersion(String)} and {@link
#fixVersionIds(String)} are used then you will probably
- * end up with a JQL query that is valid, but returns nothing. Unless they
both only reference the same fixVersion
- *
- * @param fixVersionIds
- * @return
- */
- public JiraQueryBuilder fixVersionIds( String fixVersionIds )
+ public JiraQueryBuilder components( String components )
{
- addCommaSeparatedValues( "fixVersion", fixVersionIds );
+ addCommaSeparatedValues( "component", components );
return this;
}
- public JiraQueryBuilder statusIds( String statusIds )
+ public JiraQueryBuilder filter( String filter )
{
- addCommaSeparatedValues( "status", statusIds );
+ this.filter = filter;
return this;
}
- public JiraQueryBuilder priorityIds( String priorityIds )
+ /**
+ * When both {@link #fixVersion(String)} and {@link
#fixVersionIds(String)} are used then you will probably
+ * end up with a JQL query that is valid, but returns nothing. Unless they
both only reference the same fixVersion
+ *
+ * @param fixVersion
+ * @return
+ */
+ public JiraQueryBuilder fixVersion( String fixVersion )
{
- addCommaSeparatedValues( "priority", priorityIds );
+ addSingleValue( "fixVersion", fixVersion );
return this;
}
- public JiraQueryBuilder resolutionIds( String resolutionIds )
+ /**
+ * When both {@link #fixVersion(String)} and {@link
#fixVersionIds(String)} are used then you will probably
+ * end up with a JQL query that is valid, but returns nothing. Unless they
both only reference the same fixVersion
+ *
+ * @param fixVersionIds
+ * @return
+ */
+ public JiraQueryBuilder fixVersionIds( String fixVersionIds )
{
- addCommaSeparatedValues( "resolution", resolutionIds );
+ addCommaSeparatedValues( "fixVersion", fixVersionIds );
return this;
}
- public JiraQueryBuilder components( String components )
+ public Log getLog()
{
- addCommaSeparatedValues( "component", components );
- return this;
+ return log;
}
- public JiraQueryBuilder typeIds( String typeIds )
+ public JiraQueryBuilder priorityIds( String priorityIds )
{
- addCommaSeparatedValues( "type", typeIds );
+ addCommaSeparatedValues( "priority", priorityIds );
return this;
}
- public JiraQueryBuilder filter( String filter )
+ public JiraQueryBuilder project( String project )
{
- this.filter = filter;
+ addSingleValue( "project", project );
return this;
}
- /**
- * When both {@link #fixVersion(String)} and {@link
#fixVersionIds(String)} are used then you will probably
- * end up with a JQL query that is valid, but returns nothing. Unless they
both only reference the same fixVersion
- *
- * @param fixVersion
- * @return
- */
- public JiraQueryBuilder fixVersion( String fixVersion )
+ public JiraQueryBuilder resolutionIds( String resolutionIds )
{
- addSingleValue( "fixVersion", fixVersion );
+ addCommaSeparatedValues( "resolution", resolutionIds );
return this;
}
@@ -138,38 +157,23 @@ public class JqlQueryBuilder
return this;
}
- private void addSingleSortColumn( String name )
+ public JiraQueryBuilder statusIds( String statusIds )
{
- boolean descending = false;
- name = name.trim().toLowerCase( Locale.ENGLISH );
- if ( name.endsWith( "desc" ) )
- {
- descending = true;
- name = name.substring( 0, name.length() - 4 ).trim();
- }
- else if ( name.endsWith( "asc" ) )
- {
- descending = false;
- name = name.substring( 0, name.length() - 3 ).trim();
- }
- orderBy.append( name );
- orderBy.append( descending ? " DESC" : " ASC" );
+ addCommaSeparatedValues( "status", statusIds );
+ return this;
}
- private void addSingleValue( String key, String value )
+ public JiraQueryBuilder typeIds( String typeIds )
{
- if ( value != null )
- {
- if ( query.length() > 0 )
- {
- query.append( " AND " );
- }
- query.append( key ).append( " = " );
- trimAndQuoteValue( value );
- }
+ addCommaSeparatedValues( "type", typeIds );
+ return this;
}
+ /* --------------------------------------------------------------------- */
+ /* Private methods */
+ /* --------------------------------------------------------------------- */
+
private void addCommaSeparatedValues( String key, String values )
{
if ( values != null )
@@ -193,47 +197,47 @@ public class JqlQueryBuilder
}
}
- private void trimAndQuoteValue( String value )
+ private void addSingleSortColumn( String name )
{
- String trimmedValue = value.trim();
- if ( trimmedValue.contains( " " ) || trimmedValue.contains( "." ) )
+ boolean descending = false;
+ name = name.trim().toLowerCase( Locale.ENGLISH );
+ if ( name.endsWith( "desc" ) )
{
- query.append( "\"" ).append( trimmedValue ).append( "\"" );
+ descending = true;
+ name = name.substring( 0, name.length() - 4 ).trim();
}
- else
+ else if ( name.endsWith( "asc" ) )
{
- query.append( trimmedValue );
+ descending = false;
+ name = name.substring( 0, name.length() - 3 ).trim();
}
+ orderBy.append( name );
+ orderBy.append( descending ? " DESC" : " ASC" );
}
- public String build()
+ private void addSingleValue( String key, String value )
{
- try
+ if ( value != null )
{
- String jqlQuery;
- // If the user has defined a filter - use that
- if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
- {
- jqlQuery = filter;
- }
- else
+ if ( query.length() > 0 )
{
- jqlQuery = query.toString() + orderBy.toString();
+ query.append( " AND " );
}
- getLog().debug( "Encoding JBL query " + jqlQuery );
- String encodedQuery = URLEncoder.encode( jqlQuery, "UTF-8" );
- getLog().debug( "Encoded JBL query " + encodedQuery );
- return encodedQuery;
- }
- catch ( UnsupportedEncodingException e )
- {
- getLog().error( "Unable to encode JBL query with UTF-8", e );
- throw new RuntimeException( e );
+ query.append( key ).append( " = " );
+ trimAndQuoteValue( value );
}
}
- public Log getLog()
+ private void trimAndQuoteValue( String value )
{
- return log;
+ String trimmedValue = value.trim();
+ if ( trimmedValue.contains( " " ) || trimmedValue.contains( "." ) )
+ {
+ query.append( "\"" ).append( trimmedValue ).append( "\"" );
+ }
+ else
+ {
+ query.append( trimmedValue );
+ }
}
}
Modified:
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
URL:
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java?rev=1379896&r1=1379895&r2=1379896&view=diff
==============================================================================
---
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
(original)
+++
maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/ParameterQueryBuilder.java
Sat Sep 1 23:29:13 2012
@@ -35,17 +35,17 @@ import org.apache.maven.plugin.logging.L
public class ParameterQueryBuilder
implements JiraQueryBuilder
{
+ private String filter = "";
/** Log for debug output. */
protected Log log;
- private String filter = "";
private StringBuilder query = new StringBuilder();
- /** Mapping containing all allowed JIRA status values. */
- protected final Map<String,String> statusMap = new HashMap<String,String>(
8 );
- /** Mapping containing all allowed JIRA resolution values. */
- protected final Map<String,String> resolutionMap = new
HashMap<String,String>( 8 );
/** Mapping containing all allowed JIRA priority values. */
protected final Map<String,String> priorityMap = new
HashMap<String,String>( 8 );
+ /** Mapping containing all allowed JIRA resolution values. */
+ protected final Map<String,String> resolutionMap = new
HashMap<String,String>( 8 );
+ /** Mapping containing all allowed JIRA status values. */
+ protected final Map<String,String> statusMap = new HashMap<String,String>(
8 );
/** Mapping containing all allowed JIRA type values. */
protected final Map<String,String> typeMap = new HashMap<String,String>( 8
);
@@ -53,11 +53,11 @@ public class ParameterQueryBuilder
{
this.log = log;
- statusMap.put( "Open", "1" );
- statusMap.put( "In Progress", "3" );
- statusMap.put( "Reopened", "4" );
- statusMap.put( "Resolved", "5" );
- statusMap.put( "Closed", "6" );
+ priorityMap.put( "Blocker", "1" );
+ priorityMap.put( "Critical", "2" );
+ priorityMap.put( "Major", "3" );
+ priorityMap.put( "Minor", "4" );
+ priorityMap.put( "Trivial", "5" );
resolutionMap.put( "Unresolved", "-1" );
resolutionMap.put( "Fixed", "1" );
@@ -66,11 +66,11 @@ public class ParameterQueryBuilder
resolutionMap.put( "Incomplete", "4" );
resolutionMap.put( "Cannot Reproduce", "5" );
- priorityMap.put( "Blocker", "1" );
- priorityMap.put( "Critical", "2" );
- priorityMap.put( "Major", "3" );
- priorityMap.put( "Minor", "4" );
- priorityMap.put( "Trivial", "5" );
+ statusMap.put( "Open", "1" );
+ statusMap.put( "In Progress", "3" );
+ statusMap.put( "Reopened", "4" );
+ statusMap.put( "Resolved", "5" );
+ statusMap.put( "Closed", "6" );
typeMap.put( "Bug", "1" );
typeMap.put( "New Feature", "2" );
@@ -81,6 +81,44 @@ public class ParameterQueryBuilder
typeMap.put( "Sub-task", "7" );
}
+ public String build()
+ {
+ // If the user has defined a filter - use that
+ if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
+ {
+ return this.filter;
+ }
+ else
+ {
+ return query.toString();
+ }
+ }
+
+ public JiraQueryBuilder components( String components )
+ {
+ // add components
+ if ( components != null )
+ {
+ String[] componentsArr = components.split( "," );
+
+ for ( String component : componentsArr )
+ {
+ component = component.trim();
+ if ( component.length() > 0 )
+ {
+ query.append( "&component=" ).append( component );
+ }
+ }
+ }
+ return this;
+ }
+
+ public JiraQueryBuilder filter( String filter )
+ {
+ this.filter = filter;
+ return this;
+ }
+
/**
* This method has no effect in this implementation.
*/
@@ -107,37 +145,9 @@ public class ParameterQueryBuilder
return this;
}
- public JiraQueryBuilder statusIds( String statusIds )
+ public Log getLog()
{
- // get the Status Ids
- if ( statusIds != null )
- {
- String[] stats = statusIds.split( "," );
- for ( String stat : stats )
- {
- stat = stat.trim();
- String statusParam = statusMap.get( stat );
-
- if ( statusParam != null )
- {
- query.append( "&statusIds=" ).append( statusParam );
- }
- else
- {
- // if it's numeric we can handle it too.
- try
- {
- Integer.parseInt( stat );
- query.append( "&statusIds=" ).append( stat );
- }
- catch ( NumberFormatException nfe )
- {
- getLog().error( "maven-changes-plugin: invalid
statusId " + stat );
- }
- }
- }
- }
- return this;
+ return log;
}
public JiraQueryBuilder priorityIds( String priorityIds )
@@ -190,45 +200,6 @@ public class ParameterQueryBuilder
return this;
}
- public JiraQueryBuilder components( String components )
- {
- // add components
- if ( components != null )
- {
- String[] componentsArr = components.split( "," );
-
- for ( String component : componentsArr )
- {
- component = component.trim();
- if ( component.length() > 0 )
- {
- query.append( "&component=" ).append( component );
- }
- }
- }
- return this;
- }
-
- public JiraQueryBuilder typeIds( String typeIds )
- {
- // get the Type Ids
- if ( typeIds != null )
- {
- String[] types = typeIds.split( "," );
-
- for ( String type : types )
- {
- String typeParam = typeMap.get( type.trim() );
-
- if ( typeParam != null )
- {
- query.append( "&type=" ).append( typeParam );
- }
- }
- }
- return this;
- }
-
public JiraQueryBuilder sortColumnNames( String sortColumnNames )
{
// get the Sort order
@@ -331,27 +302,56 @@ public class ParameterQueryBuilder
return this;
}
- public JiraQueryBuilder filter( String filter )
+ public JiraQueryBuilder statusIds( String statusIds )
{
- this.filter = filter;
+ // get the Status Ids
+ if ( statusIds != null )
+ {
+ String[] stats = statusIds.split( "," );
+ for ( String stat : stats )
+ {
+ stat = stat.trim();
+ String statusParam = statusMap.get( stat );
+
+ if ( statusParam != null )
+ {
+ query.append( "&statusIds=" ).append( statusParam );
+ }
+ else
+ {
+ // if it's numeric we can handle it too.
+ try
+ {
+ Integer.parseInt( stat );
+ query.append( "&statusIds=" ).append( stat );
+ }
+ catch ( NumberFormatException nfe )
+ {
+ getLog().error( "maven-changes-plugin: invalid
statusId " + stat );
+ }
+ }
+ }
+ }
return this;
}
- public String build()
+ public JiraQueryBuilder typeIds( String typeIds )
{
- // If the user has defined a filter - use that
- if ( ( this.filter != null ) && ( this.filter.length() > 0 ) )
- {
- return this.filter;
- }
- else
+ // get the Type Ids
+ if ( typeIds != null )
{
- return query.toString();
- }
- }
+ String[] types = typeIds.split( "," );
- public Log getLog()
- {
- return log;
+ for ( String type : types )
+ {
+ String typeParam = typeMap.get( type.trim() );
+
+ if ( typeParam != null )
+ {
+ query.append( "&type=" ).append( typeParam );
+ }
+ }
+ }
+ return this;
}
}