Search in sources :

Example 31 with SessionState

use of org.openforis.collect.web.session.SessionState in project collect by openforis.

the class DataService method getActiveRecord.

protected CollectRecord getActiveRecord() {
    SessionState sessionState = getSessionState();
    CollectRecord activeRecord = sessionState.getActiveRecord();
    return activeRecord;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord)

Example 32 with SessionState

use of org.openforis.collect.web.session.SessionState in project collect by openforis.

the class DataService method assignOwner.

@Secured(CLEANSING)
public void assignOwner(int recordId, Integer ownerId) throws RecordLockedException, MultipleEditException {
    SessionState sessionState = sessionManager.getSessionState();
    recordManager.assignOwner(sessionState.getActiveSurvey(), recordId, ownerId, sessionState.getUser(), sessionState.getSessionId());
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) Secured(org.springframework.security.access.annotation.Secured)

Example 33 with SessionState

use of org.openforis.collect.web.session.SessionState in project collect by openforis.

the class DataService method moveRecords.

@Secured(CLEANSING)
public SurveyLockingJobProxy moveRecords(String rootEntity, int fromStepNumber, final boolean promote) {
    BulkRecordMoveJob job = collectJobManager.createJob(BulkRecordMoveJob.class);
    SessionState sessionState = getSessionState();
    final String userName = sessionState.getUser().getUsername();
    job.setSurvey(sessionState.getActiveSurvey());
    job.setRootEntity(rootEntity);
    job.setPromote(promote);
    final Step fromStep = Step.valueOf(fromStepNumber);
    job.setFromStep(fromStep);
    job.setUser(sessionState.getUser());
    job.setRecordMovedCallback(new BulkRecordMoveJob.Callback() {

        @Override
        public void recordMoved(CollectRecord record) {
            if (promote) {
                publishRecordPromotedEvents(record, userName);
            } else {
                publishRecordDeletedEvent(record, fromStep.toRecordStep(), userName);
            }
        }
    });
    collectJobManager.startSurveyJob(job);
    return new SurveyLockingJobProxy(job);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) SurveyLockingJobProxy(org.openforis.collect.remoting.service.concurrency.proxy.SurveyLockingJobProxy) BulkRecordMoveJob(org.openforis.collect.io.data.BulkRecordMoveJob) Secured(org.springframework.security.access.annotation.Secured)

Example 34 with SessionState

use of org.openforis.collect.web.session.SessionState 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)

Example 35 with SessionState

use of org.openforis.collect.web.session.SessionState in project collect by openforis.

the class ModelService method getActiveLanguageCode.

protected String getActiveLanguageCode() {
    SessionState sessionState = sessionManager.getSessionState();
    Locale locale = sessionState.getLocale();
    String lang;
    if (locale != null) {
        lang = locale.getLanguage();
    } else {
        lang = "en";
    }
    return lang;
}
Also used : Locale(java.util.Locale) SessionState(org.openforis.collect.web.session.SessionState)

Aggregations

SessionState (org.openforis.collect.web.session.SessionState)44 CollectSurvey (org.openforis.collect.model.CollectSurvey)18 User (org.openforis.collect.model.User)16 CollectRecord (org.openforis.collect.model.CollectRecord)15 Secured (org.springframework.security.access.annotation.Secured)13 Step (org.openforis.collect.model.CollectRecord.Step)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 RecordFilter (org.openforis.collect.model.RecordFilter)7 Locale (java.util.Locale)5 RecordStep (org.openforis.collect.event.RecordStep)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 File (java.io.File)3 HashMap (java.util.HashMap)3 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)3 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)3 Transactional (org.springframework.transaction.annotation.Transactional)3 IOException (java.io.IOException)2 Date (java.util.Date)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 BulkRecordMoveJob (org.openforis.collect.io.data.BulkRecordMoveJob)2