Search in sources :

Example 1 with FilterDAO

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;
}
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 2 with FilterDAO

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
    }
}
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 3 with FilterDAO

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

Example 4 with FilterDAO

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;
}
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 5 with FilterDAO

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);
    }
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) FilterBean(org.akaza.openclinica.bean.extract.FilterBean)

Aggregations

FormProcessor (org.akaza.openclinica.control.form.FormProcessor)8 FilterDAO (org.akaza.openclinica.dao.extract.FilterDAO)8 EntityBeanTable (org.akaza.openclinica.web.bean.EntityBeanTable)8 HashMap (java.util.HashMap)7 ArrayList (java.util.ArrayList)6 FilterBean (org.akaza.openclinica.bean.extract.FilterBean)4 Collection (java.util.Collection)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)1 FilterObjectBean (org.akaza.openclinica.bean.extract.FilterObjectBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)1 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)1 SectionBean (org.akaza.openclinica.bean.submit.SectionBean)1 Validator (org.akaza.openclinica.control.form.Validator)1 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)1 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)1 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)1 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)1