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;
}
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;
}
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);
}
}
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);
}
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);
}
}
Aggregations