use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method getCrfs.
@SuppressWarnings("unchecked")
private ArrayList<CRFBean> getCrfs(StudyEventDefinitionBean eventDefinition) {
if (this.crfBeans == null) {
crfBeans = new ArrayList<CRFBean>();
eventDefinitionCrfs = new ArrayList<EventDefinitionCRFBean>();
for (EventDefinitionCRFBean eventDefinitionCrf : (List<EventDefinitionCRFBean>) getEventDefintionCRFDAO().findAllActiveByEventDefinitionId(eventDefinition.getId())) {
CRFBean crfBean = (CRFBean) getCrfDAO().findByPK(eventDefinitionCrf.getCrfId());
ArrayList<CRFVersionBean> crfVersions = (ArrayList<CRFVersionBean>) getCrfVersionDAO().findAllByCRFId(eventDefinitionCrf.getCrfId());
crfBean.setVersions(crfVersions);
if (eventDefinitionCrf.getParentId() == 0) {
crfBeans.add(crfBean);
eventDefinitionCrfs.add(eventDefinitionCrf);
}
}
return crfBeans;
}
return crfBeans;
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class ListEventsForSubjectTableFactory method configureColumns.
@Override
protected void configureColumns(TableFacade tableFacade, Locale locale) {
resword = ResourceBundleProvider.getWordsBundle(locale);
resformat = ResourceBundleProvider.getFormatBundle(locale);
tableFacade.setColumnProperties(columnNames);
Row row = tableFacade.getTable().getRow();
int index = 0;
configureColumn(row.getColumn(columnNames[index]), resword.getString("study_subject_ID"), null, null);
++index;
configureColumn(row.getColumn(columnNames[index]), resword.getString("subject_status"), new StatusCellEditor(), new StatusDroplistFilterEditor());
++index;
configureColumn(row.getColumn(columnNames[index]), resword.getString("site_id"), null, null);
++index;
configureColumn(row.getColumn(columnNames[index]), resword.getString("gender"), null, null, true, false);
++index;
// group class columns
for (int i = index; i < index + studyGroupClasses.size(); i++) {
StudyGroupClassBean studyGroupClass = studyGroupClasses.get(i - index);
configureColumn(row.getColumn(columnNames[i]), studyGroupClass.getName(), new StudyGroupClassCellEditor(studyGroupClass), new SubjectGroupClassDroplistFilterEditor(studyGroupClass), true, false);
}
configureColumn(row.getColumn(columnNames[index + studyGroupClasses.size()]), resword.getString("event_status"), new EventStatusCellEditor(), new SubjectEventStatusDroplistFilterEditor(), true, false);
++index;
configureColumn(row.getColumn(columnNames[index + studyGroupClasses.size()]), resword.getString("event_date"), new EventStartDateCellEditor(), null);
++index;
// crf columns
for (int i = index + studyGroupClasses.size(); i < columnNames.length - 1; i++) {
CRFBean crfBean = crfBeans.get(i - (index + studyGroupClasses.size()));
configureColumn(row.getColumn(columnNames[i]), crfBean.getName(), new EventCrfCellEditor(), new SubjectEventCRFStatusDroplistFilterEditor(), true, false);
}
String actionsHeader = resword.getString("rule_actions") + "               ";
configureColumn(row.getColumn(columnNames[columnNames.length - 1]), actionsHeader, new ActionsCellEditor(), new DefaultActionsEditor(locale), true, false);
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class DefineStudyEventServlet method confirmDefinition2.
private void confirmDefinition2() throws Exception {
FormProcessor fp = new FormProcessor(request);
CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
ArrayList crfArray = new ArrayList();
Map tmpCRFIdMap = (HashMap) session.getAttribute("tmpCRFIdMap");
// trying to avoid NPE not sure why we would get it there ((tmpCRFIdMap.containsKey(id))), tbh
if (tmpCRFIdMap == null) {
tmpCRFIdMap = new HashMap();
}
ArrayList crfsWithVersion = (ArrayList) session.getAttribute("crfsWithVersion");
for (int i = 0; i < crfsWithVersion.size(); i++) {
int id = fp.getInt("id" + i);
String name = fp.getString("name" + i);
// String label = fp.getString("label" + i);
String selected = fp.getString("selected" + i);
// logger.info("selected:" + selected);
if (!StringUtils.isBlank(selected) && "yes".equalsIgnoreCase(selected.trim())) {
logger.debug("one crf selected");
CRFBean cb = new CRFBean();
cb.setId(id);
cb.setName(name);
// only find active verions
ArrayList versions = (ArrayList) vdao.findAllActiveByCRF(cb.getId());
cb.setVersions(versions);
crfArray.add(cb);
} else {
if (tmpCRFIdMap.containsKey(id)) {
tmpCRFIdMap.remove(id);
}
}
}
for (Iterator tmpCRFIterator = tmpCRFIdMap.keySet().iterator(); tmpCRFIterator.hasNext(); ) {
int id = (Integer) tmpCRFIterator.next();
String name = (String) tmpCRFIdMap.get(id);
boolean isExists = false;
for (Iterator it = crfArray.iterator(); it.hasNext(); ) {
CRFBean cb = (CRFBean) it.next();
if (id == cb.getId()) {
isExists = true;
}
}
if (!isExists) {
CRFBean cb = new CRFBean();
cb.setId(id);
cb.setName(name);
// only find active verions
ArrayList versions = (ArrayList) vdao.findAllActiveByCRF(cb.getId());
cb.setVersions(versions);
crfArray.add(cb);
}
}
session.removeAttribute("tmpCRFIdMap");
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
if (crfArray.size() == 0) {
// no crf seleted
// addPageMessage("At least one CRF must be selected.");
// request.setAttribute("crfs", crfs);
addPageMessage(respage.getString("no_CRF_selected_for_definition_add_later"));
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
sed.setCrfs(new ArrayList());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
session.setAttribute("definition", sed);
request.setAttribute("eventDefinitionCRFs", new ArrayList());
// not used on page
session.setAttribute("edCRFs", new ArrayList());
forwardPage(Page.DEFINE_STUDY_EVENT_CONFIRM);
// forwardPage(Page.DEFINE_STUDY_EVENT2);
} else {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
// crfs selected by user
sed.setCrfs(crfArray);
session.setAttribute("eventDefinitionCRFs", new ArrayList());
session.setAttribute("definition", sed);
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
ArrayList<String> sdvOptions = new ArrayList<String>();
sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
request.setAttribute("sdvOptions", sdvOptions);
forwardPage(Page.DEFINE_STUDY_EVENT3);
}
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class DefineStudyEventServlet method submitDefinition.
/**
* Inserts the new study into database NullPointer catch added by tbh
* 092007, mean to fix task #1642 in Mantis
*/
private void submitDefinition() throws NullPointerException {
StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
// added tbh 092007, to catch bug # 1531
if (sed.getName() == "" || sed.getName() == null) {
throw new NullPointerException();
}
logger.debug("Definition bean to be created:" + sed.getName() + sed.getStudyId());
// fine the last one's ordinal
ArrayList defs = edao.findAllByStudy(currentStudy);
if (defs == null || defs.isEmpty()) {
sed.setOrdinal(1);
} else {
int lastCount = defs.size() - 1;
StudyEventDefinitionBean last = (StudyEventDefinitionBean) defs.get(lastCount);
sed.setOrdinal(last.getOrdinal() + 1);
}
sed.setOwner(ub);
sed.setCreatedDate(new Date());
sed.setStatus(Status.AVAILABLE);
StudyEventDefinitionBean sed1 = (StudyEventDefinitionBean) edao.create(sed);
EventDefinitionCRFDAO cdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = new ArrayList();
if (session.getAttribute("edCRFs") != null) {
eventDefinitionCRFs = (ArrayList) session.getAttribute("edCRFs");
}
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
edc.setOwner(ub);
edc.setCreatedDate(new Date());
edc.setStatus(Status.AVAILABLE);
edc.setStudyEventDefinitionId(sed1.getId());
edc.setOrdinal(i + 1);
StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao.findByPK(sed.getId());
CRFBean cBean = (CRFBean) crfdao.findByPK(edc.getCrfId());
String crfPath = sedBean.getOid() + "." + cBean.getOid();
getEventDefinitionCrfTagService().saveEventDefnCrfOfflineTag(2, crfPath, edc, sedBean);
cdao.create(edc);
}
session.removeAttribute("definition");
session.removeAttribute("edCRFs");
session.removeAttribute("crfsWithVersion");
addPageMessage(respage.getString("the_new_event_definition_created_succesfully"));
}
use of org.akaza.openclinica.bean.admin.CRFBean in project OpenClinica by OpenClinica.
the class InitUpdateEventDefinitionServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO sdao = new StudyEventDefinitionDAO(sm.getDataSource());
String idString = request.getParameter("id");
logger.info("definition id: " + idString);
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_definition_to_edit"));
forwardPage(Page.LIST_DEFINITION_SERVLET);
} else {
// definition id
int defId = Integer.valueOf(idString.trim()).intValue();
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) sdao.findByPK(defId);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
if (currentStudy.getId() != sed.getStudyId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
EventDefinitionCRFDAO edao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList eventDefinitionCRFs = (ArrayList) edao.findAllParentsByDefinition(defId);
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList newEventDefinitionCRFs = new ArrayList();
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
ArrayList versions = (ArrayList) cvdao.findAllActiveByCRF(edc.getCrfId());
edc.setVersions(versions);
CRFBean crf = (CRFBean) cdao.findByPK(edc.getCrfId());
edc.setCrfName(crf.getName());
edc.setCrf(crf);
edc.setParticipantForm(edc.isParticipantForm());
// TO DO: use a better way on JSP page,eg.function tag
edc.setNullFlags(processNullValues(edc));
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(edc.getDefaultVersionId());
edc.setDefaultVersionName(defaultVersion.getName());
String crfPath = sed.getOid() + "." + edc.getCrf().getOid();
edc.setOffline(getEventDefinitionCrfTagService().getEventDefnCrfOfflineStatus(2, crfPath, true));
newEventDefinitionCRFs.add(edc);
}
session.setAttribute("definition", sed);
session.setAttribute("eventDefinitionCRFs", newEventDefinitionCRFs);
// changed above to new list because static, in-place updating is
// updating all EDCs, tbh 102007
ArrayList<String> sdvOptions = new ArrayList<String>();
sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
request.setAttribute("sdvOptions", sdvOptions);
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
}
}
Aggregations