Search in sources :

Example 1 with EventProducer

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

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

use of org.openforis.collect.event.EventProducer 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 4 with EventProducer

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

Example 5 with EventProducer

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

the class RecordController 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)

Aggregations

EventProducer (org.openforis.collect.event.EventProducer)8 RecordEvent (org.openforis.collect.event.RecordEvent)8 CollectRecord (org.openforis.collect.model.CollectRecord)6 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)6 Value (org.openforis.idm.model.Value)3 RecordTransaction (org.openforis.collect.event.RecordTransaction)2 CollectSurvey (org.openforis.collect.model.CollectSurvey)2 User (org.openforis.collect.model.User)2 MultipleEditException (org.openforis.collect.persistence.MultipleEditException)2 Secured (org.springframework.security.access.annotation.Secured)2 RecordIndexException (org.openforis.collect.manager.RecordIndexException)1 RecordPromoteException (org.openforis.collect.manager.RecordPromoteException)1 NodeChangeSetProxy (org.openforis.collect.model.proxy.NodeChangeSetProxy)1 RecordProxy (org.openforis.collect.model.proxy.RecordProxy)1 RecordLockedException (org.openforis.collect.persistence.RecordLockedException)1 RecordPersistenceException (org.openforis.collect.persistence.RecordPersistenceException)1 RecordUnlockedException (org.openforis.collect.persistence.RecordUnlockedException)1 SessionState (org.openforis.collect.web.session.SessionState)1 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)1 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)1