Search in sources :

Example 1 with OpenClinicaException

use of org.akaza.openclinica.exception.OpenClinicaException in project OpenClinica by OpenClinica.

the class CreateCRFVersionServlet method processRequest.

@SuppressWarnings("unchecked")
@Override
public void processRequest() throws Exception {
    resetPanel();
    panel.setStudyInfoShown(true);
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
    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);
    request.setAttribute("xformEnabled", CoreResources.getField("xform.enabled"));
    String action = request.getParameter("action");
    CRFVersionBean version = (CRFVersionBean) session.getAttribute("version");
    if (StringUtil.isBlank(action)) {
        logger.debug("action is blank");
        request.setAttribute("version", version);
        forwardPage(Page.CREATE_CRF_VERSION);
    } else if ("confirm".equalsIgnoreCase(action)) {
        String dir = SQLInitServlet.getField("filePath");
        if (!new File(dir).exists()) {
            logger.debug("The filePath in datainfo.properties is invalid " + dir);
            addPageMessage(resword.getString("the_filepath_you_defined"));
            forwardPage(Page.CREATE_CRF_VERSION);
            // BWP 01/13/2009 >>
            return;
        // >>
        }
        // 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.debug("Made the directory " + theDir);
        }
        // MultipartRequest multi = new MultipartRequest(request, theDir, 50 * 1024 * 1024);
        String tempFile = "";
        try {
            tempFile = uploadFile(theDir, version);
        } catch (CRFReadingException crfException) {
            Validator.addError(errors, "excel_file", crfException.getMessage());
            String msg = crfException.getMessage();
            request.setAttribute("formMessages", errors);
            forwardPage(Page.CREATE_CRF_VERSION);
            return;
        } catch (Exception e) {
            // 
            logger.warn("*** Found exception during file upload***");
            e.printStackTrace();
        }
        session.setAttribute("tempFileName", tempFile);
        // provided and/or not xls format
        if (errors.isEmpty()) {
            String s = ((NewCRFBean) session.getAttribute("nib")).getVersionName();
            if (s.length() > 255) {
                Validator.addError(errors, "excel_file", resword.getString("the_version_CRF_version_more_than_255"));
            } else if (s.length() <= 0) {
                Validator.addError(errors, "excel_file", resword.getString("the_VERSION_column_was_blank"));
            }
            version.setName(s);
            if (version.getCrfId() == 0) {
                version.setCrfId(fp.getInt("crfId"));
            }
            session.setAttribute("version", version);
        }
        if (!errors.isEmpty()) {
            logger.debug("has validation errors ");
            request.setAttribute("formMessages", errors);
            forwardPage(Page.CREATE_CRF_VERSION);
        } else {
            CRFBean crf = (CRFBean) cdao.findByPK(version.getCrfId());
            ArrayList versions = (ArrayList) vdao.findAllByCRF(crf.getId());
            for (int i = 0; i < versions.size(); i++) {
                CRFVersionBean version1 = (CRFVersionBean) versions.get(i);
                if (version.getName().equals(version1.getName())) {
                    // version already exists
                    logger.debug("Version already exists; owner or not:" + ub.getId() + "," + version1.getOwnerId());
                    if (ub.getId() != version1.getOwnerId()) {
                        // not owner
                        addPageMessage(respage.getString("CRF_version_try_upload_exists_database") + version1.getOwner().getName() + respage.getString("please_contact_owner_to_delete"));
                        forwardPage(Page.CREATE_CRF_VERSION);
                        return;
                    } else {
                        // owner,
                        ArrayList definitions = edao.findByDefaultVersion(version1.getId());
                        if (!definitions.isEmpty()) {
                            // used in
                            // definition
                            request.setAttribute("definitions", definitions);
                            forwardPage(Page.REMOVE_CRF_VERSION_DEF);
                            return;
                        } else {
                            // not used in definition
                            int previousVersionId = version1.getId();
                            version.setId(previousVersionId);
                            session.setAttribute("version", version);
                            session.setAttribute("previousVersionId", new Integer(previousVersionId));
                            forwardPage(Page.REMOVE_CRF_VERSION_CONFIRM);
                            return;
                        }
                    }
                }
            }
            // didn't find same version in the DB,let user upload the excel
            // file
            logger.debug("didn't find same version in the DB,let user upload the excel file.");
            // List excelErr =
            // ((ArrayList)request.getAttribute("excelErrors"));
            List excelErr = (ArrayList) session.getAttribute("excelErrors");
            logger.debug("excelErr.isEmpty()=" + excelErr.isEmpty());
            if (excelErr != null && excelErr.isEmpty()) {
                addPageMessage(resword.getString("congratulations_your_spreadsheet_no_errors"));
                forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PREVIEW);
            } else {
                logger.debug("OpenClinicaException thrown, forwarding to CREATE_CRF_VERSION_CONFIRM.");
                forwardPage(Page.CREATE_CRF_VERSION_CONFIRM);
            }
            return;
        }
    } else if ("confirmsql".equalsIgnoreCase(action)) {
        NewCRFBean nib = (NewCRFBean) session.getAttribute("nib");
        if (nib != null && nib.getItemQueries() != null) {
            request.setAttribute("openQueries", nib.getItemQueries());
        } else {
            request.setAttribute("openQueries", new HashMap());
        }
        boolean canDelete = false;
        // check whether need to delete previous version
        Boolean deletePreviousVersion = (Boolean) session.getAttribute("deletePreviousVersion");
        Integer previousVersionId = (Integer) session.getAttribute("previousVersionId");
        if (deletePreviousVersion != null && deletePreviousVersion.equals(Boolean.TRUE) && previousVersionId != null && previousVersionId.intValue() > 0) {
            logger.debug("Need to delete previous version");
            // whether we can delete
            canDelete = canDeleteVersion(previousVersionId.intValue());
            if (!canDelete) {
                logger.debug("but cannot delete previous version");
                if (session.getAttribute("itemsHaveData") == null && session.getAttribute("eventsForVersion") == null) {
                    addPageMessage(respage.getString("you_are_not_owner_some_items_cannot_delete"));
                }
                if (session.getAttribute("itemsHaveData") == null) {
                    session.setAttribute("itemsHaveData", new ArrayList());
                }
                if (session.getAttribute("eventsForVersion") == null) {
                    session.setAttribute("eventsForVersion", new ArrayList());
                }
                forwardPage(Page.CREATE_CRF_VERSION_NODELETE);
                return;
            }
            ArrayList<ItemBean> nonSharedItems = (ArrayList<ItemBean>) vdao.findNotSharedItemsByVersion(previousVersionId.intValue());
            // htaycher: here is the trick we need to put in nib1.setItemQueries()
            // update statements for shared items and insert for nonShared that were just deleted 5927
            HashMap item_table_statements = new HashMap();
            ArrayList<String> temp = new ArrayList<String>(nonSharedItems.size());
            for (ItemBean item : nonSharedItems) {
                temp.add(item.getName());
                item_table_statements.put(item.getName(), nib.getBackupItemQueries().get(item.getName()));
            }
            for (String item_name : (Set<String>) nib.getItemQueries().keySet()) {
                // check if item shared
                if (!temp.contains(item_name)) {
                    item_table_statements.put(item_name, nib.getItemQueries().get(item_name));
                }
            }
            // statements to run
            if (!nonSharedItems.isEmpty()) {
                request.setAttribute("openQueries", item_table_statements);
            }
            // htaycher: put all statements in
            nib.setItemQueries(item_table_statements);
            session.setAttribute("nib", nib);
        }
        // submit
        logger.debug("commit sql");
        NewCRFBean nib1 = (NewCRFBean) session.getAttribute("nib");
        if (nib1 != null) {
            try {
                if (canDelete) {
                    nib1.deleteInsertToDB();
                } else {
                    nib1.insertToDB();
                }
                request.setAttribute("queries", nib1.getQueries());
                // YW << for add a link to "View CRF Version Data Entry".
                // For this purpose, CRFVersion id is needed.
                // So the latest CRFVersion Id of A CRF Id is it.
                CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
                ArrayList crfvbeans = new ArrayList();
                logger.debug("CRF-ID [" + version.getCrfId() + "]");
                int crfVersionId = 0;
                String versionOID = null;
                if (version.getCrfId() != 0) {
                    crfvbeans = cvdao.findAllByCRFId(version.getCrfId());
                    CRFVersionBean cvbean = (CRFVersionBean) crfvbeans.get(crfvbeans.size() - 1);
                    crfVersionId = cvbean.getId();
                    versionOID = cvbean.getOid();
                    for (Iterator iter = crfvbeans.iterator(); iter.hasNext(); ) {
                        cvbean = (CRFVersionBean) iter.next();
                        if (crfVersionId < cvbean.getId()) {
                            crfVersionId = cvbean.getId();
                        }
                    }
                }
                // Not needed; crfVersionId will be autoboxed in Java 5
                // this was added for the old CVS java compiler
                Integer cfvID = new Integer(crfVersionId);
                if (cfvID == 0) {
                    cfvID = cvdao.findCRFVersionId(nib1.getCrfId(), nib1.getVersionName());
                }
                CRFVersionBean finalVersion = (CRFVersionBean) cvdao.findByPK(cfvID);
                version.setCrfId(nib1.getCrfId());
                version.setOid(finalVersion.getOid());
                CRFBean crfBean = (CRFBean) cdao.findByPK(version.getCrfId());
                crfBean.setUpdatedDate(version.getCreatedDate());
                crfBean.setUpdater(ub);
                cdao.update(crfBean);
                // workaround to get a correct file name below, tbh 06/2008
                request.setAttribute("crfVersionId", cfvID);
                // YW >>
                // return those properties to initial values
                session.removeAttribute("version");
                session.removeAttribute("eventsForVersion");
                session.removeAttribute("itemsHaveData");
                session.removeAttribute("nib");
                session.removeAttribute("deletePreviousVersion");
                session.removeAttribute("previousVersionId");
                // save new version spreadsheet
                String tempFile = (String) session.getAttribute("tempFileName");
                if (tempFile != null) {
                    logger.debug("*** ^^^ *** saving new version spreadsheet" + tempFile);
                    try {
                        String dir = SQLInitServlet.getField("filePath");
                        File f = new File(dir + "crf" + File.separator + "original" + File.separator + tempFile);
                        // check to see whether crf/new/ folder exists
                        // inside, if not,
                        // creates
                        // the crf/new/ folder
                        String finalDir = dir + "crf" + File.separator + "new" + File.separator;
                        if (!new File(finalDir).isDirectory()) {
                            logger.debug("need to create folder for excel files" + finalDir);
                            new File(finalDir).mkdirs();
                        }
                        // String newFile = version.getCrfId() +
                        // version.getName() + ".xls";
                        String newFile = version.getCrfId() + version.getOid() + ".xls";
                        logger.debug("*** ^^^ *** new file: " + newFile);
                        File nf = new File(finalDir + newFile);
                        logger.debug("copying old file " + f.getName() + " to new file " + nf.getName());
                        copy(f, nf);
                    // ?
                    } catch (IOException ie) {
                        logger.debug("==============");
                        addPageMessage(respage.getString("CRF_version_spreadsheet_could_not_saved_contact"));
                    }
                }
                session.removeAttribute("tempFileName");
                session.removeAttribute(MODULE);
                session.removeAttribute("excelErrors");
                session.removeAttribute("htmlTab");
                forwardPage(Page.CREATE_CRF_VERSION_DONE);
            } catch (OpenClinicaException pe) {
                logger.debug("--------------");
                session.setAttribute("excelErrors", nib1.getErrors());
                // request.setAttribute("excelErrors", nib1.getErrors());
                forwardPage(Page.CREATE_CRF_VERSION_ERROR);
            }
        } else {
            forwardPage(Page.CREATE_CRF_VERSION);
        }
    } else if ("delete".equalsIgnoreCase(action)) {
        logger.debug("user wants to delete previous version");
        List excelErr = (ArrayList) session.getAttribute("excelErrors");
        logger.debug("for overwrite CRF version, excelErr.isEmpty()=" + excelErr.isEmpty());
        if (excelErr != null && excelErr.isEmpty()) {
            addPageMessage(resword.getString("congratulations_your_spreadsheet_no_errors"));
            // should be moved to excelErr != null block
            session.setAttribute("deletePreviousVersion", Boolean.TRUE);
            forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PREVIEW);
        } else {
            // should be moved to excelErr != null
            session.setAttribute("deletePreviousVersion", Boolean.FALSE);
            // block
            logger.debug("OpenClinicaException thrown, forwarding to CREATE_CRF_VERSION_CONFIRM.");
            forwardPage(Page.CREATE_CRF_VERSION_CONFIRM);
        }
    }
}
Also used : ItemBean(org.akaza.openclinica.bean.submit.ItemBean) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CRFReadingException(org.akaza.openclinica.exception.CRFReadingException) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) 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) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) IOException(java.io.IOException) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException) CRFReadingException(org.akaza.openclinica.exception.CRFReadingException) IOException(java.io.IOException) NewCRFBean(org.akaza.openclinica.bean.admin.NewCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) NewCRFBean(org.akaza.openclinica.bean.admin.NewCRFBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) File(java.io.File)

