mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 07:55:47 +01:00
improve manager paging api
This commit is contained in:
@@ -38,6 +38,7 @@ package sonia.scm;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -86,15 +87,26 @@ public interface Manager<T extends ModelObject, E extends Exception>
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param sortby
|
||||
* @param desc
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
* @since 1.4
|
||||
*/
|
||||
public Collection<T> getAll(String sortby, boolean desc, int start,
|
||||
int limit);
|
||||
public Collection<T> getAll(int start, int limit);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param comparator
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
* @since 1.4
|
||||
*/
|
||||
public Collection<T> getAll(Comparator<T> comparator, int start, int limit);
|
||||
}
|
||||
|
||||
@@ -505,7 +505,9 @@ public abstract class AbstractManagerResource<T extends ModelObject,
|
||||
|
||||
if (limit > 0)
|
||||
{
|
||||
items = manager.getAll(sortby, desc, start, limit);
|
||||
|
||||
// TODO create comparator
|
||||
items = manager.getAll(start, limit);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -63,6 +63,7 @@ import sonia.scm.util.Util;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
@@ -367,20 +368,18 @@ public class XmlGroupManager extends AbstractGroupManager
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sortby
|
||||
* @param desc
|
||||
*
|
||||
* @param comparator
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Group> getAll(String sortby, boolean desc, int start,
|
||||
public Collection<Group> getAll(Comparator<Group> comparator, int start,
|
||||
int limit)
|
||||
{
|
||||
|
||||
// TODO sort
|
||||
return Util.createSubCollection(groupDB.values(),
|
||||
return Util.createSubCollection(groupDB.values(), comparator,
|
||||
new CollectionAppender<Group>()
|
||||
{
|
||||
@Override
|
||||
@@ -391,6 +390,21 @@ public class XmlGroupManager extends AbstractGroupManager
|
||||
}, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Group> getAll(int start, int limit)
|
||||
{
|
||||
return getAll(null, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -71,6 +71,7 @@ import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
@@ -400,20 +401,18 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sortby
|
||||
* @param desc
|
||||
*
|
||||
* @param comparator
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Repository> getAll(String sortby, boolean desc, int start,
|
||||
int limit)
|
||||
public Collection<Repository> getAll(Comparator<Repository> comparator,
|
||||
int start, int limit)
|
||||
{
|
||||
|
||||
// TODO sort
|
||||
return Util.createSubCollection(repositoryDB.values(),
|
||||
return Util.createSubCollection(repositoryDB.values(), comparator,
|
||||
new CollectionAppender<Repository>()
|
||||
{
|
||||
@Override
|
||||
@@ -424,6 +423,21 @@ public class XmlRepositoryManager extends AbstractRepositoryManager
|
||||
}, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<Repository> getAll(int start, int limit)
|
||||
{
|
||||
return getAll(null, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -69,6 +69,7 @@ import java.io.InputStream;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -411,20 +412,18 @@ public class XmlUserManager extends AbstractUserManager
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sortby
|
||||
* @param desc
|
||||
*
|
||||
* @param comaparator
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<User> getAll(String sortby, boolean desc, int start,
|
||||
public Collection<User> getAll(Comparator<User> comaparator, int start,
|
||||
int limit)
|
||||
{
|
||||
|
||||
// TODO sort
|
||||
return Util.createSubCollection(userDB.values(),
|
||||
return Util.createSubCollection(userDB.values(), comaparator,
|
||||
new CollectionAppender<User>()
|
||||
{
|
||||
@Override
|
||||
@@ -435,6 +434,21 @@ public class XmlUserManager extends AbstractUserManager
|
||||
}, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param start
|
||||
* @param limit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Collection<User> getAll(int start, int limit)
|
||||
{
|
||||
return getAll(null, start, limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user