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;
}
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;
}
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;
}
Aggregations