Search in sources :

Example 61 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class RequestPasswordServlet method confirmPassword.

/**
 * @param request
 * @param response
 */
private void confirmPassword() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    v.addValidation("name", Validator.NO_BLANKS);
    v.addValidation("email", Validator.IS_A_EMAIL);
    v.addValidation("passwdChallengeQuestion", Validator.NO_BLANKS);
    v.addValidation("passwdChallengeAnswer", Validator.NO_BLANKS);
    errors = v.validate();
    // user bean from web
    UserAccountBean ubForm = new UserAccountBean();
    // form
    ubForm.setName(fp.getString("name"));
    ubForm.setEmail(fp.getString("email"));
    ubForm.setPasswdChallengeQuestion(fp.getString("passwdChallengeQuestion"));
    ubForm.setPasswdChallengeAnswer(fp.getString("passwdChallengeAnswer"));
    sm = new SessionManager(null, ubForm.getName(), SpringServletAccess.getApplicationContext(context));
    UserAccountDAO uDAO = new UserAccountDAO(sm.getDataSource());
    // see whether this user in the DB
    UserAccountBean ubDB = (UserAccountBean) uDAO.findByUserName(ubForm.getName());
    UserAccountBean updater = ubDB;
    request.setAttribute("userBean1", ubForm);
    if (!errors.isEmpty()) {
        logger.info("after processing form,has errors");
        request.setAttribute("formMessages", errors);
        forwardPage(Page.REQUEST_PWD);
    } else {
        logger.info("after processing form,no errors");
        // whether this user's email is in the DB
        if (ubDB.getEmail() != null && ubDB.getEmail().equalsIgnoreCase(ubForm.getEmail())) {
            logger.info("ubDB.getPasswdChallengeQuestion()" + ubDB.getPasswdChallengeQuestion());
            logger.info("ubForm.getPasswdChallengeQuestion()" + ubForm.getPasswdChallengeQuestion());
            logger.info("ubDB.getPasswdChallengeAnswer()" + ubDB.getPasswdChallengeAnswer());
            logger.info("ubForm.getPasswdChallengeAnswer()" + ubForm.getPasswdChallengeAnswer());
            // if this user's password challenge can be verified
            if (ubDB.getPasswdChallengeQuestion().equals(ubForm.getPasswdChallengeQuestion()) && ubDB.getPasswdChallengeAnswer().equalsIgnoreCase(ubForm.getPasswdChallengeAnswer())) {
                SecurityManager sm = ((SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager"));
                String newPass = sm.genPassword();
                OpenClinicaJdbcService ocService = ((OpenClinicaJdbcService) SpringServletAccess.getApplicationContext(context).getBean("ocUserDetailsService"));
                String newDigestPass = sm.encrytPassword(newPass, ocService.loadUserByUsername(ubForm.getName()));
                ubDB.setPasswd(newDigestPass);
                // passwdtimestamp should be null ,fix
                // PrepareStatementFactory
                Calendar cal = Calendar.getInstance();
                // Date date = local_df.parse("01/01/1900");
                // cal.setTime(date);
                // ubDB.setPasswdTimestamp(cal.getTime());
                ubDB.setPasswdTimestamp(null);
                ubDB.setUpdater(updater);
                ubDB.setLastVisitDate(new Date());
                logger.info("user bean to be updated:" + ubDB.getId() + ubDB.getName() + ubDB.getActiveStudyId());
                uDAO.update(ubDB);
                sendPassword(newPass, ubDB);
            } else {
                addPageMessage(respage.getString("your_password_not_verified_try_again"));
                forwardPage(Page.REQUEST_PWD);
            }
        } else {
            addPageMessage(respage.getString("your_email_address_not_found_try_again"));
            forwardPage(Page.REQUEST_PWD);
        }
    }
}
Also used : SecurityManager(org.akaza.openclinica.core.SecurityManager) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) SessionManager(org.akaza.openclinica.core.SessionManager) Calendar(java.util.Calendar) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Validator(org.akaza.openclinica.control.form.Validator) OpenClinicaJdbcService(org.akaza.openclinica.web.filter.OpenClinicaJdbcService) Date(java.util.Date)

