Search in sources :

Example 41 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class DiscrepancyNoteOutputServlet method processRequest.

/* Handle the HTTP Get or Post request. */
@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // the fileName contains any subject id and study unique protocol id;
    // see: chooseDownloadFormat.jsp
    String fileName = request.getParameter("fileName");
    // the filename is formulated correctly
    if (fileName != null) {
        fileName = fileName.replaceAll(" ", "_");
    }
    fileName = fileName == null ? "" : fileName;
    // the format will be either csv (comma separated values) or pdf (portable document format)
    String format = request.getParameter("fmt");
    String studyIdentifier = request.getParameter("studyIdentifier");
    // Determine whether to limit the displayed DN's to a certain resolutionStatus
    // CHANGED TO LIST OF RESOLUTION STATUS IDS
    /*int resolutionStatus = 0;
        try {
            resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
        } catch(NumberFormatException nfe){
            //Show all DN's
            resolutionStatus=-1;
        }*/
    // possibly for a later implementation: int definitionId = fp.getInt("defId");
    //here subjectId actually is study_subject_id !!!
    int subjectId = fp.getInt("subjectId");
    int discNoteType = fp.getInt("discNoteType");
    DownloadDiscrepancyNote downLoader = new DownloadDiscrepancyNote();
    if ("csv".equalsIgnoreCase(format)) {
        fileName = fileName + ".csv";
        response.setContentType(DownloadDiscrepancyNote.CSV);
    } else {
        response.setContentType(DownloadDiscrepancyNote.PDF);
        fileName = fileName + ".pdf";
    }
    response.addHeader(CONTENT_DISPOSITION_HEADER, CONTENT_DISPOSITION_VALUE + fileName);
    // Are we downloading a List of discrepancy notes or just one?
    // Not needed now: boolean isList = ("y".equalsIgnoreCase(isAList));
    StudyBean studyBean = (StudyBean) session.getAttribute("study");
    //        Set<Integer> resolutionStatusIds = (HashSet) session.getAttribute("resolutionStatus");
    // It will also change any resolution status IDs among parents of children that have a different
    // id value (last boolean parameter; 'true' to perform the latter task)
    // In this case we want to include all the discrepancy notes, despite the res status or
    // type filtering, because we don't want to filter out parents, thus leaving out a child note
    // that might match the desired res status
    ListNotesFilter listNotesFilter = new ListNotesFilter();
    ViewNotesService viewNotesService = (ViewNotesService) WebApplicationContextUtils.getWebApplicationContext(getServletContext()).getBean("viewNotesService");
    ViewNotesFilterCriteria filter = ViewNotesFilterCriteria.buildFilterCriteria(getFilters(request), getDateFormat(), discrepancyNoteTypesDecoder, resolutionStatusDecoder);
    List<DiscrepancyNoteBean> notes = viewNotesService.listNotes(currentStudy, filter, ViewNotesSortCriteria.buildFilterCriteria(getSortOrder(request)));
    ArrayList<DiscrepancyNoteBean> allDiscNotes = notes instanceof ArrayList ? (ArrayList<DiscrepancyNoteBean>) notes : new ArrayList<DiscrepancyNoteBean>(notes);
    allDiscNotes = populateRowsWithAttachedData(allDiscNotes);
    // Now we have to package all the discrepancy notes in DiscrepancyNoteThread objects
    // Do the filtering for type or status here
    DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();
    Set<Integer> resolutionStatusIds = emptySet();
    List<DiscrepancyNoteThread> discrepancyNoteThreads = discNoteUtil.createThreads(allDiscNotes, sm.getDataSource(), studyBean);
    if ("csv".equalsIgnoreCase(format)) {
        /*response.setContentLength(
              downLoader.getListContentLength(allDiscNotes,DownloadDiscrepancyNote.CSV));*/
        //3014: this has been changed to only show the parent of the thread; then changed back again!
        int contentLen = downLoader.getThreadListContentLength(discrepancyNoteThreads);
        response.setContentLength(contentLen);
        /*downLoader.downLoadDiscBeans(allDiscNotes,
              DownloadDiscrepancyNote.CSV,response.getOutputStream(), null);*/
        downLoader.downLoadThreadedDiscBeans(discrepancyNoteThreads, DownloadDiscrepancyNote.CSV, response, null);
    } else {
        response.setHeader("Pragma", "public");
        /*downLoader.downLoadDiscBeans(allDiscNotes,
              DownloadDiscrepancyNote.PDF,
              response.getOutputStream(), studyIdentifier);*/
        downLoader.downLoadThreadedDiscBeans(discrepancyNoteThreads, DownloadDiscrepancyNote.PDF, response, studyIdentifier);
    }
}
Also used : DownloadDiscrepancyNote(org.akaza.openclinica.bean.extract.DownloadDiscrepancyNote) ViewNotesService(org.akaza.openclinica.service.managestudy.ViewNotesService) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ViewNotesFilterCriteria(org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria) ArrayList(java.util.ArrayList) ListNotesFilter(org.akaza.openclinica.dao.managestudy.ListNotesFilter) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DiscrepancyNoteUtil(org.akaza.openclinica.service.DiscrepancyNoteUtil) DiscrepancyNoteThread(org.akaza.openclinica.service.DiscrepancyNoteThread)

