Search in sources :

Example 26 with FormProcessor

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

the class PauseJobServlet method processRequest.

// also perhaps DRY, tbh
@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    String triggerName = fp.getString("tname");
    // String gName = fp.getString("gname");
    String gName = request.getParameter("gname");
    String finalGroupName = "";
    if ("".equals(gName) || "0".equals(gName)) {
        finalGroupName = XsltTriggerService.TRIGGER_GROUP_NAME;
    } else {
        // should equal 1
        finalGroupName = groupImportName;
    }
    String deleteMe = fp.getString("del");
    scheduler = getScheduler();
    Trigger trigger = scheduler.getTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
    try {
        if (("y".equals(deleteMe)) && (ub.isSysAdmin())) {
            scheduler.deleteJob(JobKey.jobKey(triggerName, finalGroupName));
            // set return message here
            logger.debug("deleted job: " + triggerName);
            addPageMessage("The following job " + triggerName + " and its corresponding Trigger have been deleted from the system.");
        } else {
            if (scheduler.getTriggerState(TriggerKey.triggerKey(triggerName, finalGroupName)) == Trigger.TriggerState.PAUSED) {
                scheduler.resumeTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
                // trigger.setPriority(Trigger.DEFAULT_PRIORITY);
                logger.debug("-- resuming trigger! " + triggerName + " " + finalGroupName);
                addPageMessage("This trigger " + triggerName + " has been resumed and will continue to run until paused or deleted.");
            // set message here
            } else {
                scheduler.pauseTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
                // trigger.setPriority(Trigger.STATE_PAUSED);
                logger.debug("-- pausing trigger! " + triggerName + " " + finalGroupName);
                addPageMessage("This trigger " + triggerName + " has been paused, and will not run again until it is restored.");
            // set message here
            }
        }
    } catch (NullPointerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // set a message
    if ("".equals(gName) || "0".equals(gName)) {
        forwardPage(Page.VIEW_JOB_SERVLET);
    } else {
        forwardPage(Page.VIEW_IMPORT_JOB_SERVLET);
    }
}
Also used : Trigger(org.quartz.Trigger) FormProcessor(org.akaza.openclinica.control.form.FormProcessor)

Example 27 with FormProcessor

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

the class RestoreCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt("id", true);
    String action = request.getParameter("action");
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_restore"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        ArrayList versions = cvdao.findAllByCRFId(crfId);
        crf.setVersions(versions);
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList edcs = (ArrayList) edcdao.findAllByCRF(crfId);
        SectionDAO secdao = new SectionDAO(sm.getDataSource());
        EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
        ArrayList eventCRFs = evdao.findAllByCRF(crfId);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("crfToRestore", crf);
            request.setAttribute("eventCRFs", eventCRFs);
            forwardPage(Page.RESTORE_CRF);
        } else {
            logger.info("submit to restore the crf");
            crf.setStatus(Status.AVAILABLE);
            crf.setUpdater(ub);
            crf.setUpdatedDate(new Date());
            cdao.update(crf);
            for (int i = 0; i < versions.size(); i++) {
                CRFVersionBean version = (CRFVersionBean) versions.get(i);
                if (version.getStatus().equals(Status.AUTO_DELETED)) {
                    version.setStatus(Status.AVAILABLE);
                    version.setUpdater(ub);
                    version.setUpdatedDate(new Date());
                    cvdao.update(version);
                    ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
                    for (int j = 0; j < sections.size(); j++) {
                        SectionBean section = (SectionBean) sections.get(j);
                        if (section.getStatus().equals(Status.AUTO_DELETED)) {
                            section.setStatus(Status.AVAILABLE);
                            section.setUpdater(ub);
                            section.setUpdatedDate(new Date());
                            secdao.update(section);
                        }
                    }
                }
            }
            for (int i = 0; i < edcs.size(); i++) {
                EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
                if (edc.getStatus().equals(Status.AUTO_DELETED)) {
                    edc.setStatus(Status.AVAILABLE);
                    edc.setUpdater(ub);
                    edc.setUpdatedDate(new Date());
                    edcdao.update(edc);
                }
            }
            ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
                if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
                    eventCRF.setStatus(Status.AVAILABLE);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    evdao.update(eventCRF);
                    ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
                    for (int j = 0; j < items.size(); j++) {
                        ItemDataBean item = (ItemDataBean) items.get(j);
                        if (item.getStatus().equals(Status.AUTO_DELETED)) {
                            item.setStatus(Status.AVAILABLE);
                            item.setUpdater(ub);
                            item.setUpdatedDate(new Date());
                            idao.update(item);
                        }
                    }
                }
            }
            addPageMessage(respage.getString("the_CRF") + crf.getName() + " " + respage.getString("has_been_restored_succesfully"));
            forwardPage(Page.CRF_LIST_SERVLET);
        }
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 28 with FormProcessor

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

