Search in sources :

Example 1 with RecordProxy

use of org.openforis.collect.model.proxy.RecordProxy 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 RecordProxy

use of org.openforis.collect.model.proxy.RecordProxy in project collect by openforis.

the class DataService method createRecord.

@Secured(ENTRY)
public RecordProxy createRecord(String rootEntityName, String versionName, Step recordStep) throws RecordPersistenceException, RecordIndexException {
    SessionState sessionState = sessionManager.getSessionState();
    if (sessionState.isActiveRecordBeingEdited()) {
        throw new MultipleEditException();
    }
    CollectSurvey activeSurvey = sessionState.getActiveSurvey();
    User user = sessionState.getUser();
    CollectRecord record = recordManager.instantiateRecord(activeSurvey, rootEntityName, user, versionName, recordStep);
    NodeChangeSet changeSet = recordManager.initializeRecord(record);
    List<RecordEvent> events = new EventProducer().produceFor(changeSet, user.getUsername());
    sessionManager.onEvents(events);
    sessionManager.setActiveRecord(record);
    prepareRecordIndexing();
    RecordProxy recordProxy = new RecordProxy(record, getProxyContext(), true);
    return recordProxy;
}
Also used : SessionState(org.openforis.collect.web.session.SessionState) CollectRecord(org.openforis.collect.model.CollectRecord) NodeChangeSet(org.openforis.collect.model.NodeChangeSet) RecordProxy(org.openforis.collect.model.proxy.RecordProxy) User(org.openforis.collect.model.User) EventProducer(org.openforis.collect.event.EventProducer) MultipleEditException(org.openforis.collect.persistence.MultipleEditException) RecordEvent(org.openforis.collect.event.RecordEvent) CollectSurvey(org.openforis.collect.model.CollectSurvey) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

RecordProxy (org.openforis.collect.model.proxy.RecordProxy)2 Locale (java.util.Locale)1 ProxyContext (org.openforis.collect.ProxyContext)1 EventProducer (org.openforis.collect.event.EventProducer)1 RecordEvent (org.openforis.collect.event.RecordEvent)1 CollectRecord (org.openforis.collect.model.CollectRecord)1 CollectSurvey (org.openforis.collect.model.CollectSurvey)1 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)1 User (org.openforis.collect.model.User)1 MultipleEditException (org.openforis.collect.persistence.MultipleEditException)1 SessionState (org.openforis.collect.web.session.SessionState)1 Secured (org.springframework.security.access.annotation.Secured)1