mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
improve manager sort api
This commit is contained in:
@@ -83,6 +83,17 @@ public interface Manager<T extends ModelObject, E extends Exception>
|
|||||||
*/
|
*/
|
||||||
public Collection<T> getAll();
|
public Collection<T> getAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param comparator
|
||||||
|
* @return
|
||||||
|
* @since 1.4
|
||||||
|
*/
|
||||||
|
public Collection<T> getAll(Comparator<T> comparator);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -62,9 +62,12 @@ import sonia.scm.util.Util;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -351,16 +354,35 @@ public class XmlGroupManager extends AbstractGroupManager
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Group> getAll()
|
public Collection<Group> getAll()
|
||||||
|
{
|
||||||
|
return getAll(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param comparator
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Collection<Group> getAll(Comparator<Group> comparator)
|
||||||
{
|
{
|
||||||
SecurityUtil.assertIsAdmin(securityContextProvider);
|
SecurityUtil.assertIsAdmin(securityContextProvider);
|
||||||
|
|
||||||
LinkedList<Group> groups = new LinkedList<Group>();
|
List<Group> groups = new ArrayList<Group>();
|
||||||
|
|
||||||
for (Group group : groupDB.values())
|
for (Group group : groupDB.values())
|
||||||
{
|
{
|
||||||
groups.add(group.clone());
|
groups.add(group.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comparator != null)
|
||||||
|
{
|
||||||
|
Collections.sort(groups, comparator);
|
||||||
|
}
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,10 +71,10 @@ import java.io.IOException;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -377,12 +377,14 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
|||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* @param comparator
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<Repository> getAll()
|
public Collection<Repository> getAll(Comparator<Repository> comparator)
|
||||||
{
|
{
|
||||||
LinkedList<Repository> repositories = new LinkedList<Repository>();
|
List<Repository> repositories = new ArrayList<Repository>();
|
||||||
|
|
||||||
for (Repository repository : repositoryDB.values())
|
for (Repository repository : repositoryDB.values())
|
||||||
{
|
{
|
||||||
@@ -394,9 +396,26 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comparator != null)
|
||||||
|
{
|
||||||
|
Collections.sort(repositories, comparator);
|
||||||
|
}
|
||||||
|
|
||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Collection<Repository> getAll()
|
||||||
|
{
|
||||||
|
return getAll(null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -395,16 +396,35 @@ public class XmlUserManager extends AbstractUserManager
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Collection<User> getAll()
|
public Collection<User> getAll()
|
||||||
|
{
|
||||||
|
return getAll(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method description
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param comparator
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Collection<User> getAll(Comparator<User> comparator)
|
||||||
{
|
{
|
||||||
SecurityUtil.assertIsAdmin(scurityContextProvider);
|
SecurityUtil.assertIsAdmin(scurityContextProvider);
|
||||||
|
|
||||||
LinkedList<User> users = new LinkedList<User>();
|
List<User> users = new ArrayList<User>();
|
||||||
|
|
||||||
for (User user : userDB.values())
|
for (User user : userDB.values())
|
||||||
{
|
{
|
||||||
users.add(user.clone());
|
users.add(user.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comparator != null)
|
||||||
|
{
|
||||||
|
Collections.sort(users, comparator);
|
||||||
|
}
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user