the class RestoreCRFVersionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int versionId = fp.getInt("id", true);
    String action = fp.getString("action");
    if (versionId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_version_to_restore"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        if (StringUtil.isBlank(action)) {
            addPageMessage(respage.getString("no_action_specified"));
            forwardPage(Page.CRF_LIST_SERVLET);
            return;
        }
        CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId);
        SectionDAO secdao = new SectionDAO(sm.getDataSource());
        EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
        // find all event crfs by version id
        ArrayList eventCRFs = evdao.findAllByCRFVersion(versionId);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("versionToRestore", version);
            request.setAttribute("eventCRFs", eventCRFs);
            forwardPage(Page.RESTORE_CRF_VERSION);
        } else {
            logger.info("submit to restore the crf version");
            // version
            version.setStatus(Status.AVAILABLE);
            version.setUpdater(ub);
            version.setUpdatedDate(new Date());
            cvdao.update(version);
            // all sections
            ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
            for (int j = 0; j < sections.size(); j++) {
                SectionBean section = (SectionBean) sections.get(j);
                if (section.getStatus().equals(Status.AUTO_DELETED)) {
                    section.setStatus(Status.AVAILABLE);
                    section.setUpdater(ub);
                    section.setUpdatedDate(new Date());
                    secdao.update(section);
                }
            }
            // all item data related to event crfs
            ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
                if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
                    eventCRF.setStatus(Status.AVAILABLE);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    evdao.update(eventCRF);
                    ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
                    for (int j = 0; j < items.size(); j++) {
                        ItemDataBean item = (ItemDataBean) items.get(j);
                        if (item.getStatus().equals(Status.AUTO_DELETED)) {
                            item.setStatus(Status.AVAILABLE);
                            item.setUpdater(ub);
                            item.setUpdatedDate(new Date());
                            idao.update(item);
                        }
                    }
                }
            }
            addPageMessage(respage.getString("the_CRF_version") + version.getName() + " " + respage.getString("has_been_restored_succesfully"));
            forwardPage(Page.CRF_LIST_SERVLET);
        }
    }
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 29 with FormProcessor

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

the class InitUpdateCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_version_to_update"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        if (!ub.isSysAdmin() && (crf.getOwnerId() != ub.getId())) {
            addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
            forwardPage(Page.MENU_SERVLET);
            return;
        } else {
            session.setAttribute(CRF, crf);
            forwardPage(Page.UPDATE_CRF);
        }
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 30 with FormProcessor

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

the class ViewCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    panel.setSubmitDataModule(false);
    panel.setExtractData(false);
    panel.setCreateDataset(false);
    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from, manage or admin
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    int crfId = fp.getInt(CRF_ID);
    List<StudyBean> studyBeans = null;
    if (crfId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
        forwardPage(Page.CRF_LIST);
    } else {
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        // CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
        FormLayoutDAO fdao = new FormLayoutDAO<>(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        // ArrayList<CRFVersionBean> crfVersions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        ArrayList<FormLayoutBean> layoutVersions = (ArrayList<FormLayoutBean>) fdao.findAllByCRF(crfId);
        crf.setVersions(layoutVersions);
        ArrayList<ItemGroupCrvVersionUtil> items_verified = verifyUniqueItemPlacementInGroups(crf.getName());
        request.setAttribute("items", items_verified);
        if ("admin".equalsIgnoreCase(module)) {
            // BWP 3279: generate a table showing a list of studies associated with the CRF>>
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            studyBeans = findStudiesForCRFId(crfId, studyDAO);
            // Create the Jmesa table for the studies associated with the CRF
            String studyHtml = renderStudiesTable(studyBeans);
            request.setAttribute("studiesTableHTML", studyHtml);
        // >>
        }
        Collection<TableColumnHolder> items = populate(crf, layoutVersions);
        request.setAttribute(CRF, crf);
        forwardPage(Page.VIEW_CRF);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) ItemGroupCrvVersionUtil(org.akaza.openclinica.core.util.ItemGroupCrvVersionUtil) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

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