Search in sources :

Example 56 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class RestODMFilter method checkAuth.

private Boolean checkAuth(StudyBean studyBean, UserAccountBean userBean) {
    Boolean auth = false;
    StudyUserRoleBean studyRole = getRoleByStudy(studyBean, getDataSource(), userBean);
    Role r = studyRole.getRole();
    if (r != null) {
        // r = userBean.getActiveStudyRole();
        if (r != null && (r.equals(Role.COORDINATOR) || r.equals(Role.STUDYDIRECTOR))) {
            auth = true;
        }
        //{
        if (r != null && (r.equals(Role.ADMIN) || r.equals(Role.COORDINATOR) || r.equals(Role.STUDYDIRECTOR) || r.equals(Role.INVESTIGATOR) || r.equals(Role.MONITOR) || r.equals(Role.RESEARCHASSISTANT) || r.equals(Role.RESEARCHASSISTANT2))) {
            auth = true;
        }
    //}
    }
    return auth;
}
Also used : Role(org.akaza.openclinica.bean.core.Role) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean)

Example 57 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class StudyUserRoleRow method compareColumn.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.core.EntityBeanRow#compareColumn(java.lang.Object,
     *      int)
     */
@Override
protected int compareColumn(Object row, int sortingColumn) {
    if (!row.getClass().equals(StudyUserRoleRow.class)) {
        return 0;
    }
    StudyUserRoleBean thisAccount = (StudyUserRoleBean) bean;
    StudyUserRoleBean argAccount = (StudyUserRoleBean) ((StudyUserRoleRow) row).bean;
    int answer = 0;
    switch(sortingColumn) {
        case COL_USERNAME:
            answer = thisAccount.getUserName().toLowerCase().compareTo(argAccount.getUserName().toLowerCase());
            break;
        case COL_FIRSTNAME:
            answer = thisAccount.getFirstName().toLowerCase().compareTo(argAccount.getFirstName().toLowerCase());
            break;
        case COL_LASTNAME:
            answer = thisAccount.getLastName().toLowerCase().compareTo(argAccount.getLastName().toLowerCase());
            break;
        case COL_ROLE:
            answer = thisAccount.getRoleName().toLowerCase().compareTo(argAccount.getRoleName().toLowerCase());
            break;
        case COL_STUDYNAME:
            answer = thisAccount.getStudyName().toLowerCase().compareTo(argAccount.getStudyName().toLowerCase());
            break;
        case COL_STATUS:
            answer = thisAccount.getStatus().compareTo(argAccount.getStatus());
            break;
    }
    return answer;
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean)

Example 58 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class SetUpStudyRole method setUp.

public void setUp(HttpSession httpSession, UserAccountBean userAccountBean) {
    StudyUserRoleBean currentRole = new StudyUserRoleBean();
    StudyBean currentStudy = new StudyBean();
    StudyInfoPanel panel = new StudyInfoPanel();
    StudyDAO sdao = new StudyDAO(dataSource);
    if (userAccountBean.getId() > 0 && userAccountBean.getActiveStudyId() > 0) {
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
        currentStudy = (StudyBean) sdao.findByPK(userAccountBean.getActiveStudyId());
        ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
        currentStudy.setStudyParameters(studyParameters);
        StudyConfigService scs = new StudyConfigService(dataSource);
        if (currentStudy.getParentStudyId() <= 0) {
            // top study
            scs.setParametersForStudy(currentStudy);
        } else {
            // YW <<
            currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
            // YW >>
            scs.setParametersForSite(currentStudy);
        }
        // set up the panel here, tbh
        panel.reset();
        /*
            * panel.setData("Study", currentStudy.getName());
            * panel.setData("Summary", currentStudy.getSummary());
            * panel.setData("Start Date",
            * sdf.format(currentStudy.getDatePlannedStart()));
            * panel.setData("End Date",
            * sdf.format(currentStudy.getDatePlannedEnd()));
            * panel.setData("Principal Investigator",
            * currentStudy.getPrincipalInvestigator());
            */
        httpSession.setAttribute(STUDY_INFO_PANEL, panel);
    } else {
        currentStudy = new StudyBean();
    }
    httpSession.setAttribute("study", currentStudy);
    // restored
    if (currentStudy.getParentStudyId() > 0) {
        currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
    }
    if (currentStudy.getParentStudyId() > 0) {
        /*The Role decription will be set depending on whether the user logged in at
       study lever or site level. issue-2422*/
        List roles = Role.toArrayList();
        for (Iterator it = roles.iterator(); it.hasNext(); ) {
            Role role = (Role) it.next();
            switch(role.getId()) {
                case 2:
                    role.setDescription("site_Study_Coordinator");
                    break;
                case 3:
                    role.setDescription("site_Study_Director");
                    break;
                case 4:
                    role.setDescription("site_investigator");
                    break;
                case 5:
                    role.setDescription("site_Data_Entry_Person");
                    break;
                case 6:
                    role.setDescription("site_monitor");
                    break;
                case 7:
                    role.setDescription("site_Data_Entry_Person2");
                    break;
                default:
            }
        }
    } else {
        /*If the current study is a site, we will change the role description. issue-2422*/
        List roles = Role.toArrayList();
        for (Iterator it = roles.iterator(); it.hasNext(); ) {
            Role role = (Role) it.next();
            switch(role.getId()) {
                case 2:
                    role.setDescription("Study_Coordinator");
                    break;
                case 3:
                    role.setDescription("Study_Director");
                    break;
                case 4:
                    role.setDescription("investigator");
                    break;
                case 5:
                    role.setDescription("Data_Entry_Person");
                    break;
                case 6:
                    role.setDescription("monitor");
                    break;
                default:
            }
        }
    }
    if (currentRole.getId() <= 0) {
        // kept as "invalid" -- YW 06-21-2007
        if (userAccountBean.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
            currentRole = userAccountBean.getRoleByStudy(currentStudy.getId());
            if (currentStudy.getParentStudyId() > 0) {
                // Checking if currentStudy has been removed or not will
                // ge good enough -- YW 10-17-2007
                StudyUserRoleBean roleInParent = userAccountBean.getRoleByStudy(currentStudy.getParentStudyId());
                // inherited role from parent study, pick the higher
                // role
                currentRole.setRole(Role.max(currentRole.getRole(), roleInParent.getRole()));
            }
        // logger.info("currentRole:" + currentRole.getRoleName());
        } else {
            currentRole = new StudyUserRoleBean();
        }
        httpSession.setAttribute("userRole", currentRole);
    } else // active study has been removed.
    if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
        currentRole.setRole(Role.INVALID);
        currentRole.setStatus(Status.DELETED);
        httpSession.setAttribute("userRole", currentRole);
    }
}
Also used : Role(org.akaza.openclinica.bean.core.Role) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel)

