Search in sources :

Example 91 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class StudySubjectServiceImpl method getDisplayStudyEventsForStudySubject.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<DisplayStudyEventBean> getDisplayStudyEventsForStudySubject(StudySubjectBean studySubject, UserAccountBean userAccount, StudyUserRoleBean currentRole) {
    StudyEventDAO studyEventDao = new StudyEventDAO(dataSource);
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
    StudyDAO studyDao = new StudyDAO(dataSource);
    EventDefinitionCRFDAO eventDefinitionCrfDao = new EventDefinitionCRFDAO(dataSource);
    EventCRFDAO eventCrfDao = new EventCRFDAO(dataSource);
    CRFDAO crfDao = new CRFDAO(dataSource);
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(dataSource);
    ArrayList events = studyEventDao.findAllByStudySubject(studySubject);
    Map<Integer, StudyEventDefinitionBean> eventDefinitionByEvent = studyEventDefinitionDao.findByStudySubject(studySubject.getId());
    StudyBean study = (StudyBean) studyDao.findByPK(studySubject.getStudyId());
    Map<Integer, SortedSet<EventDefinitionCRFBean>> eventDefinitionCrfByStudyEventDefinition;
    if (study.getParentStudyId() < 1) {
        // Is a study
        eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinitionForStudy(studySubject.getId());
    } else {
        // Is a site
        eventDefinitionCrfByStudyEventDefinition = eventDefinitionCrfDao.buildEventDefinitionCRFListByStudyEventDefinition(studySubject.getId(), study.getId(), study.getParentStudyId());
    }
    Map<Integer, SortedSet<EventCRFBean>> eventCrfListByStudyEvent = eventCrfDao.buildEventCrfListByStudyEvent(studySubject.getId());
    Map<Integer, Integer> maxOrdinalByStudyEvent = studyEventDefinitionDao.buildMaxOrdinalByStudyEvent(studySubject.getId());
    Set<Integer> nonEmptyEventCrf = eventCrfDao.buildNonEmptyEventCrfIds(studySubject.getId());
    Map<Integer, CRFVersionBean> crfVersionById = crfVersionDao.buildCrfVersionById(studySubject.getId());
    Map<Integer, CRFBean> crfById = crfDao.buildCrfById(studySubject.getId());
    ArrayList<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
    for (int i = 0; i < events.size(); i++) {
        StudyEventBean event = (StudyEventBean) events.get(i);
        StudyEventDefinitionBean sed = eventDefinitionByEvent.get(event.getStudyEventDefinitionId());
        event.setStudyEventDefinition(sed);
        List eventDefinitionCRFs = new ArrayList((eventDefinitionCrfByStudyEventDefinition.containsKey(sed.getId()) ? eventDefinitionCrfByStudyEventDefinition.get(sed.getId()) : Collections.EMPTY_LIST));
        List eventCRFs = new ArrayList((eventCrfListByStudyEvent.containsKey(event.getId())) ? eventCrfListByStudyEvent.get(event.getId()) : Collections.EMPTY_LIST);
        // construct info needed on view study event page
        DisplayStudyEventBean de = new DisplayStudyEventBean();
        de.setStudyEvent(event);
        de.setDisplayEventCRFs((ArrayList<DisplayEventCRFBean>) getDisplayEventCRFs(eventCRFs, userAccount, currentRole, event.getSubjectEventStatus(), study, nonEmptyEventCrf, crfVersionById, crfById, event.getStudyEventDefinitionId(), eventDefinitionCRFs));
        ArrayList<DisplayEventDefinitionCRFBean> al = getUncompletedCRFs(eventDefinitionCRFs, eventCRFs, event.getSubjectEventStatus(), nonEmptyEventCrf, crfVersionById, crfById);
        populateUncompletedCRFsWithCRFAndVersions(al, crfVersionById, crfById);
        de.setUncompletedCRFs(al);
        // de.setMaximumSampleOrdinal(studyEventDao.getMaxSampleOrdinal(sed,
        // studySubject));
        de.setMaximumSampleOrdinal(maxOrdinalByStudyEvent.get(event.getStudyEventDefinitionId()));
        displayEvents.add(de);
    // event.setEventCRFs(createAllEventCRFs(eventCRFs,
    // eventDefinitionCRFs));
    }
    return displayEvents;
}
Also used : ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) SortedSet(java.util.SortedSet) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) List(java.util.List) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) 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) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) DisplayStudyEventBean(org.akaza.openclinica.bean.managestudy.DisplayStudyEventBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean)

