Search in sources :

Example 86 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.

the class RemoveCRFVersionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int versionId = fp.getInt("id", true);
    String module = fp.getString("module");
    request.setAttribute("module", module);
    String action = fp.getString("action");
    if (versionId == 0) {
        addPageMessage(respage.getString("please_choose_a_CRF_version_to_remove"));
        forwardPage(Page.CRF_LIST_SERVLET);
    } else {
        if (StringUtil.isBlank(action)) {
            addPageMessage(respage.getString("no_action_specified"));
            forwardPage(Page.CRF_LIST_SERVLET);
            return;
        }
        CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId);
        if (!ub.isSysAdmin() && (version.getOwnerId() != ub.getId())) {
            addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
            forwardPage(Page.MENU_SERVLET);
            return;
        }
        SectionDAO secdao = new SectionDAO(sm.getDataSource());
        EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
        // find all event crfs by version id
        ArrayList eventCRFs = evdao.findUndeletedWithStudySubjectsByCRFVersion(versionId);
        if ("confirm".equalsIgnoreCase(action)) {
            request.setAttribute("versionToRemove", version);
            request.setAttribute("eventCRFs", eventCRFs);
            forwardPage(Page.REMOVE_CRF_VERSION);
        } else {
            logger.info("submit to remove the crf version");
            // version
            version.setStatus(Status.DELETED);
            version.setUpdater(ub);
            version.setUpdatedDate(new Date());
            cvdao.update(version);
            // crfs in the second pass
            for (int ii = 0; ii < eventCRFs.size(); ii++) {
                EventCRFBean ecbean = (EventCRFBean) eventCRFs.get(ii);
                ecbean.setStatus(Status.AUTO_DELETED);
                ecbean.setUpdater(ub);
                ecbean.setUpdatedDate(new Date());
                evdao.update(ecbean);
            }
            // added above tbh 092007, to fix task
            // all sections
            ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
            for (int j = 0; j < sections.size(); j++) {
                SectionBean section = (SectionBean) sections.get(j);
                if (!section.getStatus().equals(Status.DELETED)) {
                    section.setStatus(Status.AUTO_DELETED);
                    section.setUpdater(ub);
                    section.setUpdatedDate(new Date());
                    secdao.update(section);
                }
            }
            // all item data related to event crfs
            ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
            for (int i = 0; i < eventCRFs.size(); i++) {
                EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
                if (!eventCRF.getStatus().equals(Status.DELETED)) {
                    eventCRF.setStatus(Status.AUTO_DELETED);
                    eventCRF.setUpdater(ub);
                    eventCRF.setUpdatedDate(new Date());
                    evdao.update(eventCRF);
                    ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
                    for (int j = 0; j < items.size(); j++) {
                        ItemDataBean item = (ItemDataBean) items.get(j);
                        if (!item.getStatus().equals(Status.DELETED)) {
                            item.setStatus(Status.AUTO_DELETED);
                            item.setUpdater(ub);
                            item.setUpdatedDate(new Date());
                            idao.update(item);
                        }
                    }
                }
            }
            ArrayList versionList = (ArrayList) cvdao.findAllByCRF(version.getCrfId());
            if (versionList.size() > 0) {
                EventDefinitionCRFDAO edCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
                ArrayList edcList = (ArrayList) edCRFDao.findAllByCRF(version.getCrfId());
                for (int i = 0; i < edcList.size(); i++) {
                    EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcList.get(i);
                    updateEventDef(edcBean, edCRFDao, versionList);
                }
            }
            addPageMessage(respage.getString("the_CRF") + version.getName() + " " + respage.getString("has_been_removed_succesfully"));
            forwardPage(Page.CRF_LIST_SERVLET);
        }
    }
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) Date(java.util.Date) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) SectionBean(org.akaza.openclinica.bean.submit.SectionBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) SectionDAO(org.akaza.openclinica.dao.submit.SectionDAO)

Example 87 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.

