Search in sources :

Example 1 with InstructorSearchPageData

use of teammates.ui.pagedata.InstructorSearchPageData in project teammates by TEAMMATES.

the class InstructorSearchPageAction method execute.

@Override
protected ActionResult execute() {
    gateKeeper.verifyInstructorPrivileges(account);
    String searchKey = getRequestParamValue(Const.ParamsNames.SEARCH_KEY);
    if (searchKey == null) {
        searchKey = "";
    }
    int numberOfSearchOptions = 0;
    boolean isSearchForStudents = getRequestParamAsBoolean(Const.ParamsNames.SEARCH_STUDENTS);
    if (isSearchForStudents) {
        numberOfSearchOptions++;
    }
    boolean isSearchFeedbackSessionData = getRequestParamAsBoolean(Const.ParamsNames.SEARCH_FEEDBACK_SESSION_DATA);
    if (isSearchFeedbackSessionData) {
        numberOfSearchOptions++;
    }
    FeedbackResponseCommentSearchResultBundle frCommentSearchResults = new FeedbackResponseCommentSearchResultBundle();
    StudentSearchResultBundle studentSearchResults = new StudentSearchResultBundle();
    int totalResultsSize = 0;
    if (searchKey.isEmpty() || numberOfSearchOptions == 0) {
        // display search tips and tutorials
        statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_SEARCH_TIPS, StatusMessageColor.INFO));
    } else {
        // Start searching
        List<InstructorAttributes> instructors = logic.getInstructorsForGoogleId(account.googleId);
        if (isSearchFeedbackSessionData) {
            frCommentSearchResults = logic.searchFeedbackResponseComments(searchKey, instructors);
        }
        if (isSearchForStudents) {
            studentSearchResults = logic.searchStudents(searchKey, instructors);
        }
        totalResultsSize = frCommentSearchResults.numberOfResults + studentSearchResults.numberOfResults;
        Set<String> instructorEmails = new HashSet<>();
        for (InstructorAttributes instructor : instructors) {
            instructorEmails.add(instructor.email);
        }
        if (totalResultsSize == 0) {
            statusToUser.add(new StatusMessage(Const.StatusMessages.INSTRUCTOR_SEARCH_NO_RESULTS, StatusMessageColor.WARNING));
        }
    }
    InstructorSearchPageData data = new InstructorSearchPageData(account, sessionToken);
    data.init(frCommentSearchResults, studentSearchResults, searchKey, isSearchFeedbackSessionData, isSearchForStudents);
    return createShowPageResult(Const.ViewURIs.INSTRUCTOR_SEARCH, data);
}
Also used : StudentSearchResultBundle(teammates.common.datatransfer.StudentSearchResultBundle) InstructorSearchPageData(teammates.ui.pagedata.InstructorSearchPageData) FeedbackResponseCommentSearchResultBundle(teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle) StatusMessage(teammates.common.util.StatusMessage) InstructorAttributes(teammates.common.datatransfer.attributes.InstructorAttributes) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 FeedbackResponseCommentSearchResultBundle (teammates.common.datatransfer.FeedbackResponseCommentSearchResultBundle)1 StudentSearchResultBundle (teammates.common.datatransfer.StudentSearchResultBundle)1 InstructorAttributes (teammates.common.datatransfer.attributes.InstructorAttributes)1 StatusMessage (teammates.common.util.StatusMessage)1 InstructorSearchPageData (teammates.ui.pagedata.InstructorSearchPageData)1