Search in sources :

Example 96 with FormProcessor

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

the class EnterDataForStudyEventServlet method processRequest.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
@Override
protected void processRequest() throws Exception {
    // removeLockedCRF(ub.getId());
    getCrfLocker().unlockAllForUser(ub.getId());
    FormProcessor fp = new FormProcessor(request);
    int eventId = fp.getInt(INPUT_EVENT_ID, true);
    request.setAttribute("eventId", eventId + "");
    request.setAttribute("originatingPage", URLEncoder.encode("EnterDataForStudyEvent?eventId=" + eventId, "UTF-8"));
    // so we can display the event for which we're entering data
    StudyEventBean seb = getStudyEvent(eventId);
    // so we can display the subject's label
    StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
    StudySubjectBean studySubjectBean = (StudySubjectBean) ssdao.findByPK(seb.getStudySubjectId());
    int studyId = studySubjectBean.getStudyId();
    StudyDAO studydao = new StudyDAO(sm.getDataSource());
    StudyBean study = (StudyBean) studydao.findByPK(studyId);
    // If the study subject derives from a site, and is being viewed from a
    // parent study,
    // then the study IDs will be different. However, since each note is
    // saved with the specific
    // study ID, then its study ID may be different than the study subject's
    // ID.
    boolean subjectStudyIsCurrentStudy = studyId == currentStudy.getId();
    boolean isParentStudy = study.getParentStudyId() < 1;
    // Get any disc notes for this study event
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(sm.getDataSource());
    ArrayList<DiscrepancyNoteBean> allNotesforSubjectAndEvent = new ArrayList<DiscrepancyNoteBean>();
    // These methods return only parent disc notes
    if (subjectStudyIsCurrentStudy && isParentStudy) {
        allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudyAndId(currentStudy, studySubjectBean.getId());
    } else {
        // findAllStudyEventByStudiesAndSubjectId
        if (!isParentStudy) {
            StudyBean stParent = (StudyBean) studydao.findByPK(study.getParentStudyId());
            allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(stParent, study, studySubjectBean.getId());
        } else {
            allNotesforSubjectAndEvent = discrepancyNoteDAO.findAllStudyEventByStudiesAndSubjectId(currentStudy, study, studySubjectBean.getId());
        }
    }
    if (!allNotesforSubjectAndEvent.isEmpty()) {
        setRequestAttributesForNotes(allNotesforSubjectAndEvent);
    }
    // prepare to figure out what the display should look like
    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
    ArrayList<EventCRFBean> eventCRFs = ecdao.findAllByStudyEvent(seb);
    ArrayList<Boolean> doRuleSetsExist = new ArrayList<Boolean>();
    RuleSetDAO ruleSetDao = new RuleSetDAO(sm.getDataSource());
    for (EventCRFBean eventCrfBean : eventCRFs) {
    // Boolean result = ruleSetDao.findByEventCrf(eventCrfBean) != null
    // ? Boolean.TRUE : Boolean.FALSE;
    // doRuleSetsExist.add(result);
    }
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, seb.getStudyEventDefinitionId());
    // get the event definition CRFs for which no event CRF exists
    // the event definition CRFs must be populated with versions so we can
    // let the user choose which version he will enter data for
    // However, this method seems to be returning DisplayEventDefinitionCRFs
    // that contain valid eventCRFs??
    ArrayList uncompletedEventDefinitionCRFs = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs);
    populateUncompletedCRFsWithCRFAndVersions(uncompletedEventDefinitionCRFs);
    // BWP 2816 << Attempt to provide the DisplayEventDefinitionCRF with a
    // valid owner
    // only if its container eventCRf has a valid id
    populateUncompletedCRFsWithAnOwner(uncompletedEventDefinitionCRFs);
    // >>BWP
    // for the event definition CRFs for which event CRFs exist, get
    // DisplayEventCRFBeans, which the JSP will use to determine what
    // the user will see for each event CRF
    // removing the below row in exchange for the ViewStudySubjectServlet
    // version, for two
    // reasons:
    // 1. concentrate all business logic in one place
    // 2. VSSS seems to handle the javascript creation correctly
    // ArrayList displayEventCRFs = getDisplayEventCRFs(eventCRFs,
    // eventDefinitionCRFs, seb.getSubjectEventStatus());
    ArrayList displayEventCRFs = ViewStudySubjectServlet.getDisplayEventCRFs(sm.getDataSource(), eventCRFs, eventDefinitionCRFs, ub, currentRole, seb.getSubjectEventStatus(), study);
    // Issue 3212 BWP << hide certain CRFs at the site level
    if (currentStudy.getParentStudyId() > 0) {
        HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
        uncompletedEventDefinitionCRFs = hideCRFManager.removeHiddenEventDefinitionCRFBeans(uncompletedEventDefinitionCRFs);
        displayEventCRFs = hideCRFManager.removeHiddenEventCRFBeans(displayEventCRFs);
    }
    // >>
    request.setAttribute(BEAN_STUDY_EVENT, seb);
    request.setAttribute("doRuleSetsExist", doRuleSetsExist);
    request.setAttribute(BEAN_STUDY_SUBJECT, studySubjectBean);
    request.setAttribute(BEAN_UNCOMPLETED_EVENTDEFINITIONCRFS, uncompletedEventDefinitionCRFs);
    request.setAttribute(BEAN_DISPLAY_EVENT_CRFS, displayEventCRFs);
    // @pgawade 31-Aug-2012 fix for issue #15315: Reverting to set the request variable "beans" back
    // this is for generating side info panel
    ArrayList beans = ViewStudySubjectServlet.getDisplayStudyEventsForStudySubject(studySubjectBean, sm.getDataSource(), ub, currentRole);
    request.setAttribute("beans", beans);
    EventCRFBean ecb = new EventCRFBean();
    ecb.setStudyEventId(eventId);
    request.setAttribute("eventCRF", ecb);
    // Make available the study
    request.setAttribute("study", currentStudy);
    forwardPage(Page.ENTER_DATA_FOR_STUDY_EVENT);
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) RuleSetDAO(org.akaza.openclinica.dao.rule.RuleSetDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) HideCRFManager(org.akaza.openclinica.service.crfdata.HideCRFManager) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 97 with FormProcessor

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