Example 59 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class ListDiscNotesForCRFServletTest method test_ListDiscNotesForCRFServlet_MayViewDN.

// Scenario
// Data Entry Person (site) can access Subject    
public void test_ListDiscNotesForCRFServlet_MayViewDN() {
    UserAccountBean ub = new UserAccountBean();
    //StudyUserRoleBean currentRole = new StudyUserRoleBean();
    //currentRole.setRole(Role.COORDINATOR);
    StudyUserRoleBean studyUserRoleBeanMock = mock(StudyUserRoleBean.class);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT);
    boolean result1 = ListDiscNotesForCRFServlet.mayViewDN(ub, studyUserRoleBeanMock);
    assertEquals(true, result1);
    // Positive Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.RESEARCHASSISTANT2);
    boolean result2 = ListDiscNotesForCRFServlet.mayViewDN(ub, studyUserRoleBeanMock);
    assertEquals(true, result2);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.ADMIN);
    boolean result3 = ListDiscNotesForCRFServlet.mayViewDN(ub, studyUserRoleBeanMock);
    assertEquals(false, result3);
    // Negative Testing
    when(studyUserRoleBeanMock.getRole()).thenReturn(Role.INVALID);
    boolean result4 = ListDiscNotesForCRFServlet.mayViewDN(ub, studyUserRoleBeanMock);
    assertEquals(false, result4);
}
Also used : StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean)

Example 60 with StudyUserRoleBean

use of org.akaza.openclinica.bean.login.StudyUserRoleBean in project OpenClinica by OpenClinica.

the class ChangeStudyServlet method confirmChangeStudy.

private void confirmChangeStudy(ArrayList studies) throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    v.addValidation("studyId", Validator.IS_AN_INTEGER);
    errors = v.validate();
    if (!errors.isEmpty()) {
        request.setAttribute("studies", studies);
        forwardPage(Page.CHANGE_STUDY);
    } else {
        int studyId = fp.getInt("studyId");
        logger.info("new study id:" + studyId);
        for (int i = 0; i < studies.size(); i++) {
            StudyUserRoleBean studyWithRole = (StudyUserRoleBean) studies.get(i);
            if (studyWithRole.getStudyId() == studyId) {
                request.setAttribute("studyId", new Integer(studyId));
                session.setAttribute("studyWithRole", studyWithRole);
                request.setAttribute("currentStudy", currentStudy);
                forwardPage(Page.CHANGE_STUDY_CONFIRM);
                return;
            }
        }
        addPageMessage(restext.getString("no_study_selected"));
        forwardPage(Page.CHANGE_STUDY);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) Validator(org.akaza.openclinica.control.form.Validator)

Aggregations

StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)76 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)35 ArrayList (java.util.ArrayList)34 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)28 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)23 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)22 Date (java.util.Date)16 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)16 Role (org.akaza.openclinica.bean.core.Role)15 HashMap (java.util.HashMap)14 Iterator (java.util.Iterator)12 InsufficientPermissionException (org.akaza.openclinica.web.InsufficientPermissionException)10 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)9 Validator (org.akaza.openclinica.control.form.Validator)6 SimpleDateFormat (java.text.SimpleDateFormat)4 HttpSession (javax.servlet.http.HttpSession)4 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)4 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)4 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)4 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)4