Example 2 with OpenClinicaException

use of org.akaza.openclinica.exception.OpenClinicaException in project OpenClinica by OpenClinica.

the class DataEntryServlet method runDynamicsCheck.

/*
     * function written out here to return itemMetadataGroupBeans after they have been checked for show/hide via dynamics.
     * author: tbh 04/2010
     *
     */
private ItemGroupMetadataBean runDynamicsCheck(ItemGroupMetadataBean metadataBean, HttpServletRequest request) {
    EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
    try {
        if (!metadataBean.isShowGroup()) {
            // set isShown here, tbh 04/2010
            boolean showGroup = getItemMetadataService().isGroupShown(metadataBean.getId(), ecb);
            if (getServletPage(request).equals(Page.DOUBLE_DATA_ENTRY_SERVLET)) {
                showGroup = getItemMetadataService().hasGroupPassedDDE(metadataBean.getId(), ecb.getId());
            }
            metadataBean.setShowGroup(showGroup);
        // what about the items which should be shown?
        // if (getServletPage().equals(Page.ADMIN_EDIT_SERVLET) && metadataBean.isShowGroup()) {
        // metadataBean.setHighlighted(true);
        // }
        // sets highlighting for AE, tbh 05/2010
        // unset highlighting for admin editing, tbh 06/2010
        }
    // << tbh 04/2010
    } catch (OpenClinicaException oce) {
        // do nothing for right now, just store the bean
        LOGGER.debug("throws an OCE for " + metadataBean.getId());
    }
    return metadataBean;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException)

