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;
}
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;
}
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;
}
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;
}
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);
}
Aggregations