use of org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method updateRepeatingGroupDynItemsInASection.
public void updateRepeatingGroupDynItemsInASection(List<DisplayItemWithGroupBean> displayItemWithGroups, int sectionId, int crfVersionId, int eventCrfId) {
for (DisplayItemWithGroupBean itemWithGroup : displayItemWithGroups) {
if (itemWithGroup.isInGroup()) {
DisplayItemGroupBean digb = itemWithGroup.getItemGroup();
if (isGroupRepeating(digb.getItemGroupBean().getMeta())) {
int groupId = digb.getItemGroupBean().getId();
List<Integer> itemIds = this.dynamicsItemFormMetadataDao.findItemIdsForAGroupInSection(groupId, sectionId, crfVersionId, eventCrfId);
if (itemIds != null && itemIds.size() > 0) {
List<Integer> showItemIds = this.dynamicsItemFormMetadataDao.findShowItemIdsForAGroupInSection(groupId, sectionId, crfVersionId, eventCrfId);
this.updateItemGroupInASection(digb, itemIds, showItemIds);
this.updateGroupDynItemsInASection(itemWithGroup, showItemIds, groupId, sectionId, crfVersionId, eventCrfId);
}
}
}
}
}
use of org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method populateNotesWithDBNoteCounts.
/*
* change to explicitly re-set the section bean after reviewing the disc note counts, tbh 01/2010
*/
protected DisplaySectionBean populateNotesWithDBNoteCounts(FormDiscrepancyNotes discNotes, DisplaySectionBean section, HttpServletRequest request) {
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(getDataSource());
// ArrayList items = section.getItems();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ArrayList<DiscrepancyNoteBean> ecNotes = dndao.findEventCRFDNotesFromEventCRF(ecb);
ArrayList<DiscrepancyNoteBean> existingNameNotes = new ArrayList(), nameNotes = new ArrayList();
ArrayList<DiscrepancyNoteBean> existingIntrvDateNotes = new ArrayList(), dateNotes = new ArrayList();
long t = System.currentTimeMillis();
logMe("Method:populateNotesWithDBNoteCounts" + t);
int intNew = 0, intRes = 0, intUpdated = 0, intClosed = 0, intNA = 0;
int dateNew = 0, dateRes = 0, dateUpdated = 0, dateClosed = 0, dateNA = 0;
boolean hasMoreThreads = false;
for (int i = 0; i < ecNotes.size(); i++) {
DiscrepancyNoteBean dn = ecNotes.get(i);
if (INTERVIEWER_NAME.equalsIgnoreCase(dn.getColumn())) {
discNotes.setNumExistingFieldNotes(INPUT_INTERVIEWER, 1);
request.setAttribute("hasNameNote", "yes");
request.setAttribute(INTERVIEWER_NAME_NOTE, dn);
if (dn.getParentDnId() == 0)
existingNameNotes.add(dn);
}
if (DATE_INTERVIEWED.equalsIgnoreCase(dn.getColumn())) {
discNotes.setNumExistingFieldNotes(INPUT_INTERVIEW_DATE, 1);
request.setAttribute("hasDateNote", "yes");
request.setAttribute(INTERVIEWER_DATE_NOTE, dn);
if (dn.getParentDnId() == 0)
existingIntrvDateNotes.add(dn);
}
}
logMe("Method:populateNotesWithDBNoteCounts before calling setToolTipEventNotes" + System.currentTimeMillis() + "time took:" + (System.currentTimeMillis() - t));
setToolTipEventNotes(request);
request.setAttribute("nameNoteResStatus", getDiscrepancyNoteResolutionStatus(existingNameNotes));
request.setAttribute("IntrvDateNoteResStatus", getDiscrepancyNoteResolutionStatus(existingIntrvDateNotes));
request.setAttribute("existingNameNotes", existingNameNotes);
request.setAttribute("existingIntrvDateNotes", existingIntrvDateNotes);
List<DisplayItemWithGroupBean> allItems = section.getDisplayItemGroups();
LOGGER.debug("start to populate notes: " + section.getDisplayItemGroups().size());
this.output(allItems);
logMe("Looping through allItems time:" + System.currentTimeMillis() + "time took from the begining" + (System.currentTimeMillis() - t));
for (int k = 0; k < allItems.size(); k++) {
DisplayItemWithGroupBean itemWithGroup = allItems.get(k);
if (itemWithGroup.isInGroup()) {
LOGGER.debug("group item DNote...");
List<DisplayItemGroupBean> digbs = itemWithGroup.getItemGroups();
LOGGER.trace("digbs size: " + digbs.size());
for (int i = 0; i < digbs.size(); i++) {
DisplayItemGroupBean displayGroup = digbs.get(i);
List<DisplayItemBean> items = displayGroup.getItems();
for (int j = 0; j < items.size(); j++) {
DisplayItemBean dib = items.get(j);
int itemDataId = dib.getData().getId();
int numNotes = dndao.findNumExistingNotesForItem(itemDataId);
int numNotes1 = dndao.findNumOfActiveExistingNotesForItemData(itemDataId);
int ordinal = this.getManualRows(digbs);
String inputName = getGroupItemInputName(displayGroup, displayGroup.getFormInputOrdinal(), dib);
if (!displayGroup.isAuto()) {
inputName = getGroupItemManualInputName(displayGroup, i, dib);
}
discNotes.setNumExistingFieldNotes(inputName, numNotes1);
ArrayList notes = discNotes.getNotes(inputName);
// + notes2.size());
dib.setNumDiscrepancyNotes(numNotes + notes.size());
dib.setDiscrepancyNoteStatus(getDiscrepancyNoteResolutionStatus(itemDataId, notes));
dib = setTotals(dib, itemDataId, notes, ecb.getId());
LOGGER.debug("dib note size:" + dib.getNumDiscrepancyNotes() + " " + dib.getData().getId() + " " + inputName);
items.set(j, dib);
}
displayGroup.setItems(items);
digbs.set(i, displayGroup);
}
itemWithGroup.setItemGroups(digbs);
} else {
LOGGER.trace("single item db note");
DisplayItemBean dib = itemWithGroup.getSingleItem();
try {
ResponseOptionBean rob = (ResponseOptionBean) dib.getMetadata().getResponseSet().getOptions().get(0);
LOGGER.trace("test print of options for coding: " + rob.getValue());
} catch (NullPointerException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
}
int itemDataId = dib.getData().getId();
int itemId = dib.getItem().getId();
int numNotes = dndao.findNumExistingNotesForItem(itemDataId);
int numNotes1 = dndao.findNumOfActiveExistingNotesForItemData(itemDataId);
String inputFieldName = "input" + itemId;
discNotes.setNumExistingFieldNotes(inputFieldName, numNotes1);
dib.setNumDiscrepancyNotes(numNotes + discNotes.getNotes(inputFieldName).size());
dib.setDiscrepancyNoteStatus(getDiscrepancyNoteResolutionStatus(itemDataId, discNotes.getNotes(inputFieldName)));
dib = setTotals(dib, itemDataId, discNotes.getNotes(inputFieldName), ecb.getId());
ArrayList childItems = dib.getChildren();
for (int j = 0; j < childItems.size(); j++) {
DisplayItemBean child = (DisplayItemBean) childItems.get(j);
int childItemDataId = child.getData().getId();
int childItemId = child.getItem().getId();
int childNumNotes = dndao.findNumExistingNotesForItem(childItemDataId);
String childInputFieldName = "input" + childItemId;
LOGGER.debug("*** setting " + childInputFieldName);
discNotes.setNumExistingFieldNotes(childInputFieldName, childNumNotes);
child.setNumDiscrepancyNotes(childNumNotes + discNotes.getNotes(childInputFieldName).size());
child.setDiscrepancyNoteStatus(getDiscrepancyNoteResolutionStatus(childItemDataId, discNotes.getNotes(childInputFieldName)));
child = setTotals(child, childItemDataId, discNotes.getNotes(childInputFieldName), ecb.getId());
childItems.set(j, child);
}
dib.setChildren(childItems);
itemWithGroup.setSingleItem(runDynamicsItemCheck(dib, null, request));
}
// missing piece of the puzzle - reset the itemgroup into all items?
allItems.set(k, itemWithGroup);
}
section.setDisplayItemGroups(allItems);
return section;
}
use of org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method createItemWithGroups.
//@pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method createItemWithGroups
protected List<DisplayItemWithGroupBean> createItemWithGroups(DisplaySectionBean dsb, boolean hasItemGroup, int eventCRFDefId, HttpServletRequest request, boolean isSubmitted) {
HttpSession session = request.getSession();
List<DisplayItemWithGroupBean> displayItemWithGroups = new ArrayList<DisplayItemWithGroupBean>();
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
ItemDAO idao = new ItemDAO(getDataSource());
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
// BWP>> Get a List<String> of any null values such as NA or NI
// method returns null values as a List<String>
// >>BWP
ArrayList items = dsb.getItems();
// For adding null values to display items
FormBeanUtil formBeanUtil = new FormBeanUtil();
List<String> nullValuesList = formBeanUtil.getNullValuesByEventCRFDefId(eventCRFDefId, getDataSource());
LOGGER.trace("single items size: " + items.size());
for (int i = 0; i < items.size(); i++) {
DisplayItemBean item = (DisplayItemBean) items.get(i);
DisplayItemWithGroupBean newOne = new DisplayItemWithGroupBean();
newOne.setSingleItem(runDynamicsItemCheck(item, null, request));
newOne.setOrdinal(item.getMetadata().getOrdinal());
newOne.setInGroup(false);
newOne.setPageNumberLabel(item.getMetadata().getPageNumberLabel());
displayItemWithGroups.add(newOne);
// logger.trace("just added on line 1979:
// "+newOne.getSingleItem().getData().getValue());
}
if (hasItemGroup) {
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
ArrayList<ItemDataBean> data = iddao.findAllBySectionIdAndEventCRFId(sb.getId(), ecb.getId());
HashMap<String, ItemDataBean> dataMap = (HashMap<String, ItemDataBean>) getAllActive(data);
if (data != null && data.size() > 0) {
session.setAttribute(HAS_DATA_FLAG, true);
}
LOGGER.trace("found data: " + data.size());
LOGGER.trace("data.toString: " + data.toString());
for (DisplayItemGroupBean itemGroup : dsb.getDisplayFormGroups()) {
LOGGER.debug("found one itemGroup");
DisplayItemWithGroupBean newOne = new DisplayItemWithGroupBean();
// to arrange item groups and other single items, the ordinal of
// a item group will be the ordinal of the first item in this
// group
DisplayItemBean firstItem = itemGroup.getItems().get(0);
// so we are either checking the first or the last item, BUT ONLY ONCE
newOne.setPageNumberLabel(firstItem.getMetadata().getPageNumberLabel());
newOne.setItemGroup(itemGroup);
newOne.setInGroup(true);
newOne.setOrdinal(itemGroup.getGroupMetaBean().getOrdinal());
List<ItemBean> itBeans = idao.findAllItemsByGroupIdOrdered(itemGroup.getItemGroupBean().getId(), sb.getCRFVersionId());
List<DisplayItemBean> dibs = new ArrayList();
boolean hasData = false;
int checkAllColumns = 0;
if (data.size() > 0)
hasData = true;
//@pgawade 30-May-2012 Fix for issue 13963 - added an extra parameter 'isSubmitted' to method buildMatrixForRepeatingGroups
newOne = buildMatrixForRepeatingGroups(newOne, itemGroup, ecb, sb, itBeans, dataMap, nullValuesList, isSubmitted);
if (hasData) {
//TODO: fix the group_has_data flag on bean not on session
session.setAttribute(GROUP_HAS_DATA, Boolean.TRUE);
} else {
session.setAttribute(GROUP_HAS_DATA, Boolean.FALSE);
// no data, still add a blank row for displaying
if (nullValuesList != null && nullValuesList.size() > 0) {
LOGGER.trace("set with nullValuesList of : " + nullValuesList);
}
dibs = FormBeanUtil.getDisplayBeansFromItems(itBeans, getDataSource(), ecb, sb.getId(), nullValuesList, getServletContext());
DisplayItemGroupBean digb2 = new DisplayItemGroupBean();
digb2.setItems(dibs);
digb2.setEditFlag("initial");
}
displayItemWithGroups.add(newOne);
}
}
// if hasItemGroup
Collections.sort(displayItemWithGroups);
return displayItemWithGroups;
}
use of org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method updateDataOrdinals.
protected void updateDataOrdinals(List<DisplayItemWithGroupBean> displayItemWithGroups) {
for (int i = 0; i < displayItemWithGroups.size(); ++i) {
DisplayItemWithGroupBean diwb = displayItemWithGroups.get(i);
HashMap<Integer, String> editFlags = new HashMap<Integer, String>();
HashMap<Integer, Integer> nextOrdinals = new HashMap<Integer, Integer>();
if (diwb.isInGroup()) {
List<DisplayItemGroupBean> dbGroups = diwb.getDbItemGroups();
for (int j = 0; j < dbGroups.size(); j++) {
DisplayItemGroupBean displayGroup = dbGroups.get(j);
List<DisplayItemBean> items = displayGroup.getItems();
for (DisplayItemBean displayItem : items) {
int itemId = displayItem.getItem().getId();
int ordinal = displayItem.getData().getOrdinal();
if ("initial".equalsIgnoreCase(displayGroup.getEditFlag())) {
nextOrdinals.put(itemId, 1);
} else {
if (nextOrdinals.containsKey(itemId)) {
int max = nextOrdinals.get(itemId);
nextOrdinals.put(itemId, ordinal > max ? ordinal + 1 : max);
} else {
nextOrdinals.put(itemId, ordinal + 1);
}
}
editFlags.put(displayItem.getData().getId(), displayGroup.getEditFlag());
}
}
List<DisplayItemGroupBean> dgbs = diwb.getItemGroups();
int nextOrdinal = 0;
for (int j = 0; j < dgbs.size(); j++) {
DisplayItemGroupBean displayGroup = dgbs.get(j);
List<DisplayItemBean> oItems = displayGroup.getItems();
String editFlag = displayGroup.getEditFlag();
for (DisplayItemBean displayItem : oItems) {
int itemId = displayItem.getItem().getId();
nextOrdinal = nextOrdinals.get(itemId);
int ordinal = 0;
String editflag = "add".equalsIgnoreCase(editFlag) ? editFlag : editFlags.get(displayItem.getData().getId());
if (editflag.length() > 0) {
if ("add".equalsIgnoreCase(editflag)) {
ordinal = nextOrdinals.get(itemId);
displayItem.getData().setOrdinal(ordinal);
nextOrdinals.put(itemId, nextOrdinal + 1);
} else if ("edit".equalsIgnoreCase(editflag)) {
displayItem.getData().setOrdinal(displayItem.getDbData().getOrdinal());
}
}
}
}
}
}
}
use of org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean in project OpenClinica by OpenClinica.
the class DataEntryServlet method reshuffleErrorGroupNamesKK.
private HashMap reshuffleErrorGroupNamesKK(HashMap errors, List<DisplayItemWithGroupBean> allItems, HttpServletRequest request) {
int manualRows = 0;
if (errors == null || errors.size() < 1) {
return errors;
}
for (int i = 0; i < allItems.size(); i++) {
DisplayItemWithGroupBean diwb = allItems.get(i);
if (diwb.isInGroup()) {
List<DisplayItemGroupBean> dgbs = diwb.getItemGroups();
for (int j = 0; j < dgbs.size(); j++) {
DisplayItemGroupBean digb = dgbs.get(j);
ItemGroupBean igb = digb.getItemGroupBean();
List<DisplayItemBean> dibs = digb.getItems();
if (j == 0) {
// first repeat
for (DisplayItemBean dib : dibs) {
String intendedKey = digb.getInputId() + getInputName(dib);
String replacementKey = digb.getItemGroupBean().getOid() + "_" + j + getInputName(dib);
if (!replacementKey.equals(intendedKey) && errors.containsKey(intendedKey)) {
// String errorMessage = (String)errors.get(intendedKey);
errors.put(replacementKey, errors.get(intendedKey));
errors.remove(intendedKey);
LOGGER.debug("removing: " + intendedKey + " and replacing it with " + replacementKey);
}
}
} else {
// everything in between
manualRows++;
for (DisplayItemBean dib : dibs) {
String intendedKey = digb.getInputId() + getInputName(dib);
String replacementKey = digb.getItemGroupBean().getOid() + "_manual" + j + getInputName(dib);
if (!replacementKey.equals(intendedKey) && errors.containsKey(intendedKey)) {
// String errorMessage = (String)errors.get(intendedKey);
errors.put(replacementKey, errors.get(intendedKey));
errors.remove(intendedKey);
LOGGER.debug("removing: " + intendedKey + " and replacing it with " + replacementKey);
}
}
}
}
}
}
request.setAttribute("manualRows", new Integer(manualRows));
return errors;
}
Aggregations