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);
}
}
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);
}
}
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
}
}
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;
}
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;
}
Aggregations