Search in sources :

Example 36 with SessionState

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

the class SessionService method initSession.

/**
 * Set a locale (language, country) into the session state object
 *
 * @return map with user, sessionId
 * @throws DatabaseVersionNotCompatibleException
 */
// @Secured("isAuthenticated()")
public Map<String, Object> initSession(String locale) throws DatabaseVersionNotCompatibleException {
    databaseVersionManager.checkIsVersionCompatible();
    sessionManager.setLocale(locale);
    SessionState sessionState = sessionManager.getSessionState();
    User user = sessionState.getUser();
    UserProxy userProxy = new UserProxy(user);
    String sessionId = sessionState.getSessionId();
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("user", userProxy);
    result.put("sessionId", sessionId);
    return result;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) User(org.openforis.collect.model.User) HashMap(java.util.HashMap) UserProxy(org.openforis.collect.model.proxy.UserProxy)

Example 37 with SessionState

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

the class SessionService method setActiveSurvey.

protected SurveyProxy setActiveSurvey(CollectSurvey survey, boolean work) {
    SessionState sessionState = sessionManager.getSessionState();
    sessionState.setActiveSurvey(survey);
    sessionState.setActiveSurveyWork(work);
    SurveyProxy proxy = new SurveyProxy(survey);
    return proxy;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) SurveyProxy(org.openforis.collect.metamodel.proxy.SurveyProxy)

Example 38 with SessionState

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

the class UserSessionService method changePassword.

public OperationResult changePassword(String oldPassword, String newPassword) throws UserPersistenceException {
    SessionState sessionState = sessionManager.getSessionState();
    User currentUser = sessionState.getUser();
    return userManager.changePassword(currentUser.getUsername(), oldPassword, newPassword);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) User(org.openforis.collect.model.User)

Example 39 with SessionState

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

the class BackupRestoreController method createRecordFilter.

private RecordFilter createRecordFilter(CollectSurvey survey, Integer rootEntityId, boolean onlyOwnedRecords, String[] rootEntityKeyValues) {
    RecordFilter recordFilter = new RecordFilter(survey, rootEntityId);
    // filter by record owner
    if (onlyOwnedRecords) {
        SessionState sessionState = sessionManager.getSessionState();
        User user = sessionState.getUser();
        recordFilter.setOwnerId(user.getId());
    }
    // filter by root entity keys
    recordFilter.setKeyValues(rootEntityKeyValues);
    return recordFilter;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) User(org.openforis.collect.model.User) RecordFilter(org.openforis.collect.model.RecordFilter)

Example 40 with SessionState

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

the class SessionManager method setLocale.

public void setLocale(String localeStr) {
    Locale locale = toLocale(localeStr);
    SessionState sessionState = getSessionState();
    sessionState.setLocale(locale);
}
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