use of org.akaza.openclinica.dao.extract.FilterDAO 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.dao.extract.FilterDAO 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.dao.extract.FilterDAO 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;
}
use of org.akaza.openclinica.dao.extract.FilterDAO in project OpenClinica by OpenClinica.
the class RemoveFilterServlet 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();
// 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("CreateFiltersOne", new HashMap());
table.setRows(filterRows);
table.computeDisplay();
return table;
}
use of org.akaza.openclinica.dao.extract.FilterDAO in project OpenClinica by OpenClinica.
the class RemoveFilterServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int filterId = fp.getInt("filterId");
FilterDAO fDAO = new FilterDAO(sm.getDataSource());
FilterBean filter = (FilterBean) fDAO.findByPK(filterId);
String action = request.getParameter("action");
if (resword.getString("remove_this_filter").equalsIgnoreCase(action)) {
filter.setStatus(Status.DELETED);
fDAO.update(filter);
addPageMessage(respage.getString("filter_removed_admin_can_access_and_reverse"));
EntityBeanTable table = getFilterTable();
request.setAttribute("table", table);
forwardPage(Page.CREATE_FILTER_SCREEN_1);
} else if (resword.getString("cancel").equalsIgnoreCase(action)) {
EntityBeanTable table = getFilterTable();
request.setAttribute("table", table);
forwardPage(Page.CREATE_FILTER_SCREEN_1);
} else {
request.setAttribute("filter", filter);
forwardPage(Page.REMOVE_FILTER);
}
}
Aggregations