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));
}
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;
}
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;
}
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;
}
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));
}
Aggregations