the class ImportCRFDataServlet method processRequest.

@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    // keep the module in the session
    session.setAttribute(MODULE, module);
    String action = request.getParameter("action");
    CRFVersionBean version = (CRFVersionBean) session.getAttribute("version");
    File xsdFile = new File(SpringServletAccess.getPropertiesDir(context) + "ODM1-3-0.xsd");
    File xsdFile2 = new File(SpringServletAccess.getPropertiesDir(context) + "ODM1-2-1.xsd");
    if (StringUtil.isBlank(action)) {
        logger.info("action is blank");
        request.setAttribute("version", version);
        forwardPage(Page.IMPORT_CRF_DATA);
    }
    if ("confirm".equalsIgnoreCase(action)) {
        String dir = SQLInitServlet.getField("filePath");
        if (!new File(dir).exists()) {
            logger.info("The filePath in datainfo.properties is invalid " + dir);
            addPageMessage(respage.getString("filepath_you_defined_not_seem_valid"));
            forwardPage(Page.IMPORT_CRF_DATA);
        }
        // All the uploaded files will be saved in filePath/crf/original/
        String theDir = dir + "crf" + File.separator + "original" + File.separator;
        if (!new File(theDir).isDirectory()) {
            new File(theDir).mkdirs();
            logger.info("Made the directory " + theDir);
        }
        // MultipartRequest multi = new MultipartRequest(request, theDir, 50 * 1024 * 1024);
        File f = null;
        try {
            f = uploadFile(theDir, version);
        } catch (Exception e) {
            logger.warn("*** Found exception during file upload***");
            e.printStackTrace();
        }
        if (f == null) {
            forwardPage(Page.IMPORT_CRF_DATA);
        }
        // TODO
        // validation steps
        // 1. valid xml - validated by file uploader below
        // LocalConfiguration config = LocalConfiguration.getInstance();
        // config.getProperties().setProperty(
        // "org.exolab.castor.parser.namespaces",
        // "true");
        // config
        // .getProperties()
        // .setProperty("org.exolab.castor.sax.features",
        // "http://xml.org/sax/features/validation,
        // http://apache.org/xml/features/validation/schema,
        // http://apache.org/xml/features/validation/schema-full-checking");
        // // above sets to validate against namespace
        Mapping myMap = new Mapping();
        // @pgawade 18-April-2011 Fix for issue 8394
        String ODM_MAPPING_DIRPath = CoreResources.ODM_MAPPING_DIR;
        myMap.loadMapping(ODM_MAPPING_DIRPath + File.separator + "cd_odm_mapping.xml");
        Unmarshaller um1 = new Unmarshaller(myMap);
        // um1.addNamespaceToPackageMapping("http://www.openclinica.org/ns/odm_ext_v130/v3.1", "OpenClinica");
        // um1.addNamespaceToPackageMapping("http://www.cdisc.org/ns/odm/v1.3"
        // ,
        // "ODMContainer");
        boolean fail = false;
        ODMContainer odmContainer = new ODMContainer();
        session.removeAttribute("odmContainer");
        try {
            // schemaValidator.validateAgainstSchema(f, xsdFile);
            // utf-8 compliance, tbh 06/2009
            InputStreamReader isr = new InputStreamReader(new FileInputStream(f), "UTF-8");
            odmContainer = (ODMContainer) um1.unmarshal(isr);
            logger.debug("Found crf data container for study oid: " + odmContainer.getCrfDataPostImportContainer().getStudyOID());
            logger.debug("found length of subject list: " + odmContainer.getCrfDataPostImportContainer().getSubjectData().size());
            // 2. validates against ODM 1.3
            // check it all below, throw an exception and route to a
            // different
            // page if not working
            // TODO this block of code needs the xerces serializer in order
            // to
            // work
            // StringWriter myWriter = new StringWriter();
            // Marshaller m1 = new Marshaller(myWriter);
            //
            // m1.setProperty("org.exolab.castor.parser.namespaces",
            // "true");
            // m1
            // .setProperty("org.exolab.castor.sax.features",
            // "http://xml.org/sax/features/validation,
            // http://apache.org/xml/features/validation/schema,
            // http://apache.org/xml/features/validation/schema-full-checking
            // ");
            //
            // m1.setMapping(myMap);
            // m1.setNamespaceMapping("",
            // "http://www.cdisc.org/ns/odm/v1.3");
            // m1.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3
            // ODM1-3.xsd");
            // m1.marshal(odmContainer);
            // if you havent thrown it, you wont throw it here
            addPageMessage(respage.getString("passed_xml_validation"));
        } catch (Exception me1) {
            me1.printStackTrace();
            // expanding it to all exceptions, but hoping to catch Marshal
            // Exception or SAX Exceptions
            logger.info("found exception with xml transform");
            //
            logger.info("trying 1.2.1");
            try {
                schemaValidator.validateAgainstSchema(f, xsdFile2);
                // for backwards compatibility, we also try to validate vs
                // 1.2.1 ODM 06/2008
                InputStreamReader isr = new InputStreamReader(new FileInputStream(f), "UTF-8");
                odmContainer = (ODMContainer) um1.unmarshal(isr);
            } catch (Exception me2) {
                // not sure if we want to report me2
                MessageFormat mf = new MessageFormat("");
                mf.applyPattern(respage.getString("your_xml_is_not_well_formed"));
                Object[] arguments = { me1.getMessage() };
                addPageMessage(mf.format(arguments));
                //
                // addPageMessage("Your XML is not well-formed, and does not
                // comply with the ODM 1.3 Schema. Please check it, and try
                // again. It returned the message: "
                // + me1.getMessage());
                // me1.printStackTrace();
                forwardPage(Page.IMPORT_CRF_DATA);
            // you can't really wait to forward because then you throw
            // NPEs
            // in the next few parts of the code
            }
        }
        // TODO need to output further here
        // 2.a. is the study the same one that the user is in right now?
        // 3. validates against study metadata
        // 3.a. is that study subject in that study?
        // 3.b. is that study event def in that study?
        // 3.c. is that site in that study?
        // 3.d. is that crf version in that study event def?
        // 3.e. are those item groups in that crf version?
        // 3.f. are those items in that item group?
        List<String> errors = getImportCRFDataService().validateStudyMetadata(odmContainer, ub.getActiveStudyId());
        if (errors != null) {
            // add to session
            // forward to another page
            logger.info(errors.toString());
            for (String error : errors) {
                addPageMessage(error);
            }
            if (errors.size() > 0) {
                // fail = true;
                forwardPage(Page.IMPORT_CRF_DATA);
            } else {
                addPageMessage(respage.getString("passed_study_check"));
                addPageMessage(respage.getString("passed_oid_metadata_check"));
            }
        }
        logger.debug("passed error check");
        // TODO ADD many validation steps before we get to the
        // session-setting below
        // 4. is the event in the correct status to accept data import?
        // -- scheduled, data entry started, completed
        // (and the event should already be created)
        // (and the event should be independent, ie not affected by other
        // events)
        Boolean eventCRFStatusesValid = getImportCRFDataService().eventCRFStatusesValid(odmContainer, ub);
        ImportCRFInfoContainer importCrfInfo = new ImportCRFInfoContainer(odmContainer, sm.getDataSource());
        // The eventCRFBeans list omits EventCRFs that don't match UpsertOn rules. If EventCRF did not exist and
        // doesn't match upsert, it won't be created.
        List<EventCRFBean> eventCRFBeans = getImportCRFDataService().fetchEventCRFBeans(odmContainer, ub);
        List<DisplayItemBeanWrapper> displayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
        HashMap<String, String> totalValidationErrors = new HashMap<String, String>();
        HashMap<String, String> hardValidationErrors = new HashMap<String, String>();
        // The following map is used for setting the EventCRF status post import.
        HashMap<Integer, String> importedCRFStatuses = getImportCRFDataService().fetchEventCRFStatuses(odmContainer);
        // method in the ImportCRFDataService is modified for this fix.
        if (eventCRFBeans == null) {
            fail = true;
            addPageMessage(respage.getString("no_event_status_matching"));
        } else {
            ArrayList<Integer> permittedEventCRFIds = new ArrayList<Integer>();
            logger.info("found a list of eventCRFBeans: " + eventCRFBeans.toString());
            // List<DisplayItemBeanWrapper> displayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
            // HashMap<String, String> totalValidationErrors = new
            // HashMap<String, String>();
            // HashMap<String, String> hardValidationErrors = new
            // HashMap<String, String>();
            logger.debug("found event crfs " + eventCRFBeans.size());
            // -- does the event already exist? if not, fail
            if (!eventCRFBeans.isEmpty()) {
                for (EventCRFBean eventCRFBean : eventCRFBeans) {
                    DataEntryStage dataEntryStage = eventCRFBean.getStage();
                    Status eventCRFStatus = eventCRFBean.getStatus();
                    logger.info("Event CRF Bean: id " + eventCRFBean.getId() + ", data entry stage " + dataEntryStage.getName() + ", status " + eventCRFStatus.getName());
                    if (eventCRFStatus.equals(Status.AVAILABLE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
                        // actually want the negative
                        // was status == available and the stage questions, but
                        // when you are at 'data entry complete' your status is
                        // set to 'unavailable'.
                        // >> tbh 09/2008
                        // HOWEVER, when one event crf is removed and the rest
                        // are good, what happens???
                        // need to create a list and inform that one is blocked
                        // and the rest are not...
                        //
                        permittedEventCRFIds.add(new Integer(eventCRFBean.getId()));
                    } else {
                    // fail = true;
                    // addPageMessage(respage.getString(
                    // "the_event_crf_not_correct_status"));
                    // forwardPage(Page.IMPORT_CRF_DATA);
                    }
                }
                // did we exclude all the event CRFs? if not, pass, else fail
                if (eventCRFBeans.size() >= permittedEventCRFIds.size()) {
                    addPageMessage(respage.getString("passed_event_crf_status_check"));
                } else {
                    fail = true;
                    addPageMessage(respage.getString("the_event_crf_not_correct_status"));
                }
                try {
                    List<DisplayItemBeanWrapper> tempDisplayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
                    tempDisplayItemBeanWrappers = getImportCRFDataService().lookupValidationErrors(request, odmContainer, ub, totalValidationErrors, hardValidationErrors, permittedEventCRFIds);
                    logger.debug("generated display item bean wrappers " + tempDisplayItemBeanWrappers.size());
                    logger.debug("size of total validation errors: " + totalValidationErrors.size());
                    displayItemBeanWrappers.addAll(tempDisplayItemBeanWrappers);
                } catch (NullPointerException npe1) {
                    // what if you have 2 event crfs but the third is a fake?
                    fail = true;
                    logger.debug("threw a NPE after calling lookup validation errors");
                    System.out.println(ExceptionUtils.getStackTrace(npe1));
                    addPageMessage(respage.getString("an_error_was_thrown_while_validation_errors"));
                // npe1.printStackTrace();
                } catch (OpenClinicaException oce1) {
                    fail = true;
                    logger.debug("threw an OCE after calling lookup validation errors " + oce1.getOpenClinicaMessage());
                    addPageMessage(oce1.getOpenClinicaMessage());
                }
            } else if (!eventCRFStatusesValid) {
                fail = true;
                addPageMessage(respage.getString("the_event_crf_not_correct_status"));
            } else {
                fail = true;
                addPageMessage(respage.getString("no_event_crfs_matching_the_xml_metadata"));
            }
        // for (HashMap<String, String> crfData : importedData) {
        // DisplayItemBeanWrapper displayItemBeanWrapper =
        // testing(request,
        // crfData);
        // displayItemBeanWrappers.add(displayItemBeanWrapper);
        // errors = displayItemBeanWrapper.getValidationErrors();
        //
        // }
        }
        if (fail) {
            logger.debug("failed here - forwarding...");
            forwardPage(Page.IMPORT_CRF_DATA);
        } else {
            addPageMessage(respage.getString("passing_crf_edit_checks"));
            session.setAttribute("odmContainer", odmContainer);
            session.setAttribute("importedData", displayItemBeanWrappers);
            session.setAttribute("validationErrors", totalValidationErrors);
            session.setAttribute("hardValidationErrors", hardValidationErrors);
            session.setAttribute("importedCRFStatuses", importedCRFStatuses);
            session.setAttribute("importCrfInfo", importCrfInfo);
            // above are updated 'statically' by the method that originally
            // generated the wrappers; soon the only thing we will use
            // wrappers for is the 'overwrite' flag
            logger.debug("+++ content of total validation errors: " + totalValidationErrors.toString());
            SummaryStatsBean ssBean = getImportCRFDataService().generateSummaryStatsBean(odmContainer, displayItemBeanWrappers, importCrfInfo);
            session.setAttribute("summaryStats", ssBean);
            // will have to set hard edit checks here as well
            session.setAttribute("subjectData", odmContainer.getCrfDataPostImportContainer().getSubjectData());
            forwardPage(Page.VERIFY_IMPORT_SERVLET);
        }
    // }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Mapping(org.exolab.castor.mapping.Mapping) SummaryStatsBean(org.akaza.openclinica.bean.submit.crfdata.SummaryStatsBean) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) ODMContainer(org.akaza.openclinica.bean.submit.crfdata.ODMContainer) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) Unmarshaller(org.exolab.castor.xml.Unmarshaller) DisplayItemBeanWrapper(org.akaza.openclinica.bean.submit.DisplayItemBeanWrapper) Status(org.akaza.openclinica.bean.core.Status) InputStreamReader(java.io.InputStreamReader) MessageFormat(java.text.MessageFormat) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) FileInputStream(java.io.FileInputStream) DataEntryStage(org.akaza.openclinica.bean.core.DataEntryStage) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) File(java.io.File)

Example 98 with FormProcessor

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

the class InitialDataEntryServlet method getServletPage.

/*
     * (non-Javadoc)
     *
     * @see
     * org.akaza.openclinica.control.submit.DataEntryServlet#getServletPage()
     */
@Override
protected String getServletPage(HttpServletRequest request) {
    FormProcessor fp = new FormProcessor(request);
    String tabId = fp.getString("tab", true);
    String sectionId = fp.getString(DataEntryServlet.INPUT_SECTION_ID, true);
    String eventCRFId = fp.getString(INPUT_EVENT_CRF_ID, true);
    if (StringUtil.isBlank(sectionId) || StringUtil.isBlank(tabId)) {
        return Page.INITIAL_DATA_ENTRY_SERVLET.getFileName();
    } else {
        Page target = Page.INITIAL_DATA_ENTRY_SERVLET;
        return target.getFileName() + "?eventCRFId=" + eventCRFId + "&sectionId=" + sectionId + "&tab=" + tabId;
    //return target.getFileName()+;
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Page(org.akaza.openclinica.view.Page)

Example 99 with FormProcessor

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

the class ListStudySubjectsServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    getCrfLocker().unlockAllForUser(ub.getId());
    FormProcessor fp = new FormProcessor(request);
    if (fp.getString("showMoreLink").equals("")) {
        showMoreLink = true;
    } else {
        showMoreLink = Boolean.parseBoolean(fp.getString("showMoreLink"));
    }
    String idSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
    // set up auto study subject id
    if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
        //Shaoyu Su
        // int nextLabel = getStudySubjectDAO().findTheGreatestLabel() + 1;
        // request.setAttribute("label", new Integer(nextLabel).toString());
        request.setAttribute("label", resword.getString("id_generated_Save_Add"));
        fp.addPresetValue("label", resword.getString("id_generated_Save_Add"));
    }
    if (fp.getRequest().getParameter("subjectOverlay") == null) {
        Date today = new Date(System.currentTimeMillis());
        String todayFormatted = local_df.format(today);
        if (request.getAttribute(PRESET_VALUES) != null) {
            fp.setPresetValues((HashMap) request.getAttribute(PRESET_VALUES));
        }
        fp.addPresetValue(AddNewSubjectServlet.INPUT_ENROLLMENT_DATE, todayFormatted);
        fp.addPresetValue(AddNewSubjectServlet.INPUT_EVENT_START_DATE, todayFormatted);
        setPresetValues(fp.getPresetValues());
    }
    request.setAttribute("closeInfoShowIcons", true);
    if (fp.getString("navBar").equals("yes") && fp.getString("findSubjects_f_studySubject.label").trim().length() > 0) {
        StudySubjectBean studySubject = getStudySubjectDAO().findByLabelAndStudy(fp.getString("findSubjects_f_studySubject.label"), currentStudy);
        if (studySubject.getId() > 0) {
            request.setAttribute("id", new Integer(studySubject.getId()).toString());
            forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
        } else {
            createTable();
        }
    } else {
        createTable();
    }
}
Also used : StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Date(java.util.Date)

Example 100 with FormProcessor

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

the class MarkEventCRFCompleteServlet method mayProceed.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.control.core.SecureController#mayProceed()
     */
@Override
protected void mayProceed() throws InsufficientPermissionException {
    locale = LocaleResolver.getLocale(request);
    // <
    // resexception=ResourceBundle.getBundle(
    // "org.akaza.openclinica.i18n.exceptions",locale);
    // < respage =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
    // locale);
    // < resword =
    // ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
    fp = new FormProcessor(request);
    if (currentRole.equals(Role.COORDINATOR) || currentRole.equals(Role.STUDYDIRECTOR)) {
        return;
    }
    getEventCRFBean();
    Role r = currentRole.getRole();
    if (ecb.getStage().equals(DataEntryStage.INITIAL_DATA_ENTRY)) {
        if (ecb.getOwnerId() != ub.getId() && !r.equals(Role.COORDINATOR) && !r.equals(Role.STUDYDIRECTOR)) {
            request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
            addPageMessage(respage.getString("not_mark_CRF_complete6"));
            throw new InsufficientPermissionException(Page.TABLE_OF_CONTENTS_SERVLET, resexception.getString("not_study_owner"), "1");
        }
    } else if (ecb.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
        if (ecb.getValidatorId() != ub.getId() && !r.equals(Role.COORDINATOR) && !r.equals(Role.STUDYDIRECTOR)) {
            request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN, ecb);
            addPageMessage(respage.getString("not_mark_CRF_complete7"));
            throw new InsufficientPermissionException(Page.TABLE_OF_CONTENTS_SERVLET, resexception.getString("not_study_owner"), "1");
        }
    }
    return;
}
Also used : Role(org.akaza.openclinica.bean.core.Role) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException)

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