use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class StudyAuditLogServlet method processRequest.
/*
* (non-Javadoc) Assume that we get the user id automatically. We will jump
* from the edit user page if the user is an admin, they can get to see the
* users' log
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
/*
* (non-Javadoc) redo this servlet to run the audits per study subject for
* the study; need to add a studyId param and then use the
* StudySubjectDAO.findAllByStudyOrderByLabel() method to grab a lot of
* study subject beans and then return them much like in
* ViewStudySubjectAuditLogServet.process() currentStudy instead of studyId?
*/
@Override
protected void processRequest() throws Exception {
int studyId = currentStudy.getId();
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
AuditDAO adao = new AuditDAO(sm.getDataSource());
UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyDAO studydao = new StudyDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
StudyAuditLogTableFactory factory = new StudyAuditLogTableFactory();
factory.setSubjectDao(sdao);
factory.setStudySubjectDao(subdao);
factory.setUserAccountDao(uadao);
factory.setCurrentStudy(currentStudy);
String auditLogsHtml = factory.createTable(request, response).render();
request.setAttribute("auditLogsHtml", auditLogsHtml);
forwardPage(Page.AUDIT_LOGS_STUDY);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class RemoveStudyUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_remove_his_role"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
String action = request.getParameter("action");
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
if ("confirm".equalsIgnoreCase(action)) {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(studyId);
request.setAttribute("uStudy", study);
forwardPage(Page.REMOVE_USER_ROLE_IN_STUDY);
} else {
// remove role
FormProcessor fp = new FormProcessor(request);
String userName = fp.getString("name");
int studyId = fp.getInt("studyId");
int roleId = fp.getInt("roleId");
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStatus(Status.DELETED);
sur.setUpdater(ub);
sur.setUpdatedDate(new Date());
udao.updateStudyUserRole(sur, userName);
addPageMessage(sendEmail(user, sur));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class RestoreStudyUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_restore_his_role"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
String action = request.getParameter("action");
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
StudyBean study = (StudyBean) sdao.findByPK(studyId);
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
request.setAttribute("uStudy", study);
forwardPage(Page.RESTORE_USER_ROLE_IN_STUDY);
} else {
// restore role
FormProcessor fp = new FormProcessor(request);
String userName = fp.getString("name");
int roleId = fp.getInt("roleId");
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStatus(Status.AVAILABLE);
sur.setUpdater(ub);
sur.setUpdatedDate(new Date());
udao.updateStudyUserRole(sur, userName);
String restoreMessage = user.getFirstName() + " " + user.getLastName() + " (" + resword.getString("username") + ": " + user.getName() + ") " + respage.getString("has_been_restored_to_the_study_site") + " " + study.getName() + " " + respage.getString("with_the_role") + " " + sur.getRoleName() + ". " + respage.getString("the_user_is_now_be_able_to_access_study");
addPageMessage(restoreMessage);
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class SetStudyUserRoleServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudyDAO sdao = new StudyDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_set_role_for"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
String action = request.getParameter("action");
FormProcessor fp = new FormProcessor(request);
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
StudyBean userStudy = (StudyBean) sdao.findByPK(fp.getInt("studyId"));
if ("confirm".equalsIgnoreCase(action)) {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
uRole.setStudyName(userStudy.getName());
request.setAttribute("uRole", uRole);
ArrayList roles = Role.toArrayList();
// admin is not a user role, only used for tomcat
roles.remove(Role.ADMIN);
roles.remove(Role.RESEARCHASSISTANT2);
StudyBean studyBean = (StudyBean) sdao.findByPK(uRole.getStudyId());
if (currentStudy.getParentStudyId() > 0) {
roles.remove(Role.COORDINATOR);
roles.remove(Role.STUDYDIRECTOR);
} else if (studyBean.getParentStudyId() > 0) {
roles.remove(Role.COORDINATOR);
roles.remove(Role.STUDYDIRECTOR);
// TODO: redo this fix
Role r = Role.RESEARCHASSISTANT;
r.setDescription("site_Data_Entry_Person");
roles.remove(Role.RESEARCHASSISTANT);
roles.add(r);
Role ri = Role.INVESTIGATOR;
ri.setDescription("site_investigator");
roles.remove(Role.INVESTIGATOR);
roles.add(ri);
Role r2 = Role.RESEARCHASSISTANT2;
r2.setDescription("site_Data_Entry_Person2");
roles.remove(Role.RESEARCHASSISTANT2);
roles.add(r2);
}
request.setAttribute("roles", roles);
forwardPage(Page.SET_USER_ROLE_IN_STUDY);
} else {
// set role
String userName = fp.getString("name");
int studyId = fp.getInt("studyId");
int roleId = fp.getInt("roleId");
StudyUserRoleBean sur = new StudyUserRoleBean();
sur.setName(userName);
sur.setRole(Role.get(roleId));
sur.setStudyId(studyId);
sur.setStudyName(userStudy.getName());
sur.setStatus(Status.AVAILABLE);
sur.setUpdater(ub);
sur.setUpdatedDate(new Date());
udao.updateStudyUserRole(sur, userName);
addPageMessage(sendEmail(user, sur));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class DiscrepancyNoteDAO method getEntityFromHashMap.
/**
* <p>
* getEntityFromHashMap, the method that gets the object from the database query.
*/
@Override
public Object getEntityFromHashMap(HashMap hm) {
DiscrepancyNoteBean eb = new DiscrepancyNoteBean();
Date dateCreated = (Date) hm.get("date_created");
Integer ownerId = (Integer) hm.get("owner_id");
eb.setCreatedDate(dateCreated);
eb.setOwnerId(ownerId.intValue());
// discrepancy_note_id serial NOT NULL,
// description varchar(255),
// discrepancy_note_type_id numeric,
// resolution_status_id numeric,
// detailed_notes varchar(1000),
// date_created date,
// owner_id numeric,
// parent_dn_id numeric,
eb.setId(selectInt(hm, "discrepancy_note_id"));
eb.setDescription((String) hm.get("description"));
eb.setDiscrepancyNoteTypeId(((Integer) hm.get("discrepancy_note_type_id")).intValue());
eb.setResolutionStatusId(((Integer) hm.get("resolution_status_id")).intValue());
eb.setParentDnId(((Integer) hm.get("parent_dn_id")).intValue());
eb.setDetailedNotes((String) hm.get("detailed_notes"));
eb.setEntityType((String) hm.get("entity_type"));
eb.setDisType(DiscrepancyNoteType.get(eb.getDiscrepancyNoteTypeId()));
eb.setResStatus(ResolutionStatus.get(eb.getResolutionStatusId()));
eb.setStudyId(selectInt(hm, "study_id"));
eb.setAssignedUserId(selectInt(hm, "assigned_user_id"));
if (eb.getAssignedUserId() > 0) {
UserAccountDAO userAccountDAO = new UserAccountDAO(ds);
UserAccountBean assignedUser = (UserAccountBean) userAccountDAO.findByPK(eb.getAssignedUserId());
eb.setAssignedUser(assignedUser);
}
eb.setAge(selectInt(hm, "age"));
eb.setDays(selectInt(hm, "days"));
return eb;
}
Aggregations