Search in sources :

Example 11 with EventDefinitionCRFBean

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

the class DefineStudyEventServlet method validateSubmissionUrl.

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

Example 12 with EventDefinitionCRFBean

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

the class DefineStudyEventServlet method submitDefinition.

/**
 * Inserts the new study into database NullPointer catch added by tbh
 * 092007, mean to fix task #1642 in Mantis
 */
private void submitDefinition() throws NullPointerException {
    StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    // added tbh 092007, to catch bug # 1531
    if (sed.getName() == "" || sed.getName() == null) {
        throw new NullPointerException();
    }
    logger.debug("Definition bean to be created:" + sed.getName() + sed.getStudyId());
    // fine the last one's ordinal
    ArrayList defs = edao.findAllByStudy(currentStudy);
    if (defs == null || defs.isEmpty()) {
        sed.setOrdinal(1);
    } else {
        int lastCount = defs.size() - 1;
        StudyEventDefinitionBean last = (StudyEventDefinitionBean) defs.get(lastCount);
        sed.setOrdinal(last.getOrdinal() + 1);
    }
    sed.setOwner(ub);
    sed.setCreatedDate(new Date());
    sed.setStatus(Status.AVAILABLE);
    StudyEventDefinitionBean sed1 = (StudyEventDefinitionBean) edao.create(sed);
    EventDefinitionCRFDAO cdao = new EventDefinitionCRFDAO(sm.getDataSource());
    CRFDAO crfdao = new CRFDAO(sm.getDataSource());
    StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
    ArrayList eventDefinitionCRFs = new ArrayList();
    if (session.getAttribute("edCRFs") != null) {
        eventDefinitionCRFs = (ArrayList) session.getAttribute("edCRFs");
    }
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        edc.setOwner(ub);
        edc.setCreatedDate(new Date());
        edc.setStatus(Status.AVAILABLE);
        edc.setStudyEventDefinitionId(sed1.getId());
        edc.setOrdinal(i + 1);
        StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao.findByPK(sed.getId());
        CRFBean cBean = (CRFBean) crfdao.findByPK(edc.getCrfId());
        String crfPath = sedBean.getOid() + "." + cBean.getOid();
        getEventDefinitionCrfTagService().saveEventDefnCrfOfflineTag(2, crfPath, edc, sedBean);
        cdao.create(edc);
    }
    session.removeAttribute("definition");
    session.removeAttribute("edCRFs");
    session.removeAttribute("crfsWithVersion");
    addPageMessage(respage.getString("the_new_event_definition_created_succesfully"));
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) Date(java.util.Date) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 13 with EventDefinitionCRFBean

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

the class InitUpdateEventDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
    String idString = request.getParameter("id");
    logger.info("definition id: " + idString);
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_definition_to_edit"));
        forwardPage(Page.LIST_DEFINITION_SERVLET);
    } else {
        // definition id
        int defId = Integer.valueOf(idString.trim()).intValue();
        StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        if (currentStudy.getId() != sed.getStudyId()) {
            addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
            forwardPage(Page.MENU_SERVLET);
            return;
        }
        EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
        ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllParentsByDefinition(defId);
        CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
        CRFDAO cdao = new CRFDAO(sm.getDataSource());
        ArrayList newEventDefinitionCRFs = new ArrayList();
        for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
            EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
            ArrayList versions = (ArrayList) cvdao.findAllActiveByCRF(edc.getCrfId());
            edc.setVersions(versions);
            CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
            edc.setCrfName(crf.getName());
            edc.setCrf(crf);
            edc.setParticipantForm(edc.isParticipantForm());
            // TO DO: use a better way on JSP page,eg.function tag
            edc.setNullFlags(processNullValues(edc));
            CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
            edc.setDefaultVersionName(defaultVersion.getName());
            String crfPath = sed.getOid() + "." + edc.getCrf().getOid();
            edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
            newEventDefinitionCRFs.add(edc);
        }
        session.setAttribute("definition", sed);
        session.setAttribute("eventDefinitionCRFs", newEventDefinitionCRFs);
        // changed above to new list because static, in-place updating is
        // updating all EDCs, tbh 102007
        ArrayList<String> sdvOptions = new ArrayList<String>();
        sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
        sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
        request.setAttribute("sdvOptions", sdvOptions);
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    }
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) 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)