Example 92 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class StudySubjectServiceImpl method getDisplayEventCRFs.

private List<DisplayEventCRFBean> getDisplayEventCRFs(List eventCRFs, UserAccountBean ub, StudyUserRoleBean currentRole, SubjectEventStatus status, StudyBean study, Set<Integer> nonEmptyEventCrf, Map<Integer, CRFVersionBean> crfVersionById, Map<Integer, CRFBean> crfById, Integer studyEventDefinitionId, List eventDefinitionCRFs) {
    ArrayList<DisplayEventCRFBean> answer = new ArrayList<DisplayEventCRFBean>();
    for (int i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
        // populate the event CRF with its crf bean
        int crfVersionId = ecb.getCRFVersionId();
        // CRFVersionBean cvb = crfVersionById.get(ecb.getCRFVersionId());
        CRFVersionBean cvb = crfVersionById.get(crfVersionId);
        ecb.setCrfVersion(cvb);
        // CRFBean cb = crfDao.findByVersionId(crfVersionId);
        CRFBean cb = crfById.get(cvb.getCrfId());
        ecb.setCrf(cb);
        EventDefinitionCRFBean edc = null;
        Iterator it = eventDefinitionCRFs.iterator();
        while (it.hasNext()) {
            EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
            if (edcBean.getCrfId() == cb.getId()) {
                edc = edcBean;
                break;
            }
        }
        // rules updated 112007 tbh
        if (status.equals(SubjectEventStatus.LOCKED) || status.equals(SubjectEventStatus.SKIPPED) || status.equals(SubjectEventStatus.STOPPED)) {
            ecb.setStage(DataEntryStage.LOCKED);
        // we need to set a SED-wide flag here, because other edcs
        // in this event can be filled in and change the status, tbh
        } else if (status.equals(SubjectEventStatus.INVALID)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!cb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        } else if (!cvb.getStatus().equals(Status.AVAILABLE)) {
            ecb.setStage(DataEntryStage.LOCKED);
        }
        // TODO need to refactor since this is similar to other code, tbh
        if (edc != null) {
            // System.out.println("edc is not null, need to set flags");
            DisplayEventCRFBean dec = new DisplayEventCRFBean();
            dec.setEventDefinitionCRF(edc);
            // System.out.println("edc.isDoubleEntry()" +
            // edc.isDoubleEntry() + ecb.getId());
            dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
            if (dec.isLocked()) {
            // System.out.println("*** found a locked DEC:
            // "+edc.getCrfName());
            }
            if (nonEmptyEventCrf.contains(ecb.getId())) {
                // consider an event crf started only if item data get
                // created
                answer.add(dec);
            }
        }
    }
    return answer;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 93 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class CreateSubStudyServlet method validateSubmissionUrl.

public ArrayList<EventDefinitionCRFBean> validateSubmissionUrl(ArrayList<EventDefinitionCRFBean> edcsInSession, ArrayList<EventDefinitionCRFBean> eventDefCrfList, Validator v, StudyEventDefinitionBean sed) {
    for (int i = 0; i < edcsInSession.size(); i++) {
        String order = i + "-" + edcsInSession.get(i).getId();
        v.addValidation("submissionUrl" + order, Validator.NO_SPACES_ALLOWED);
        EventDefinitionCRFBean sessionBean = null;
        boolean isExist = false;
        for (EventDefinitionCRFBean eventDef : eventDefCrfList) {
            sessionBean = edcsInSession.get(i);
            System.out.println("iter:           " + eventDef.getId() + "--db:    " + eventDef.getSubmissionUrl());
            System.out.println("edcsInSession:  " + sessionBean.getId() + "--session:" + sessionBean.getSubmissionUrl());
            System.out.println();
            if (sessionBean.getSubmissionUrl().trim().equals("") || sessionBean.getSubmissionUrl().trim() == null) {
                break;
            } else {
                if (eventDef.getSubmissionUrl().trim().equalsIgnoreCase(sessionBean.getSubmissionUrl().trim()) && (eventDef.getId() != sessionBean.getId())) {
                    v.addValidation("submissionUrl" + order, Validator.SUBMISSION_URL_NOT_UNIQUE);
                    sed.setPopulated(true);
                    System.out.println("Duplicate ****************************");
                    isExist = true;
                    break;
                } else if (eventDef.getSubmissionUrl().trim().equalsIgnoreCase(sessionBean.getSubmissionUrl().trim()) && (eventDef.getId() == sessionBean.getId())) {
                    System.out.println("Not Duplicate  ***********");
                    isExist = true;
                    break;
                }
            }
        }
        if (!isExist) {
            eventDefCrfList.add(sessionBean);
        }
    }
    return eventDefCrfList;
}
Also used : EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 94 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class CreateSubStudyServlet method submitSiteEventDefinitions.

private void submitSiteEventDefinitions(StudyBean site) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
    HashMap<String, Boolean> changes = (HashMap<String, Boolean>) session.getAttribute("changed");
    for (StudyEventDefinitionBean sed : seds) {
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        request.setAttribute("participateFormStatus", participateFormStatus);
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
        for (EventDefinitionCRFBean edcBean : edcs) {
            int edcStatusId = edcBean.getStatus().getId();
            if (edcStatusId == 5 || edcStatusId == 7) {
            } else {
                boolean changed = changes.get(sed.getId() + "-" + edcBean.getId());
                if (changed) {
                    edcBean.setParentId(edcBean.getId());
                    edcBean.setStudyId(site.getId());
                    edcBean.setUpdater(ub);
                    edcBean.setUpdatedDate(new Date());
                    logger.debug("create for the site");
                    edcdao.create(edcBean);
                }
            }
        }
    }
    session.removeAttribute("definitions");
    session.removeAttribute("changed");
    session.removeAttribute("sdvOptions");
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) Date(java.util.Date) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 95 with EventDefinitionCRFBean

