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