Example 62 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class ViewStudySubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    // studySubjectId
    int studySubId = fp.getInt("id", true);
    String from = fp.getString("from");
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    // if coming from change crf version -> display message
    String crfVersionChangeMsg = fp.getString("isFromCRFVersionChange");
    if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
        addPageMessage(crfVersionChangeMsg);
    }
    if (studySubId == 0) {
        addPageMessage(respage.getString("please_choose_a_subject_to_view"));
        forwardPage(Page.LIST_STUDY_SUBJECTS);
    } else {
        if (!StringUtil.isBlank(from)) {
            // form ListSubject or
            request.setAttribute("from", from);
        // ListStudySubject
        } else {
            request.setAttribute("from", "");
        }
        StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
        request.setAttribute("studySub", studySub);
        int studyId = studySub.getStudyId();
        int subjectId = studySub.getSubjectId();
        StudyDAO studydao = new StudyDAO(sm.getDataSource());
        StudyBean study = (StudyBean) studydao.findByPK(studyId);
        // Check if this StudySubject would be accessed from the Current Study
        if (studySub.getStudyId() != currentStudy.getId()) {
            if (currentStudy.getParentStudyId() > 0) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            } else {
                // The SubjectStudy is not belong to currentstudy and current study is not a site.
                Collection sites = studydao.findOlnySiteIdsByStudy(currentStudy);
                if (!sites.contains(study.getId())) {
                    addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                    forwardPage(Page.MENU_SERVLET);
                    return;
                }
            }
        }
        // If the study subject derives from a site, and is being viewed
        // from a parent study,
        // then the study IDs will be different. However, since each note is
        // saved with the specific
        // study ID, then its study ID may be different than the study
        // subject's ID.
        boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
        boolean isParentStudy = study.getParentStudyId() < 1;
        // Get any disc notes for this subject : studySubId
        DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
        List<DiscrepancyNoteBean> allNotesforSubject = new ArrayList<DiscrepancyNoteBean>();
        // These methods return only parent disc notes
        if (subjectStudyIsCurrentStudy && isParentStudy) {
            allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudyAndId(study, subjectId);
            allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudyAndId(study, studySubId));
        } else {
            if (!isParentStudy) {
                StudyBean stParent = (StudyBean) studydao.findByPK(study.getParentStudyId());
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(stParent, study, subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudiesAndStudySubjectId(stParent, study, studySubId));
            } else {
                allNotesforSubject = discrepancyNoteDAO.findAllSubjectByStudiesAndSubjectId(currentStudy, study, subjectId);
                allNotesforSubject.addAll(discrepancyNoteDAO.findAllStudySubjectByStudiesAndStudySubjectId(currentStudy, study, studySubId));
            }
        }
        if (!allNotesforSubject.isEmpty()) {
            setRequestAttributesForNotes(allNotesforSubject);
        }
        SubjectBean subject = (SubjectBean) sdao.findByPK(subjectId);
        if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
            Date dob = subject.getDateOfBirth();
            if (dob != null) {
                Calendar cal = Calendar.getInstance();
                cal.setTime(dob);
                int year = cal.get(Calendar.YEAR);
                request.setAttribute("yearOfBirth", new Integer(year));
            } else {
                request.setAttribute("yearOfBirth", "");
            }
        }
        request.setAttribute("subject", subject);
        /*
             * StudyDAO studydao = new StudyDAO(sm.getDataSource()); StudyBean
             * study = (StudyBean) studydao.findByPK(studyId);
             */
        // YW 11-26-2007 <<
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        study.getStudyParameterConfig().setCollectDob(spvdao.findByHandleAndStudy(studyId, "collectDob").getValue());
        // YW >>
        request.setAttribute("subjectStudy", study);
        if (study.getParentStudyId() > 0) {
            // this is a site,find parent
            StudyBean parentStudy2 = (StudyBean) studydao.findByPK(study.getParentStudyId());
            request.setAttribute("parentStudy", parentStudy2);
        } else {
            request.setAttribute("parentStudy", new StudyBean());
        }
        ArrayList children = (ArrayList) sdao.findAllChildrenByPK(subjectId);
        request.setAttribute("children", children);
        // find study events
        StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
        StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
        StudySubjectService studySubjectService = (StudySubjectService) WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("studySubjectService");
        List<DisplayStudyEventBean> displayEvents = studySubjectService.getDisplayStudyEventsForStudySubject(studySub, ub, currentRole);
        // Mantis Issue 5048: Preventing Investigators from Unlocking Events
        for (int i = 0; i < displayEvents.size(); i++) {
            DisplayStudyEventBean decb = displayEvents.get(i);
            if (!(currentRole.isDirector() || currentRole.isCoordinator()) && decb.getStudyEvent().getSubjectEventStatus().isLocked()) {
                decb.getStudyEvent().setEditable(false);
            }
        }
        // BWP 3212; remove event CRFs that are supposed to be "hidden" >>
        if (currentStudy.getParentStudyId() > 0) {
            HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
            for (DisplayStudyEventBean displayStudyEventBean : displayEvents) {
                hideCRFManager.removeHiddenEventCRF(displayStudyEventBean);
            }
        }
        // >>
        EntityBeanTable table = fp.getEntityBeanTable();
        // sort by start
        table.setSortingIfNotExplicitlySet(1, false);
        // date, desc
        ArrayList allEventRows = DisplayStudyEventRow.generateRowsFromBeans(displayEvents);
        String[] columns = { resword.getString("event") + " (" + resword.getString("occurrence_number") + ")", resword.getString("start_date1"), resword.getString("location"), resword.getString("status"), resword.getString("actions"), resword.getString("CRFs_atrib") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(4);
        table.hideColumnLink(5);
        // YW 11-08-2007 <<
        if (!"removed".equalsIgnoreCase(studySub.getStatus().getName()) && !"auto-removed".equalsIgnoreCase(studySub.getStatus().getName())) {
            if (currentStudy.getStatus().isAvailable() && !currentRole.getRole().equals(Role.MONITOR)) {
                table.addLink(resword.getString("add_new_event"), "CreateNewStudyEvent?" + CreateNewStudyEventServlet.INPUT_STUDY_SUBJECT_ID_FROM_VIEWSUBJECT + "=" + studySub.getId());
            }
        }
        // YW >>
        HashMap args = new HashMap();
        args.put("id", new Integer(studySubId).toString());
        table.setQuery("ViewStudySubject", args);
        table.setRows(allEventRows);
        table.computeDisplay();
        request.setAttribute("table", table);
        // request.setAttribute("displayEvents", displayEvents);
        // find group info
        SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
        ArrayList groupMaps = (ArrayList) sgmdao.findAllByStudySubject(studySubId);
        request.setAttribute("groups", groupMaps);
        // find audit log for events
        AuditEventDAO aedao = new AuditEventDAO(sm.getDataSource());
        ArrayList logs = aedao.findEventStatusLogByStudySubject(studySubId);
        // logger.warning("^^^ retrieved logs");
        UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
        ArrayList eventLogs = new ArrayList();
        // logger.warning("^^^ starting to iterate");
        for (int i = 0; i < logs.size(); i++) {
            AuditEventBean avb = (AuditEventBean) logs.get(i);
            StudyEventAuditBean sea = new StudyEventAuditBean();
            sea.setAuditEvent(avb);
            StudyEventBean se = (StudyEventBean) sedao.findByPK(avb.getEntityId());
            StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
            sea.setDefinition(sed);
            String old = avb.getOldValue().trim();
            try {
                if (!StringUtil.isBlank(old)) {
                    SubjectEventStatus oldStatus = SubjectEventStatus.get(new Integer(old).intValue());
                    sea.setOldSubjectEventStatus(oldStatus);
                }
                String newValue = avb.getNewValue().trim();
                if (!StringUtil.isBlank(newValue)) {
                    SubjectEventStatus newStatus = SubjectEventStatus.get(new Integer(newValue).intValue());
                    sea.setNewSubjectEventStatus(newStatus);
                }
            } catch (NumberFormatException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            // logger.warning("^^^ caught NFE");
            }
            UserAccountBean updater = (UserAccountBean) udao.findByPK(avb.getUserId());
            sea.setUpdater(updater);
            eventLogs.add(sea);
        }
        // logger.warning("^^^ finished iteration");
        request.setAttribute("eventLogs", eventLogs);
        forwardPage(Page.VIEW_STUDY_SUBJECT);
    }
}
Also used : HashMap(java.util.HashMap) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) AuditEventBean(org.akaza.openclinica.bean.admin.AuditEventBean) StudyEventAuditBean(org.akaza.openclinica.bean.admin.StudyEventAuditBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Calendar(java.util.Calendar) AuditEventDAO(org.akaza.openclinica.dao.admin.AuditEventDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) HideCRFManager(org.akaza.openclinica.service.crfdata.HideCRFManager) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) StudySubjectService(org.akaza.openclinica.service.managestudy.StudySubjectService) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Collection(java.util.Collection) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 63 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class CreateDiscrepancyNoteServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    List<DiscrepancyNoteType> types = DiscrepancyNoteType.list;
    request.setAttribute(DIS_TYPES, types);
    request.setAttribute(RES_STATUSES, ResolutionStatus.list);
    // this should be set based on a new property of DisplayItemBean
    boolean writeToDB = fp.getBoolean(WRITE_TO_DB, true);
    boolean isReasonForChange = fp.getBoolean(IS_REASON_FOR_CHANGE);
    int entityId = fp.getInt(ENTITY_ID);
    // subjectId has to be added to the database when disc notes area saved
    // as entity_type 'subject'
    int subjectId = fp.getInt(SUBJECT_ID);
    int itemId = fp.getInt(ITEM_ID);
    String entityType = fp.getString(ENTITY_TYPE);
    String field = fp.getString(ENTITY_FIELD);
    String column = fp.getString(ENTITY_COLUMN);
    int parentId = fp.getInt(PARENT_ID);
    // patch for repeating groups and RFC on empty fields
    int isGroup = fp.getInt(IS_GROUP_ITEM);
    // request.setAttribute(IS_GROUP_ITEM, new Integer(isGroup));
    int eventCRFId = fp.getInt(EVENT_CRF_ID);
    request.setAttribute(EVENT_CRF_ID, new Integer(eventCRFId));
    int rowCount = fp.getInt(PARENT_ROW_COUNT);
    // run only once: try to recalculate writeToDB
    if (!StringUtils.isBlank(entityType) && "itemData".equalsIgnoreCase(entityType) && isGroup != 0 && eventCRFId != 0) {
        // request.setAttribute(PARENT_ROW_COUNT, new Integer(eventCRFId));
        int ordinal_for_repeating_group_field = calculateOrdinal(isGroup, field, eventCRFId, rowCount);
        int writeToDBStatus = isWriteToDB(isGroup, field, entityId, itemId, ordinal_for_repeating_group_field, eventCRFId);
        writeToDB = (writeToDBStatus == -1) ? false : ((writeToDBStatus == 1) ? true : writeToDB);
    }
    boolean isInError = fp.getBoolean(ERROR_FLAG);
    boolean isNew = fp.getBoolean(NEW_NOTE);
    request.setAttribute(NEW_NOTE, isNew ? "1" : "0");
    String strResStatus = fp.getString(PRESET_RES_STATUS);
    if (!strResStatus.equals("")) {
        request.setAttribute(PRESET_RES_STATUS, strResStatus);
    }
    String monitor = fp.getString("monitor");
    String enterData = fp.getString("enterData");
    request.setAttribute("enterData", enterData);
    boolean enteringData = false;
    if (enterData != null && "1".equalsIgnoreCase(enterData)) {
        // variables are not set in JSP, so not from viewing data and from
        // entering data
        request.setAttribute(CAN_MONITOR, "1");
        request.setAttribute("monitor", monitor);
        enteringData = true;
    } else if ("1".equalsIgnoreCase(monitor)) {
        // change to allow user to
        // enter note for all items,
        // not just blank items
        request.setAttribute(CAN_MONITOR, "1");
        request.setAttribute("monitor", monitor);
    } else {
        request.setAttribute(CAN_MONITOR, "0");
    }
    if ("itemData".equalsIgnoreCase(entityType) && enteringData) {
        request.setAttribute("enterItemData", "yes");
    }
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
    int preUserId = 0;
    if (!StringUtils.isBlank(entityType)) {
        if ("itemData".equalsIgnoreCase(entityType) || "itemdata".equalsIgnoreCase(entityType)) {
            ItemBean item = (ItemBean) new ItemDAO(sm.getDataSource()).findByPK(itemId);
            ItemDataBean itemData = (ItemDataBean) new ItemDataDAO(sm.getDataSource()).findByPK(entityId);
            request.setAttribute("entityValue", itemData.getValue());
            request.setAttribute("entityName", item.getName());
            EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
            preUserId = ec.getOwnerId();
        } else if ("studySub".equalsIgnoreCase(entityType)) {
            StudySubjectBean ssub = (StudySubjectBean) new StudySubjectDAO(sm.getDataSource()).findByPK(entityId);
            SubjectBean sub = (SubjectBean) new SubjectDAO(sm.getDataSource()).findByPK(ssub.getSubjectId());
            preUserId = ssub.getOwnerId();
            if (!StringUtils.isBlank(column)) {
                if ("enrollment_date".equalsIgnoreCase(column)) {
                    if (ssub.getEnrollmentDate() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(ssub.getEnrollmentDate()));
                    } else {
                        request.setAttribute("entityValue", resword.getString("N/A"));
                    }
                    request.setAttribute("entityName", resword.getString("enrollment_date"));
                } else if ("gender".equalsIgnoreCase(column)) {
                    request.setAttribute("entityValue", sub.getGender() + "");
                    request.setAttribute("entityName", resword.getString("gender"));
                } else if ("date_of_birth".equalsIgnoreCase(column)) {
                    if (sub.getDateOfBirth() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(sub.getDateOfBirth()));
                    } else {
                        request.setAttribute("entityValue", resword.getString("N/A"));
                    }
                    request.setAttribute("entityName", resword.getString("date_of_birth"));
                } else if ("unique_identifier".equalsIgnoreCase(column)) {
                    if (sub.getUniqueIdentifier() != null) {
                        request.setAttribute("entityValue", sub.getUniqueIdentifier());
                    }
                    request.setAttribute("entityName", resword.getString("unique_identifier"));
                }
            }
        } else if ("subject".equalsIgnoreCase(entityType)) {
            SubjectBean sub = (SubjectBean) new SubjectDAO(sm.getDataSource()).findByPK(entityId);
            preUserId = sub.getOwnerId();
            if (!StringUtils.isBlank(column)) {
                if ("gender".equalsIgnoreCase(column)) {
                    request.setAttribute("entityValue", sub.getGender() + "");
                    request.setAttribute("entityName", resword.getString("gender"));
                } else if ("date_of_birth".equalsIgnoreCase(column)) {
                    if (sub.getDateOfBirth() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(sub.getDateOfBirth()));
                    }
                    request.setAttribute("entityName", resword.getString("date_of_birth"));
                } else if ("unique_identifier".equalsIgnoreCase(column)) {
                    request.setAttribute("entityValue", sub.getUniqueIdentifier());
                    request.setAttribute("entityName", resword.getString("unique_identifier"));
                }
            }
        } else if ("studyEvent".equalsIgnoreCase(entityType)) {
            StudyEventBean se = (StudyEventBean) new StudyEventDAO(sm.getDataSource()).findByPK(entityId);
            preUserId = se.getOwnerId();
            if (!StringUtils.isBlank(column)) {
                if ("location".equalsIgnoreCase(column)) {
                    request.setAttribute("entityValue", se.getLocation().equals("") || se.getLocation() == null ? resword.getString("N/A") : se.getLocation());
                    request.setAttribute("entityName", resword.getString("location"));
                } else if ("start_date".equalsIgnoreCase(column)) {
                    if (se.getDateStarted() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(se.getDateStarted()));
                    } else {
                        request.setAttribute("entityValue", resword.getString("N/A"));
                    }
                    request.setAttribute("entityName", resword.getString("start_date"));
                } else if ("end_date".equalsIgnoreCase(column)) {
                    if (se.getDateEnded() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(se.getDateEnded()));
                    } else {
                        request.setAttribute("entityValue", resword.getString("N/A"));
                    }
                    request.setAttribute("entityName", resword.getString("end_date"));
                }
            }
        } else if ("eventCrf".equalsIgnoreCase(entityType)) {
            EventCRFBean ec = (EventCRFBean) new EventCRFDAO(sm.getDataSource()).findByPK(entityId);
            preUserId = ec.getOwnerId();
            if (!StringUtils.isBlank(column)) {
                if ("date_interviewed".equals(column)) {
                    if (ec.getDateInterviewed() != null) {
                        request.setAttribute("entityValue", dateFormatter.format(ec.getDateInterviewed()));
                    } else {
                        request.setAttribute("entityValue", resword.getString("N/A"));
                    }
                    request.setAttribute("entityName", resword.getString("date_interviewed"));
                } else if ("interviewer_name".equals(column)) {
                    request.setAttribute("entityValue", ec.getInterviewerName());
                    request.setAttribute("entityName", resword.getString("interviewer_name"));
                }
            }
        }
    }
    // finds all the related notes
    ArrayList notes = (ArrayList) dndao.findAllByEntityAndColumn(entityType, entityId, column);
    DiscrepancyNoteBean parent = new DiscrepancyNoteBean();
    if (parentId > 0) {
        dndao.setFetchMapping(true);
        parent = (DiscrepancyNoteBean) dndao.findByPK(parentId);
        if (parent.isActive()) {
            request.setAttribute("parent", parent);
        }
        dndao.setFetchMapping(false);
    }
    FormDiscrepancyNotes newNotes = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
    if (newNotes == null) {
        newNotes = new FormDiscrepancyNotes();
    }
    boolean isNotesExistInSession = (!newNotes.getNotes(field).isEmpty()) ? true : (!newNotes.getNotes(eventCRFId + "_" + field).isEmpty()) ? true : false;
    if (!notes.isEmpty() || isNotesExistInSession) {
        request.setAttribute("hasNotes", "yes");
    } else {
        request.setAttribute("hasNotes", "no");
        logger.debug("has notes:" + "no");
    }
    // only for adding a new thread
    if (currentRole.getRole().equals(Role.RESEARCHASSISTANT) || currentRole.getRole().equals(Role.RESEARCHASSISTANT2) || currentRole.getRole().equals(Role.INVESTIGATOR)) {
        ArrayList<ResolutionStatus> resStatuses = new ArrayList<ResolutionStatus>();
        resStatuses.add(ResolutionStatus.OPEN);
        resStatuses.add(ResolutionStatus.RESOLVED);
        request.setAttribute(RES_STATUSES, resStatuses);
        List<DiscrepancyNoteType> types2 = new ArrayList<DiscrepancyNoteType>(DiscrepancyNoteType.list);
        types2.remove(DiscrepancyNoteType.QUERY);
        request.setAttribute(DIS_TYPES, types2);
        request.setAttribute(WHICH_RES_STATUSES, "22");
    } else if (currentRole.getRole().equals(Role.MONITOR)) {
        ArrayList<ResolutionStatus> resStatuses = new ArrayList();
        resStatuses.add(ResolutionStatus.OPEN);
        resStatuses.add(ResolutionStatus.UPDATED);
        resStatuses.add(ResolutionStatus.CLOSED);
        request.setAttribute(RES_STATUSES, resStatuses);
        request.setAttribute(WHICH_RES_STATUSES, "1");
        ArrayList<DiscrepancyNoteType> types2 = new ArrayList<DiscrepancyNoteType>();
        types2.add(DiscrepancyNoteType.QUERY);
        request.setAttribute(DIS_TYPES, types2);
    } else {
        // Role.STUDYDIRECTOR Role.COORDINATOR
        List<ResolutionStatus> resStatuses = new ArrayList<ResolutionStatus>(ResolutionStatus.list);
        resStatuses.remove(ResolutionStatus.NOT_APPLICABLE);
        request.setAttribute(RES_STATUSES, resStatuses);
        ;
        request.setAttribute(WHICH_RES_STATUSES, "2");
    }
    if (!fp.isSubmitted()) {
        DiscrepancyNoteBean dnb = new DiscrepancyNoteBean();
        if (subjectId > 0) {
            // BWP: this doesn't seem correct, because the SubjectId should
            // be the id for
            // the SubjectBean, different from StudySubjectBean
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(subjectId);
            dnb.setSubjectName(ssub.getName());
            dnb.setSubjectId(ssub.getId());
            dnb.setStudySub(ssub);
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            int parentStudyForSubject = 0;
            StudyBean studyBeanSub = (StudyBean) studyDAO.findByPK(ssub.getStudyId());
            if (null != studyBeanSub) {
                parentStudyForSubject = studyBeanSub.getParentStudyId();
            }
            if (ssub.getStudyId() != currentStudy.getId() && currentStudy.getId() != parentStudyForSubject) {
                addPageMessage(noAccessMessage);
                throw new InsufficientPermissionException(Page.MENU_SERVLET, exceptionName, "1");
            }
        }
        if (itemId > 0) {
            ItemBean item = (ItemBean) new ItemDAO(sm.getDataSource()).findByPK(itemId);
            dnb.setEntityName(item.getName());
            request.setAttribute("item", item);
        }
        dnb.setEntityType(entityType);
        dnb.setColumn(column);
        dnb.setEntityId(entityId);
        dnb.setField(field);
        dnb.setParentDnId(parent.getId());
        dnb.setCreatedDate(new Date());
        if (parent.getId() == 0 || isNew) {
            // no parent, new note thread
            if (enteringData) {
                if (isInError) {
                    dnb.setDiscrepancyNoteTypeId(DiscrepancyNoteType.FAILEDVAL.getId());
                } else {
                    dnb.setDiscrepancyNoteTypeId(DiscrepancyNoteType.ANNOTATION.getId());
                    dnb.setResolutionStatusId(ResolutionStatus.NOT_APPLICABLE.getId());
                // >> tbh WHO bug: set an assigned user for the parent
                // note
                // dnb.setAssignedUser(ub);
                // dnb.setAssignedUserId(ub.getId());
                // << tbh 08/2009
                }
                if (isReasonForChange) {
                    dnb.setDiscrepancyNoteTypeId(DiscrepancyNoteType.REASON_FOR_CHANGE.getId());
                    dnb.setResolutionStatusId(ResolutionStatus.NOT_APPLICABLE.getId());
                }
                // << tbh 02/2010, trumps failed evaluation error checks
                // can we put this in admin editing
                request.setAttribute("autoView", "0");
            // above set to automatically open up the user panel
            } else {
                // when the user is a CRC and is adding a note to the thread
                // it should default to Resolution Proposed,
                // and the assigned should be the user who logged the query,
                // NOT the one who is proposing the solution, tbh 02/2009
                // if (currentRole.getRole().equals(Role.COORDINATOR)) {
                // dnb.setDiscrepancyNoteTypeId(DiscrepancyNoteType.
                // REASON_FOR_CHANGE.getId());
                // request.setAttribute("autoView", "1");
                // // above set to automatically open up the user panel
                // } else {
                dnb.setDiscrepancyNoteTypeId(DiscrepancyNoteType.QUERY.getId());
                // if (currentRole.getRole().equals(Role.RESEARCHASSISTANT) && currentStudy.getId() != currentStudy.getParentStudyId()
                if (currentRole.getRole().equals(Role.RESEARCHASSISTANT) || currentRole.getRole().equals(Role.RESEARCHASSISTANT2) || currentRole.getRole().equals(Role.INVESTIGATOR)) {
                    request.setAttribute("autoView", "0");
                } else {
                    request.setAttribute("autoView", "1");
                    dnb.setAssignedUserId(preUserId);
                }
            // above set to automatically open up the user panel
            // }
            }
        } else if (parent.getDiscrepancyNoteTypeId() > 0) {
            dnb.setDiscrepancyNoteTypeId(parent.getDiscrepancyNoteTypeId());
            // adding second rule here, tbh 08/2009
            if ((currentRole.getRole().equals(Role.RESEARCHASSISTANT) || currentRole.getRole().equals(Role.RESEARCHASSISTANT2)) && currentStudy.getId() != currentStudy.getParentStudyId()) {
                dnb.setResolutionStatusId(ResolutionStatus.RESOLVED.getId());
                request.setAttribute("autoView", "0");
            // hide the panel, tbh
            } else {
                dnb.setResolutionStatusId(ResolutionStatus.UPDATED.getId());
            }
        }
        dnb.setOwnerId(parent.getOwnerId());
        String detailedDes = fp.getString("strErrMsg");
        if (detailedDes != null) {
            dnb.setDetailedNotes(detailedDes);
            logger.debug("found strErrMsg: " + fp.getString("strErrMsg"));
        }
        // #4346 TBH 10/2009
        // If the data entry form has not been saved yet, collecting info from parent page.
        // populate note infos
        dnb = getNoteInfo(dnb);
        if (dnb.getEventName() == null || dnb.getEventName().equals("")) {
            if (!fp.getString("eventName").equals("")) {
                dnb.setEventName(fp.getString("eventName"));
            } else {
                dnb.setEventName(getStudyEventDefinition(eventCRFId).getName());
            }
        }
        if (dnb.getEventStart() == null) {
            if (fp.getDate("eventDate") != null) {
                dnb.setEventStart(fp.getDate("eventDate"));
            } else {
                dnb.setEventStart(getStudyEvent(eventCRFId).getDateStarted());
            }
        }
        if (dnb.getCrfName() == null || dnb.getCrfName().equals("")) {
            if (!fp.getString("crfName").equals("")) {
                dnb.setCrfName(fp.getString("crfName"));
            } else {
                dnb.setCrfName(getCrf(eventCRFId).getName());
            }
        }
        // // #4346 TBH 10/2009
        request.setAttribute(DIS_NOTE, dnb);
        request.setAttribute("unlock", "0");
        // this should go from UI & here
        request.setAttribute(WRITE_TO_DB, writeToDB ? "1" : "0");
        ArrayList userAccounts = this.generateUserAccounts(ub.getActiveStudyId(), subjectId);
        request.setAttribute(USER_ACCOUNTS, userAccounts);
        // ideally should be only two cases
        if ((currentRole.getRole().equals(Role.RESEARCHASSISTANT) || currentRole.getRole().equals(Role.RESEARCHASSISTANT2)) && currentStudy.getId() != currentStudy.getParentStudyId()) {
            // assigning back to OP, tbh
            request.setAttribute(USER_ACCOUNT_ID, Integer.valueOf(parent.getOwnerId()).toString());
            logger.debug("assigned owner id: " + parent.getOwnerId());
        } else if (dnb.getEventCRFId() > 0) {
            logger.debug("found a event crf id: " + dnb.getEventCRFId());
            EventCRFDAO eventCrfDAO = new EventCRFDAO(sm.getDataSource());
            EventCRFBean eventCrfBean = new EventCRFBean();
            eventCrfBean = (EventCRFBean) eventCrfDAO.findByPK(dnb.getEventCRFId());
            request.setAttribute(USER_ACCOUNT_ID, Integer.valueOf(eventCrfBean.getOwnerId()).toString());
            logger.debug("assigned owner id: " + eventCrfBean.getOwnerId());
        } else {
        // the end case
        }
        // set the user account id for the user who completed data entry
        forwardPage(Page.ADD_DISCREPANCY_NOTE);
    } else {
        // Submit and Close the Discrepancy note
        FormDiscrepancyNotes noteTree = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
        FormDiscrepancyNotes noteTree_RFC_REPEAT = (FormDiscrepancyNotes) session.getAttribute(FLAG_DISCREPANCY_RFC);
        ;
        if (noteTree_RFC_REPEAT == null)
            noteTree_RFC_REPEAT = new FormDiscrepancyNotes();
        if (noteTree == null) {
            noteTree = new FormDiscrepancyNotes();
            logger.debug("No note tree initailized in session");
        }
        Validator v = new Validator(request);
        String description = fp.getString("description");
        int typeId = fp.getInt("typeId");
        int assignedUserAccountId = fp.getInt(SUBMITTED_USER_ACCOUNT_ID);
        int resStatusId = fp.getInt(RES_STATUS_ID);
        String detailedDes = fp.getString("detailedDes");
        int sectionId = fp.getInt("sectionId");
        DiscrepancyNoteBean note = new DiscrepancyNoteBean();
        v.addValidation("description", Validator.NO_BLANKS);
        v.addValidation("description", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
        v.addValidation("detailedDes", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
        v.addValidation("typeId", Validator.NO_BLANKS);
        HashMap errors = v.validate();
        note.setDescription(description);
        note.setDetailedNotes(detailedDes);
        note.setOwner(ub);
        note.setOwnerId(ub.getId());
        note.setCreatedDate(new Date());
        note.setResolutionStatusId(resStatusId);
        note.setDiscrepancyNoteTypeId(typeId);
        note.setParentDnId(parent.getId());
        if (typeId != DiscrepancyNoteType.ANNOTATION.getId() && typeId != DiscrepancyNoteType.FAILEDVAL.getId() && typeId != DiscrepancyNoteType.REASON_FOR_CHANGE.getId()) {
            if (assignedUserAccountId > 0) {
                note.setAssignedUserId(assignedUserAccountId);
                logger.debug("^^^ found assigned user id: " + assignedUserAccountId);
            } else {
                // a little bit of a workaround, should ideally be always from
                // the form
                note.setAssignedUserId(parent.getOwnerId());
                logger.debug("found user assigned id, in the PARENT OWNER ID: " + parent.getOwnerId() + " note that user assgined id did not work: " + assignedUserAccountId);
            }
        }
        note.setField(field);
        if (DiscrepancyNoteType.ANNOTATION.getId() == note.getDiscrepancyNoteTypeId()) {
            updateStudyEvent(entityType, entityId);
            updateStudySubjectStatus(entityType, entityId);
        }
        if (DiscrepancyNoteType.ANNOTATION.getId() == note.getDiscrepancyNoteTypeId() || DiscrepancyNoteType.REASON_FOR_CHANGE.getId() == note.getDiscrepancyNoteTypeId()) {
            note.setResStatus(ResolutionStatus.NOT_APPLICABLE);
            note.setResolutionStatusId(ResolutionStatus.NOT_APPLICABLE.getId());
        }
        if (DiscrepancyNoteType.FAILEDVAL.getId() == note.getDiscrepancyNoteTypeId() || DiscrepancyNoteType.QUERY.getId() == note.getDiscrepancyNoteTypeId()) {
            if (ResolutionStatus.NOT_APPLICABLE.getId() == note.getResolutionStatusId()) {
                Validator.addError(errors, RES_STATUS_ID, restext.getString("not_valid_res_status"));
            }
        }
        if (!parent.isActive()) {
            note.setEntityId(entityId);
            note.setEntityType(entityType);
            note.setColumn(column);
        } else {
            note.setEntityId(parent.getEntityId());
            note.setEntityType(parent.getEntityType());
            if (!StringUtils.isBlank(parent.getColumn())) {
                note.setColumn(parent.getColumn());
            } else {
                note.setColumn(column);
            }
            note.setParentDnId(parent.getId());
        }
        note.setStudyId(currentStudy.getId());
        // populate note infos
        note = getNoteInfo(note);
        request.setAttribute(DIS_NOTE, note);
        // this should go from UI & here
        request.setAttribute(WRITE_TO_DB, writeToDB ? "1" : "0");
        ArrayList userAccounts = this.generateUserAccounts(ub.getActiveStudyId(), subjectId);
        request.setAttribute(USER_ACCOUNT_ID, Integer.valueOf(note.getAssignedUserId()).toString());
        // formality more than anything else, we should go to say the note
        // is done
        Role r = currentRole.getRole();
        if (r.equals(Role.MONITOR) || r.equals(Role.INVESTIGATOR) || r.equals(Role.RESEARCHASSISTANT) || r.equals(Role.RESEARCHASSISTANT2) || r.equals(Role.COORDINATOR)) {
            // investigator
            request.setAttribute("unlock", "1");
            logger.debug("set UNLOCK to ONE");
        } else {
            request.setAttribute("unlock", "0");
            logger.debug("set UNLOCK to ZERO");
        }
        request.setAttribute(USER_ACCOUNTS, userAccounts);
        if (errors.isEmpty()) {
            if (!writeToDB) {
                noteTree.addNote(field, note);
                noteTree.addIdNote(note.getEntityId(), field);
                noteTree_RFC_REPEAT.addNote(EVENT_CRF_ID + "_" + field, note);
                noteTree_RFC_REPEAT.addIdNote(note.getEntityId(), field);
                // -> catcher                //   FORM_DISCREPANCY_NOTES_NAME
                session.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, noteTree);
                session.setAttribute(FLAG_DISCREPANCY_RFC, noteTree_RFC_REPEAT);
                // 
                /*Setting a marker to check later while saving administrative edited data. This is needed to make
                    * sure the system flags error while changing data for items which already has a DiscrepanyNote*/
                manageReasonForChangeState(session, eventCRFId + "_" + field);
                forwardPage(Page.ADD_DISCREPANCY_NOTE_DONE);
            } else {
                // if not creating a new thread(note), update exsiting notes
                // if necessary
                // if ("itemData".equalsIgnoreCase(entityType) && !isNew) {
                int pdnId = note != null ? note.getParentDnId() : 0;
                if (pdnId > 0) {
                    logger.debug("Create:find parent note for item data:" + note.getEntityId());
                    DiscrepancyNoteBean pNote = (DiscrepancyNoteBean) dndao.findByPK(pdnId);
                    logger.debug("setting DN owner id: " + pNote.getOwnerId());
                    note.setOwnerId(pNote.getOwnerId());
                    if (note.getDiscrepancyNoteTypeId() == pNote.getDiscrepancyNoteTypeId()) {
                        if (note.getResolutionStatusId() != pNote.getResolutionStatusId()) {
                            pNote.setResolutionStatusId(note.getResolutionStatusId());
                            dndao.update(pNote);
                        }
                        if (note.getAssignedUserId() != pNote.getAssignedUserId()) {
                            pNote.setAssignedUserId(note.getAssignedUserId());
                            if (pNote.getAssignedUserId() > 0) {
                                dndao.updateAssignedUser(pNote);
                            } else {
                                dndao.updateAssignedUserToNull(pNote);
                            }
                        }
                    }
                }
                note = (DiscrepancyNoteBean) dndao.create(note);
                note.setEntityId(entityId);
                dndao.createMapping(note);
                request.setAttribute(DIS_NOTE, note);
                if (note.getParentDnId() == 0) {
                    // see issue 2659 this is a new thread, we will create
                    // two notes in this case,
                    // This way one can be the parent that updates as the
                    // status changes, but one also stays as New.
                    note.setParentDnId(note.getId());
                    note = (DiscrepancyNoteBean) dndao.create(note);
                    dndao.createMapping(note);
                }
                /*Setting a marker to check later while saving administrative edited data. This is needed to make
                    * sure the system flags error while changing data for items which already has a DiscrepanyNote*/
                // session.setAttribute(DataEntryServlet.NOTE_SUBMITTED, true);
                // session.setAttribute(DataEntryServlet.NOTE_SUBMITTED, true);
                // String field_id_for_RFC_hash = buildDiscrepancyNoteIdForRFCHash(eventCRFId,entityId, isGroup, field, ordinal_for_repeating_group_field);
                String field_id_for_RFC_hash = eventCRFId + "_" + field;
                manageReasonForChangeState(session, field_id_for_RFC_hash);
                logger.debug("found resolution status: " + note.getResolutionStatusId());
                String email = fp.getString(EMAIL_USER_ACCOUNT);
                logger.debug("found email: " + email);
                if (note.getAssignedUserId() > 0 && "1".equals(email.trim()) && DiscrepancyNoteType.QUERY.getId() == note.getDiscrepancyNoteTypeId()) {
                    logger.debug("++++++ found our way here: " + note.getDiscrepancyNoteTypeId() + " id number and " + note.getDisType().getName());
                    // generate email for user here
                    StringBuffer message = new StringBuffer();
                    // generate message here
                    UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
                    ItemDAO itemDAO = new ItemDAO(sm.getDataSource());
                    ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                    ItemBean item = new ItemBean();
                    ItemDataBean itemData = new ItemDataBean();
                    SectionBean section = new SectionBean();
                    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
                    UserAccountBean assignedUser = (UserAccountBean) userAccountDAO.findByPK(note.getAssignedUserId());
                    String alertEmail = assignedUser.getEmail();
                    message.append(MessageFormat.format(respage.getString("mailDNHeader"), assignedUser.getFirstName(), assignedUser.getLastName()));
                    message.append("<A HREF='" + SQLInitServlet.getField("sysURL.base") + "ViewNotes?module=submit&listNotes_f_discrepancyNoteBean.user=" + assignedUser.getName() + "&listNotes_f_entityName=" + note.getEntityName() + "'>" + SQLInitServlet.getField("sysURL.base") + "</A><BR/>");
                    message.append(respage.getString("you_received_this_from"));
                    StudyBean study = (StudyBean) studyDAO.findByPK(note.getStudyId());
                    SectionDAO sectionDAO = new SectionDAO(sm.getDataSource());
                    if ("itemData".equalsIgnoreCase(entityType)) {
                        itemData = (ItemDataBean) iddao.findByPK(note.getEntityId());
                        item = (ItemBean) itemDAO.findByPK(itemData.getItemId());
                        if (sectionId > 0) {
                            section = (SectionBean) sectionDAO.findByPK(sectionId);
                        } else {
                        // Todo section should be initialized when sectionId = 0
                        }
                    }
                    message.append(respage.getString("email_body_separator"));
                    message.append(respage.getString("disc_note_info"));
                    message.append(respage.getString("email_body_separator"));
                    message.append(MessageFormat.format(respage.getString("mailDNParameters1"), note.getDescription(), note.getDetailedNotes(), ub.getName()));
                    message.append(respage.getString("email_body_separator"));
                    message.append(respage.getString("entity_information"));
                    message.append(respage.getString("email_body_separator"));
                    message.append(MessageFormat.format(respage.getString("mailDNParameters2"), study.getName(), note.getSubjectName()));
                    if (!("studySub".equalsIgnoreCase(entityType) || "subject".equalsIgnoreCase(entityType))) {
                        message.append(MessageFormat.format(respage.getString("mailDNParameters3"), note.getEventName()));
                        if (!"studyEvent".equalsIgnoreCase(note.getEntityType())) {
                            message.append(MessageFormat.format(respage.getString("mailDNParameters4"), note.getCrfName()));
                            if (!"eventCrf".equalsIgnoreCase(note.getEntityType())) {
                                if (sectionId > 0) {
                                    message.append(MessageFormat.format(respage.getString("mailDNParameters5"), section.getName()));
                                }
                                message.append(MessageFormat.format(respage.getString("mailDNParameters6"), item.getName()));
                            }
                        }
                    }
                    message.append(respage.getString("email_body_separator"));
                    message.append(MessageFormat.format(respage.getString("mailDNThanks"), study.getName()));
                    message.append(respage.getString("email_body_separator"));
                    message.append(respage.getString("disclaimer"));
                    message.append(respage.getString("email_body_separator"));
                    message.append(respage.getString("email_footer"));
                    String emailBodyString = message.toString();
                    sendEmail(alertEmail.trim(), EmailEngine.getAdminEmail(), MessageFormat.format(respage.getString("mailDNSubject"), study.getName(), note.getEntityName()), emailBodyString, true, null, null, true);
                } else {
                    logger.debug("did not send email, but did save DN");
                }
                // addPageMessage(
                // "Your discrepancy note has been saved into database.");
                addPageMessage(respage.getString("note_saved_into_db"));
                addPageMessage(respage.getString("page_close_automatically"));
                forwardPage(Page.ADD_DISCREPANCY_NOTE_SAVE_DONE);
            }
        } else {
            if (parentId > 0) {
                if (note.getResolutionStatusId() == ResolutionStatus.NOT_APPLICABLE.getId()) {
                    request.setAttribute("autoView", "0");
                }
            } else {
                if (note.getDiscrepancyNoteTypeId() == DiscrepancyNoteType.QUERY.getId()) {
                    request.setAttribute("autoView", "1");
                } else {
                    request.setAttribute("autoView", "0");
                }
            }
            setInputMessages(errors);
            forwardPage(Page.ADD_DISCREPANCY_NOTE);
        }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) HashMap(java.util.HashMap) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) ArrayList(java.util.ArrayList) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) ResolutionStatus(org.akaza.openclinica.bean.core.ResolutionStatus) DiscrepancyNoteType(org.akaza.openclinica.bean.core.DiscrepancyNoteType) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) List(java.util.List) ArrayList(java.util.ArrayList) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) Role(org.akaza.openclinica.bean.core.Role) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DateFormat(java.text.DateFormat) Validator(org.akaza.openclinica.control.form.Validator) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 64 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class ViewNotesServlet method processRequest.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
