use of com.willshex.blogwt.shared.api.search.call.SearchAllRequest in project blogwt by billy1380.
the class SearchService method searchAll.
public Request searchAll(SearchAllRequest input, AsyncSuccess<SearchAllRequest, SearchAllResponse> onSuccess, AsyncFailure<SearchAllRequest> onFailure) {
Request handle = null;
try {
handle = sendRequest(SearchMethodSearchAll, input, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
try {
SearchAllResponse outputParameter = new SearchAllResponse();
parseResponse(response, outputParameter);
if (onSuccess != null) {
onSuccess.call(input, outputParameter);
}
onCallSuccess(SearchService.this, SearchMethodSearchAll, input, outputParameter);
} catch (JSONException | HttpException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(SearchService.this, SearchMethodSearchAll, input, exception);
}
}
@Override
public void onError(Request request, Throwable exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(SearchService.this, SearchMethodSearchAll, input, exception);
}
});
onCallStart(SearchService.this, SearchMethodSearchAll, input, handle);
} catch (RequestException exception) {
if (onFailure != null) {
onFailure.call(input, exception);
}
onCallFailure(SearchService.this, SearchMethodSearchAll, input, exception);
}
return handle;
}
use of com.willshex.blogwt.shared.api.search.call.SearchAllRequest in project blogwt by billy1380.
the class SearchJsonServlet method processAction.
@Override
protected String processAction(String action, JsonObject request) {
String output = "null";
if ("SearchAll".equals(action)) {
SearchAllRequest input = new SearchAllRequest();
input.fromJson(request);
output = new SearchAllActionHandler().handle(input).toString();
}
return output;
}
use of com.willshex.blogwt.shared.api.search.call.SearchAllRequest in project blogwt by billy1380.
the class SearchController method fetchSearchResults.
private void fetchSearchResults(String query) {
final SearchAllRequest input = ApiHelper.setAccessCode(new SearchAllRequest());
input.session = SessionController.get().sessionForApiCall();
input.query = query;
if (searchAllRequest != null) {
searchAllRequest.cancel();
}
searchAllRequest = ApiHelper.createSearchClient().searchAll(input, new AsyncCallback<SearchAllResponse>() {
@Override
public void onSuccess(SearchAllResponse output) {
searchAllRequest = null;
if (output.status == StatusType.StatusTypeSuccess) {
List<SearchResult> results = new ArrayList<SearchController.SearchResult>();
if (output.posts != null) {
for (Post post : output.posts) {
results.add(new SearchResult(post));
}
}
if (output.pages != null) {
for (Page page : output.pages) {
results.add(new SearchResult(page));
}
}
if (output.users != null) {
for (User user : output.users) {
results.add(new SearchResult(user));
}
}
updateRowCount(results.size(), true);
updateRowData(0, results);
}
DefaultEventBus.get().fireEventFromSource(new SearchAllSuccess(input, output), SearchController.this);
}
@Override
public void onFailure(Throwable caught) {
searchAllRequest = null;
DefaultEventBus.get().fireEventFromSource(new SearchAllFailure(input, caught), SearchController.this);
}
});
}
Aggregations