Search in sources :

Example 1 with RequestManager

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

the class SearchController method getAllRequest.

/**
 * This method invokes a get all request, which is then sent
 * to the request manager which determines if the app is online or offline,
 * before doing the request.
 *
 * @see             RequestManager
 */
public void getAllRequest() {
    GetAllTasksRequest request = new GetAllTasksRequest();
    RequestManager.getInstance().invokeRequest(ctx, request);
    searchResults.clear();
    ArrayList<Task> temp;
    temp = request.getResult();
    System.out.println("Search result is: " + temp);
    while (temp != null && temp.size() > 0) {
        for (Task t : temp) {
            if (!t.getStatus().equalsIgnoreCase("assigned") && !t.getStatus().equalsIgnoreCase("completed")) {
                this.searchResults.add(t);
            }
        }
        RequestManager.getInstance().invokeRequest(ctx, request);
        temp = request.getResult();
    }
    view.notifyChange();
}
Also used : Task(com.cmput301w18t05.taskzilla.Task) GetAllTasksRequest(com.cmput301w18t05.taskzilla.request.command.GetAllTasksRequest)

Example 2 with RequestManager

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

the class ProfileController method updateUserRequest.

/**
 * getUserRequest
 * get user from RequestManager and set the
 * user to be the result for the controller
 *
 * @author Micheal-Nguyen
 */
public void updateUserRequest(User user) {
    AddUserRequest request = new AddUserRequest(user);
    RequestManager.getInstance().invokeRequest(ctx, request);
}
Also used : AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 3 with RequestManager

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

the class SignUpActivity method addUserToDB.

/**
 * This method takes the user object created and adds it to the elastic search
 * database.
 * <p>
 * This method returns false if the username the user is trying to use is already in the databse.
 *
 * @return  boolean value to determine if user was successfully added or not
 * @see     AddUserRequest
 * @see     RequestManager
 */
public boolean addUserToDB() {
    RequestManager requestManager = RequestManager.getInstance();
    AddUserRequest addUserRequest = new AddUserRequest(newUser);
    requestManager.invokeRequest(addUserRequest);
    return addUserRequest.getResult();
}
Also used : RequestManager(com.cmput301w18t05.taskzilla.request.RequestManager) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 4 with RequestManager

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

the class NotificationManager method sendNotification.

/**
 *  This method invokes a request to the requestmanager which inserts the notification to the
 *  elasticsearch server
 *
 * @param notification  Notification to be inserted
 * @see   AddNotificationRequest
 */
public void sendNotification(Notification notification) {
    AddNotificationRequest task = new AddNotificationRequest(notification);
    RequestManager.getInstance().invokeRequest(task);
}
Also used : AddNotificationRequest(com.cmput301w18t05.taskzilla.request.command.AddNotificationRequest)

Example 5 with RequestManager

use of com.cmput301w18t05.taskzilla.request.RequestManager 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

Task (com.cmput301w18t05.taskzilla.Task)2 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)2 RequestManager (com.cmput301w18t05.taskzilla.request.RequestManager)1 AddNotificationRequest (com.cmput301w18t05.taskzilla.request.command.AddNotificationRequest)1 GetAllTasksRequest (com.cmput301w18t05.taskzilla.request.command.GetAllTasksRequest)1 SearchTaskRequest (com.cmput301w18t05.taskzilla.request.command.SearchTaskRequest)1