Search in sources :

Example 71 with EventDefinitionCRFBean

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

the class RestoreCRFFromDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    String crfName = "";
    String idString = request.getParameter("id");
    logger.info("crf id:" + idString);
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
    request.setAttribute("participateFormStatus", participateFormStatus);
    if (StringUtil.isBlank(idString)) {
        addPageMessage(respage.getString("please_choose_a_CRF_to_restore"));
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    } else {
        // event crf definition id
        int id = Integer.valueOf(idString.trim()).intValue();
        for (int i = 0; i < edcs.size(); i++) {
            EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
            if (edc.getCrfId() == id) {
                edc.setStatus(Status.AVAILABLE);
                edc.setOldStatus(Status.DELETED);
                crfName = edc.getCrfName();
            }
        }
        session.setAttribute("eventDefinitionCRFs", edcs);
        addPageMessage(crfName + " " + respage.getString("has_been_restored"));
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    }
}
Also used : ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 72 with EventDefinitionCRFBean

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

the class RestoreStudyEventServlet method getDisplayEventCRFs.

/**
 * Each of the event CRFs with its corresponding CRFBean. Then generates a
 * list of DisplayEventCRFBeans, one for each event CRF.
 *
 * @param eventCRFs
 *            The list of event CRFs for this study event.
 * @param eventDefinitionCRFs
 *            The list of event definition CRFs for this study event.
 * @return The list of DisplayEventCRFBeans for this study event.
 */
private ArrayList getDisplayEventCRFs(ArrayList eventCRFs, ArrayList eventDefinitionCRFs) {
    ArrayList answer = new ArrayList();
    HashMap definitionsById = new HashMap();
    int i;
    for (i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        definitionsById.put(new Integer(edc.getStudyEventDefinitionId()), edc);
    }
    StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
    for (i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
        // populate the event CRF with its crf bean
        int crfVersionId = ecb.getCRFVersionId();
        CRFBean cb = cdao.findByVersionId(crfVersionId);
        ecb.setCrf(cb);
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(crfVersionId);
        ecb.setCrfVersion(cvb);
        // then get the definition so we can call
        // DisplayEventCRFBean.setFlags
        int studyEventId = ecb.getStudyEventId();
        int studyEventDefinitionId = sedao.getDefinitionIdFromStudyEventId(studyEventId);
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) definitionsById.get(new Integer(studyEventDefinitionId));
        DisplayEventCRFBean dec = new DisplayEventCRFBean();
        dec.setFlags(ecb, ub, currentRole, edc.isDoubleEntry());
        answer.add(dec);
    }
    return answer;
}
Also used : DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) StudyEventDAO(org.akaza.openclinica.dao.managestudy.StudyEventDAO) ArrayList(java.util.ArrayList) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) DisplayEventCRFBean(org.akaza.openclinica.bean.submit.DisplayEventCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 73 with EventDefinitionCRFBean

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

the class EnterDataForStudyEventServlet method getDisplayEventCRFs.

/**
     * Generate a list of DisplayEventCRFBean objects for a study event. Some of
     * the DisplayEventCRFBeans will represent uncompleted Event CRFs; others
     * will represent Event CRFs which are in initial data entry, have completed
     * initial data entry, are in double data entry, or have completed double
     * data entry.
     *
     * The list is sorted using the DisplayEventCRFBean's compareTo method (that
     * is, using the event definition crf bean's ordinal value.) Also, the
     * setFlags method of each DisplayEventCRFBean object will have been called
     * once.
     *
     * @param studyEvent
     *            The study event for which we want the Event CRFs.
     * @param ecdao
     *            An EventCRFDAO from which to grab the study event's Event
     *            CRFs.
     * @param edcdao
     *            An EventDefinitionCRFDAO from which to grab the Event CRF
     *            Definitions which apply to the study event.
     * @return A list of DisplayEventCRFBean objects releated to the study
     *         event, ordered by the EventDefinitionCRF ordinal property, and
     *         with flags already set.
     */
public static ArrayList getDisplayEventCRFs(StudyEventBean studyEvent, EventCRFDAO ecdao, EventDefinitionCRFDAO edcdao, FormLayoutDAO fldao, UserAccountBean user, StudyUserRoleBean surb) {
    ArrayList answer = new ArrayList();
    HashMap indexByCRFId = new HashMap();
    ArrayList eventCRFs = ecdao.findAllByStudyEvent(studyEvent);
    ArrayList eventDefinitionCRFs = edcdao.findAllByEventDefinitionId(studyEvent.getStudyEventDefinitionId());
    // TODO: map this out to another function
    ArrayList crfVersions = (ArrayList) fldao.findAll();
    HashMap crfIdByCRFVersionId = new HashMap();
    for (int i = 0; i < crfVersions.size(); i++) {
        FormLayoutBean cvb = (FormLayoutBean) crfVersions.get(i);
        crfIdByCRFVersionId.put(new Integer(cvb.getId()), new Integer(cvb.getCrfId()));
    }
    // put the event definition crfs inside DisplayEventCRFs
    for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
        EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
        DisplayEventCRFBean decb = new DisplayEventCRFBean();
        decb.setEventDefinitionCRF(edcb);
        answer.add(decb);
        indexByCRFId.put(new Integer(edcb.getCrfId()), new Integer(answer.size() - 1));
    }
    // attach EventCRFs to the DisplayEventCRFs
    for (int i = 0; i < eventCRFs.size(); i++) {
        EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
        Integer crfVersionId = new Integer(ecb.getFormLayoutId());
        if (crfIdByCRFVersionId.containsKey(crfVersionId)) {
            Integer crfId = (Integer) crfIdByCRFVersionId.get(crfVersionId);
            if (crfId != null && indexByCRFId.containsKey(crfId)) {
                Integer indexObj = (Integer) indexByCRFId.get(crfId);
                if (indexObj != null) {
                    int index = indexObj.intValue();
                    if (index > 0 && index < answer.size()) {
                        DisplayEventCRFBean decb = (DisplayEventCRFBean) answer.get(index);
                        decb.setEventCRF(ecb);
                        answer.set(index, decb);
                    }
                }
            }
        }
    }
    for (int i = 0; i < answer.size(); i++) {
        DisplayEventCRFBean decb = (DisplayEventCRFBean) answer.get(i);
        decb.setFlags(decb.getEventCRF(), user, surb, decb.getEventDefinitionCRF().isDoubleEntry());
        answer.set(i, decb);
    }
    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) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) DisplayEventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.DisplayEventDefinitionCRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 74 with EventDefinitionCRFBean

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

the class EventDefinitionCrfTagDAO method findByPK.

@Override
public EntityBean findByPK(int ID) {
    EventDefinitionCRFBean eb = new EventDefinitionCRFBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(new Integer(1), new Integer(ID));
    String sql = digester.getQuery("findByPK");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (EventDefinitionCRFBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 75 with EventDefinitionCRFBean

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

the class OdmExtractDAO method getEventDefCRF.

private EventDefinitionCRFBean getEventDefCRF(StudyEventDefBean studyEventDefBean, ElementRefBean formRef, int studyId) {
    StudyBean studyBean = (StudyBean) sdao.findByPK(studyId);
    StudyEventDefinitionBean sedBean = seddao.findByOid(studyEventDefBean.getOid());
    CRFBean crfBean = crfdao.findByOid(formRef.getElementDefOID());
    return edcdao.findByStudyEventDefinitionIdAndCRFId(studyBean, sedBean.getId(), crfBean.getId());
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

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