Search in sources :

Example 1 with ListNotesTableFactory

use of org.akaza.openclinica.control.submit.ListNotesTableFactory 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)

Aggregations

HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)1 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)1 ListNotesTableFactory (org.akaza.openclinica.control.submit.ListNotesTableFactory)1 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)1 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)1 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)1 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)1 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)1 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)1 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)1 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)1 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)1 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)1 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)1 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)1 SubjectDAO (org.akaza.openclinica.dao.submit.SubjectDAO)1 TableFacade (org.jmesa.facade.TableFacade)1