Example 14 with EventDefinitionCRFBean

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

the class InitUpdateSubStudyServlet method createEventDefinitions.

private void createEventDefinitions(StudyBean parentStudy) throws MalformedURLException {
    FormProcessor fp = new FormProcessor(request);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    int siteId = Integer.valueOf(request.getParameter("id").trim());
    ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
    StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    seds = sedDao.findAllByStudy(parentStudy);
    int start = 0;
    for (StudyEventDefinitionBean sed : seds) {
        String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
        if (participateFormStatus.equals("enabled"))
            baseUrl();
        request.setAttribute("participateFormStatus", participateFormStatus);
        int defId = sed.getId();
        ArrayList<EventDefinitionCRFBean> edcs = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllByDefinitionAndSiteIdAndParentStudyId(defId, siteId, parentStudy.getId());
        ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
        // sed.setCrfNum(edcs.size());
        for (EventDefinitionCRFBean edcBean : edcs) {
            CRFBean cBean = (CRFBean) cdao.findByPK(edcBean.getCrfId());
            String crfPath = sed.getOid() + "." + cBean.getOid();
            edcBean.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
            int edcStatusId = edcBean.getStatus().getId();
            CRFBean crf = (CRFBean) cdao.findByPK(edcBean.getCrfId());
            int crfStatusId = crf.getStatusId();
            if (edcStatusId == 5 || edcStatusId == 7 || crfStatusId == 5 || crfStatusId == 7) {
            } else {
                ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) cvdao.findAllActiveByCRF(edcBean.getCrfId());
                edcBean.setVersions(versions);
                edcBean.setCrfName(crf.getName());
                if (edcBean.getParentId() == 0)
                    edcBean.setSubmissionUrl("");
                CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edcBean.getDefaultVersionId());
                edcBean.setDefaultVersionName(defaultVersion.getName());
                String sversionIds = edcBean.getSelectedVersionIds();
                ArrayList<Integer> idList = new ArrayList<Integer>();
                if (sversionIds.length() > 0) {
                    String[] ids = sversionIds.split("\\,");
                    for (String id : ids) {
                        idList.add(Integer.valueOf(id));
                    }
                }
                edcBean.setSelectedVersionIdList(idList);
                defCrfs.add(edcBean);
                ++start;
            }
        }
        logger.debug("definitionCrfs size=" + defCrfs.size() + " total size=" + edcs.size());
        sed.setCrfs(defCrfs);
        sed.setCrfNum(defCrfs.size());
    }
    // not sure if request is better, since not sure if there is another
    // process using this.
    session.setAttribute("definitions", seds);
    session.setAttribute("sdvOptions", this.setSDVOptions());
}
Also used : EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) 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)

Example 15 with EventDefinitionCRFBean

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

the class ChangeDefinitionCRFOrdinalServlet method increase.

/**
 * Increases the ordinal for current object and decrease the ordinal of the
 * previous one
 *
 * @param idCurrent
 * @param idPrevious
 * @param dao
 */
private void increase(int idCurrent, int idPrevious, int currOrdinal, int prevOrdinal, int defId, EventDefinitionCRFDAO dao) {
    EventDefinitionCRFBean current = (EventDefinitionCRFBean) dao.findByPK(idCurrent);
    EventDefinitionCRFBean previous = (EventDefinitionCRFBean) dao.findByPK(idPrevious);
    if (current.getOrdinal() == currOrdinal && previous.getOrdinal() == prevOrdinal) {
        if (idCurrent > 0) {
            int currentOrdinal = current.getOrdinal();
            current.setOrdinal(currentOrdinal - 1);
            current.setUpdater((UserAccountBean) session.getAttribute("userBean"));
            dao.update(current);
        }
        if (idPrevious > 0) {
            int previousOrdinal = previous.getOrdinal();
            previous.setOrdinal(previousOrdinal + 1);
            previous.setUpdater((UserAccountBean) session.getAttribute("userBean"));
            dao.update(previous);
        }
        ArrayList currOrdlist = dao.findAllByEventDefinitionIdAndOrdinal(defId, current.getOrdinal());
        ArrayList prevOrdlist = dao.findAllByEventDefinitionIdAndOrdinal(defId, previous.getOrdinal());
        if (currOrdlist.size() > 1 || prevOrdlist.size() > 1) {
            fixDuplicates(defId, dao);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

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