Search in sources :

Example 6 with User

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

the class DataService method checkoutRecord.

@Secured(ENTRY_LIMITED)
public RecordProxy checkoutRecord(int id, Integer stepNumber, boolean forceUnlock) throws RecordPersistenceException, RecordIndexException {
    SessionState sessionState = sessionManager.getSessionState();
    if (sessionState.isActiveRecordBeingEdited()) {
        throw new MultipleEditException();
    }
    final CollectSurvey survey = sessionState.getActiveSurvey();
    User user = sessionState.getUser();
    Step step = stepNumber == null ? null : Step.valueOf(stepNumber);
    CollectRecord record = step == null ? recordManager.checkout(survey, user, id, sessionState.getSessionId(), forceUnlock) : recordManager.checkout(survey, user, id, step, sessionState.getSessionId(), forceUnlock);
    sessionManager.setActiveRecord(record);
    prepareRecordIndexing();
    return toProxy(record);
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) User(org.openforis.collect.model.User) MultipleEditException(org.openforis.collect.persistence.MultipleEditException) RecordStep(org.openforis.collect.event.RecordStep) Step(org.openforis.collect.model.CollectRecord.Step) CollectSurvey(org.openforis.collect.model.CollectSurvey) Secured(org.springframework.security.access.annotation.Secured)

Example 7 with User

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

the class ModelService method getSurveySummaries.

public List<SurveySummary> getSurveySummaries() {
    String lang = getActiveLanguageCode();
    User loggedUser = sessionManager.getLoggedUser();
    List<SurveySummary> summaries = surveyManager.getSurveySummaries(lang, loggedUser);
    return summaries;
}
Also used : User(org.openforis.collect.model.User) SurveySummary(org.openforis.collect.model.SurveySummary)

Example 8 with User

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

the class UserService method save.

public UserProxy save(UserProxy user) throws UserPersistenceException {
    User u = user.toUser();
    userManager.save(u, sessionManager.getLoggedUser());
    UserProxy proxy = new UserProxy(u);
    return proxy;
}
Also used : User(org.openforis.collect.model.User) UserProxy(org.openforis.collect.model.proxy.UserProxy)

Example 9 with User

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

the class UserProxy method toUser.

public User toUser() {
    User user = super.toUser();
    user.setPassword(password);
    user.setRawPassword(rawPassword);
    user.setRoles(getRolesFromCodes(roles));
    return user;
}
Also used : User(org.openforis.collect.model.User)

Example 10 with User

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

the class DataHandler method startRecord.

public void startRecord(String localName, Attributes attributes) {
    String versionName = extractVersionName(attributes);
    record = new CollectRecord(currentSurvey, versionName, localName, validationEnabled);
    String stateAttr = attributes.getValue(ATTRIBUTE_STATE);
    State state = State.fromCode(stateAttr);
    record.setState(state);
    Date created = Dates.parseDateTime(attributes.getValue(ATTRIBUTE_DATE_CREATED));
    Date modified = Dates.parseDateTime(attributes.getValue(ATTRIBUTE_DATE_MODIFIED));
    record.setCreationDate(created);
    record.setModifiedDate(modified);
    String createdByUserName = attributes.getValue(ATTRIBUTE_CREATED_BY);
    User createdBy = fetchUser(createdByUserName);
    record.setCreatedBy(createdBy);
    String modifiedByUserName = attributes.getValue(ATTRIBUTE_MODIFIED_BY);
    User modifiedBy = fetchUser(modifiedByUserName);
    record.setModifiedBy(modifiedBy);
    node = record.getRootEntity();
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) User(org.openforis.collect.model.User) State(org.openforis.collect.model.CollectRecord.State) Date(java.util.Date)

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