use of org.openforis.collect.model.proxy.RecordSummaryProxy in project collect by openforis.
the class DataService method loadRecordSummaries.
/**
* @param rootEntityName
* @param offset
* @param toIndex
* @param orderByFieldName
* @param filter
*
* @return map with "count" and "records" items
*/
@Secured(USER)
public Map<String, Object> loadRecordSummaries(String rootEntityName, int offset, int maxNumberOfRows, List<RecordSummarySortField> sortFields, String[] keyValues) {
Map<String, Object> result = new HashMap<String, Object>();
SessionState sessionState = sessionManager.getSessionState();
CollectSurvey activeSurvey = sessionState.getActiveSurvey();
Schema schema = activeSurvey.getSchema();
EntityDefinition rootEntityDefinition = schema.getRootEntityDefinition(rootEntityName);
RecordFilter filter = new RecordFilter(activeSurvey, rootEntityDefinition.getId());
filter.setKeyValues(keyValues);
filter.setOffset(offset);
filter.setMaxNumberOfRecords(maxNumberOfRows);
// load summaries
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, getProxyContext());
result.put("records", proxies);
// count total records
int count = recordManager.countRecords(filter);
result.put("count", count);
return result;
}
use of org.openforis.collect.model.proxy.RecordSummaryProxy in project collect by openforis.
the class DataService method loadRecordSummaries.
@Secured(USER)
public Map<String, Object> loadRecordSummaries(RecordFilterProxy filterProxy, List<RecordSummarySortField> sortFields, String localeStr) {
Map<String, Object> result = new HashMap<String, Object>();
CollectSurvey survey;
if (filterProxy.getSurveyId() > 0) {
survey = surveyManager.getById(filterProxy.getSurveyId());
} else {
SessionState sessionState = sessionManager.getSessionState();
survey = sessionState.getActiveSurvey();
}
RecordFilter filter = filterProxy.toFilter(survey);
// load summaries
List<CollectRecordSummary> summaries = recordManager.loadSummaries(filter, sortFields);
Locale locale = LocaleUtils.toLocale(localeStr);
ProxyContext proxyContext = new ProxyContext(locale, messageSource, surveyContext);
List<RecordSummaryProxy> proxies = RecordSummaryProxy.fromList(summaries, proxyContext);
result.put("records", proxies);
// count total records
int count = recordManager.countRecords(filter);
result.put("count", count);
return result;
}
Aggregations