Search in sources :

Example 1 with ProxyContext

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);
}
Also used : Locale(java.util.Locale) RecordProxy(org.openforis.collect.model.proxy.RecordProxy) ProxyContext(org.openforis.collect.ProxyContext)

Example 2 with ProxyContext

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;
}
Also used : Locale(java.util.Locale) SessionState(org.openforis.collect.web.session.SessionState) ProxyContext(org.openforis.collect.ProxyContext) HashMap(java.util.HashMap) RecordSummaryProxy(org.openforis.collect.model.proxy.RecordSummaryProxy) CollectRecordSummary(org.openforis.collect.model.CollectRecordSummary) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

Locale (java.util.Locale)2 ProxyContext (org.openforis.collect.ProxyContext)2 HashMap (java.util.HashMap)1 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 RecordFilter (org.openforis.collect.model.RecordFilter)1 RecordProxy (org.openforis.collect.model.proxy.RecordProxy)1 RecordSummaryProxy (org.openforis.collect.model.proxy.RecordSummaryProxy)1 SessionState (org.openforis.collect.web.session.SessionState)1 Secured (org.springframework.security.access.annotation.Secured)1