use of org.akaza.openclinica.bean.submit.DisplayItemBean in project OpenClinica by OpenClinica.
the class PrintEventCRFServlet method validateDisplayItemBean.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.submit.DataEntryServlet#validateDisplayItemBean(org.akaza.openclinica.core.form.Validator,
* org.akaza.openclinica.bean.submit.DisplayItemBean)
*/
@Override
protected DisplayItemBean validateDisplayItemBean(DiscrepancyValidator v, DisplayItemBean dib, String inputName, HttpServletRequest request) {
ItemBean ib = dib.getItem();
org.akaza.openclinica.bean.core.ResponseType rt = dib.getMetadata().getResponseSet().getResponseType();
// note that this step sets us up both for
// displaying the data on the form again, in the event of an error
// and sending the data to the database, in the event of no error
dib = loadFormValue(dib, request);
// types TEL and ED are not supported yet
if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXT) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.TEXTAREA)) {
dib = validateDisplayItemBeanText(v, dib, inputName, request);
} else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.RADIO) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECT)) {
dib = validateDisplayItemBeanSingleCV(v, dib, inputName);
} else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {
dib = validateDisplayItemBeanMultipleCV(v, dib, inputName);
} else if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CALCULATION) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.GROUP_CALCULATION)) {
// for now, treat calculation like any other text input --
// eventually this might need to be customized
dib = validateDisplayItemBeanText(v, dib, inputName, request);
}
return dib;
}
use of org.akaza.openclinica.bean.submit.DisplayItemBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method buildMatrixForRepeatingGroups.
//@pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
protected DisplayItemWithGroupBean buildMatrixForRepeatingGroups(DisplayItemWithGroupBean diwgb, DisplayItemGroupBean itemGroup, EventCRFBean ecb, SectionBean sb, List<ItemBean> itBeans, Map<String, ItemDataBean> dataMap, List<String> nullValuesList, boolean isSubmitted) {
int tempOrdinal = 1;
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
int maxOrdinal = iddao.getMaxOrdinalForGroup(ecb, sb, itemGroup.getItemGroupBean());
//Incase of no data
if (maxOrdinal == 0)
maxOrdinal = 1;
ItemFormMetadataDAO ifmdao = new ItemFormMetadataDAO<String, ArrayList>(getDataSource());
List<DisplayItemGroupBean> itemGroups = new ArrayList<DisplayItemGroupBean>();
boolean groupHasData = false;
for (int i = 1; i <= maxOrdinal; i++) {
List<DisplayItemBean> displayItemBeans = new ArrayList<DisplayItemBean>();
DisplayItemGroupBean dig = new DisplayItemGroupBean();
for (ItemBean itBean : itBeans) {
DisplayItemBean displayItemBean = new DisplayItemBean();
ItemFormMetadataBean ifm = ifmdao.findByItemIdAndCRFVersionId(itBean.getId(), ecb.getCRFVersionId());
// itBean.setItemMeta(ifm);//TODO:remove this or the one down displayItemBean.setMetadata(ifm);
displayItemBean.setMetadata(ifm);
displayItemBean.setItem(itBean);
ItemDataBean itemData = dataMap.get(itBean.getId() + "," + i);
if (itemData != null) {
//to indicate any item in the group has data;
groupHasData = true;
displayItemBean.setIsNewItem(false);
}
if (itemData == null) {
itemData = displayItemBean.getData();
itemData.setValue("");
itemData.setOrdinal(i);
}
addNullValues(displayItemBean, nullValuesList);
displayItemBean.setData(itemData);
// displayItemBean.loadDBValue();
if (ecb.getStage() == DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE || ecb.getStage() == DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) {
if (shouldLoadDBValues(displayItemBean) && !isSubmitted) {
displayItemBean.loadDBValue();
}
} else {
if (shouldLoadDBValues(displayItemBean)) {
LOGGER.trace("should load db values is true, set value");
displayItemBean.loadDBValue();
LOGGER.trace("just got data loaded: " + displayItemBean.getData().getValue());
}
}
displayItemBeans.add(displayItemBean);
}
Collections.sort(displayItemBeans);
dig.setItems(displayItemBeans);
dig.setHasData(groupHasData);
itemGroups.add(dig);
}
diwgb.setItemGroups(itemGroups);
diwgb.setDbItemGroups(itemGroups);
return diwgb;
}
use of org.akaza.openclinica.bean.submit.DisplayItemBean 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.DisplayItemBean in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method validateDisplayItemGroupBean.
@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, RuleValidator rv, HashMap<String, ArrayList<String>> groupOrdinalPLusItemOid, HttpServletRequest request, HttpServletResponse response) {
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
// logger.info("===got this far");
int keyId = ecb.getId();
Integer validationCount = (Integer) request.getSession().getAttribute(COUNT_VALIDATE + keyId);
formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
LOGGER.info("found formgroups size for " + digb.getGroupMetaBean().getName() + ": " + formGroups.size() + " compare to db groups size: " + digbs.size());
String inputName = "";
for (int i = 0; i < formGroups.size(); i++) {
DisplayItemGroupBean displayGroup = formGroups.get(i);
List<DisplayItemBean> items = displayGroup.getItems();
int order = displayGroup.getOrdinal();
if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
order = displayGroup.getFormInputOrdinal();
}
for (DisplayItemBean displayItem : items) {
if (displayGroup.isAuto()) {
inputName = getGroupItemInputName(displayGroup, order, displayItem);
} else {
inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
}
if (displayItem.getMetadata().isShowItem() || getItemMetadataService().isShown(displayItem.getItem().getId(), ecb, displayItem.getData())) {
// add the validation
if (groupOrdinalPLusItemOid.containsKey(displayItem.getItem().getOid()) || groupOrdinalPLusItemOid.containsKey(String.valueOf(order + 1) + displayItem.getItem().getOid())) {
LOGGER.debug("IN : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, true, groupOrdinalPLusItemOid.get(String.valueOf(order + 1) + displayItem.getItem().getOid()), request);
} else {
validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, false, null, request);
}
} else {
LOGGER.debug("OUT : " + String.valueOf(order + 1) + displayItem.getItem().getOid());
}
// validateDisplayItemBean(v, displayItem, inputName);
}
}
return formGroups;
}
use of org.akaza.openclinica.bean.submit.DisplayItemBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method processInputForGroupItem.
/**
* @param fp
* @param dibs
* @param i
* @param digb
* @return
*/
private List<DisplayItemBean> processInputForGroupItem(FormProcessor fp, List<DisplayItemBean> dibs, int i, DisplayItemGroupBean digb, boolean isAuto) {
for (int j = 0; j < dibs.size(); j++) {
DisplayItemBean displayItem = dibs.get(j);
String inputName = "";
org.akaza.openclinica.bean.core.ResponseType rt = displayItem.getMetadata().getResponseSet().getResponseType();
if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.CHECKBOX) || rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECTMULTI)) {
if (isAuto) {
inputName = getGroupItemInputName(digb, i, displayItem);
} else {
inputName = getGroupItemManualInputName(digb, i, displayItem);
}
ArrayList valueArray = fp.getStringArray(inputName);
displayItem.setFieldName(inputName);
displayItem.loadFormValue(valueArray);
} else {
if (isAuto) {
inputName = getGroupItemInputName(digb, i, displayItem);
} else {
inputName = getGroupItemManualInputName(digb, i, displayItem);
}
displayItem.setFieldName(inputName);
displayItem.loadFormValue(fp.getString(inputName));
// necessary here
if (rt.equals(org.akaza.openclinica.bean.core.ResponseType.SELECT)) {
ensureSelectedOption(displayItem);
}
// BWP>>
}
}
return dibs;
}
Aggregations