Search in sources :

Example 11 with RecordEvent

use of org.openforis.collect.event.RecordEvent 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

RecordEvent (org.openforis.collect.event.RecordEvent)11 EventProducer (org.openforis.collect.event.EventProducer)8 CollectRecord (org.openforis.collect.model.CollectRecord)6 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)6 CollectSurvey (org.openforis.collect.model.CollectSurvey)3 Value (org.openforis.idm.model.Value)3 Transactional (org.springframework.transaction.annotation.Transactional)3 UpdateAttributeCommand (org.openforis.collect.command.UpdateAttributeCommand)2 RecordTransaction (org.openforis.collect.event.RecordTransaction)2 User (org.openforis.collect.model.User)2 MultipleEditException (org.openforis.collect.persistence.MultipleEditException)2 Secured (org.springframework.security.access.annotation.Secured)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Connection (java.sql.Connection)1 ArrayList (java.util.ArrayList)1 RecordStep (org.openforis.collect.event.RecordStep)1 RecordIndexException (org.openforis.collect.manager.RecordIndexException)1 RecordPromoteException (org.openforis.collect.manager.RecordPromoteException)1 NodeChangeSetProxy (org.openforis.collect.model.proxy.NodeChangeSetProxy)1