<commit_before>package edu.northwestern.bioinformatics.studycalendar.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import edu.northwestern.bioinformatics.studycalendar.dao.SiteDao;
import edu.northwestern.bioinformatics.studycalendar.dao.StudyDao;
import edu.northwestern.bioinformatics.studycalendar.domain.Site;
import edu.northwestern.bioinformatics.studycalendar.domain.Study;
import edu.northwestern.bioinformatics.studycalendar.service.SiteService;
import edu.northwestern.bioinformatics.studycalendar.service.TemplateService;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.AccessControl;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarAuthorizationManager;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarProtectionGroup;
import gov.nih.nci.security.authorization.domainobjects.User;

/**
 * @author <NAME>
 * @author <NAME>
 *
 */

@AccessControl(protectionGroups = StudyCalendarProtectionGroup.SITE_COORDINATOR)
public class ParticipantCoordinatorsBySiteController extends PscAbstractController {

    private SiteDao siteDao;
    private StudyDao studyDao;
    private TemplateService templateService;
    static Log log = LogFactory.getLog(ParticipantCoordinatorsBySiteController.class);

    public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Site site = siteDao.getById(ServletRequestUtils.getRequiredIntParameter(request, "site"));
        Study study = studyDao.getById(ServletRequestUtils.getRequiredIntParameter(request, "study"));
        Map<String, List<User>> userLists = templateService.getParticipantCoordinators(study, site);
        log.debug("+++" + userLists);
        Map model = new HashMap();
        model.put("assigned", userLists.get(StudyCalendarAuthorizationManager.ASSIGNED_USERS));
        model.put("available", userLists.get(StudyCalendarAuthorizationManager.AVAILABLE_USERS));
        model.put("site", site);
        return new ModelAndView("admin/ajax/participantCoordinatorsBySite", model);
    }

    @Required
    public void setSiteDao(SiteDao siteDao) {
        this.siteDao = siteDao;
    }

    @Required
    public void setStudyDao(StudyDao studyDao) {
        this.studyDao = studyDao;<commit_msg>This is an ajax controller, so it shouldn't implement CrumbSource<commit_after>package edu.northwestern.bioinformatics.studycalendar.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.web.bind.ServletRequestUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.mvc.AbstractController;

import edu.northwestern.bioinformatics.studycalendar.dao.SiteDao;
import edu.northwestern.bioinformatics.studycalendar.dao.StudyDao;
import edu.northwestern.bioinformatics.studycalendar.domain.Site;
import edu.northwestern.bioinformatics.studycalendar.domain.Study;
import edu.northwestern.bioinformatics.studycalendar.service.SiteService;
import edu.northwestern.bioinformatics.studycalendar.service.TemplateService;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.AccessControl;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarAuthorizationManager;
import edu.northwestern.bioinformatics.studycalendar.utils.accesscontrol.StudyCalendarProtectionGroup;
import gov.nih.nci.security.authorization.domainobjects.User;

/**
 * @author <NAME>
 * @author <NAME>
 *
 */

@AccessControl(protectionGroups = StudyCalendarProtectionGroup.SITE_COORDINATOR)
public class ParticipantCoordinatorsBySiteController extends AbstractController {
    private SiteDao siteDao;
    private StudyDao studyDao;
    private TemplateService templateService;
    static Log log = LogFactory.getLog(ParticipantCoordinatorsBySiteController.class);

    public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        Site site = siteDao.getById(ServletRequestUtils.getRequiredIntParameter(request, "site"));
        Study study = studyDao.getById(ServletRequestUtils.getRequiredIntParameter(request, "study"));
        Map<String, List<User>> userLists = templateService.getParticipantCoordinators(study, site);
        log.debug("+++" + userLists);
        Map model = new HashMap();
        model.put("assigned", userLists.get(StudyCalendarAuthorizationManager.ASSIGNED_USERS));
        model.put("available", userLists.get(StudyCalendarAuthorizationManager.AVAILABLE_USERS));
        model.put("site", site);
        return new ModelAndView("admin/ajax/participantCoordinatorsBySite", model);
    }

    @Required
    public void setSiteDao(SiteDao siteDao) {
        this.siteDao = siteDao;
    }

    @Required
    public void setStudyDao(StudyDao studyDao) {
        this.studyDao = studyDao;
{'fraction_non_alphanumeric': 0.09144072301967039, 'fraction_numerical': 0.0, 'mean_word_length': 5.882926829268293, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2775441', 'n_tokens_mistral': 1615, 'n_tokens_neox': 1538, 'n_words': 248}