Search in sources :

Example 1 with RecordEvent

use of org.openforis.collect.event.RecordEvent in project collect by openforis.

the class DataService method publishRecordPromotedEvents.

private void publishRecordPromotedEvents(CollectRecord record, String userName) {
    if (!eventQueue.isEnabled()) {
        return;
    }
    List<RecordEvent> events = new EventProducer().produceFor(record, userName);
    eventQueue.publish(new RecordTransaction(record.getSurvey().getName(), record.getId(), record.getStep().toRecordStep(), events));
}
Also used : EventProducer(org.openforis.collect.event.EventProducer) RecordEvent(org.openforis.collect.event.RecordEvent) RecordTransaction(org.openforis.collect.event.RecordTransaction)

Example 2 with RecordEvent

use of org.openforis.collect.event.RecordEvent in project collect by openforis.

the class DataService method updateActiveRecord.

@Transactional
@Secured(ENTRY_LIMITED)
public NodeChangeSetProxy updateActiveRecord(NodeUpdateRequestSetProxy requestSet) throws RecordPersistenceException, RecordIndexException {
    sessionManager.checkIsActiveRecordLocked();
    CollectRecord activeRecord = getActiveRecord();
    NodeUpdateRequestSet reqSet = requestSet.toNodeUpdateRequestSet(codeListManager, sessionManager, activeRecord);
    NodeChangeSet changeSet = updateRecord(activeRecord, reqSet);
    if (!changeSet.isEmpty() && isCurrentRecordIndexable()) {
        recordIndexService.temporaryIndex(activeRecord);
    }
    String userName = sessionManager.getSessionState().getUser().getUsername();
    List<RecordEvent> events = new EventProducer().produceFor(changeSet, userName);
    sessionManager.onEvents(events);
    NodeChangeSetProxy result = new NodeChangeSetProxy(activeRecord, changeSet, getProxyContext());
    if (requestSet.isAutoSave()) {
        try {
            saveActiveRecord();
            result.setRecordSaved(true);
        } catch (Exception e) {
            result.setRecordSaved(false);
        }
    }
    return result;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) NodeChangeSet(org.openforis.collect.model.NodeChangeSet) EventProducer(org.openforis.collect.event.EventProducer) RecordEvent(org.openforis.collect.event.RecordEvent) NodeChangeSetProxy(org.openforis.collect.model.proxy.NodeChangeSetProxy) RecordPromoteException(org.openforis.collect.manager.RecordPromoteException) RecordUnlockedException(org.openforis.collect.persistence.RecordUnlockedException) RecordIndexException(org.openforis.collect.manager.RecordIndexException) RecordLockedException(org.openforis.collect.persistence.RecordLockedException) MultipleEditException(org.openforis.collect.persistence.MultipleEditException) RecordPersistenceException(org.openforis.collect.persistence.RecordPersistenceException) Secured(org.springframework.security.access.annotation.Secured) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with RecordEvent

use of org.openforis.collect.event.RecordEvent in project collect by openforis.

the class RDBReportingRepositories method process.

@Override
public void process(final RecordTransaction recordTransaction) {
    final RelationalSchema rdbSchema = getRelatedRelationalSchema(recordTransaction);
    final CollectSurvey survey = (CollectSurvey) rdbSchema.getSurvey();
    RecordStep step = recordTransaction.getRecordStep();
    withConnection(survey.getName(), step, new Callback() {

        public void execute(Connection connection) {
            RDBUpdater rdbUpdater = createRDBUpdater(rdbSchema, connection);
            for (RecordEvent recordEvent : recordTransaction.getEvents()) {
                EventHandler handler = new EventHandler(recordEvent, rdbSchema, survey, rdbUpdater);
                handler.handle();
            }
        }
    });
}
Also used : RecordStep(org.openforis.collect.event.RecordStep) Connection(java.sql.Connection) RecordEvent(org.openforis.collect.event.RecordEvent) CollectSurvey(org.openforis.collect.model.CollectSurvey) RelationalSchema(org.openforis.collect.relational.model.RelationalSchema)

Example 4 with RecordEvent

use of org.openforis.collect.event.RecordEvent in project collect by openforis.

the class AddNodeCommandHandler method execute.

@Override
public List<RecordEvent> execute(C command) {
    CollectRecord record = findRecord(command);
    Entity parentEntity = record.findNodeByPath(command.getParentEntityPath());
    NodeDefinition nodeDef = parentEntity.getDefinition().getChildDefinition(command.getNodeDefId());
    NodeChangeSet changeSet = recordUpdater.addNode(parentEntity, nodeDef);
    recordManager.save(record);
    List<RecordEvent> events = new EventProducer().produceFor(changeSet, command.getUsername());
    return events;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) Entity(org.openforis.idm.model.Entity) NodeChangeSet(org.openforis.collect.model.NodeChangeSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) EventProducer(org.openforis.collect.event.EventProducer) RecordEvent(org.openforis.collect.event.RecordEvent)

Example 5 with RecordEvent

use of org.openforis.collect.event.RecordEvent in project collect by openforis.

the class UpdateAttributeCommandHandler method execute.

@Override
public List<RecordEvent> execute(UpdateAttributeCommand command) {
    CollectRecord record = findRecord(command);
    Attribute<?, Value> attribute = findAttribute(command, record);
    Value value = extractValue(command);
    NodeChangeSet changeSet = recordUpdater.updateAttribute(attribute, value);
    recordManager.save(record);
    List<RecordEvent> events = new EventProducer().produceFor(changeSet, command.getUsername());
    return events;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) NodeChangeSet(org.openforis.collect.model.NodeChangeSet) BooleanValue(org.openforis.idm.model.BooleanValue) Value(org.openforis.idm.model.Value) EventProducer(org.openforis.collect.event.EventProducer) RecordEvent(org.openforis.collect.event.RecordEvent)

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