Example 3 with OpenClinicaException

use of org.akaza.openclinica.exception.OpenClinicaException in project OpenClinica by OpenClinica.

the class AddNewSubjectServlet method processRequest.

// YW >>
/*
     * (non-Javadoc)
     * 
     * @see org.akaza.openclinica.control.core.SecureController#processRequest()
     */
@Override
protected void processRequest() throws Exception {
    checkStudyLocked(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_locked"));
    checkStudyFrozen(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_frozen"));
    StudySubjectDAO ssd = new StudySubjectDAO(sm.getDataSource());
    StudyDAO stdao = new StudyDAO(sm.getDataSource());
    StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
    ArrayList classes = new ArrayList();
    panel.setStudyInfoShown(false);
    FormProcessor fp = new FormProcessor(request);
    FormDiscrepancyNotes discNotes;
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    // TODO l10n for dates? Note that in some places we hard-code the YOB by
    // using "01/01/"+yob,
    // not exactly supporting i18n...tbh
    // YW << update study parameters of current study.
    // "collectDob" and "genderRequired" are set as the same as the parent
    // study
    int parentStudyId = currentStudy.getParentStudyId();
    if (parentStudyId <= 0) {
        parentStudyId = currentStudy.getId();
        classes = sgcdao.findAllActiveByStudy(currentStudy);
    } else {
        StudyBean parentStudy = (StudyBean) stdao.findByPK(parentStudyId);
        classes = sgcdao.findAllActiveByStudy(parentStudy);
    }
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "collectDob");
    currentStudy.getStudyParameterConfig().setCollectDob(parentSPV.getValue());
    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "genderRequired");
    currentStudy.getStudyParameterConfig().setGenderRequired(parentSPV.getValue());
    // YW >>
    // tbh
    StudyParameterValueBean checkPersonId = spvdao.findByHandleAndStudy(parentStudyId, "subjectPersonIdRequired");
    currentStudy.getStudyParameterConfig().setSubjectPersonIdRequired(checkPersonId.getValue());
    if (!fp.isSubmitted()) {
        if (fp.getBoolean("instr")) {
            session.removeAttribute(FORM_DISCREPANCY_NOTES_NAME);
            forwardPage(Page.INSTRUCTIONS_ENROLL_SUBJECT);
        } else {
            setUpBeans(classes);
            Date today = new Date(System.currentTimeMillis());
            String todayFormatted = local_df.format(today);
            fp.addPresetValue(INPUT_ENROLLMENT_DATE, todayFormatted);
            // YW 10-07-2007 <<
            String idSetting = "";
            if (currentStudy.getParentStudyId() > 0) {
                parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
                currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
            }
            idSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
            // YW >>
            logger.info("subject id setting :" + idSetting);
            // available ID (label) for now
            if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
                // Shaoyu Su
                // int nextLabel = ssd.findTheGreatestLabel() + 1;
                // fp.addPresetValue(INPUT_LABEL, new Integer(nextLabel).toString());
                fp.addPresetValue(INPUT_LABEL, resword.getString("id_generated_Save_Add"));
            }
            setPresetValues(fp.getPresetValues());
            discNotes = new FormDiscrepancyNotes();
            session.setAttribute(FORM_DISCREPANCY_NOTES_NAME, discNotes);
            forwardPage(Page.ADD_NEW_SUBJECT);
        }
    } else {
        // values in database <subject> table for "add existing subject"
        if (!fp.getBoolean(EXISTING_SUB_SHOWN)) {
            DOB = fp.getString(INPUT_DOB);
            YOB = fp.getString(INPUT_YOB);
            GENDER = fp.getString(INPUT_GENDER);
        }
        // YW >>
        discNotes = (FormDiscrepancyNotes) session.getAttribute(FORM_DISCREPANCY_NOTES_NAME);
        if (discNotes == null) {
            discNotes = new FormDiscrepancyNotes();
        }
        DiscrepancyValidator v = new DiscrepancyValidator(request, discNotes);
        v.addValidation(INPUT_LABEL, Validator.NO_BLANKS);
        String subIdSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
        if (!subIdSetting.equalsIgnoreCase("auto non-editable") && !subIdSetting.equalsIgnoreCase("auto editable")) {
            v.addValidation(INPUT_LABEL, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
        }
        if (currentStudy.getStudyParameterConfig().getSubjectPersonIdRequired().equals("required")) {
            v.addValidation(INPUT_UNIQUE_IDENTIFIER, Validator.NO_BLANKS);
        }
        v.addValidation(INPUT_UNIQUE_IDENTIFIER, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
        if (!StringUtils.isBlank(fp.getString(INPUT_SECONDARY_LABEL))) {
            v.addValidation(INPUT_SECONDARY_LABEL, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 30);
        }
        String dobSetting = currentStudy.getStudyParameterConfig().getCollectDob();
        if (dobSetting.equals("1")) {
            // date of birth
            v.addValidation(INPUT_DOB, Validator.IS_A_DATE);
            if (!StringUtils.isBlank(fp.getString("INPUT_DOB"))) {
                v.alwaysExecuteLastValidation(INPUT_DOB);
            }
            v.addValidation(INPUT_DOB, Validator.DATE_IN_PAST);
        } else if (dobSetting.equals("2")) {
            // year of birth
            v.addValidation(INPUT_YOB, Validator.IS_AN_INTEGER);
            v.alwaysExecuteLastValidation(INPUT_YOB);
            v.addValidation(INPUT_YOB, Validator.COMPARES_TO_STATIC_VALUE, NumericComparisonOperator.GREATER_THAN_OR_EQUAL_TO, 1000);
            // get today's year
            Date today = new Date();
            Calendar c = Calendar.getInstance();
            c.setTime(today);
            int currentYear = c.get(Calendar.YEAR);
            v.addValidation(INPUT_YOB, Validator.COMPARES_TO_STATIC_VALUE, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, currentYear);
        } else {
            // DOB not used, added tbh 102007
            logger.info("should read this only if DOB not used");
        }
        ArrayList acceptableGenders = new ArrayList();
        acceptableGenders.add("m");
        acceptableGenders.add("f");
        if (!currentStudy.getStudyParameterConfig().getGenderRequired().equals("false")) {
            v.addValidation(INPUT_GENDER, Validator.IS_IN_SET, acceptableGenders);
        }
        v.addValidation(INPUT_ENROLLMENT_DATE, Validator.IS_A_DATE);
        v.alwaysExecuteLastValidation(INPUT_ENROLLMENT_DATE);
        v.addValidation(INPUT_ENROLLMENT_DATE, Validator.DATE_IN_PAST);
        boolean locationError = false;
        if (fp.getBoolean("addWithEvent")) {
            v.addValidation(INPUT_EVENT_START_DATE, Validator.IS_A_DATE);
            v.alwaysExecuteLastValidation(INPUT_EVENT_START_DATE);
            if (currentStudy.getStudyParameterConfig().getEventLocationRequired().equalsIgnoreCase("required")) {
                v.addValidation("location", Validator.NO_BLANKS);
                locationError = true;
            }
        }
        HashMap errors = v.validate();
        SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
        // global
        String uniqueIdentifier = fp.getString(INPUT_UNIQUE_IDENTIFIER);
        // Id
        SubjectBean subjectWithSameId = new SubjectBean();
        SubjectBean subjectWithSameIdInParent = new SubjectBean();
        boolean showExistingRecord = false;
        if (!uniqueIdentifier.equals("")) {
            boolean subjectWithSameIdInCurrentStudyTree = false;
            // checks whether there is a subject with same id inside current
            // study/site
            subjectWithSameId = sdao.findByUniqueIdentifierAndStudy(uniqueIdentifier, currentStudy.getId());
            // tbh
            if (subjectWithSameId.isActive()) {
                // ||
                // subjectWithSameIdInParent.isActive())
                // {
                Validator.addError(errors, INPUT_UNIQUE_IDENTIFIER, resexception.getString("subject_with_person_ID") + " " + uniqueIdentifier + " " + resexception.getString("is_already_enrolled_in_this_study"));
                subjectWithSameIdInCurrentStudyTree = true;
                logger.info("just added unique id in study tree");
            } else {
                // checks whether there is a subject with same id inside
                // sites of
                // current study
                subjectWithSameId = sdao.findByUniqueIdentifierAndParentStudy(uniqueIdentifier, currentStudy.getId());
                if (subjectWithSameId.isActive()) {
                    StudySubjectBean ssub = ssd.findBySubjectIdAndStudy(subjectWithSameId.getId(), currentStudy);
                    StudyBean site = (StudyBean) stdao.findByPK(ssub.getStudyId());
                    Validator.addError(errors, INPUT_UNIQUE_IDENTIFIER, resexception.getString("this_subject_person_ID") + " " + uniqueIdentifier + resexception.getString("has_already_enrolled_site") + site.getName() + resexception.getString("of_current_study_need_to_move") + resexception.getString("please_have_user_manage_privileges"));
                    subjectWithSameIdInCurrentStudyTree = true;
                } else {
                    // check whether there is a subject with same id in the
                    // parent study
                    subjectWithSameId = sdao.findByUniqueIdentifierAndStudy(uniqueIdentifier, currentStudy.getParentStudyId());
                    if (subjectWithSameId.isActive()) {
                        Validator.addError(errors, INPUT_UNIQUE_IDENTIFIER, resexception.getString("this_subject_with_person_ID") + " " + uniqueIdentifier + resexception.getString("has_already_enrolled_parent_study"));
                        subjectWithSameIdInCurrentStudyTree = true;
                    } else {
                        // YW 11-26-2007 << check whether there is a subject
                        // with the same id in other sites of the same study
                        subjectWithSameId = sdao.findByUniqueIdentifierAndParentStudy(uniqueIdentifier, currentStudy.getParentStudyId());
                        if (subjectWithSameId.isActive()) {
                            Validator.addError(errors, INPUT_UNIQUE_IDENTIFIER, resexception.getString("this_subject_with_person_ID") + " " + uniqueIdentifier + resexception.getString("has_already_enrolled_site_study"));
                            subjectWithSameIdInCurrentStudyTree = true;
                        }
                    // YW >>
                    }
                }
            }
            if (!subjectWithSameIdInCurrentStudyTree) {
                subjectWithSameId = sdao.findByUniqueIdentifier(uniqueIdentifier);
                // found subject with same id in other study
                if (subjectWithSameId.isActive()) {
                    showExistingRecord = true;
                }
            }
        }
        // end of the block if(!uniqueIdentifier.equals(""))
        String label = fp.getString(INPUT_LABEL);
        String personId = fp.getString(INPUT_UNIQUE_IDENTIFIER);
        String secondaryLable = fp.getString(INPUT_SECONDARY_LABEL);
        // then Study Subject ID should be created when db row is inserted.
        if (label.contains("<") || label.contains(">")) {
            Validator.addError(errors, INPUT_LABEL, resexception.getString("study_subject_id_can_not_contain_html_lessthan_or_greaterthan_elements"));
        }
        if (secondaryLable.contains("<") || secondaryLable.contains(">")) {
            Validator.addError(errors, INPUT_SECONDARY_LABEL, resexception.getString("secondary_id_can_not_contain_html_lessthan_or_greaterthan_elements"));
        }
        if (personId.contains("<") || personId.contains(">")) {
            Validator.addError(errors, INPUT_UNIQUE_IDENTIFIER, resexception.getString("person_id_can_not_contain_html_lessthan_or_greaterthan_elements"));
        }
        if (!label.equalsIgnoreCase(resword.getString("id_generated_Save_Add"))) {
            StudySubjectBean subjectWithSameLabel = ssd.findByLabelAndStudy(label, currentStudy);
            StudySubjectBean subjectWithSameLabelInParent = new StudySubjectBean();
            // tbh
            if (currentStudy.getParentStudyId() > 0) {
                // <
                subjectWithSameLabelInParent = ssd.findSameByLabelAndStudy(label, currentStudy.getParentStudyId(), 0);
            // --
            // blank
            // id
            // since
            // the
            // ss
            // hasn't
            // been
            // created
            // yet,
            // tbh
            }
            // tbh
            if (subjectWithSameLabel.isActive() || subjectWithSameLabelInParent.isActive()) {
                Validator.addError(errors, INPUT_LABEL, resexception.getString("another_assigned_this_ID_choose_unique"));
            }
        }
        if (!classes.isEmpty()) {
            for (int i = 0; i < classes.size(); i++) {
                StudyGroupClassBean sgc = (StudyGroupClassBean) classes.get(i);
                int groupId = fp.getInt("studyGroupId" + i);
                String notes = fp.getString("notes" + i);
                if ("Required".equals(sgc.getSubjectAssignment()) && groupId == 0) {
                    Validator.addError(errors, "studyGroupId" + i, resexception.getString("group_class_is_required"));
                }
                if (notes.trim().length() > 255) {
                    Validator.addError(errors, "notes" + i, resexception.getString("notes_cannot_longer_255"));
                }
                sgc.setStudyGroupId(groupId);
                sgc.setGroupNotes(notes);
            }
        }
        if (!errors.isEmpty()) {
            addPageMessage(respage.getString("there_were_some_errors_submission"));
            if (locationError) {
                addPageMessage(respage.getString("location_blank_error"));
            }
            setInputMessages(errors);
            fp.addPresetValue(INPUT_DOB, fp.getString(INPUT_DOB));
            fp.addPresetValue(INPUT_YOB, fp.getString(INPUT_YOB));
            fp.addPresetValue(INPUT_GENDER, fp.getString(INPUT_GENDER));
            fp.addPresetValue(INPUT_UNIQUE_IDENTIFIER, uniqueIdentifier);
            fp.addPresetValue(INPUT_LABEL, label);
            fp.addPresetValue(INPUT_SECONDARY_LABEL, fp.getString(INPUT_SECONDARY_LABEL));
            fp.addPresetValue(INPUT_ENROLLMENT_DATE, fp.getString(INPUT_ENROLLMENT_DATE));
            fp.addPresetValue(INPUT_EVENT_START_DATE, fp.getString(INPUT_EVENT_START_DATE));
            fp.addPresetValue(STUDY_EVENT_DEFINITION, fp.getInt(STUDY_EVENT_DEFINITION));
            fp.addPresetValue(LOCATION, fp.getString(LOCATION));
            fp.addPresetValue(EDIT_DOB, fp.getString(EDIT_DOB));
            setPresetValues(fp.getPresetValues());
            setUpBeans(classes);
            boolean existingSubShown = fp.getBoolean(EXISTING_SUB_SHOWN);
            if (!existingSubShown) {
                Object isSubjectOverlay = fp.getRequest().getParameter("subjectOverlay");
                if (isSubjectOverlay != null) {
                    int eventId = fp.getInt("studyEventDefinition");
                    if (eventId < 1) {
                        Validator.addError(errors, STUDY_EVENT_DEFINITION, resexception.getString("input_not_acceptable_option"));
                    }
                    String location = fp.getString(LOCATION);
                    if (location == null && location.length() == 0) {
                        Validator.addError(errors, LOCATION, resexception.getString("field_not_blank"));
                    }
                    request.setAttribute("showOverlay", true);
                    forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
                } else {
                    forwardPage(Page.ADD_NEW_SUBJECT);
                }
            } else {
                forwardPage(Page.ADD_EXISTING_SUBJECT);
            }
        } else {
            // no errors
            StudySubjectBean studySubject = new StudySubjectBean();
            SubjectBean subject = new SubjectBean();
            boolean existingSubShown = fp.getBoolean(EXISTING_SUB_SHOWN);
            if (showExistingRecord && !existingSubShown) {
                needUpdate = false;
                subject = subjectWithSameId;
                Calendar cal = Calendar.getInstance();
                int year = 0;
                if (subject.getDateOfBirth() != null) {
                    cal.setTime(subject.getDateOfBirth());
                    year = cal.get(Calendar.YEAR);
                    fp.addPresetValue(INPUT_DOB, local_df.format(subject.getDateOfBirth()));
                } else {
                    fp.addPresetValue(INPUT_DOB, "");
                }
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("1") && !subject.isDobCollected()) {
                    // fp.addPresetValue(EDIT_DOB, "yes");
                    fp.addPresetValue(INPUT_DOB, fp.getString(INPUT_DOB));
                }
                // YW << it has been taken off to solve bug0001125
                /*
                     * else { fp.addPresetValue(INPUT_DOB, ""); }
                     */
                // YW >>
                fp.addPresetValue(INPUT_YOB, String.valueOf(year));
                if (!currentStudy.getStudyParameterConfig().getGenderRequired().equals("false")) {
                    fp.addPresetValue(INPUT_GENDER, subject.getGender() + "");
                } else {
                    fp.addPresetValue(INPUT_GENDER, "");
                }
                // Shaoyu Su: delay setting INPUT_LABEL field
                if (!label.equalsIgnoreCase(resword.getString("id_generated_Save_Add"))) {
                    fp.addPresetValue(INPUT_LABEL, label);
                }
                fp.addPresetValue(INPUT_SECONDARY_LABEL, fp.getString(INPUT_SECONDARY_LABEL));
                fp.addPresetValue(INPUT_ENROLLMENT_DATE, fp.getString(INPUT_ENROLLMENT_DATE));
                fp.addPresetValue(INPUT_EVENT_START_DATE, fp.getString(INPUT_EVENT_START_DATE));
                // YW >>
                fp.addPresetValue(INPUT_UNIQUE_IDENTIFIER, subject.getUniqueIdentifier());
                setPresetValues(fp.getPresetValues());
                setUpBeans(classes);
                // YW <<
                int warningCount = 0;
                if (currentStudy.getStudyParameterConfig().getGenderRequired().equalsIgnoreCase("true")) {
                    if (String.valueOf(subjectWithSameId.getGender()).equals(" ")) {
                        fp.addPresetValue(G_WARNING, "emptytrue");
                        fp.addPresetValue(INPUT_GENDER, GENDER);
                        needUpdate = true;
                        updateSubject = subjectWithSameId;
                        updateSubject.setGender(GENDER.toCharArray()[0]);
                        warningCount++;
                    } else if (!String.valueOf(subjectWithSameId.getGender()).equals(GENDER)) {
                        fp.addPresetValue(G_WARNING, "true");
                        warningCount++;
                    } else {
                        fp.addPresetValue(G_WARNING, "false");
                    }
                } else {
                    fp.addPresetValue(G_WARNING, "false");
                }
                // Current study required DOB
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("1")) {
                    // date-of-birth in subject table is not completed
                    if (subjectWithSameId.isDobCollected() == false) {
                        needUpdate = true;
                        updateSubject = subjectWithSameId;
                        updateSubject.setDobCollected(true);
                        if (subjectWithSameId.getDateOfBirth() == null) {
                            fp.addPresetValue(INPUT_DOB, DOB);
                            updateSubject.setDateOfBirth(new Date(DOB));
                        } else {
                            String y = String.valueOf(subjectWithSameId.getDateOfBirth()).split("\\-")[0];
                            String[] d = DOB.split("\\/");
                            // if year-of-birth in subject table
                            if (!y.equals("0001")) {
                                // year, use year-of-birth
                                if (!y.equals(d[2])) {
                                    fp.addPresetValue(D_WARNING, "dobYearWrong");
                                    fp.addPresetValue(INPUT_DOB, d[0] + "/" + d[1] + "/" + y);
                                    updateSubject.setDateOfBirth(sdf.parse(d[0] + "/" + d[1] + "/" + y));
                                } else {
                                    fp.addPresetValue(D_WARNING, "dobUsed");
                                    fp.addPresetValue(INPUT_DOB, DOB);
                                    updateSubject.setDateOfBirth(sdf.parse(DOB));
                                }
                            } else // date-of-birth is not required in subject
                            // table
                            {
                                fp.addPresetValue(D_WARNING, "emptyD");
                                fp.addPresetValue(INPUT_DOB, DOB);
                                updateSubject.setDateOfBirth(sdf.parse(DOB));
                            }
                        }
                        warningCount++;
                    } else // date-of-birth in subject table but doesn't match DOB
                    if (!local_df.format(subjectWithSameId.getDateOfBirth()).toString().equals(DOB)) {
                        // System.out.println("comparing " +
                        // local_df.format(
                        // subjectWithSameId.getDateOfBirth()).toString());
                        fp.addPresetValue(D_WARNING, "currentDOBWrong");
                        warningCount++;
                    } else // date-of-birth in subject table matchs DOB
                    {
                        fp.addPresetValue(D_WARNING, "false");
                    }
                } else // current Study require YOB
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
                    String y = String.valueOf(subjectWithSameId.getDateOfBirth()).split("\\-")[0];
                    // year of date-of-birth in subject table is avaible
                    if (!y.equals("0001")) {
                        // year in subject table doesn't match YOB,
                        if (!y.equals(YOB)) {
                            fp.addPresetValue(Y_WARNING, "yobWrong");
                            warningCount++;
                        } else // year in subject table matches YOB
                        {
                            fp.addPresetValue(Y_WARNING, "false");
                        }
                    } else // year of date-of-birth in the subject talbe is not
                    // availbe, YOB is used
                    {
                        needUpdate = true;
                        updateSubject = subjectWithSameId;
                        fp.addPresetValue(Y_WARNING, "yearEmpty");
                        fp.addPresetValue(INPUT_YOB, YOB);
                        updateSubject.setDateOfBirth(sdf.parse("01/01/" + YOB));
                        warningCount++;
                    }
                } else // current study require no DOB, there is no need to check
                // date-of-birth in the subject table
                {
                    fp.addPresetValue(Y_WARNING, "false");
                }
                if (warningCount > 0) {
                    warningCount = 0;
                    forwardPage(Page.ADD_EXISTING_SUBJECT);
                    return;
                }
            // forwardPage(Page.ADD_EXISTING_SUBJECT);
            // return;
            // YW >>
            }
            // to be inserted into both <subject> and <studysubject> tables
            if (!showExistingRecord) {
                // YW >>
                if (!StringUtil.isBlank(fp.getString(INPUT_GENDER))) {
                    subject.setGender(fp.getString(INPUT_GENDER).charAt(0));
                } else {
                    subject.setGender(' ');
                }
                subject.setUniqueIdentifier(uniqueIdentifier);
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("1")) {
                    if (!StringUtil.isBlank(fp.getString(INPUT_DOB))) {
                        subject.setDateOfBirth(fp.getDate(INPUT_DOB));
                        subject.setDobCollected(true);
                    } else {
                        subject.setDateOfBirth(null);
                        subject.setDobCollected(false);
                    }
                } else if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
                    // generate a fake birthday in 01/01/YYYY format, only
                    // the year is
                    // valid
                    // added the "2" to make sure that 'not used' is kept to
                    // null, tbh 102007
                    subject.setDobCollected(false);
                    int yob = fp.getInt(INPUT_YOB);
                    Date fakeDate = new Date("01/01/" + yob);
                    // Calendar fakeCal = Calendar.getInstance();
                    // fakeCal.set(Calendar.YEAR, yob);
                    // fakeCal.set(Calendar.MONTH, 1);
                    // fakeCal.set(Calendar.DAY_OF_MONTH, 1);
                    // String dobString = "01/01/" + yob;
                    String dobString = local_df.format(fakeDate);
                    try {
                        Date fakeDOB = local_df.parse(dobString);
                        subject.setDateOfBirth(fakeDOB);
                    } catch (ParseException pe) {
                        subject.setDateOfBirth(new Date());
                        addPageMessage(respage.getString("problem_happened_saving_year"));
                    }
                }
                subject.setStatus(Status.AVAILABLE);
                subject.setOwner(ub);
                subject = sdao.create(subject);
                if (!subject.isActive()) {
                    throw new OpenClinicaException(resexception.getString("could_not_create_subject"), "3");
                }
            // YW << for showExistingRecord && existingSubShown,
            // If input value(s) is(are) different from database,
            // warning will be shown.
            // If value(s) in database is(are) empty, entered value(s)
            // could be used;
            // Otherwise, value(s) in database will be used.
            // For date-of-birth, if database only has year-of-birth,
            // the year in database will be used for year part
            } else if (existingSubShown) {
                if (!needUpdate) {
                    subject = subjectWithSameId;
                } else {
                    updateSubject.setUpdater(ub);
                    updateSubject = (SubjectBean) sdao.update(updateSubject);
                    if (!updateSubject.isActive()) {
                        throw new OpenClinicaException("Could not create subject.", "5");
                    }
                    subject = updateSubject;
                    needUpdate = false;
                }
            }
            // YW >>
            // enroll the subject in the active study
            studySubject.setSubjectId(subject.getId());
            studySubject.setStudyId(currentStudy.getId());
            studySubject.setLabel(fp.getString(INPUT_LABEL));
            studySubject.setSecondaryLabel(fp.getString(INPUT_SECONDARY_LABEL));
            studySubject.setStatus(Status.AVAILABLE);
            studySubject.setEnrollmentDate(fp.getDate(INPUT_ENROLLMENT_DATE));
            if (fp.getBoolean("addWithEvent")) {
                studySubject.setEventStartDate(fp.getDate(INPUT_EVENT_START_DATE));
            }
            studySubject.setOwner(ub);
            // Shaoyu Su: prevent same label ("Study Subject ID")
            if (fp.getString(INPUT_LABEL).equalsIgnoreCase(resword.getString("id_generated_Save_Add"))) {
                synchronized (simpleLockObj) {
                    int nextLabel = ssd.findTheGreatestLabel() + 1;
                    studySubject.setLabel(nextLabel + "");
                    studySubject = ssd.createWithoutGroup(studySubject);
                    if (showExistingRecord && !existingSubShown) {
                        fp.addPresetValue(INPUT_LABEL, label);
                    }
                }
            } else {
                studySubject = ssd.createWithoutGroup(studySubject);
            }
            if (!classes.isEmpty() && studySubject.isActive()) {
                SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
                for (int i = 0; i < classes.size(); i++) {
                    StudyGroupClassBean group = (StudyGroupClassBean) classes.get(i);
                    int studyGroupId = group.getStudyGroupId();
                    String notes = group.getGroupNotes();
                    SubjectGroupMapBean map = new SubjectGroupMapBean();
                    map.setNotes(group.getGroupNotes());
                    map.setStatus(Status.AVAILABLE);
                    map.setStudyGroupId(group.getStudyGroupId());
                    map.setStudySubjectId(studySubject.getId());
                    map.setStudyGroupClassId(group.getId());
                    map.setOwner(ub);
                    if (map.getStudyGroupId() > 0) {
                        sgmdao.create(map);
                    }
                }
            }
            if (!studySubject.isActive()) {
                throw new OpenClinicaException(resexception.getString("could_not_create_study_subject"), "4");
            }
            // save discrepancy notes into DB
            FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(FORM_DISCREPANCY_NOTES_NAME);
            DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
            String[] subjectFields = { INPUT_DOB, INPUT_YOB, INPUT_GENDER };
            for (String element : subjectFields) {
                saveFieldNotes(element, fdn, dndao, subject.getId(), "subject", currentStudy);
            }
            saveFieldNotes(INPUT_ENROLLMENT_DATE, fdn, dndao, studySubject.getId(), "studySub", currentStudy);
            request.removeAttribute(FormProcessor.FIELD_SUBMITTED);
            request.setAttribute(CreateNewStudyEventServlet.INPUT_STUDY_SUBJECT, studySubject);
            request.setAttribute(CreateNewStudyEventServlet.INPUT_REQUEST_STUDY_SUBJECT, "no");
            request.setAttribute(FormProcessor.FIELD_SUBMITTED, "0");
            addPageMessage(respage.getString("subject_with_unique_identifier") + studySubject.getLabel() + respage.getString("X_was_created_succesfully"));
            if (fp.getBoolean("addWithEvent")) {
                createStudyEvent(fp, studySubject);
                // YW <<
                request.setAttribute("id", studySubject.getId() + "");
                // String url= response.encodeRedirectURL("ViewStudySubject?id=" + studySubject.getId());
                // response.sendRedirect(url);
                forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
                // + studySubject.getId()));
                return;
            }
            String submitEvent = fp.getString(SUBMIT_EVENT_BUTTON);
            String submitEnroll = fp.getString(SUBMIT_ENROLL_BUTTON);
            String submitDone = fp.getString(SUBMIT_DONE_BUTTON);
            session.removeAttribute(FORM_DISCREPANCY_NOTES_NAME);
            if (!StringUtil.isBlank(submitEvent)) {
                forwardPage(Page.CREATE_NEW_STUDY_EVENT_SERVLET);
            } else if (!StringUtil.isBlank(submitEnroll)) {
                // NEW MANTIS ISSUE 4770
                setUpBeans(classes);
                Date today = new Date(System.currentTimeMillis());
                String todayFormatted = local_df.format(today);
                fp.addPresetValue(INPUT_ENROLLMENT_DATE, todayFormatted);
                // YW 10-07-2007 <<
                String idSetting = "";
                if (currentStudy.getParentStudyId() > 0) {
                    parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
                    currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
                }
                idSetting = currentStudy.getStudyParameterConfig().getSubjectIdGeneration();
                // YW >>
                logger.info("subject id setting :" + idSetting);
                // set up auto study subject id
                if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
                    // Shaoyu Su
                    // int nextLabel = ssd.findTheGreatestLabel() + 1;
                    // fp.addPresetValue(INPUT_LABEL, new Integer(nextLabel).toString());
                    fp.addPresetValue(INPUT_LABEL, resword.getString("id_generated_Save_Add"));
                }
                setPresetValues(fp.getPresetValues());
                discNotes = new FormDiscrepancyNotes();
                session.setAttribute(FORM_DISCREPANCY_NOTES_NAME, discNotes);
                // End of 4770
                forwardPage(Page.ADD_NEW_SUBJECT);
            } else {
                // forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
                // forwardPage(Page.SUBMIT_DATA_SERVLET);
                request.setAttribute("id", studySubject.getId() + "");
                // String url=response.encodeRedirectURL("ViewStudySubject?id=" + studySubject.getId());
                // response.sendRedirect(url);
                forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
                return;
            }
        }
    // end of no error (errors.isEmpty())
    }
