Search in sources :

Example 1 with LiveSearchCallback

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchService method search.

@Override
public void search(final String pattern, final int maxResults, final LiveSearchCallback<String> callback) {
    final List<String> filteredCustomEntries;
    if (pattern == null || pattern.isEmpty()) {
        filteredCustomEntries = customEntries;
    } else {
        filteredCustomEntries = customEntries.stream().filter(entry -> entry.contains(pattern)).collect(Collectors.toList());
    }
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> processFilterResponse(response, filteredCustomEntries, maxResults, callback);
    ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
    SearchRequestImpl request = new SearchRequestImpl(pattern, 1, maxResults);
    if (AssigneeType.USER.equals(type)) {
        userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
    } else {
        userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) Group(org.jboss.errai.security.shared.api.Group) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) Collectors(java.util.stream.Collectors) EntryCreationLiveSearchService(org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) Inject(javax.inject.Inject) List(java.util.List) Message(org.jboss.errai.bus.client.api.messaging.Message) Dependent(javax.enterprise.context.Dependent) AbstractEntityManager(org.uberfire.ext.security.management.api.AbstractEntityManager) User(org.jboss.errai.security.shared.api.identity.User) Optional(java.util.Optional) LiveSearchCallback(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback) AssigneeType(org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType) ClientUserSystemManager(org.uberfire.ext.security.management.client.ClientUserSystemManager) Message(org.jboss.errai.bus.client.api.messaging.Message) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl)

Example 2 with LiveSearchCallback

use of org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback in project kie-wb-common by kiegroup.

the class AssigneeLiveSearchService method searchEntry.

@Override
public void searchEntry(String key, LiveSearchCallback<String> callback) {
    SearchRequestImpl request = new SearchRequestImpl(key, 1, 1);
    ErrorCallback<Message> searchErrorCallback = (message, throwable) -> processError(callback);
    RemoteCallback<AbstractEntityManager.SearchResponse<?>> searchResponseRemoteCallback = response -> searchEntry(key, response, callback);
    if (AssigneeType.USER.equals(type)) {
        userSystemManager.users(searchResponseRemoteCallback, searchErrorCallback).search(request);
    } else {
        userSystemManager.groups(searchResponseRemoteCallback, searchErrorCallback).search(request);
    }
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) Group(org.jboss.errai.security.shared.api.Group) Set(java.util.Set) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl) Collectors(java.util.stream.Collectors) EntryCreationLiveSearchService(org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) LiveSearchResults(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults) Inject(javax.inject.Inject) List(java.util.List) Message(org.jboss.errai.bus.client.api.messaging.Message) Dependent(javax.enterprise.context.Dependent) AbstractEntityManager(org.uberfire.ext.security.management.api.AbstractEntityManager) User(org.jboss.errai.security.shared.api.identity.User) Optional(java.util.Optional) LiveSearchCallback(org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback) AssigneeType(org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType) ClientUserSystemManager(org.uberfire.ext.security.management.client.ClientUserSystemManager) Message(org.jboss.errai.bus.client.api.messaging.Message) SearchRequestImpl(org.uberfire.ext.security.management.impl.SearchRequestImpl)

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 Collectors (java.util.stream.Collectors)2 Dependent (javax.enterprise.context.Dependent)2 Inject (javax.inject.Inject)2 Message (org.jboss.errai.bus.client.api.messaging.Message)2 ErrorCallback (org.jboss.errai.common.client.api.ErrorCallback)2 RemoteCallback (org.jboss.errai.common.client.api.RemoteCallback)2 Group (org.jboss.errai.security.shared.api.Group)2 User (org.jboss.errai.security.shared.api.identity.User)2 AssigneeType (org.kie.workbench.common.stunner.bpmn.forms.model.AssigneeType)2 AbstractEntityManager (org.uberfire.ext.security.management.api.AbstractEntityManager)2 ClientUserSystemManager (org.uberfire.ext.security.management.client.ClientUserSystemManager)2 SearchRequestImpl (org.uberfire.ext.security.management.impl.SearchRequestImpl)2 EntryCreationLiveSearchService (org.uberfire.ext.widgets.common.client.dropdown.EntryCreationLiveSearchService)2 LiveSearchCallback (org.uberfire.ext.widgets.common.client.dropdown.LiveSearchCallback)2 LiveSearchResults (org.uberfire.ext.widgets.common.client.dropdown.LiveSearchResults)2