Search in sources :

Example 1 with Limit

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);
         */
}
Also used : SubjectAggregateContainer(org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer) WebContext(org.jmesa.web.WebContext) StudySubjectSDVSort(org.akaza.openclinica.dao.StudySubjectSDVSort) StudySubjectSDVFilter(org.akaza.openclinica.dao.StudySubjectSDVFilter) Limit(org.jmesa.limit.Limit)

Example 2 with Limit

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;
}
Also used : FilterSet(org.jmesa.limit.FilterSet) Limit(org.jmesa.limit.Limit) SubjectSDVContainer(org.akaza.openclinica.controller.helper.table.SubjectSDVContainer) SortSet(org.jmesa.limit.SortSet)

Example 3 with Limit

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;
}
Also used : Limit(org.jmesa.limit.Limit)

Example 4 with Limit

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();
    }
}
Also used : TableFacade(org.jmesa.facade.TableFacade) Limit(org.jmesa.limit.Limit) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 5 with Limit

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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit) SubjectEventStatus(org.akaza.openclinica.bean.core.SubjectEventStatus)

Aggregations

Limit (org.jmesa.limit.Limit)24 ArrayList (java.util.ArrayList)14 HashMap (java.util.HashMap)13 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)6 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)5 List (java.util.List)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)4 SubjectEventStatus (org.akaza.openclinica.bean.core.SubjectEventStatus)3 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)3 Date (java.util.Date)2 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)2 ResolutionStatus (org.akaza.openclinica.bean.core.ResolutionStatus)2 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)2 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)2 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)2 StudyGroupClassBean (org.akaza.openclinica.bean.managestudy.StudyGroupClassBean)2 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)2 SubjectGroupMapBean (org.akaza.openclinica.bean.submit.SubjectGroupMapBean)2 SubjectSDVContainer (org.akaza.openclinica.controller.helper.table.SubjectSDVContainer)2