<commit_before>package gov.nih.nci.cabig.caaers.web.admin;

import gov.nih.nci.cabig.caaers.domain.*;
import gov.nih.nci.cabig.caaers.web.fields.*;
import gov.nih.nci.cabig.caaers.web.fields.validators.FieldValidator;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.validation.Errors;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.HashSet;
import java.util.List;

/**
 * @author <NAME>
 */
public class ResearchStaffTab extends TabWithFields<ResearchStaff> {

    protected static final Log log = LogFactory.getLog(ResearchStaffTab.class);

    private static final String RESEARCH_STAFF_FIELD_GROUP = "researchStaff";

    private static final String SITE_FIELD_GROUP = "site";

    private static final UserGroupType[] ASSIGNABLE_USER_GROUP_TYPES = {
            UserGroupType.caaers_ae_cd, UserGroupType.caaers_participant_cd,
            UserGroupType.caaers_site_cd, UserGroupType.caaers_study_cd };

    public ResearchStaffTab() {
        super("Research Staff Details", "Details", "admin/research_staff_details");
        setAutoPopulateHelpKey(true);
        addHelpKeyExclusion("firstName", "middleName", "lastName", "emailAddress", "phoneNumber",
                        "faxNumber");
    }

    @Override
    public Map<String, Object> referenceData(ResearchStaff staff) {
        Map<String, Object> refdata = super.referenceData(staff);
        // populate information related to USER Groups
        for (UserGroupType type : ASSIGNABLE_USER_GROUP_TYPES) {
            refdata.put(type.name(), staff.isAssociatedToUserGroup(type));
        }
        return refdata;
    }

    @Override
    public void onBind(HttpServletRequest request, ResearchStaff staff, Errors errors) {
        super.onBind(request, staff, errors);

        // populate the user groups correctly.
        staff.getUserGroupTypes().clear();
        for (UserGroupType type : ASSIGNABLE_USER_GROUP_TYPES) {
            if (BooleanUtils.toBoolean(request.getParameter(type.name()))) {
                staff.getUserGroupTypes().add(UserGroupType.valueOf(type.name()));
            }
        }
    }

    @Override
    protected void validate(final ResearchStaff command, final BeanWrapper commandBean,
                    final Map<String, InputFieldGroup> fieldGroups, final Errors errors) {
        super.validate(command, commandBean, fieldGroups, errors);<commit_msg>referenceData - overriding related change,    WorkflowTab's subclass should override from referenceData(HttpServletRequest, Command)<commit_after>package gov.nih.nci.cabig.caaers.web.admin;

import gov.nih.nci.cabig.caaers.domain.*;
import gov.nih.nci.cabig.caaers.web.fields.*;
import gov.nih.nci.cabig.caaers.web.fields.validators.FieldValidator;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanWrapper;
import org.springframework.validation.Errors;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;
import java.util.HashSet;
import java.util.List;

/**
 * @author <NAME>
 */
public class ResearchStaffTab extends TabWithFields<ResearchStaff> {

    protected static final Log log = LogFactory.getLog(ResearchStaffTab.class);

    private static final String RESEARCH_STAFF_FIELD_GROUP = "researchStaff";

    private static final String SITE_FIELD_GROUP = "site";

    private static final UserGroupType[] ASSIGNABLE_USER_GROUP_TYPES = {
            UserGroupType.caaers_ae_cd, UserGroupType.caaers_participant_cd,
            UserGroupType.caaers_site_cd, UserGroupType.caaers_study_cd };

    public ResearchStaffTab() {
        super("Research Staff Details", "Details", "admin/research_staff_details");
        setAutoPopulateHelpKey(true);
        addHelpKeyExclusion("firstName", "middleName", "lastName", "emailAddress", "phoneNumber",
                        "faxNumber");
    }

    @Override
    public Map<String, Object> referenceData(HttpServletRequest request, ResearchStaff staff) {
        Map<String, Object> refdata = super.referenceData(staff);
        // populate information related to USER Groups
        for (UserGroupType type : ASSIGNABLE_USER_GROUP_TYPES) {
            refdata.put(type.name(), staff.isAssociatedToUserGroup(type));
        }
        return refdata;
    }

    @Override
    public void onBind(HttpServletRequest request, ResearchStaff staff, Errors errors) {
        super.onBind(request, staff, errors);

        // populate the user groups correctly.
        staff.getUserGroupTypes().clear();
        for (UserGroupType type : ASSIGNABLE_USER_GROUP_TYPES) {
            if (BooleanUtils.toBoolean(request.getParameter(type.name()))) {
                staff.getUserGroupTypes().add(UserGroupType.valueOf(type.name()));
            }
        }
    }

    @Override
    protected void validate(final ResearchStaff command, final BeanWrapper commandBean,
                    final Map<String, InputFieldGroup> fieldGroups, final Errors errors) {
        super.validate(command, commandBean, fieldGroups, errors);
{'fraction_non_alphanumeric': 0.09895138226882745, 'fraction_numerical': 0.0, 'mean_word_length': 3.650709219858156, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2019511', 'n_tokens_mistral': 1537, 'n_tokens_neox': 1482, 'n_words': 297}