use of org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
StudySubjectSDVFilter studySubjectSDVFilter = getStudySubjectSDVFilter(limit);
WebContext context = tableFacade.getWebContext();
if (context != null) {
studyId = Integer.parseInt(context.getParameter("studyId"));
contextPath = context.getContextPath();
}
String restore = context.getRequestAttribute(limit.getId() + "_restore") + "";
if (!limit.isComplete()) {
int totalRows = getTotalRowCount(studySubjectSDVFilter);
tableFacade.setTotalRows(totalRows);
} else if (restore != null && "true".equalsIgnoreCase(restore)) {
int totalRows = getTotalRowCount(studySubjectSDVFilter);
int pageNum = limit.getRowSelect().getPage();
int maxRows = limit.getRowSelect().getMaxRows();
tableFacade.setMaxRows(maxRows);
tableFacade.setTotalRows(totalRows);
limit.getRowSelect().setPage(pageNum);
}
StudySubjectSDVSort studySubjectSDVSort = getStudySubjectSDVSort(limit);
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
// Collection<StudySubjectBean> items = getStudySubjectDAO().getWithFilterAndSort(getStudyBean(),
// studySubjectSDVFilter, subjectSort, rowStart, rowEnd);
Collection<SubjectAggregateContainer> items = getFilteredItems(studySubjectSDVFilter, studySubjectSDVSort, rowStart, rowEnd);
tableFacade.setItems(items);
/*
*
*
* Limit limit = tableFacade.getLimit();
* FilterSet filterSet = limit.getFilterSet();
* WebContext context = tableFacade.getWebContext();
* if (context != null) {
* studyId = Integer.parseInt(context.getParameter("studyId"));
* contextPath = context.getContextPath();
* }
* int totalRows = getTotalRowCount();
*
* tableFacade.setTotalRows(totalRows);
* SortSet sortSet = limit.getSortSet();
* int rowStart = limit.getRowSelect().getRowStart();
* int rowEnd = limit.getRowSelect().getRowEnd();
* Collection<SubjectAggregateContainer> items = getFilteredItems(filterSet, sortSet, rowStart, rowEnd);
* ;
*
* tableFacade.setItems(items);
*/
}
use of org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method getRow.
private SubjectAggregateContainer getRow(StudySubjectBean studySubjectBean) {
SubjectAggregateContainer row = new SubjectAggregateContainer();
EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
StudyDAO studyDAO = new StudyDAO(dataSource);
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(dataSource);
row.setStudySubjectId(studySubjectBean.getLabel());
row.setPersonId(studySubjectBean.getUniqueIdentifier());
row.setStudySubjectStatus(studySubjectBean.getStatus().getName());
int numberEventCRFs = eventCRFDAO.countEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
row.setTotalEventCRF(numberEventCRFs + "");
StudyBean studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
row.setSiteId(studyBean.getIdentifier());
List<EventCRFBean> eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
HashMap<String, Integer> stats = getEventCRFStats(eventCRFBeans, studySubjectBean);
// int numberCRFComplete = getNumberCompletedEventCRFs(eventCRFBeans);
// row.setNumberCRFComplete(numberCRFComplete + "");
row.setNumberCRFComplete(stats.get("numberOfCompletedEventCRFs") + "");
row.setNumberOfCRFsSDV(stats.get("numberOfSDVdEventCRFs") + "");
// row.setNumberOfCRFsSDV(getNumberSDVdEventCRFs(eventCRFBeans) + "");
// boolean studySubjectSDVd =
// eventCRFDAO.countEventCRFsByByStudySubjectCompleteOrLockedAndNotSDVd(studySubjectBean.getId()) == 0 &&
// numberCRFComplete > 0;
boolean studySubjectSDVd = stats.get("areEventCRFsSDVd") == -1 || stats.get("areEventCRFsSDVd") == 1 ? false : true;
StringBuilder sdvStatus = new StringBuilder("");
if (stats.get("shouldDisplaySDVButton") == 0) {
sdvStatus.append("");
} else if (studySubjectSDVd) {
sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
sdvStatus.append(studySubjectBean.getId());
sdvStatus.append(")'>");
sdvStatus.append(getIconForCrfStatusPrefix()).append("DoubleCheck").append(ICON_FORCRFSTATUS_SUFFIX).append("</a></center>");
} else {
sdvStatus.append("<center><input style='margin-right: 5px' type='checkbox' ").append("class='sdvCheck'").append(" name='").append("sdvCheck_").append(studySubjectBean.getId()).append("' /></center>");
}
row.setSdvStatus(sdvStatus.toString());
List<StudyGroupBean> studyGroupBeans = studyGroupDAO.getGroupByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
if (studyGroupBeans != null && !studyGroupBeans.isEmpty()) {
row.setGroup(studyGroupBeans.get(0).getName());
}
StringBuilder actions = new StringBuilder("<table><tr><td>");
StringBuilder urlPrefix = new StringBuilder("<a href=\"");
StringBuilder path = new StringBuilder(contextPath).append("/pages/viewAllSubjectSDVtmp?studyId=").append(studyId).append("&sdv_f_studySubjectId=");
path.append(studySubjectBean.getLabel());
urlPrefix.append(path).append("\">");
actions.append(urlPrefix).append(SDVUtil.VIEW_ICON_HTML).append("</a></td>");
if (!studySubjectSDVd && stats.get("shouldDisplaySDVButton") == 1) {
StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/sdvStudySubject").append("';").append("this.form.theStudySubjectId.value='").append(studySubjectBean.getId()).append("';").append("this.form.submit();");
if (!studyBean.getStatus().isLocked()) {
actions.append("<td><input type=\"submit\" class=\"button\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" /></td>");
}
} else if (!studySubjectSDVd) {
actions.append("<td> SDV N/A</td>");
}
actions.append("</tr></table>");
row.setActions(actions.toString());
return row;
}
use of org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method getFilteredItems.
@SuppressWarnings("unchecked")
private Collection<SubjectAggregateContainer> getFilteredItems(StudySubjectSDVFilter filterSet, StudySubjectSDVSort sortSet, int rowStart, int rowEnd) {
List<SubjectAggregateContainer> rows = new ArrayList<SubjectAggregateContainer>();
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
List<StudySubjectBean> studySubjectBeans = studySubjectDAO.findAllByStudySDV(studyId, studyId, filterSet, sortSet, rowStart, rowEnd);
SubjectAggregateContainer containerTmp = null;
for (StudySubjectBean studSubjBean : studySubjectBeans) {
containerTmp = getRow(studSubjBean);
rows.add(containerTmp);
}
return rows;
}
Aggregations