Search in sources :

Example 1 with RowSelect

use of org.jmesa.limit.RowSelect in project OpenClinica by OpenClinica.

the class ViewNotesFilterCriteria method buildFilterCriteria.

public static ViewNotesFilterCriteria buildFilterCriteria(Limit limit, String datePattern, Map<String, String> discrepancyNoteTypeDecoder, Map<String, String> resolutionTypeDecoder) {
    ViewNotesFilterCriteria criteria = new ViewNotesFilterCriteria();
    FilterSet filterSet = limit.getFilterSet();
    if (filterSet != null) {
        DateFormat df = new SimpleDateFormat(datePattern);
        for (Filter filter : filterSet.getFilters()) {
            String columnName = filter.getProperty();
            String filterName = FILTER_BY_TABLE_COLUMN.get(columnName);
            if (filterName == null) {
                throw new IllegalArgumentException("No query fragment available for column '" + columnName + "'");
            }
            String value = filter.getValue();
            if (filterName.equals("discrepancy_note_type_id")) {
                value = discrepancyNoteTypeDecoder.get(value);
            } else if (filterName.equals("resolution_status_id")) {
                value = resolutionTypeDecoder.get(value);
            }
            criteria.getFilters().put(filterName, processValue(filterName, value, df));
        }
    }
    RowSelect rowSelect = limit.getRowSelect();
    if (rowSelect != null) {
        criteria.pageNumber = rowSelect.getPage();
        criteria.pageSize = rowSelect.getMaxRows();
    }
    return criteria;
}
Also used : RowSelect(org.jmesa.limit.RowSelect) FilterSet(org.jmesa.limit.FilterSet) Filter(org.jmesa.limit.Filter) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with RowSelect

use of org.jmesa.limit.RowSelect in project OpenClinica by OpenClinica.

the class AbstractTableFactory method getRowSelects.

private ArrayList<RowSelect> getRowSelects(int size) {
    ArrayList<RowSelect> rowSelects = new ArrayList<RowSelect>();
    int i = 0;
    for (i = 0; i < size / 50; i++) {
        RowSelect rowSelect = new RowSelectImpl(i + 1, 50, size);
        rowSelects.add(rowSelect);
    }
    if (size % 50 > 0) {
        RowSelect rowSelect = new RowSelectImpl(i + 1, size % 50, size);
        rowSelects.add(rowSelect);
    }
    return rowSelects;
}
Also used : RowSelectImpl(org.jmesa.limit.RowSelectImpl) RowSelect(org.jmesa.limit.RowSelect) ArrayList(java.util.ArrayList)

Example 3 with RowSelect

use of org.jmesa.limit.RowSelect in project OpenClinica by OpenClinica.

the class AbstractTableFactory method createLimits.

private ArrayList<Limit> createLimits() {
    Limit limit = new LimitImpl(getTableName());
    ArrayList<Limit> limits = new ArrayList<Limit>();
    int size = getSize(limit);
    for (RowSelect rowSelect : getRowSelects(size)) {
        Limit theLimit = new LimitImpl(getTableName());
        theLimit.setRowSelect(rowSelect);
        theLimit.setExportType(ExportType.CSV);
        limits.add(theLimit);
    }
    return limits;
}
Also used : RowSelect(org.jmesa.limit.RowSelect) ArrayList(java.util.ArrayList) Limit(org.jmesa.limit.Limit) LimitImpl(org.jmesa.limit.LimitImpl)

Aggregations

RowSelect (org.jmesa.limit.RowSelect)3 ArrayList (java.util.ArrayList)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Filter (org.jmesa.limit.Filter)1 FilterSet (org.jmesa.limit.FilterSet)1 Limit (org.jmesa.limit.Limit)1 LimitImpl (org.jmesa.limit.LimitImpl)1 RowSelectImpl (org.jmesa.limit.RowSelectImpl)1