use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.
the class PrintCRFServlet method processRequest.
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
FormProcessor fp = new FormProcessor(request);
// The PrintDataEntry servlet handles this parameter
int eventCRFId = fp.getInt("ecId");
//JN:The following were the the global variables, moved as local.
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
// Whether IE6 or IE7 is involved
String isIE = fp.getString("ie");
if ("y".equalsIgnoreCase(isIE)) {
request.setAttribute("isInternetExplorer", "true");
}
int eventDefinitionCRFId = fp.getInt("eventDefinitionCRFId");
// EventDefinitionCRFDao findByStudyEventIdAndCRFVersionId(int
// studyEventId, int crfVersionId)
SectionDAO sdao = new SectionDAO(getDataSource());
CRFVersionDAO crfVersionDAO = new CRFVersionDAO(getDataSource());
CRFDAO crfDao = new CRFDAO(getDataSource());
ArrayList<SectionBean> allSectionBeans = new ArrayList<SectionBean>();
ArrayList sectionBeans = new ArrayList();
// The existing application doesn't print null values, even if they are
// defined in the event definition
int crfVersionId = fp.getInt("id", true);
boolean isSubmitted = false;
if (crfVersionId == 0) {
addPageMessage(respage.getString("please_choose_a_crf_to_view_details"), request);
forwardPage(Page.CRF_LIST_SERVLET, request, response);
} else {
// BWP 2/7/2008>> Find out if the CRF has grouped tables, and if so,
// use
// that dedicated JSP
ItemGroupDAO itemGroupDao = new ItemGroupDAO(getDataSource());
// Find truely grouped tables, not groups with a name of 'Ungrouped'
List<ItemGroupBean> itemGroupBeans = itemGroupDao.findOnlyGroupsByCRFVersionID(crfVersionId);
if (itemGroupBeans.size() > 0) {
// get a DisplaySectionBean for each section of the CRF, sort
// them, then
// dispatch the request to a print JSP. The constructor for this
// handler takes
// a boolean value depending on whether data is involved or not
// ('false' in terms of this
// servlet; see PrintDataEntryServlet).
DisplaySectionBeanHandler handler = new DisplaySectionBeanHandler(false, getDataSource(), getServletContext());
handler.setCrfVersionId(crfVersionId);
handler.setEventCRFId(eventCRFId);
List<DisplaySectionBean> displaySectionBeans = handler.getDisplaySectionBeans();
request.setAttribute("listOfDisplaySectionBeans", displaySectionBeans);
// Make available the CRF names and versions for
// the web page's header
CRFVersionBean crfverBean = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionId);
request.setAttribute("crfVersionBean", crfverBean);
CRFBean crfBean = crfDao.findByVersionId(crfVersionId);
request.setAttribute("crfBean", crfBean);
// Set an attribute signaling that data is not involved
request.setAttribute("dataInvolved", "false");
// request.setAttribute("displaySection",displaySection);
forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PRINT_GROUPS, request, response);
// IllegalStateException
return;
}
//JN:Revisit ME
ecb = new EventCRFBean();
ecb.setCRFVersionId(crfVersionId);
CRFVersionBean version = (CRFVersionBean) crfVersionDAO.findByPK(crfVersionId);
ArrayList sects = (ArrayList) sdao.findByVersionId(version.getId());
for (int i = 0; i < sects.size(); i++) {
sb = (SectionBean) sects.get(i);
// super.sb = sb;
int sectId = sb.getId();
if (sectId > 0) {
allSectionBeans.add((SectionBean) sdao.findByPK(sectId));
}
}
request.setAttribute(ALL_SECTION_BEANS, allSectionBeans);
request.setAttribute(INPUT_EVENT_CRF, ecb);
sectionBeans = super.getAllDisplayBeans(request);
}
request.setAttribute(INPUT_EVENT_CRF, ecb);
request.setAttribute(SECTION_BEAN, sb);
DisplaySectionBean dsb = super.getDisplayBean(false, false, request, isSubmitted);
request.setAttribute("allSections", sectionBeans);
request.setAttribute("displayAllCRF", "1");
request.setAttribute(BEAN_DISPLAY, dsb);
request.setAttribute(BEAN_ANNOTATIONS, ecb.getAnnotations());
request.setAttribute("sec", sb);
request.setAttribute("EventCRFBean", ecb);
forwardPage(Page.VIEW_SECTION_DATA_ENTRY_PRINT, request, response);
}
use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method prepareItemdataOrdinals.
protected HashMap<Integer, TreeSet<Integer>> prepareItemdataOrdinals(HttpServletRequest request) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
HashMap<Integer, TreeSet<Integer>> ordinals = new HashMap<Integer, TreeSet<Integer>>();
SectionDAO sdao = new SectionDAO(getDataSource());
ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
for (SectionBean section : sbs) {
ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(section.getId(), ecb.getId());
if (idbs != null && idbs.size() > 0) {
for (ItemDataBean idb : idbs) {
int itemId = idb.getItemId();
TreeSet<Integer> os = new TreeSet<Integer>();
if (ordinals == null) {
os.add(idb.getOrdinal());
ordinals.put(itemId, os);
} else if (ordinals.containsKey(itemId)) {
os = ordinals.get(itemId);
os.add(idb.getOrdinal());
ordinals.put(itemId, os);
} else {
os.add(idb.getOrdinal());
ordinals.put(itemId, os);
}
}
}
}
return ordinals;
}
use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method getAllDisplayBeans.
/**
* Retrieve the DisplaySectionBean which will be used to display the Event CRF Section on the JSP, and also is used to controll processRequest.
* @param request TODO
*/
protected ArrayList getAllDisplayBeans(HttpServletRequest request) throws Exception {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ArrayList sections = new ArrayList();
HttpSession session = request.getSession();
StudyBean study = (StudyBean) session.getAttribute("study");
SectionDAO sdao = new SectionDAO(getDataSource());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
// ALL_SECTION_BEANS
ArrayList<SectionBean> allSectionBeans = (ArrayList<SectionBean>) request.getAttribute(ALL_SECTION_BEANS);
for (int j = 0; j < allSectionBeans.size(); j++) {
SectionBean sb = allSectionBeans.get(j);
DisplaySectionBean section = new DisplaySectionBean();
section.setEventCRF(ecb);
if (sb.getParentId() > 0) {
SectionBean parent = (SectionBean) sdao.findByPK(sb.getParentId());
sb.setParent(parent);
}
section.setSection(sb);
CRFVersionDAO cvdao = new CRFVersionDAO(getDataSource());
CRFVersionBean cvb = (CRFVersionBean) cvdao.findByPK(ecb.getCRFVersionId());
section.setCrfVersion(cvb);
CRFDAO cdao = new CRFDAO(getDataSource());
CRFBean cb = (CRFBean) cdao.findByPK(cvb.getCrfId());
section.setCrf(cb);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
EventDefinitionCRFBean edcb = edcdao.findByStudyEventIdAndCRFVersionId(study, ecb.getStudyEventId(), cvb.getId());
section.setEventDefinitionCRF(edcb);
// setup DAO's here to avoid creating too many objects
ItemDAO idao = new ItemDAO(getDataSource());
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO(getDataSource());
iddao = new ItemDataDAO(getDataSource(), locale);
// get all the display item beans
ArrayList displayItems = getParentDisplayItems(false, sb, edcb, idao, ifmdao, iddao, false, request);
LOGGER.debug("222 just ran get parent display, has group " + " FALSE has ungrouped FALSE");
// now sort them by ordinal
Collections.sort(displayItems);
// now get the child DisplayItemBeans
for (int i = 0; i < displayItems.size(); i++) {
DisplayItemBean dib = (DisplayItemBean) displayItems.get(i);
dib.setChildren(getChildrenDisplayItems(dib, edcb, request));
if (shouldLoadDBValues(dib)) {
LOGGER.trace("should load db values is true, set value");
dib.loadDBValue();
}
displayItems.set(i, dib);
}
section.setItems(displayItems);
sections.add(section);
}
return sections;
}
use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method mayProceed.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#mayProceed()
*/
@Override
protected void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
checkStudyLocked(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_locked"), request, response);
checkStudyFrozen(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_frozen"), request, response);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
HttpSession session = request.getSession();
locale = LocaleResolver.getLocale(request);
// < respage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
// locale);
// < restext =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
// <
// resexception=ResourceBundle.getBundle(
// "org.akaza.openclinica.i18n.exceptions",locale);
// < resword =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
getInputBeans(request);
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
FormProcessor fp = new FormProcessor(request);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
// BWP 12/2/07>> The following COUNT_VALIDATE session attribute is not
// accessible,
// for unknown reasons (threading problems?), when
// double-data entry displays error messages; it's value is always 0; so
// I have to create my
// own session variable here to keep track of DDE stages
// We'll go by the SectionBean's ordinal first
int tabNumber = 1;
if (sb != null) {
tabNumber = sb.getOrdinal();
}
// if tabNumber still isn't valid, check the "tab" parameter
if (tabNumber < 1) {
if (fp == null) {
fp = new FormProcessor(request);
}
String tab = fp.getString("tab");
if (tab == null || tab.length() < 1) {
tabNumber = 1;
} else {
tabNumber = fp.getInt("tab");
}
}
SectionDAO sectionDao = new SectionDAO(getDataSource());
int crfVersionId = ecb.getCRFVersionId();
int eventCRFId = ecb.getId();
ArrayList sections = sectionDao.findAllByCRFVersionId(crfVersionId);
int sectionSize = sections.size();
HttpSession mySession = request.getSession();
DoubleDataProgress doubleDataProgress = (DoubleDataProgress) mySession.getAttribute(DDE_PROGESS);
if (doubleDataProgress == null || doubleDataProgress.getEventCRFId() != eventCRFId) {
doubleDataProgress = new DoubleDataProgress(sectionSize, eventCRFId);
mySession.setAttribute(DDE_PROGESS, doubleDataProgress);
}
boolean hasVisitedSection = doubleDataProgress.getSectionVisited(tabNumber, eventCRFId);
// setting up one-time validation here
// admit that it's an odd place to put it, but where else?
// placing it in dataentryservlet is creating too many counts
int keyId = ecb.getId();
Integer count = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);
if (count != null) {
count++;
session.setAttribute(COUNT_VALIDATE + keyId, count);
LOGGER.info("^^^just set count to session: " + count);
} else {
count = 0;
session.setAttribute(COUNT_VALIDATE + keyId, count);
LOGGER.info("***count not found, set to session: " + count);
}
DataEntryStage stage = ecb.getStage();
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) && !hasVisitedSection) {
// if the user has not entered this section yet in Double Data
// Entry, then
// set a flag that default values should be shown in the form
request.setAttribute(DDE_ENTERED, true);
}
// Now update the session attribute
doubleDataProgress.setSectionVisited(eventCRFId, tabNumber, true);
mySession.setAttribute("doubleDataProgress", doubleDataProgress);
// StudyEventStatus status =
Role r = currentRole.getRole();
session.setAttribute("mayProcessUploading", "true");
return;
}
use of org.akaza.openclinica.bean.submit.SectionBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method prepareGroupSizes.
protected HashMap<Integer, Integer> prepareGroupSizes(HashMap<String, ItemBean> scoreItems, HttpServletRequest request) {
HashMap<Integer, Integer> groupSizes = new HashMap<Integer, Integer>();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
SectionDAO sdao = new SectionDAO(getDataSource());
Iterator iter = scoreItems.keySet().iterator();
while (iter.hasNext()) {
int itemId = scoreItems.get(iter.next().toString()).getId();
groupSizes.put(itemId, 1);
}
ArrayList<SectionBean> sbs = sdao.findAllByCRFVersionId(ecb.getCRFVersionId());
for (SectionBean section : sbs) {
ArrayList<ItemDataBean> idbs = iddao.findAllActiveBySectionIdAndEventCRFId(section.getId(), ecb.getId());
for (ItemDataBean idb : idbs) {
int itemId = idb.getItemId();
if (groupSizes != null && groupSizes.containsKey(itemId)) {
int groupsize = iddao.getGroupSize(itemId, ecb.getId());
groupsize = groupsize > 0 ? groupsize : 1;
groupSizes.put(itemId, groupsize);
}
}
}
return groupSizes;
}
Aggregations