the class ViewNoteServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    Locale locale = LocaleResolver.getLocale(request);
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, locale);
    DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
    dndao.setFetchMapping(true);
    int noteId = fp.getInt(NOTE_ID, true);
    DiscrepancyNoteBean note = (DiscrepancyNoteBean) dndao.findByPK(noteId);
    String entityType = note.getEntityType();
    if (note.getEntityId() > 0 && !entityType.equals("")) {
        if (!StringUtil.isBlank(entityType)) {
            if ("itemData".equalsIgnoreCase(entityType)) {
                ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
                ItemDataBean itemData = (ItemDataBean) iddao.findByPK(note.getEntityId());
                ItemDAO idao = new ItemDAO(sm.getDataSource());
                ItemBean item = (ItemBean) idao.findByPK(itemData.getItemId());
                note.setEntityValue(itemData.getValue());
                note.setEntityName(item.getName());
                //Mantis Issue 5165. It should be itemData.getId() instead of item.getId()
                note.setEntityId(itemData.getId());
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(ec.getStudyEventId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
                CRFVersionBean cv = (CRFVersionBean) cvdao.findByPK(ec.getCRFVersionId());
                CRFDAO cdao = new CRFDAO(sm.getDataSource());
                CRFBean crf = (CRFBean) cdao.findByPK(cv.getCrfId());
                note.setCrfName(crf.getName());
            } else if ("studySub".equalsIgnoreCase(entityType)) {
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(note.getEntityId());
                note.setStudySub(ssub);
                // System.out.println("column" + note.getColumn());
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(ssub.getSubjectId());
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("enrollment_date".equalsIgnoreCase(note.getColumn())) {
                        if (ssub.getEnrollmentDate() != null) {
                            note.setEntityValue(dateFormatter.format(ssub.getEnrollmentDate()));
                        }
                        note.setEntityName(resword.getString("enrollment_date"));
                    } else if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    }
                }
            } else if ("subject".equalsIgnoreCase(entityType)) {
                SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
                SubjectBean sub = (SubjectBean) sdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = new StudySubjectBean();
                ssub.setLabel(sub.getUniqueIdentifier());
                note.setStudySub(ssub);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("gender".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityValue(sub.getGender() + "");
                        note.setEntityName(resword.getString("gender"));
                    } else if ("date_of_birth".equalsIgnoreCase(note.getColumn())) {
                        if (sub.getDateOfBirth() != null) {
                            note.setEntityValue(dateFormatter.format(sub.getDateOfBirth()));
                        }
                        note.setEntityName(resword.getString("date_of_birth"));
                    } else if ("unique_identifier".equalsIgnoreCase(note.getColumn())) {
                        note.setEntityName(resword.getString("unique_identifier"));
                        note.setEntityValue(sub.getUniqueIdentifier());
                    }
                }
            } else if ("studyEvent".equalsIgnoreCase(entityType)) {
                StudyEventDAO sed = new StudyEventDAO(sm.getDataSource());
                StudyEventBean se = (StudyEventBean) sed.findByPK(note.getEntityId());
                StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
                StudySubjectBean ssub = (StudySubjectBean) ssdao.findByPK(se.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
                StudyEventDefinitionBean sedb = (StudyEventDefinitionBean) seddao.findByPK(se.getStudyEventDefinitionId());
                se.setName(sedb.getName());
                note.setEvent(se);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("location".equalsIgnoreCase(note.getColumn())) {
                        request.setAttribute("entityValue", se.getLocation());
                        request.setAttribute("entityName", resword.getString("location"));
                        note.setEntityName(resword.getString("location"));
                        note.setEntityValue(se.getLocation());
                    } else if ("date_start".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateStarted() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateStarted()));
                        }
                        note.setEntityName(resword.getString("start_date"));
                    } else if ("date_end".equalsIgnoreCase(note.getColumn())) {
                        if (se.getDateEnded() != null) {
                            note.setEntityValue(dateFormatter.format(se.getDateEnded()));
                        }
                        note.setEntityName(resword.getString("end_date"));
                    }
                }
            } else if ("eventCrf".equalsIgnoreCase(entityType)) {
                EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
                EventCRFBean ec = (EventCRFBean) ecdao.findByPK(note.getEntityId());
                StudySubjectBean ssub = (StudySubjectBean) new StudySubjectDAO(sm.getDataSource()).findByPK(ec.getStudySubjectId());
                note.setStudySub(ssub);
                StudyEventBean event = (StudyEventBean) new StudyEventDAO(sm.getDataSource()).findByPK(ec.getStudyEventId());
                note.setEvent(event);
                if (!StringUtil.isBlank(note.getColumn())) {
                    if ("date_interviewed".equals(note.getColumn())) {
                        if (ec.getDateInterviewed() != null) {
                            note.setEntityValue(dateFormatter.format(ec.getDateInterviewed()));
                        }
                        note.setEntityName(resword.getString("date_interviewed"));
                    } else if ("interviewer_name".equals(note.getColumn())) {
                        note.setEntityValue(ec.getInterviewerName());
                        note.setEntityName(resword.getString("interviewer_name"));
                    }
                }
            }
        }
    }
    // Mantis Issue 8495.
    if (note.getStudyId() != currentStudy.getId()) {
        if (currentStudy.getParentStudyId() > 0) {
            if (currentStudy.getId() != note.getStudySub().getStudyId()) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        } else {
            // The SubjectStudy is not belong to currentstudy and current study is not a site.
            StudyDAO studydao = new StudyDAO(sm.getDataSource());
            Collection sites;
            sites = studydao.findOlnySiteIdsByStudy(currentStudy);
            if (!sites.contains(note.getStudySub().getStudyId())) {
                addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
                forwardPage(Page.MENU_SERVLET);
                return;
            }
        }
    }
    // Check end
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    ArrayList<DiscrepancyNoteBean> notes = dndao.findAllEntityByPK(note.getEntityType(), noteId);
    Date lastUpdatedDate = note.getCreatedDate();
    UserAccountBean lastUpdator = (UserAccountBean) udao.findByPK(note.getOwnerId());
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId == 0) { note = n; note.setLastUpdator((UserAccountBean)
         * udao.findByPK(n.getOwnerId()));
         * note.setLastDateUpdated(n.getCreatedDate()); lastUpdatedDate =
         * note.getLastDateUpdated(); lastUpdator = note.getLastUpdator(); } }
         */
    // BWP 3029 >> This algorithm needs to be changed to properly set
    // the parent note's status and updated date
    // First sort the notes on their ID; this will put the parent note
    // first; and
    // the note with the latest status and updated date last
    java.util.Collections.sort(notes);
    DiscrepancyNoteBean lastChild = notes.get(notes.size() - 1);
    lastUpdatedDate = lastChild.getCreatedDate();
    lastUpdator = (UserAccountBean) udao.findByPK(lastChild.getOwnerId());
    note.setLastUpdator(lastUpdator);
    note.setLastDateUpdated(lastUpdatedDate);
    note.setUpdatedDate(lastUpdatedDate);
    for (DiscrepancyNoteBean dnBean : notes) {
        if (dnBean.getParentDnId() > 0) {
            note.getChildren().add(dnBean);
        }
    }
    /*
         * for (int i = 0; i < notes.size(); i++) { DiscrepancyNoteBean n =
         * (DiscrepancyNoteBean) notes.get(i); int pId = n.getParentDnId(); if
         * (pId > 0) { note.getChildren().add(n);
         *
         * if (!n.getCreatedDate().before(lastUpdatedDate)) { lastUpdatedDate =
         * n.getCreatedDate(); lastUpdator = (UserAccountBean)
         * udao.findByPK(n.getOwnerId()); note.setLastUpdator(lastUpdator);
         * note.setLastDateUpdated(lastUpdatedDate);
         * note.setResolutionStatusId(n.getResolutionStatusId());
         * note.setResStatus(ResolutionStatus.get(n.getResolutionStatusId())); } } }
         */
    note.setNumChildren(note.getChildren().size());
    note.setDisType(DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId()));
    request.setAttribute(DIS_NOTE, note);
    forwardPage(Page.VIEW_SINGLE_NOTE);
}
Also used : Locale(java.util.Locale) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) 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) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DateFormat(java.text.DateFormat) Collection(java.util.Collection) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Example 88 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.

