mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
add autocomplete endpoint
This commit is contained in:
@@ -41,11 +41,13 @@ import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.GenericDAO;
|
||||
import sonia.scm.ModelObject;
|
||||
import sonia.scm.group.xml.XmlGroupDAO;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
import sonia.scm.store.ConfigurationStore;
|
||||
import sonia.scm.util.AssertUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import sonia.scm.store.ConfigurationStore;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -234,6 +236,16 @@ public abstract class AbstractXmlDAO<I extends ModelObject,
|
||||
return ImmutableList.copyOf(db.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<I> getFiltered(String searched, int limit) {
|
||||
int size = db.values().size();
|
||||
AssertUtil.assertIsNotEmpty(searched);
|
||||
return ImmutableList.copyOf(db.values().stream()
|
||||
.filter(item -> item.getId().contains(searched) || (item.getDisplayName() != null && item.getDisplayName().contains(searched)))
|
||||
.limit(limit <= 0 ? size : limit)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user