@Override
protected void processRequest() throws Exception {
    String module = request.getParameter("module");
    String moduleStr = "manage";
    if (module != null && module.trim().length() > 0) {
        if ("submit".equals(module)) {
            request.setAttribute("module", "submit");
            moduleStr = "submit";
        } else if ("admin".equals(module)) {
            request.setAttribute("module", "admin");
            moduleStr = "admin";
        } else {
            request.setAttribute("module", "manage");
        }
    }
    FormProcessor fp = new FormProcessor(request);
    if (fp.getString("showMoreLink").equals("")) {
        showMoreLink = true;
    } else {
        showMoreLink = Boolean.parseBoolean(fp.getString("showMoreLink"));
    }
    int oneSubjectId = fp.getInt("id");
    // BWP 11/03/2008 3029: This session attribute in removed in
    // ResolveDiscrepancyServlet.mayProceed() >>
    session.setAttribute("subjectId", oneSubjectId);
    // >>
    int resolutionStatusSubj = fp.getInt(RESOLUTION_STATUS);
    int discNoteType = 0;
    try {
        discNoteType = Integer.parseInt(request.getParameter("type"));
    } catch (NumberFormatException nfe) {
        // Show all DN's
        discNoteType = -1;
    }
    request.setAttribute(DISCREPANCY_NOTE_TYPE, discNoteType);
    boolean removeSession = fp.getBoolean("removeSession");
    // BWP 11/03/2008 3029: This session attribute in removed in
    // ResolveDiscrepancyServlet.mayProceed() >>
    session.setAttribute("module", module);
    // >>
    // Do we only want to view the notes for 1 subject?
    String viewForOne = fp.getString("viewForOne");
    boolean isForOneSubjectsNotes = "y".equalsIgnoreCase(viewForOne);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    dndao.setFetchMapping(true);
    int resolutionStatus = 0;
    try {
        resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
    } catch (NumberFormatException nfe) {
        // Show all DN's
        resolutionStatus = -1;
    }
    if (removeSession) {
        session.removeAttribute(WIN_LOCATION);
        session.removeAttribute(NOTES_TABLE);
    }
    // after resolving a note, user wants to go back to view notes page, we
    // save the current URL
    // so we can go back later
    session.setAttribute(WIN_LOCATION, "ViewNotes?viewForOne=" + viewForOne + "&id=" + oneSubjectId + "&module=" + module + " &removeSession=1");
    boolean hasAResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 5;
    Set<Integer> resolutionStatusIds = (HashSet) session.getAttribute(RESOLUTION_STATUS);
    // remove the session if there is no resolution status
    if (!hasAResolutionStatus && resolutionStatusIds != null) {
        session.removeAttribute(RESOLUTION_STATUS);
        resolutionStatusIds = null;
    }
    if (hasAResolutionStatus) {
        if (resolutionStatusIds == null) {
            resolutionStatusIds = new HashSet<Integer>();
        }
        resolutionStatusIds.add(resolutionStatus);
        session.setAttribute(RESOLUTION_STATUS, resolutionStatusIds);
    }
    StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
    StudyDAO studyDao = new StudyDAO(sm.getDataSource());
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO crfDao = new CRFDAO(sm.getDataSource());
    StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO eventDefinitionCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
    ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource());
    ItemDAO itemDao = new ItemDAO(sm.getDataSource());
    EventCRFDAO eventCRFDao = new EventCRFDAO(sm.getDataSource());
    ListNotesTableFactory factory = new ListNotesTableFactory(showMoreLink);
    factory.setSubjectDao(sdao);
    factory.setStudySubjectDao(subdao);
    factory.setUserAccountDao(uadao);
    factory.setStudyDao(studyDao);
    factory.setCurrentStudy(currentStudy);
    factory.setDiscrepancyNoteDao(dndao);
    factory.setCrfDao(crfDao);
    factory.setCrfVersionDao(crfVersionDao);
    factory.setStudyEventDao(studyEventDao);
    factory.setStudyEventDefinitionDao(studyEventDefinitionDao);
    factory.setEventDefinitionCRFDao(eventDefinitionCRFDao);
    factory.setItemDao(itemDao);
    factory.setItemDataDao(itemDataDao);
    factory.setEventCRFDao(eventCRFDao);
    factory.setModule(moduleStr);
    factory.setDiscNoteType(discNoteType);
    factory.setResolutionStatus(resolutionStatus);
    factory.setViewNotesService(resolveViewNotesService());
    // factory.setResolutionStatusIds(resolutionStatusIds);
    TableFacade tf = factory.createTable(request, response);
    Map<String, Map<String, String>> stats = generateDiscrepancyNotesSummary(factory.getNotesSummary());
    Map<String, String> totalMap = generateDiscrepancyNotesTotal(stats);
    int grandTotal = 0;
    for (String typeName : totalMap.keySet()) {
        String total = totalMap.get(typeName);
        grandTotal = total.equals("--") ? grandTotal + 0 : grandTotal + Integer.parseInt(total);
    }
    request.setAttribute("summaryMap", stats);
    tf.setTotalRows(grandTotal);
    String viewNotesHtml = tf.render();
    request.setAttribute("viewNotesHtml", viewNotesHtml);
    String viewNotesURL = this.getPageURL();
    session.setAttribute("viewNotesURL", viewNotesURL);
    String viewNotesPageFileName = this.getPageServletFileName();
    session.setAttribute("viewNotesPageFileName", viewNotesPageFileName);
    request.setAttribute("mapKeys", ResolutionStatus.getMembers());
    request.setAttribute("typeNames", DiscrepancyNoteUtil.getTypeNames());
    request.setAttribute("typeKeys", totalMap);
    request.setAttribute("grandTotal", grandTotal);
    if ("yes".equalsIgnoreCase(fp.getString(PRINT))) {
        List<DiscrepancyNoteBean> allNotes = factory.findAllNotes(tf);
        request.setAttribute("allNotes", allNotes);
        forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_PRINT);
    } else {
        forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY);
    }
}
Also used : ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) HashSet(java.util.HashSet) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) 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) 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) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) TableFacade(org.jmesa.facade.TableFacade) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) HashMap(java.util.HashMap) Map(java.util.Map) ListNotesTableFactory(org.akaza.openclinica.control.submit.ListNotesTableFactory)