// end of fp.isSubmitted()
}
Also used : SubjectGroupMapBean(org.akaza.openclinica.bean.submit.SubjectGroupMapBean) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) ArrayList(java.util.ArrayList) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) SubjectGroupMapDAO(org.akaza.openclinica.dao.submit.SubjectGroupMapDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) Calendar(java.util.Calendar) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) Date(java.util.Date) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) DisplaySubjectBean(org.akaza.openclinica.bean.submit.DisplaySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) DiscrepancyValidator(org.akaza.openclinica.control.form.DiscrepancyValidator) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) ParseException(java.text.ParseException) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SimpleDateFormat(java.text.SimpleDateFormat)

Example 4 with OpenClinicaException

use of org.akaza.openclinica.exception.OpenClinicaException 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 5 with OpenClinicaException

use of org.akaza.openclinica.exception.OpenClinicaException in project OpenClinica by OpenClinica.

the class FormBeanUtil method createDisplaySectionBWithFormGroups.

/**
 * Create a DisplaySectionBean with a list of ItemGroupBeans. This List will
 * include any ItemGroupBeans that are associated with ungrouped items; in
 * other words, the DisplaySectionBean will represent a section that has
 * both ungrouped and grouped tables.
 *
 * @param sectionId
 *            The Section ID associated with the Items, which end up
 *            providing the content of the tables.
 * @param crfVersionId
 *            The CRF version ID associated with the Items.
 * @param dataSource
 * @param eventCRFDefId
 *            The id for the Event CRF Definition.
 * @return A DisplaySectionBean with sorted ItemGroupBeans, meaning the
 *         ItemGroupBeans should be listed in the order that they appear on
 *         the CRF section.
 * @return A DisplaySectionBean representing a CRF section.
 */
