use of org.akaza.openclinica.bean.submit.DisplayItemGroupBean 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.DisplayItemGroupBean 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.DisplayItemGroupBean in project OpenClinica by OpenClinica.
the class InitialDataEntryServlet 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) {
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
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) {
// tbh trying to set this correctly 01/2010
if (displayGroup.isAuto()) {
inputName = getGroupItemInputName(displayGroup, order, displayItem);
} else {
inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
// manualcount++;
}
logger.debug("THe oid is " + displayItem.getItem().getOid() + " order : " + order + " inputName : " + inputName);
if (groupOrdinalPLusItemOid.containsKey(displayItem.getItem().getOid()) || groupOrdinalPLusItemOid.containsKey(String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid())) {
logger.debug("IN : " + String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid());
validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, true, groupOrdinalPLusItemOid.get(String.valueOf(displayGroup.getIndex() + 1) + displayItem.getItem().getOid()), request);
} else {
validateDisplayItemBean(v, displayItem, inputName, rv, groupOrdinalPLusItemOid, false, null, request);
}
}
}
return formGroups;
}
use of org.akaza.openclinica.bean.submit.DisplayItemGroupBean in project OpenClinica by OpenClinica.
the class ViewBuilderPrintDecorator method incrementDisplayBeanOrdinals.
/**
* This method takes a List of DisplayItemGroupBeans, and increases the
* ordinals of some of the beans, to compensate for the fact that previous
* DisplayItemGroupBeans in the List have been split up into single-column
* beans with new ordinals. Therefore, the DisplayItemGroupBeans following
* them on the section have to have their ordinals (specifying their
* position on the CRF section) incremented, so that they keep their proper
* position on the CRF.
*
* @param displayItemGroupBeans
* A List of DisplayItemGroupBeans, representing group tables on
* a CRF section.
* @param startOrdinal
* The ordinal of the DisplayItemGroupBean that is split up into
* multiple DisplayItemGroupBeans.
* @param incrementByNumber
* The number by which the following DisplayItemGroupBeans have
* to increment their ordinals. This number is equal to split-up
* DisplayItemGroupBean.getItems().size() - 1 .
*/
public void incrementDisplayBeanOrdinals(List<DisplayItemGroupBean> displayItemGroupBeans, int startOrdinal, int incrementByNumber) {
int tempOrdinal = 0;
for (DisplayItemGroupBean displayItemGroupBean : displayItemGroupBeans) {
tempOrdinal = displayItemGroupBean.getOrdinal();
if (tempOrdinal <= startOrdinal)
continue;
displayItemGroupBean.setOrdinal(displayItemGroupBean.getOrdinal() + incrementByNumber);
}
}
use of org.akaza.openclinica.bean.submit.DisplayItemGroupBean in project OpenClinica by OpenClinica.
the class ViewBuilderPrintDecorator method reduceColumnsGroupTables.
/**
*
* @param groupBeans
* @return
*/
public List<DisplayItemGroupBean> reduceColumnsGroupTables(List<DisplayItemGroupBean> groupBeans) {
if (groupBeans == null || groupBeans.size() == 0)
return groupBeans;
List<DisplayItemGroupBean> newGroupBeans = new ArrayList<DisplayItemGroupBean>();
// the ordinal of the first group table that is being broken up into
// multiple columns
// we then have to change the ordinals of all of the group beans that
// follow this one.
// See below
int startOrdinal = 0;
int i = 0;
for (DisplayItemGroupBean existingDisplayBean : groupBeans) {
// beans
if (existingDisplayBean.getItems().size() > 3 && !BeanFactory.UNGROUPED.equalsIgnoreCase(existingDisplayBean.getItemGroupBean().getName())) {
startOrdinal = existingDisplayBean.getOrdinal();
// increment the ordinals of the other beans to make up for this
// one
// this.incrementDisplayBeanOrdinals(groupBeans, startOrdinal, existingDisplayBean.getItems().size() - 1);
newGroupBeans.addAll(splitUpGroupBeanIntoSingleColumns(existingDisplayBean));
} else {
// otherwise, add the existing bean to the List
newGroupBeans.add(existingDisplayBean);
}
}
// Now sort the new beans on their ordinal
Collections.sort(newGroupBeans);
return newGroupBeans;
}
Aggregations