Search in sources :

Example 51 with UserAccountDAO

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);
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) AuditDAO(org.akaza.openclinica.dao.admin.AuditDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 52 with UserAccountDAO

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);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Example 53 with UserAccountDAO

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);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date)

Example 54 with UserAccountDAO

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);
        }
    }
}
Also used : Role(org.akaza.openclinica.bean.core.Role) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Date(java.util.Date)

Example 55 with UserAccountDAO

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;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date)

Aggregations

UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)101 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)69 ArrayList (java.util.ArrayList)44 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)43 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)42 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)36 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)24 Date (java.util.Date)23 HashMap (java.util.HashMap)21 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)18 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)16 Locale (java.util.Locale)15 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)14 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)13 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)12 SubjectDAO (org.akaza.openclinica.dao.submit.SubjectDAO)12 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)11 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10