public DisplaySectionBean createDisplaySectionBWithFormGroups(int sectionId, int crfVersionId, DataSource dataSource, int eventCRFDefId, EventCRFBean eventCrfBean, ServletContext context) {
    DisplaySectionBean displaySectionBean = new DisplaySectionBean();
    ItemGroupDAO formGroupDAO = new ItemGroupDAO(dataSource);
    ItemGroupMetadataDAO igMetaDAO = new ItemGroupMetadataDAO(dataSource);
    ItemDAO itemDao = new ItemDAO(dataSource);
    ItemFormMetadataDAO metaDao = new ItemFormMetadataDAO(dataSource);
    SectionDAO sectionDao = new SectionDAO(dataSource);
    // Give the DisplaySectionBean a legitimate SectionBean
    SectionBean secBean = (SectionBean) sectionDao.findByPK(sectionId);
    displaySectionBean.setSection(secBean);
    // changed from: findGroupBySectionId
    List<ItemGroupBean> itemGroupBeans = formGroupDAO.findLegitGroupAllBySectionId(sectionId);
    // all items associated with the section, including those not in a group
    List<ItemFormMetadataBean> allMetas = new ArrayList<ItemFormMetadataBean>();
    try {
        allMetas = metaDao.findAllBySectionId(sectionId);
    } catch (OpenClinicaException oce) {
        logger.info("oce.getOpenClinicaMessage() = " + oce.getOpenClinicaMessage());
    }
    // Sort these items according to their position on the CRF; their
    // ordinal
    Collections.sort(allMetas);
    // The DisplayItemGroupBean(s) for "nongrouped" items
    List<DisplayItemGroupBean> nonGroupBeans = null;
    // if(itemGroupBeans.isEmpty()) return displaySectionBean;
    // Find out whether there are any checkboxes/radios/select elements
    // and if so, get any null values
    // associated with them
    List<String> nullValuesList = new ArrayList<String>();
    boolean itemsHaveChecksRadios = itemsIncludeChecksRadiosSelects(allMetas);
    if (itemsHaveChecksRadios && eventCRFDefId > 0) {
        // method returns null values as a List<String>
        nullValuesList = this.getNullValuesByEventCRFDefId(eventCRFDefId, dataSource);
    }
    // Get the items associated with each group
    List<ItemBean> itBeans;
    List<DisplayItemBean> displayItems;
    List<DisplayItemGroupBean> displayFormBeans = new ArrayList<DisplayItemGroupBean>();
    DisplayItemGroupBean displayItemGBean;
    for (ItemGroupBean itemGroup : itemGroupBeans) {
        itBeans = itemDao.findAllItemsByGroupId(itemGroup.getId(), crfVersionId);
        logger.debug("just ran find all by group id " + itemGroup.getId() + " found " + itBeans.size() + " item beans");
        List<ItemGroupMetadataBean> metadata = igMetaDAO.findMetaByGroupAndSection(itemGroup.getId(), crfVersionId, sectionId);
        if (!metadata.isEmpty()) {
            // for a given crf version, all the items in the same group
            // have the same group metadata info
            // so we can get one of the metadata and set the metadata for
            // the group
            ItemGroupMetadataBean meta = metadata.get(0);
            itemGroup.setMeta(meta);
        }
        displayItems = getDisplayBeansFromItems(itBeans, dataSource, eventCrfBean, sectionId, nullValuesList, context);
        displayItemGBean = this.createDisplayFormGroup(displayItems, itemGroup);
        displayFormBeans.add(displayItemGBean);
    }
    // We still have to sort these display item group beans on their
    // ItemGroupMetadataBean?
    // then number their ordinals accordingly
    Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {

        public int compare(DisplayItemGroupBean displayItemGroupBean, DisplayItemGroupBean displayItemGroupBean1) {
            return displayItemGroupBean.getGroupMetaBean().compareTo(displayItemGroupBean1.getGroupMetaBean());
        }
    });
    // Now provide the display item group beans with an ordinal
    int digOrdinal = 0;
    for (DisplayItemGroupBean digBean : displayFormBeans) {
        digBean.setOrdinal(++digOrdinal);
    }
    // find out whether there are any ungrouped items by comparing the
    // number of
    // grouped items to allMetas.size()
    // List<DisplayItemGroupBean> nonGroupBeans=null;
    int tempCount = 0;
    for (DisplayItemGroupBean groupBean : displayFormBeans) {
        tempCount += groupBean.getItems().size();
    }
    if (tempCount < allMetas.size()) {
        nonGroupBeans = createGroupBeansForNongroupedItems(allMetas, displayFormBeans, sectionId, dataSource, nullValuesList, eventCrfBean, context);
    }
    if (nonGroupBeans != null) {
        displayFormBeans.addAll(nonGroupBeans);
    }
    // sort the list according to the ordinal of the contained
    // DisplayItemGroupBeans
    Collections.sort(displayFormBeans, new Comparator<DisplayItemGroupBean>() {

        public int compare(DisplayItemGroupBean disFormGroupBean, DisplayItemGroupBean disFormGroupBean1) {
            Integer compInt = disFormGroupBean1.getOrdinal();
            Integer compInt2 = disFormGroupBean.getOrdinal();
            return compInt2.compareTo(compInt);
        }
    });
    displaySectionBean.setDisplayFormGroups(displayFormBeans);
    return displaySectionBean;
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ItemGroupDAO(org.akaza.openclinica.dao.submit.ItemGroupDAO) ArrayList(java.util.ArrayList) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) ItemGroupMetadataBean(org.akaza.openclinica.bean.submit.ItemGroupMetadataBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemFormMetadataDAO(org.akaza.openclinica.dao.submit.ItemFormMetadataDAO) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) ItemGroupMetadataDAO(org.akaza.openclinica.dao.submit.ItemGroupMetadataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) DisplayItemGroupBean(org.akaza.openclinica.bean.submit.DisplayItemGroupBean) ItemGroupBean(org.akaza.openclinica.bean.submit.ItemGroupBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Aggregations

OpenClinicaException (org.akaza.openclinica.exception.OpenClinicaException)23 ArrayList (java.util.ArrayList)18 HashMap (java.util.HashMap)11 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)8 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)7 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)7 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)7 Connection (java.sql.Connection)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)6 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)6 ItemFormMetadataDAO (org.akaza.openclinica.dao.submit.ItemFormMetadataDAO)6 MessageFormat (java.text.MessageFormat)5 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)5 ItemGroupBean (org.akaza.openclinica.bean.submit.ItemGroupBean)5 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)5 ItemGroupDAO (org.akaza.openclinica.dao.submit.ItemGroupDAO)5 IOException (java.io.IOException)4 Iterator (java.util.Iterator)4