Search in sources :

Example 36 with CRFBean

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

the class CRFDAO method findByVersionId.

public CRFBean findByVersionId(int crfVersionId) {
    CRFBean answer = new CRFBean();
    this.unsetTypeExpected();
    this.setTypesExpected();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(crfVersionId));
    String sql = digester.getQuery("findByVersionId");
    ArrayList rows = select(sql, variables);
    if (rows.size() > 0) {
        HashMap row = (HashMap) rows.get(0);
        answer = (CRFBean) getEntityFromHashMap(row);
    }
    return answer;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 37 with CRFBean

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

the class CRFDAO method update.

public EntityBean update(EntityBean eb) {
    CRFBean cb = (CRFBean) eb;
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(cb.getStatus().getId()));
    // variables.put(Integer.valueOf(2), cb.getLabel());
    variables.put(Integer.valueOf(2), cb.getName());
    variables.put(Integer.valueOf(3), cb.getDescription());
    variables.put(Integer.valueOf(4), Integer.valueOf(cb.getUpdater().getId()));
    variables.put(Integer.valueOf(5), Integer.valueOf(cb.getId()));
    this.execute(digester.getQuery("update"), variables);
    return eb;
}
Also used : HashMap(java.util.HashMap) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 38 with CRFBean

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

the class CRFDAO method create.

public EntityBean create(EntityBean eb) {
    CRFBean cb = (CRFBean) eb;
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(cb.getStatus().getId()));
    // variables.put(Integer.valueOf(2), cb.getLabel());
    variables.put(Integer.valueOf(2), cb.getName());
    variables.put(Integer.valueOf(3), cb.getDescription());
    variables.put(Integer.valueOf(4), Integer.valueOf(cb.getOwner().getId()));
    variables.put(Integer.valueOf(5), getValidOid(cb, cb.getName()));
    variables.put(Integer.valueOf(6), cb.getStudyId());
    // am i the only one who runs their daos' unit tests after I change
    // things, tbh?
    this.execute(digester.getQuery("create"), variables);
    if (isQuerySuccessful()) {
        cb.setActive(true);
    }
    return cb;
}
Also used : HashMap(java.util.HashMap) CRFBean(org.akaza.openclinica.bean.admin.CRFBean)

Example 39 with CRFBean

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

the class StudyEventDAO method findCRFsByStudyEvent.

public HashMap findCRFsByStudyEvent(StudyEventBean seb) {
    // Soon-to-be-depreciated, replaced by find crfs by study, tbh 11-26
    // returns a hashmap of crfs + arraylist of crfversions,
    // for creating a checkbox list of crf versions all collected by
    // the study event primary key, tbh
    HashMap crfs = new HashMap();
    this.setCRFTypesExpected();
    HashMap variables = new HashMap();
    variables.put(Integer.valueOf(1), Integer.valueOf(seb.getStudyEventDefinitionId()));
    ArrayList alist = this.select(digester.getQuery("findCRFsByStudyEvent"), variables);
    Iterator it = alist.iterator();
    CRFDAO cdao = new CRFDAO(this.ds);
    CRFVersionDAO cvdao = new CRFVersionDAO(this.ds);
    while (it.hasNext()) {
        HashMap answers = (HashMap) it.next();
        logger.warn("***First CRF ID: " + answers.get("crf_id"));
        logger.warn("***Next CRFVersion ID: " + answers.get("crf_version_id"));
        // here's the logic:
        // grab a crf,
        // iterate through crfs in hashmap,
        // if one matches, grab it;
        // take a look at its arraylist of versions;
        // if there is no version correlating, add it;
        // else, add the crf with a fresh arraylist + one version.
        // how long could this take to run???
        CRFBean cbean = (CRFBean) cdao.findByPK(((Integer) answers.get("crf_id")).intValue());
        CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(((Integer) answers.get("crf_version_id")).intValue());
        Set se = crfs.entrySet();
        boolean found = false;
        boolean versionFound = false;
        for (Iterator itse = se.iterator(); itse.hasNext(); ) {
            Map.Entry me = (Map.Entry) itse.next();
            CRFBean checkCrf = (CRFBean) me.getKey();
            if (checkCrf.getId() == cbean.getId()) {
                found = true;
                ArrayList oldList = (ArrayList) me.getValue();
                Iterator itself = oldList.iterator();
                while (itself.hasNext()) {
                    CRFVersionBean cvbCheck = (CRFVersionBean) itself.next();
                    if (cvbCheck.getId() == cvb.getId()) {
                        versionFound = true;
                    }
                }
                // end of iteration through versions
                if (!versionFound) {
                    oldList.add(cvb);
                    crfs.put(cbean, oldList);
                }
            // end of adding new version to old crf
            }
        // end of check to see if current crf is in list
        }
        // end of iterating
        if (!found) {
            // add new crf here with version
            // CRFVersionBean cvb = (CRFVersionBean)cvdao.findByPK(
            // ((Integer)answers.get("crf_version_id")).intValue());
            ArrayList newList = new ArrayList();
            newList.add(cvb);
            crfs.put(cbean, newList);
        }
    }
    return crfs;
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) Set(java.util.Set) CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) Iterator(java.util.Iterator) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with CRFBean

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

the class RuleSetService method getRuleSetsByCrfStudyAndStudyEventDefinition.

/*
     * (non-Javadoc)
     * @see
     * org.akaza.openclinica.service.rule.RuleSetServiceInterface#getRuleSetsByCrfStudyAndStudyEventDefinition(org.akaza.openclinica.bean.managestudy.StudyBean,
     * org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean, org.akaza.openclinica.bean.submit.CRFVersionBean)
     */
public List<RuleSetBean> getRuleSetsByCrfStudyAndStudyEventDefinition(StudyBean study, StudyEventDefinitionBean sed, CRFVersionBean crfVersion) {
    CRFBean crf = getCrfDao().findByVersionId(crfVersion.getId());
    logger.debug("crfVersionID : " + crfVersion.getId() + " studyId : " + study.getId() + " studyEventDefinition : " + sed.getId());
    List<RuleSetBean> ruleSets = getRuleSetDao().findByCrfVersionOrCrfAndStudyAndStudyEventDefinition(crfVersion, crf, study, sed);
    logger.info("getRuleSetsByCrfStudyAndStudyEventDefinition() : ruleSets Size {} : ", ruleSets.size());
    if (ruleSets != null && ruleSets.size() > 0) {
        for (RuleSetBean ruleSetBean : ruleSets) {
            getObjects(ruleSetBean);
        }
    } else {
        ruleSets = new ArrayList<RuleSetBean>();
    }
    return ruleSets;
// return eagerFetchRuleSet(ruleSets);
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) 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