Example 42 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class CreateFiltersOneServlet method processRequest.

// < ResourceBundlerestext,resword,respage,resexception;
@Override
public void processRequest() throws Exception {
    // clean up the previous setup, if necessary
    session.removeAttribute("newExp");
    // removes the new explanation for setting up the create dataset
    // covers the plan if you cancel out of a process then want to get in
    // again, tbh
    String action = request.getParameter("action");
    if (StringUtil.isBlank(action)) {
        // our start page:
        // note that this is now set up to accept the
        // tabling classes created in View.
        FormProcessor fp = new FormProcessor(request);
        FilterDAO fdao = new FilterDAO(sm.getDataSource());
        EntityBeanTable table = fp.getEntityBeanTable();
        ArrayList filters = new ArrayList();
        if (ub.isSysAdmin()) {
            filters = (ArrayList) fdao.findAllAdmin();
        } else {
            filters = (ArrayList) fdao.findAll();
        }
        ArrayList filterRows = FilterRow.generateRowsFromBeans(filters);
        String[] columns = { resword.getString("filter_name"), resword.getString("description"), resword.getString("created_by"), resword.getString("created_date"), resword.getString("status"), resword.getString("actions") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(5);
        table.addLink(resword.getString("create_new_filter"), "CreateFiltersOne?action=begin");
        table.setQuery("CreateFiltersOne", new HashMap());
        table.setRows(filterRows);
        table.computeDisplay();
        request.setAttribute("table", table);
        // the code above replaces the following line:
        // request.setAttribute("filters",filters);
        forwardPage(Page.CREATE_FILTER_SCREEN_1);
    } else if ("begin".equalsIgnoreCase(action)) {
        forwardPage(Page.CREATE_FILTER_SCREEN_2);
    }
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList)

Example 43 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ApplyFilterServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    // if details == show details with an option to return to the list page
    if (StringUtil.isBlank(action)) {
        EntityBeanTable table = getFilterTable();
        request.setAttribute("table", table);
        forwardPage(Page.APPLY_FILTER);
    } else if ("validate".equalsIgnoreCase(action)) {
        FormProcessor fp = new FormProcessor(request);
        HashMap errors = new HashMap();
        if (fp.getString("submit").equalsIgnoreCase(resword.getString("apply_filter"))) {
            if (fp.getInt("filterId") > 0) {
                FilterDAO fdao = new FilterDAO(sm.getDataSource());
                FilterBean fb = (FilterBean) fdao.findByPK(fp.getInt("filterId"));
                session.setAttribute("newFilter", fb);
            } else {
                Validator.addError(errors, "all", resword.getString("no_filter_was_chosen"));
            }
            if (!errors.isEmpty()) {
                EntityBeanTable table = getFilterTable();
                request.setAttribute("table", table);
                addPageMessage(respage.getString("errors_in_submission_see_below"));
                setInputMessages(errors);
                forwardPage(Page.APPLY_FILTER);
            } else {
                // move on to the next page in create dataset
                request.setAttribute("statuses", getStatuses());
                forwardPage(Page.CREATE_DATASET_4);
            }
        } else if (fp.getString("submit").equalsIgnoreCase(resword.getString("create_new_filter"))) {
            // forward on to the rules, already on screen 2
            forwardPage(Page.CREATE_FILTER_SCREEN_2);
        } else if (fp.getString("submit").equalsIgnoreCase(resword.getString("skip_apply_filter_and_save"))) {
            // send back to creating a dataset:
            // TODO set the longitudinal dates?
            // or back a screen before/after that?
            String[] fieldNames = { "firstmonth", "firstyear", "lastmonth", "lastyear" };
            fp.setCurrentIntValuesAsPreset(fieldNames);
            setPresetValues(fp.getPresetValues());
            request.setAttribute(BEAN_MONTHS, getMonths());
            request.setAttribute(BEAN_YEARS, getYears());
            forwardPage(Page.CREATE_DATASET_3);
        } else {
        // throw an error, you shouldn't get here
        }
    } else if ("return".equalsIgnoreCase(action)) {
    // TODO figure out if we need this? tbh
    } else if ("details".equalsIgnoreCase(action)) {
        FormProcessor fp = new FormProcessor(request);
        int filterId = fp.getInt("filterId");
        FilterDAO fDAO = new FilterDAO(sm.getDataSource());
        FilterBean showFilter = (FilterBean) fDAO.findByPK(filterId);
        request.setAttribute(BEAN_FILTER, showFilter);
        forwardPage(Page.VIEW_FILTER_DETAILS);
    } else {
    // throw an error, you can't get here
    }
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) HashMap(java.util.HashMap) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) FilterBean(org.akaza.openclinica.bean.extract.FilterBean)

