Search in sources :

Example 1 with ViewNotesFilterCriteria

use of org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria 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 2 with ViewNotesFilterCriteria

use of org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria in project OpenClinica by OpenClinica.

the class ListNotesTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());
    int parentStudyId = 0;
    Limit limit = tableFacade.getLimit();
    if (!limit.isComplete()) {
        parentStudyId = currentStudy.getId();
        // Build row count of various DN types
        int totalRows = getDiscrepancyNoteDao().getSubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getStudySubjectDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getStudyEventDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getEventCrfDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        totalRows += getDiscrepancyNoteDao().getItemDataDNCountWithFilter(getListNoteFilter(limit), parentStudyId);
        tableFacade.setTotalRows(totalRows);
    }
    ViewNotesFilterCriteria filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
    notesSummary = getViewNotesService().calculateNotesSummary(getCurrentStudy(), filter);
    int pageSize = limit.getRowSelect().getMaxRows();
    int firstRecordShown = (limit.getRowSelect().getPage() - 1) * pageSize;
    if (firstRecordShown > notesSummary.getTotal() && notesSummary.getTotal() != 0) {
        // The page selected goes beyond the dataset size
        // Move to the last page
        limit.getRowSelect().setPage((int) Math.ceil((double) notesSummary.getTotal() / pageSize));
        filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
    }
    List<DiscrepancyNoteBean> items = getViewNotesService().listNotes(getCurrentStudy(), filter, ViewNotesSortCriteria.buildFilterCriteria(limit.getSortSet()));
    this.setAllNotes(items);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    for (DiscrepancyNoteBean discrepancyNoteBean : items) {
        HashMap<Object, Object> h = new HashMap<Object, Object>();
        h.put("studySubject", discrepancyNoteBean.getStudySub());
        h.put("studySubject.label", discrepancyNoteBean.getStudySub().getLabel());
        h.put("discrepancyNoteBean.disType", discrepancyNoteBean.getDisType());
        h.put("discrepancyNoteBean.resolutionStatus", discrepancyNoteBean.getResStatus());
        h.put("age", discrepancyNoteBean.getAge());
        h.put("days", discrepancyNoteBean.getDays());
        h.put("siteId", discrepancyNoteBean.getSiteId());
        h.put("discrepancyNoteBean", discrepancyNoteBean);
        h.put("discrepancyNoteBean.createdDate", discrepancyNoteBean.getCreatedDate());
        h.put("discrepancyNoteBean.updatedDate", discrepancyNoteBean.getUpdatedDate());
        h.put("eventName", discrepancyNoteBean.getEventName());
        h.put("eventStartDate", discrepancyNoteBean.getEventStart());
        h.put("crfName", discrepancyNoteBean.getCrfName());
        h.put("crfStatus", discrepancyNoteBean.getCrfStatus());
        h.put("entityName", discrepancyNoteBean.getEntityName());
        h.put("entityValue", discrepancyNoteBean.getEntityValue());
        h.put("discrepancyNoteBean", discrepancyNoteBean);
        h.put("discrepancyNoteBean.description", discrepancyNoteBean.getDescription());
        h.put("discrepancyNoteBean.detailedNotes", discrepancyNoteBean.getDetailedNotes());
        h.put("numberOfNotes", discrepancyNoteBean.getNumChildren());
        h.put("discrepancyNoteBean.user", discrepancyNoteBean.getAssignedUser());
        h.put("discrepancyNoteBean.entityType", discrepancyNoteBean.getEntityType());
        h.put("discrepancyNoteBean.owner", discrepancyNoteBean.getOwner());
        theItems.add(h);
        setStudyHasDiscNotes(true);
    }
    tableFacade.setItems(theItems);
}
Also used : HashMap(java.util.HashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ViewNotesFilterCriteria(org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit)

Example 3 with ViewNotesFilterCriteria

use of org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria in project OpenClinica by OpenClinica.

the class ListNotesTableFactory method findAllNotes.

public List<DiscrepancyNoteBean> findAllNotes(TableFacade tableFacade) {
    Limit limit = tableFacade.getLimit();
    limit.setRowSelect(null);
    ViewNotesFilterCriteria filter = ViewNotesFilterCriteria.buildFilterCriteria(limit, getDateFormat(), discrepancyNoteTypeDropdown.getDecoder(), resolutionStatusDropdown.getDecoder());
    List<DiscrepancyNoteBean> items = getViewNotesService().listNotes(getCurrentStudy(), filter, ViewNotesSortCriteria.buildFilterCriteria(limit.getSortSet()));
    return items;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ViewNotesFilterCriteria(org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria) Limit(org.jmesa.limit.Limit)

Aggregations

DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)3 ViewNotesFilterCriteria (org.akaza.openclinica.service.managestudy.ViewNotesFilterCriteria)3 ArrayList (java.util.ArrayList)2 Limit (org.jmesa.limit.Limit)2 HashMap (java.util.HashMap)1 DownloadDiscrepancyNote (org.akaza.openclinica.bean.extract.DownloadDiscrepancyNote)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)1 ListNotesFilter (org.akaza.openclinica.dao.managestudy.ListNotesFilter)1 DiscrepancyNoteThread (org.akaza.openclinica.service.DiscrepancyNoteThread)1 DiscrepancyNoteUtil (org.akaza.openclinica.service.DiscrepancyNoteUtil)1 ViewNotesService (org.akaza.openclinica.service.managestudy.ViewNotesService)1