the class ImportHelper method validateDisplayItemBeanSingleCV.

/**
     * Peform validation on a item which has a RADIO or SINGLESELECTresponse
     * type. This function checks that the input isn't blank, and that its value
     * comes from the controlled vocabulary (ResponseSetBean) in the
     * DisplayItemBean.
     * 
     * @param v
     *            The Validator to add validations to.
     * @param dib
     *            The DisplayItemBean to validate.
     * @return The DisplayItemBean which is validated.
     */
public DisplayItemBean validateDisplayItemBeanSingleCV(DiscrepancyValidator v, DisplayItemBean dib, String inputName) {
    if (StringUtil.isBlank(inputName)) {
        inputName = getInputName(dib);
    }
    ItemFormMetadataBean ibMeta = dib.getMetadata();
    ItemDataBean idb = dib.getData();
    if (StringUtil.isBlank(idb.getValue())) {
        if (ibMeta.isRequired()) {
            v.addValidation(inputName, Validator.IS_REQUIRED);
        }
    } else {
    // commented out because it should be a hard edit check, tbh 05/2008
    // v.addValidation(inputName,
    // Validator.IN_RESPONSE_SET_SINGLE_VALUE,
    // dib.getMetadata().getResponseSet());
    }
    return dib;
}
Also used : ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 89 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.

the class ImportHelper method validateDisplayItemBeanText.

/**
     * Peform validation on a item which has a TEXT or TEXTAREA response type.
     * If the item has a null value, it's automatically validated. Otherwise,
     * it's checked against its data type.
     * 
     * @param v
     *            The Validator to add validations to.
     * @param dib
     *            The DisplayItemBean to validate.
     * @return The DisplayItemBean which is validated.
     */