Example 44 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ApplyFilterServlet method getFilterTable.

private EntityBeanTable getFilterTable() {
    FormProcessor fp = new FormProcessor(request);
    FilterDAO fdao = new FilterDAO(sm.getDataSource());
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList filters = new ArrayList();
    if (ub.isSysAdmin()) {
        filters = (ArrayList) fdao.findAllAdmin();
    } else {
        filters = (ArrayList) fdao.findAll();
    }
    // TODO make findAllByProject????
    ArrayList filterRows = FilterRow.generateRowsFromBeans(filters);
    String[] columns = { resword.getString("filter_name"), resword.getString("description"), resword.getString("created_by"), resword.getString("created_date"), resword.getString("status"), resword.getString("actions") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(5);
    table.setQuery("ApplyFilter", new HashMap());
    table.setRows(filterRows);
    table.computeDisplay();
    return table;
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList)

Example 45 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class CreateDatasetServlet method getFilterTable.

private EntityBeanTable getFilterTable() {
    FormProcessor fp = new FormProcessor(request);
    FilterDAO fdao = new FilterDAO(sm.getDataSource());
    EntityBeanTable table = fp.getEntityBeanTable();
    ArrayList filters = (ArrayList) fdao.findAll();
    ArrayList filterRows = FilterRow.generateRowsFromBeans(filters);
    String[] columns = { resword.getString("filter_name"), resword.getString("description"), resword.getString("created_by"), resword.getString("created_date"), resword.getString("status"), resword.getString("actions") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(5);
    table.setQuery("ApplyFilter", new HashMap());
    table.setRows(filterRows);
    table.computeDisplay();
    return table;
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList)

Aggregations

FormProcessor (org.akaza.openclinica.control.form.FormProcessor)224 ArrayList (java.util.ArrayList)139 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)92 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)73 HashMap (java.util.HashMap)69 Date (java.util.Date)49 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)46 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 Validator (org.akaza.openclinica.control.form.Validator)44 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)44 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)42 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)41 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)41 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)40 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)36 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)36 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)35 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35