use of org.akaza.openclinica.dao.submit.SectionDAO 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.dao.submit.SectionDAO 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.dao.submit.SectionDAO 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.dao.submit.SectionDAO 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;
}
use of org.akaza.openclinica.dao.submit.SectionDAO in project OpenClinica by OpenClinica.
the class OpenRosaXmlGenerator method getSectionBean.
private SectionBean getSectionBean(Integer ID) {
sdao = new SectionDAO(dataSource);
SectionBean sBean = (SectionBean) sdao.findByPK(ID);
return sBean;
}
Aggregations