Search in sources :

Example 71 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CRFDAO method buildCrfById.

/**
 * @param studySubjectId
 * @return
 */
public Map<Integer, CRFBean> buildCrfById(Integer studySubjectId) {
    // <== Must be called first
    this.setTypesExpected();
    Map<Integer, CRFBean> result = new HashMap<Integer, CRFBean>();
    HashMap<Integer, Object> param = new HashMap<Integer, Object>();
    int i = 1;
    param.put(i++, studySubjectId);
    List selectResult = select(digester.getQuery("buildCrfById"), param);
    Iterator it = selectResult.iterator();
    while (it.hasNext()) {
        CRFBean bean = (CRFBean) this.getEntityFromHashMap((HashMap) it.next());
        result.put(bean.getId(), bean);
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 72 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CRFDAO method getEntityFromHashMap.

public Object getEntityFromHashMap(HashMap hm) {
    CRFBean eb = new CRFBean();
    this.setEntityAuditInformation(eb, hm);
    eb.setId(((Integer) hm.get("crf_id")).intValue());
    eb.setName((String) hm.get("name"));
    eb.setDescription((String) hm.get("description"));
    eb.setOid((String) hm.get("oc_oid"));
    eb.setStudyId(((Integer) hm.get("source_study_id")).intValue());
    return eb;
}
Also used : CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 73 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CRFDAO method findByPK.

public EntityBean findByPK(int ID) {
    CRFBean eb = new CRFBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(ID));
    // String sql = digester.getQuery("findByPK");
    // logger.warn("found findbypk query: "+sql);
    ArrayList alist = this.select(digester.getQuery("findByPK"), variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (CRFBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 74 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CRFDAO method findAnotherByName.

public EntityBean findAnotherByName(String name, int crfId) {
    CRFBean eb = new CRFBean();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), name);
    variables.put(Integer.valueOf(2), Integer.valueOf(crfId));
    String sql = digester.getQuery("findAnotherByName");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        eb = (CRFBean) this.getEntityFromHashMap((HashMap) it.next());
    }
    return eb;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 75 with CRFBean

use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.

the class CreateCRFServlet method processRequest.

@Override
public void processRequest() throws Exception {
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    String action = request.getParameter("action");
    FormProcessor fp = new FormProcessor(request);
    // checks which module the requests are from
    String module = fp.getString(MODULE);
    request.setAttribute(MODULE, module);
    request.setAttribute("xformEnabled", CoreResources.getField("xform.enabled"));
    // add the list here so that users can tell about crf creation
    // process together with workflow, tbh
    resetPanel();
    panel.setStudyInfoShown(false);
    panel.setOrderedData(true);
    setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
    setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
    setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
    setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
    setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
    if (StringUtil.isBlank(action)) {
        session.setAttribute("crf", new CRFBean());
        forwardPage(Page.CREATE_CRF);
    } else {
        if ("confirm".equalsIgnoreCase(action)) {
            Validator v = new Validator(request);
            v.addValidation("name", Validator.NO_BLANKS);
            String name = fp.getString("name");
            String description = fp.getString("description");
            CRFBean crf = new CRFBean();
            crf.setName(name.trim());
            crf.setDescription(description.trim());
            session.setAttribute("crf", crf);
            errors = v.validate();
            if (fp.getString("name").trim().length() > 255) {
                Validator.addError(errors, "name", resexception.getString("maximum_length_name_255"));
            }
            if (fp.getString("description").trim().length() > 2048) {
                Validator.addError(errors, "description", resexception.getString("maximum_length_description_255"));
            }
            if (!errors.isEmpty()) {
                logger.info("has validation errors in the first section");
                request.setAttribute("formMessages", errors);
                forwardPage(Page.CREATE_CRF);
            } else {
                CRFBean crf1 = (CRFBean) cdao.findByName(name.trim());
                if (crf1.getId() > 0) {
                    Validator.addError(errors, "name", resexception.getString("CRF_name_used_choose_unique_name"));
                    request.setAttribute("formMessages", errors);
                    forwardPage(Page.CREATE_CRF);
                } else {
                    crf = (CRFBean) session.getAttribute("crf");
                    logger.info("The crf to be saved:" + crf.getName());
                    crf.setOwner(ub);
                    crf.setCreatedDate(new Date());
                    crf.setStatus(Status.AVAILABLE);
                    crf.setStudyId(currentStudy.getId());
                    cdao.create(crf);
                    crf = (CRFBean) cdao.findByName(crf.getName());
                    CRFVersionBean version = new CRFVersionBean();
                    version.setCrfId(crf.getId());
                    session.setAttribute("version", version);
                    session.setAttribute("crfName", crf.getName());
                    session.removeAttribute("crf");
                    forwardPage(Page.CREATE_CRF_VERSION);
                }
            }
        }
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) Validator(org.akaza.openclinica.control.form.Validator) Date(java.util.Date) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Aggregations

CRFBean (org.akaza.openclinica.bean.admin.CRFBean)138 ArrayList (java.util.ArrayList)95 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)78 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)78 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)70 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)67 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)63 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)56 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)44 HashMap (java.util.HashMap)43 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)43 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)40 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)37 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)29 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)27 Iterator (java.util.Iterator)26 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)26 DisplayEventCRFBean (org.akaza.openclinica.bean.submit.DisplayEventCRFBean)22 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)21 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)20