use of org.jmesa.limit.Limit 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.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class SDVUtil method setDataAndLimitVariablesSubjects.
public int setDataAndLimitVariablesSubjects(TableFacade tableFacade, int studyId, int studySubjectId, HttpServletRequest request) {
Limit limit = tableFacade.getLimit();
FilterSet filterSet = limit.getFilterSet();
int totalRows = getTotalRowCountSubjects(filterSet, studyId, studySubjectId);
tableFacade.setTotalRows(totalRows);
SortSet sortSet = limit.getSortSet();
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<SubjectSDVContainer> items = getFilteredItemsSubject(filterSet, sortSet, rowStart, rowEnd, studyId, studySubjectId, request);
tableFacade.setItems(items);
return totalRows;
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class SDVUtil method updateLimitRowSelect.
private void updateLimitRowSelect(TableFacade tableFacade, HttpServletRequest request) {
Limit limit = tableFacade.getLimit();
String p = request.getParameter(limit.getId() + "_p_");
int pn = p != null && p.length() > 0 ? Integer.parseInt(p) : 1;
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class AbstractTableFactory method exportCSVTable.
/**
* Use this method to export all data from table. 1. filters/sorts will be ignored 2. Whole table will be exported
* page by page 3. Configure getSize(Limit limit)
*
* @param request
* @param response
* @see getSize(Limit limit), createLimits()
* @see filter & sort methods in implementations
*/
public void exportCSVTable(HttpServletRequest request, HttpServletResponse response, String path) {
locale = LocaleResolver.getLocale(request);
String DATE_FORMAT = "yyyyMMddHHmmss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
String fileName = getTableName() + "_" + sdf.format(new Date());
for (Limit limit : createLimits()) {
TableFacade tableFacade = new OCTableFacadeImpl(getTableName(), request, response, path + File.separator + fileName);
tableFacade.setStateAttr("restore");
tableFacade.setLimit(limit);
tableFacade.autoFilterAndSort(false);
setDataAndLimitVariables(tableFacade);
configureTableFacade(response, tableFacade);
configureExportColumns(tableFacade, locale);
tableFacade.render();
}
}
use of org.jmesa.limit.Limit in project OpenClinica by OpenClinica.
the class EventStatusStatisticsTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
Limit limit = tableFacade.getLimit();
SubjectEventStatus[] subjectEventStatuses = { SubjectEventStatus.SCHEDULED, SubjectEventStatus.DATA_ENTRY_STARTED, SubjectEventStatus.COMPLETED, SubjectEventStatus.SIGNED, SubjectEventStatus.LOCKED, SubjectEventStatus.SKIPPED, SubjectEventStatus.STOPPED };
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
/*
* Because we are using the State feature (via stateAttr) we can do a
* check to see if we have a complete limit already. See the State
* feature for more details Very important to set the totalRow before
* trying to get the row start and row end variables. Very important to
* set the totalRow before trying to get the row start and row end
* variables.
*/
if (!limit.isComplete()) {
int totalRows = subjectEventStatuses.length;
tableFacade.setTotalRows(totalRows);
}
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
for (SubjectEventStatus subjectEventStatus : subjectEventStatuses) {
Integer totalEventsByEventStatus = studyEventDao.getCountofEventsBasedOnEventStatus(currentStudy, subjectEventStatus);
Integer totalEvents = studyEventDao.getCountofEvents(currentStudy);
Long percentage = totalEvents == 0 ? 0 : Math.round((totalEventsByEventStatus.doubleValue() / totalEvents.doubleValue()) * 100);
HashMap<Object, Object> theItem = new HashMap<Object, Object>();
theItem.put("status", subjectEventStatus.getName());
theItem.put("studySubjects", totalEventsByEventStatus);
theItem.put("percentage", String.valueOf(percentage) + "%");
theItems.add(theItem);
}
tableFacade.setItems(theItems);
}
Aggregations