use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.

the class CreateSubStudyServlet method createSiteEventDefinitions.

private ArrayList<StudyEventDefinitionBean> createSiteEventDefinitions(StudyBean site, Validator v) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> edcsInSession = new ArrayList<EventDefinitionCRFBean>();
    StudyBean parentStudyBean;
    if (site.getParentStudyId() == 0) {
        parentStudyBean = site;
    } else {
        StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
        parentStudyBean = (StudyBean) studyDAO.findByPK(site.getParentStudyId());
    }
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyBean.getId());
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    StudyBean parentStudy = (StudyBean) new StudyDAO(sm.getDataSource()).findByPK(site.getParentStudyId());
    seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
    if (seds == null || seds.size() <= 0) {
        StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
        seds = sedDao.findAllByStudy(parentStudy);
    }
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
    for (StudyEventDefinitionBean sed : seds) {
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        // EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
        int start = 0;
        for (EventDefinitionCRFBean edcBean : edcs) {
            EventDefinitionCRFBean persistEventDefBean = (EventDefinitionCRFBean) edcdao.findByPK(edcBean.getId());
            int edcStatusId = edcBean.getStatus().getId();
            if (edcStatusId == 5 || edcStatusId == 7) {
            } else {
                String order = start + "-" + edcBean.getId();
                int defaultVersionId = fp.getInt("defaultVersionId" + order);
                String requiredCRF = fp.getString("requiredCRF" + order);
                String doubleEntry = fp.getString("doubleEntry" + order);
                String electronicSignature = fp.getString("electronicSignature" + order);
                String hideCRF = fp.getString("hideCRF" + order);
                int sdvId = fp.getInt("sdvOption" + order);
                String participantForm = fp.getString("participantForm" + order);
                String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + order);
                String submissionUrl = fp.getString("submissionUrl" + order);
                String offline = fp.getString("offline" + order);
                ArrayList<String> selectedVersionIdList = fp.getStringArray("versionSelection" + order);
                int selectedVersionIdListSize = selectedVersionIdList.size();
                String selectedVersionIds = "";
                if (selectedVersionIdListSize > 0) {
                    for (String id : selectedVersionIdList) {
                        selectedVersionIds += id + ",";
                    }
                    selectedVersionIds = selectedVersionIds.substring(0, selectedVersionIds.length() - 1);
                }
                boolean changed = false;
                boolean isRequired = !StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim()) ? true : false;
                boolean isDouble = !StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim()) ? true : false;
                boolean hasPassword = !StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim()) ? true : false;
                boolean isHide = !StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim()) ? true : false;
                if (edcBean.getParentId() > 0) {
                    int dbDefaultVersionId = edcBean.getDefaultVersionId();
                    if (defaultVersionId != dbDefaultVersionId) {
                        changed = true;
                        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
                        edcBean.setDefaultVersionId(defaultVersionId);
                        edcBean.setDefaultVersionName(defaultVersion.getName());
                    }
                    if (isRequired != edcBean.isRequiredCRF()) {
                        changed = true;
                        edcBean.setRequiredCRF(isRequired);
                    }
                    if (isDouble != edcBean.isDoubleEntry()) {
                        changed = true;
                        edcBean.setDoubleEntry(isDouble);
                    }
                    if (hasPassword != edcBean.isElectronicSignature()) {
                        changed = true;
                        edcBean.setElectronicSignature(hasPassword);
                    }
                    if (isHide != edcBean.isHideCrf()) {
                        changed = true;
                        edcBean.setHideCrf(isHide);
                    }
                    if (!submissionUrl.equals(edcBean.getSubmissionUrl()) || !submissionUrl.equals(persistEventDefBean.getSubmissionUrl())) {
                        changed = true;
                        edcBean.setSubmissionUrl(submissionUrl);
                    }
                    if (!StringUtil.isBlank(selectedVersionIds) && !selectedVersionIds.equals(edcBean.getSelectedVersionIds())) {
                        changed = true;
                        String[] ids = selectedVersionIds.split(",");
                        ArrayList<Integer> idList = new ArrayList<Integer>();
                        for (String id : ids) {
                            idList.add(Integer.valueOf(id));
                        }
                        edcBean.setSelectedVersionIdList(idList);
                        edcBean.setSelectedVersionIds(selectedVersionIds);
                    }
                    if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
                        changed = true;
                        edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
                    }
                } else {
                    // only if definition-crf has been modified, will it be
                    // saved for the site
                    int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
                    if (defaultId == defaultVersionId) {
                        if (isRequired == edcBean.isRequiredCRF()) {
                            if (isDouble == edcBean.isDoubleEntry()) {
                                if (hasPassword == edcBean.isElectronicSignature()) {
                                    if (isHide == edcBean.isHideCrf()) {
                                        if (submissionUrl.equals("")) {
                                            if (selectedVersionIdListSize > 0) {
                                                if (selectedVersionIdListSize == edcBean.getVersions().size()) {
                                                    if (sdvId > 0) {
                                                        if (sdvId != edcBean.getSourceDataVerification().getCode()) {
                                                            changed = true;
                                                            edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
                                                            edcBean.setSubmissionUrl(submissionUrl);
                                                        }
                                                    }
                                                } else {
                                                    changed = true;
                                                    String[] ids = selectedVersionIds.split(",");
                                                    ArrayList<Integer> idList = new ArrayList<Integer>();
                                                    for (String id : ids) {
                                                        idList.add(Integer.valueOf(id));
                                                    }
                                                    edcBean.setSelectedVersionIdList(idList);
                                                    edcBean.setSelectedVersionIds(selectedVersionIds);
                                                    edcBean.setSubmissionUrl(submissionUrl);
                                                }
                                            }
                                        } else {
                                            changed = true;
                                            edcBean.setSubmissionUrl(submissionUrl);
                                        }
                                    } else {
                                        changed = true;
                                        edcBean.setHideCrf(isHide);
                                        edcBean.setSubmissionUrl(submissionUrl);
                                    }
                                } else {
                                    changed = true;
                                    edcBean.setElectronicSignature(hasPassword);
                                    edcBean.setSubmissionUrl(submissionUrl);
                                }
                            } else {
                                changed = true;
                                edcBean.setDoubleEntry(isDouble);
                                edcBean.setSubmissionUrl(submissionUrl);
                            }
                        } else {
                            changed = true;
                            edcBean.setRequiredCRF(isRequired);
                            edcBean.setSubmissionUrl(submissionUrl);
                        }
                    } else {
                        changed = true;
                        CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultVersionId);
                        edcBean.setDefaultVersionId(defaultVersionId);
                        edcBean.setDefaultVersionName(defaultVersion.getName());
                    }
                }
                changes.put(sed.getId() + "-" + edcBean.getId(), changed);
                ++start;
            }
            edcsInSession.add(edcBean);
        }
        sed.setPopulated(false);
        eventDefCrfList = validateSubmissionUrl(edcsInSession, eventDefCrfList, v, sed);
        edcsInSession.clear();
    }
    errors = v.validate();
    StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
    ArrayList<StudyBean> allStudies = (ArrayList<StudyBean>) studyDAO.findAll();
    for (StudyBean thisBean : allStudies) {
        if (fp.getString("uniqueProId").trim().equals(thisBean.getIdentifier())) {
            v.addError(errors, "uniqueProId", resexception.getString("unique_protocol_id_existed"));
        }
    }
    // << tbh #3999 08/2009
    if (fp.getString("name").trim().length() > 100) {
    // Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
    }
    if (fp.getString("uniqueProId").trim().length() > 30) {
        Validator.addError(errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
    }
    if (fp.getString("description").trim().length() > 255) {
        Validator.addError(errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
    }
    if (fp.getString("prinInvestigator").trim().length() > 255) {
        Validator.addError(errors, "prinInvestigator", resexception.getString("maximum_lenght_principal_investigator_255"));
    }
    if (fp.getInt("expectedTotalEnrollment") <= 0) {
        Validator.addError(errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number"));
    }
    if (!errors.isEmpty()) {
        // logger.info("has errors");
        StudyBean study = createStudyBean();
        session.setAttribute("newStudy", study);
        session.setAttribute("definitions", seds);
        request.setAttribute("formMessages", errors);
        /*   try {
               local_df.parse(fp.getString(INPUT_START_DATE));
               fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
           } catch (ParseException pe) {
               fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
           }
           try {
               local_df.parse(fp.getString(INPUT_END_DATE));
               fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
           } catch (ParseException pe) {
               fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
           }
           try {
               local_df.parse(fp.getString(INPUT_VER_DATE));
               fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
           } catch (ParseException pe) {
               fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
           }*/
        // setPresetValues(fp.getPresetValues());
        logger.info("has validation errors");
        // request.setAttribute("formMessages", errors);
        // request.setAttribute("facRecruitStatusMap",
        // CreateStudyServlet.facRecruitStatusMap);
        // request.setAttribute("statuses", Status.toActiveArrayList());
        // forwardPage(Page.CREATE_SUB_STUDY);
        forwardPage(Page.CREATE_SUB_STUDY);
    }
    session.setAttribute("changed", changes);
    return seds;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)146 ArrayList (java.util.ArrayList)112 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)67 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)65 HashMap (java.util.HashMap)57 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)50 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)50 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)49 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)42 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)38 Iterator (java.util.Iterator)36 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)32 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)30 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)28 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)26 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)26