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