Search in sources :

Example 26 with User

use of org.openforis.collect.model.User in project collect by openforis.

the class ClientUserManager method insertUser.

@Override
public User insertUser(String name, String rawPassword, UserRole role, User createdByUser) throws UserPersistenceException {
    User user = new User(name);
    user.setRawPassword(rawPassword);
    user.addRole(role);
    save(user, createdByUser);
    return user;
}
Also used : User(org.openforis.collect.model.User)

Example 27 with User

use of org.openforis.collect.model.User in project collect by openforis.

the class RandomRecordGenerator method generate.

@Transactional
public CollectRecord generate(int surveyId, NewRecordParameters parameters) {
    CollectSurvey survey = surveyManager.getById(surveyId);
    User user = loadUser(parameters.getUserId(), parameters.getUsername());
    RecordKey recordKey = provideRandomRecordKey(survey, user, parameters.isOnlyUnanalyzedSamplingPoints());
    if (recordKey == null) {
        return null;
    }
    return this.generate(surveyId, parameters, recordKey);
}
Also used : User(org.openforis.collect.model.User) CollectSurvey(org.openforis.collect.model.CollectSurvey) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with User

use of org.openforis.collect.model.User in project collect by openforis.

the class SurveySelectVM method performSurveyPublishing.

protected void performSurveyPublishing(CollectSurvey survey, Binder binder) {
    try {
        User loggedUser = getLoggedUser();
        surveyManager.publish(survey, loggedUser);
        selectedSurvey = null;
        notifyChange("selectedSurvey");
        reloadSurveySummaries(binder);
        MessageUtil.showInfo("survey.successfully_published", survey.getName());
        surveyManager.validateRecords(survey.getId(), loggedUser);
    } catch (SurveyStoreException e) {
        throw new RuntimeException(e);
    }
}
Also used : User(org.openforis.collect.model.User) SurveyStoreException(org.openforis.collect.persistence.SurveyStoreException)

Example 29 with User

use of org.openforis.collect.model.User in project collect by openforis.

the class LocalUserManager method insertUser.

/**
 * Inserts a new user with name, password and role as specified.
 * @return
 *
 * @throws UserPersistenceException
 */
@Override
@Transactional(readOnly = false, propagation = REQUIRED)
public User insertUser(String name, String password, UserRole role, User createdByUser) throws UserPersistenceException {
    User user = new User(name);
    user.setRawPassword(password);
    user.addRole(role);
    save(user, createdByUser);
    return user;
}
Also used : User(org.openforis.collect.model.User) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with User

use of org.openforis.collect.model.User in project collect by openforis.

the class LocalUserManager method verifyPassword.

@Override
public boolean verifyPassword(String username, String password) {
    User user = userDao.loadByUserName(username, true);
    String encodedPassword = encodePassword(password);
    return user.getPassword().equals(encodedPassword);
}
Also used : User(org.openforis.collect.model.User)

Aggregations

User (org.openforis.collect.model.User)71 CollectRecord (org.openforis.collect.model.CollectRecord)19 CollectSurvey (org.openforis.collect.model.CollectSurvey)19 SessionState (org.openforis.collect.web.session.SessionState)16 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)12 Transactional (org.springframework.transaction.annotation.Transactional)11 RecordFilter (org.openforis.collect.model.RecordFilter)10 Test (org.junit.Test)8 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)6 RecordUpdater (org.openforis.collect.model.RecordUpdater)6 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)5 Date (java.util.Date)4 UserGroup (org.openforis.collect.model.UserGroup)4 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)4 Secured (org.springframework.security.access.annotation.Secured)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 RecordStep (org.openforis.collect.event.RecordStep)3 Step (org.openforis.collect.model.CollectRecord.Step)3