Search in sources :

Example 46 with FormProcessor

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

the class RemoveDatasetServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    int dsId = fp.getInt("dsId");
    DatasetDAO dsDAO = new DatasetDAO(sm.getDataSource());
    DatasetBean dataset = (DatasetBean) dsDAO.findByPK(dsId);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) sdao.findByPK(dataset.getStudyId());
    checkRoleByUserAndStudy(ub, study.getParentStudyId(), study.getId());
    if (study.getId() != currentStudy.getId() && study.getParentStudyId() != currentStudy.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    if (!ub.isSysAdmin() && dataset.getOwnerId() != ub.getId()) {
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
        forwardPage(Page.MENU_SERVLET);
        return;
    }
    String action = request.getParameter("action");
    if (resword.getString("remove_this_dataset").equalsIgnoreCase(action)) {
        dataset.setStatus(Status.DELETED);
        dsDAO.update(dataset);
        // +
        addPageMessage(respage.getString("dataset_removed"));
        // "System Administrators can "+
        // "restore it if necessary.");
        request.setAttribute("table", getDatasetTable());
        forwardPage(Page.VIEW_DATASETS);
    } else if (resword.getString("cancel").equalsIgnoreCase(action)) {
        request.setAttribute("table", getDatasetTable());
        forwardPage(Page.VIEW_DATASETS);
    } else {
        request.setAttribute("dataset", dataset);
        forwardPage(Page.REMOVE_DATASET);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 47 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor 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 48 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor 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)

Example 49 with FormProcessor

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

the class RestoreDatasetServlet method getDatasetTable.

private EntityBeanTable getDatasetTable() {
    FormProcessor fp = new FormProcessor(request);
    EntityBeanTable table = fp.getEntityBeanTable();
    DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
    ArrayList datasets = new ArrayList();
    // if (ub.isSysAdmin()) {
    // datasets =
    // (ArrayList)dsdao.findAllByStudyIdAdmin(currentStudy.getId());
    // } else {
    datasets = dsdao.findAllByStudyId(currentStudy.getId());
    // }
    ArrayList datasetRows = DatasetRow.generateRowsFromBeans(datasets);
    String[] columns = { resword.getString("dataset_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("show_only_my_datasets"), "ViewDatasets?action=owner&ownerId=" + ub.getId());
    table.addLink(resword.getString("create_dataset"), "CreateDataset");
    table.setQuery("ViewDatasets", new HashMap());
    table.setRows(datasetRows);
    table.computeDisplay();
    return table;
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO)

Example 50 with FormProcessor

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

the class RequestStudyServlet method confirm.

/**
     *
     * @param request
     * @param response
     */
private void confirm() throws Exception {
    Validator v = new Validator(request);
    v.addValidation("studyId", Validator.IS_AN_INTEGER);
    v.addValidation("studyRoleId", Validator.IS_VALID_TERM, TermType.ROLE);
    HashMap errors = v.validate();
    FormProcessor fp = new FormProcessor(request);
    StudyUserRoleBean newRole = new StudyUserRoleBean();
    if (fp.getInt("studyRoleId") > 0) {
        newRole.setRole(Role.get(fp.getInt("studyRoleId")));
    }
    newRole.setStudyId(fp.getInt("studyId"));
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean studyRequested = (StudyBean) sdao.findByPK(newRole.getStudyId());
    newRole.setStudyName(studyRequested.getName());
    session.setAttribute("newRole", newRole);
    if (!errors.isEmpty()) {
        logger.info("after processing form,error is not empty");
        request.setAttribute("formMessages", errors);
        forwardPage(Page.REQUEST_STUDY);
    } else {
        logger.info("after processing form,no errors");
        forwardPage(Page.REQUEST_STUDY_CONFIRM);
    }
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Validator(org.akaza.openclinica.control.form.Validator)

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