Search in sources :

Example 1 with SearchTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest in project Taskzilla by CMPUT301W18T05.

the class RequestManagerTest method testSearchTaskRequest.

public void testSearchTaskRequest() {
    addUser();
    addTask();
    String keywords = task.getDescription();
    SearchTaskRequest request = new SearchTaskRequest(keywords);
    RequestManager.getInstance().invokeRequest(ctx, request);
    assertNotNull(request.getTasks());
    System.out.println("------- Search output -------");
    System.out.println("******************************");
    ArrayList<Task> ret = request.getTasks();
    System.out.println(ret);
    for (Task t : ret) {
        System.out.println(t);
        Log.i("Found Task", t.getId());
    }
}
Also used : SearchTaskRequest(com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest)

Example 2 with SearchTaskRequest

use of com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest in project Taskzilla by CMPUT301W18T05.

the class SearchController method searchRequest.

/**
 * This method invokes a search request using the given keywords, which is then sent
 * to the request manager which determines if the app is online or offline, before doing
 * the request.
 *
 * @param sentence  string of keywords
 * @see             RequestManager
 */
public void searchRequest(String sentence) {
    newRequest = new SearchTaskRequest(sentence);
    RequestManager.getInstance().invokeRequest(ctx, newRequest);
    ArrayList<Task> temp;
    temp = newRequest.getTasks();
    if (temp != null && temp.size() != 0) {
        while (temp.size() > 0) {
            for (Task t : temp) if (!t.getStatus().equalsIgnoreCase("assigned") && !t.getStatus().equalsIgnoreCase("completed")) {
                this.searchResults.add(t);
            }
            RequestManager.getInstance().invokeRequest(ctx, newRequest);
            temp = newRequest.getTasks();
        }
    } else if (temp == null) {
        Toast.makeText(view.getActivity(), "Unable to search right now.", Toast.LENGTH_SHORT).show();
    } else {
        searchResults.clear();
    }
    view.notifyChange();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task) SearchTaskRequest(com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest)

Aggregations

SearchTaskRequest (com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest)2 Task (com.cmput301w18t05.taskzilla.Task)1