use of org.openforis.collect.ProxyContext in project collect by openforis.
the class RecordController method toProxy.
private RecordProxy toProxy(CollectRecord record) {
String defaultLanguage = record.getSurvey().getDefaultLanguage();
Locale locale = new Locale(defaultLanguage);
ProxyContext context = new ProxyContext(locale, messageSource, surveyContext);
return new RecordProxy(record, context);
}
use of org.openforis.collect.ProxyContext 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