Example 65 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class ViewNoteServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Locale locale = LocaleResolver.getLocale(request);
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    dndao.setFetchMapping(true);
    int noteId = fp.getInt(NOTE_ID, true);
    DiscrepancyNoteBean note = (DiscrepancyNoteBean) dndao.findByPK(noteId);
    String entityType = note.getEntityType();
    if (note.getEntityId() > 0 && !entityType.equals("")) {
        if (!StringUtil.isBlank(entityType)) {
            if ("itemData".equalsIgnoreCase(entityType)) {
                ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                ItemDataBean itemData = (ItemDataBean) iddao.findByPK(note.getEntityId());
                ItemDAO idao = new ItemDAO(sm.getDataSource());
                ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
                note.setEntityValue(itemData.getValue());
                note.setEntityName(item.getName());
                // Mantis Issue 5165. It should be itemData.getId() instead of item.getId()
                note.setEntityId(itemData.getId());
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(ec.getStudyEventId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
                CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
                CRFDAO cdao = new CRFDAO(sm.getDataSource());
                CRFBean crf = (CRFBean) cdao.findByPK(cv.getCrfId());
                note.setCrfName(crf.getName());
            } else if ("studySub".equalsIgnoreCase(entityType)) {
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(note.getEntityId());
                note.setStudySub(ssub);
                // System.out.println("column" + note.getColumn());
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(ssub.getSubjectId());
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("enrollment_date".equalsIgnoreCase(note.getColumn())) {
                        if (ssub.getEnrollmentDate() != null) {
                            note.setEntityValue(dateFormatter.format(ssub.getEnrollmentDate()));
                        }
                        note.setEntityName(resword.getString("enrollment_date"));
                    } else if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    }
                }
            } else if ("subject".equalsIgnoreCase(entityType)) {
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = new StudySubjectBean();
                ssub.setLabel(sub.getUniqueIdentifier());
                note.setStudySub(ssub);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    } else if ("unique_identifier".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityName(resword.getString("unique_identifier"));
                        note.setEntityValue(sub.getUniqueIdentifier());
                    }
                }
            } else if ("studyEvent".equalsIgnoreCase(entityType)) {
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(note.getEntityId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("location".equalsIgnoreCase(note.getColumn())) {
                        request.setAttribute("entityValue", se.getLocation());
                        request.setAttribute("entityName", resword.getString("location"));
                        note.setEntityName(resword.getString("location"));
                        note.setEntityValue(se.getLocation());
                    } else if ("date_start".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateStarted() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateStarted()));
                        }
                        note.setEntityName(resword.getString("start_date"));
                    } else if ("date_end".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateEnded() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateEnded()));
                        }
                        note.setEntityName(resword.getString("end_date"));
                    }
                }
            } else if ("eventCrf".equalsIgnoreCase(entityType)) {
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = (StudySubjectBean) new StudySubjectDAO(sm.getDataSource()).findByPK(ec.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventBean event = (StudyEventBean) new StudyEventDAO(sm.getDataSource()).findByPK(ec.getStudyEventId());
                note.setEvent(event);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("date_interviewed".equals(note.getColumn())) {
                        if (ec.getDateInterviewed() != null) {
                            note.setEntityValue(dateFormatter.format(ec.getDateInterviewed()));
                        }
                        note.setEntityName(resword.getString("date_interviewed"));
                    } else if ("interviewer_name".equals(note.getColumn())) {
                        note.setEntityValue(ec.getInterviewerName());
                        note.setEntityName(resword.getString("interviewer_name"));
                    }
                }
            }
        }
    }
    // Mantis Issue 8495.
    if (note.getStudyId() != currentStudy.getId()) {
        if (currentStudy.getParentStudyId() > 0) {
            if (currentStudy.getId() != note.getStudySub().getStudyId()) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        } else {
            // The SubjectStudy is not belong to currentstudy and current study is not a site.
            StudyDAO studydao = new StudyDAO(sm.getDataSource());
            Collection sites;
            sites = studydao.findOlnySiteIdsByStudy(currentStudy);
            if (!sites.contains(note.getStudySub().getStudyId())) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        }
    }
    // Check end
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    ArrayList<DiscrepancyNoteBean> notes = dndao.findAllEntityByPK(note.getEntityType(), noteId);
    Date lastUpdatedDate = note.getCreatedDate();
    UserAccountBean lastUpdator = (UserAccountBean) udao.findByPK(note.getOwnerId());
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId == 0) { note = n; note.setLastUpdator((UserAccountBean)
         * udao.findByPK(n.getOwnerId()));
         * note.setLastDateUpdated(n.getCreatedDate()); lastUpdatedDate =
         * note.getLastDateUpdated(); lastUpdator = note.getLastUpdator(); } }
         */
    // BWP 3029 >> This algorithm needs to be changed to properly set
    // the parent note's status and updated date
    // First sort the notes on their ID; this will put the parent note
    // first; and
    // the note with the latest status and updated date last
    java.util.Collections.sort(notes);
    DiscrepancyNoteBean lastChild = notes.get(notes.size() - 1);
    lastUpdatedDate = lastChild.getCreatedDate();
    lastUpdator = (UserAccountBean) udao.findByPK(lastChild.getOwnerId());
    note.setLastUpdator(lastUpdator);
    note.setLastDateUpdated(lastUpdatedDate);
    note.setUpdatedDate(lastUpdatedDate);
    for (DiscrepancyNoteBean dnBean : notes) {
        if (dnBean.getParentDnId() > 0) {
            note.getChildren().add(dnBean);
        }
    }
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId > 0) { note.getChildren().add(n);
         *
         * if (!n.getCreatedDate().before(lastUpdatedDate)) { lastUpdatedDate =
         * n.getCreatedDate(); lastUpdator = (UserAccountBean)
         * udao.findByPK(n.getOwnerId()); note.setLastUpdator(lastUpdator);
         * note.setLastDateUpdated(lastUpdatedDate);
         * note.setResolutionStatusId(n.getResolutionStatusId());
         * note.setResStatus(ResolutionStatus.get(n.getResolutionStatusId())); } } }
         */
    note.setNumChildren(note.getChildren().size());
    note.setDisType(DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId()));
    request.setAttribute(DIS_NOTE, note);
    forwardPage(Page.VIEW_SINGLE_NOTE);
}
Also used : Locale(java.util.Locale) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DateFormat(java.text.DateFormat) Collection(java.util.Collection) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

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