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