You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ct...@apache.org on 2009/04/02 05:20:39 UTC
svn commit: r761151 - in
/continuum/branches/continuum-1.3.x/continuum-webapp/src/main:
java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
webapp/WEB-INF/jsp/projectGroupMembers.jsp
Author: ctan
Date: Thu Apr 2 03:20:37 2009
New Revision: 761151
URL: http://svn.apache.org/viewvc?rev=761151&view=rev
Log:
[CONTINUUM-2156] fixed sorting of username in Members tab
Submitted By: Jose Morales Martinez
Modified:
continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp
Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java?rev=761151&r1=761150&r2=761151&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java (original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ProjectGroupAction.java Thu Apr 2 03:20:37 2009
@@ -22,12 +22,14 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.ComparatorUtils;
import org.apache.continuum.buildmanager.BuildManagerException;
import org.apache.continuum.buildmanager.BuildsManager;
import org.apache.continuum.model.project.ProjectScmRoot;
@@ -113,6 +115,9 @@
private String filterProperty;
private String filterKey;
+
+ //Default order is by username
+ private String sorterProperty = "username";
private boolean ascending = true;
@@ -700,9 +705,13 @@
logger.error( "Can't get the users list", e );
}
- if ( !StringUtils.isEmpty( filterKey ) )
+ if ( StringUtils.isNotBlank( filterKey ) )
{
- users = findUsers( users, filterProperty, filterKey, ascending );
+ users = findUsers( users, filterProperty, filterKey );
+ }
+ if ( StringUtils.isNotBlank( sorterProperty ) )
+ {
+ sortUsers( users, sorterProperty, ascending );
}
projectGroupUsers = new ArrayList();
@@ -747,7 +756,7 @@
}
}
- private List<User> findUsers( List<User> users, String searchProperty, String searchKey, boolean orderAscending )
+ private List<User> findUsers( List<User> users, String searchProperty, String searchKey)
{
List<User> userList = new ArrayList<User>();
for ( User user : users )
@@ -789,6 +798,37 @@
return userList;
}
+
+ private void sortUsers( List<User> userList, final String sorterProperty, final boolean orderAscending )
+ {
+ Collections.sort( userList, new Comparator<User>()
+ {
+ public int compare( User o1, User o2 )
+ {
+ String value1, value2;
+ if ( "fullName".equals( sorterProperty ) )
+ {
+ value1 = o1.getFullName();
+ value2 = o2.getFullName();
+ }
+ else if ( "email".equals( sorterProperty ) )
+ {
+ value1 = o1.getEmail();
+ value2 = o2.getEmail();
+ }
+ else
+ {
+ value1 = o1.getUsername();
+ value2 = o2.getUsername();
+ }
+ if ( orderAscending )
+ {
+ return ComparatorUtils.nullLowComparator( null ).compare( value1, value2 );
+ }
+ return ComparatorUtils.nullLowComparator( null ).compare( value2, value1 );
+ }
+ } );
+ }
public int getProjectGroupId()
{
@@ -1047,4 +1087,14 @@
return false;
}
}
+
+ public String getSorterProperty()
+ {
+ return sorterProperty;
+ }
+
+ public void setSorterProperty( String sorterProperty )
+ {
+ this.sorterProperty = sorterProperty;
+ }
}
Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp?rev=761151&r1=761150&r2=761151&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp (original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/webapp/WEB-INF/jsp/projectGroupMembers.jsp Thu Apr 2 03:20:37 2009
@@ -149,10 +149,11 @@
<s:else>
<s:a href="javascript:document.forms['sortlist'].submit()"><img src="<s:url value='/images/icon_sortup.gif' includeParams="none"/>" title="<s:text name='sort.ascending'/>" border="0"></s:a> <s:text name="user.username.label"/>
</s:else>
- <s:hidden name="ascending">${!ascending}</s:hidden>
+ <s:hidden name="ascending" value="%{!ascending}"/>
<s:hidden name="projectGroupId" />
- <s:hidden name="filterProperty" />
- <s:hidden name="filterKey" />
+ <s:hidden name="sorterProperty" value="username"/>
+ <s:hidden name="filterKey" value="%{filterKey}"/>
+ <s:hidden name="filterProperty" value="%{filterProperty}"/>
</s:form>
</th>
<th><s:text name="user.fullName.label"/></th>