public DisplayItemBean validateDisplayItemBeanText(DiscrepancyValidator discValidator, DisplayItemBean dib, String inputName) {
    if (StringUtil.isBlank(inputName)) {
        // for single items
        inputName = getInputName(dib);
    }
    ItemBean ib = dib.getItem();
    ItemFormMetadataBean ibMeta = dib.getMetadata();
    ItemDataType idt = ib.getDataType();
    ItemDataBean idb = dib.getData();
    boolean isNull = false;
    if (!isNull) {
        if (StringUtil.isBlank(idb.getValue())) {
            // check required first
            if (ibMeta.isRequired()) {
                discValidator.addValidation(inputName, Validator.IS_REQUIRED);
            }
        } else {
            if (idt.equals(ItemDataType.ST)) {
                // a string's size could be more than 255, which is more
                // than
                // the db field length
                discValidator.addValidation(inputName, Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 3999);
            } else if (idt.equals(ItemDataType.INTEGER)) {
            // hard edit check, will comment out for now, tbh 05/2008
            // v.addValidation(inputName, Validator.IS_AN_INTEGER);
            // v.alwaysExecuteLastValidation(inputName);
            } else if (idt.equals(ItemDataType.REAL)) {
            // hard edit check, will comment out for now, tbh 05/08
            // v.addValidation(inputName, Validator.IS_A_NUMBER);
            // v.alwaysExecuteLastValidation(inputName);
            } else if (idt.equals(ItemDataType.BL)) {
            // there is no validation here since this data type is
            // explicitly
            // allowed to be null
            // if the string input for this field parses to a non-zero
            // number, the
            // value will be true; otherwise, 0
            } else if (idt.equals(ItemDataType.BN)) {
            } else if (idt.equals(ItemDataType.SET)) {
                // v.addValidation(inputName, Validator.NO_BLANKS_SET);
                discValidator.addValidation(inputName, Validator.IN_RESPONSE_SET_SINGLE_VALUE, dib.getMetadata().getResponseSet());
            } else if (idt.equals(ItemDataType.DATE)) {
            // hard edit check, will comment out for now, tbh 05/08
            //v.addValidation(inputName, Validator.IS_A_DATE);
            // v.alwaysExecuteLastValidation(inputName);
            }
            String customValidationString = dib.getMetadata().getRegexp();
            if (!StringUtil.isBlank(customValidationString)) {
                Validation customValidation = null;
                if (customValidationString.startsWith("func:")) {
                    try {
                        customValidation = Validator.processCRFValidationFunction(customValidationString);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else if (customValidationString.startsWith("regexp:")) {
                    try {
                        customValidation = Validator.processCRFValidationRegex(customValidationString);
                    } catch (Exception e) {
                    }
                }
                if (customValidation != null) {
                    customValidation.setErrorMessage(dib.getMetadata().getRegexpErrorMsg());
                    discValidator.addValidation(inputName, customValidation);
                }
            }
        }
    }
    return dib;
}
Also used : Validation(org.akaza.openclinica.control.form.Validation) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDataType(org.akaza.openclinica.bean.core.ItemDataType) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ItemFormMetadataBean(org.akaza.openclinica.bean.submit.ItemFormMetadataBean)

Example 90 with ItemDataBean

use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.

the class CreateDiscrepancyNoteServlet method updateStudyEvent.

private void updateStudyEvent(String entityType, int entityId) {
    if ("itemData".equalsIgnoreCase(entityType)) {
        int itemDataId = entityId;
        ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
        ItemDataBean itemData = (ItemDataBean) iddao.findByPK(itemDataId);
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(itemData.getEventCRFId());
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
            event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
            event.setUpdater(ub);
            event.setUpdatedDate(new Date());
            svdao.update(event);
        }
    } else if ("eventCrf".equalsIgnoreCase(entityType)) {
        int eventCRFId = entityId;
        EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
        StudyEventDAO svdao = new StudyEventDAO(sm.getDataSource());
        EventCRFBean ec = (EventCRFBean) ecdao.findByPK(eventCRFId);
        StudyEventBean event = (StudyEventBean) svdao.findByPK(ec.getStudyEventId());
        if (event.getSubjectEventStatus().equals(SubjectEventStatus.SIGNED)) {
            event.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
            event.setUpdater(ub);
            event.setUpdatedDate(new Date());
            svdao.update(event);
        }
    }
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) Date(java.util.Date)

Aggregations

ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)133 ArrayList (java.util.ArrayList)74 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)64 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)61 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)42 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)41 HashMap (java.util.HashMap)39 Date (java.util.Date)37 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)37 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)33 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)33 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)26 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)26 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)26 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)26 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)21 ItemDAO (org.akaza.openclinica.dao.submit.ItemDAO)21 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)20 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)20 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)18