use of io.lumeer.engine.api.event.CreateOrUpdateSequence in project engine by Lumeer.
the class MongoSequenceDao method updateSequence.
private Sequence updateSequence(final Sequence sequence, final Bson filter) {
FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER);
try {
Bson update = new Document("$set", sequence);
final Sequence returnedSequence = databaseCollection().findOneAndUpdate(filter, update, options);
if (returnedSequence == null) {
throw new StorageException("Sequence '" + sequence.getId() + "' has not been updated.");
}
if (createOrUpdateSequenceEvent != null) {
createOrUpdateSequenceEvent.fire(new CreateOrUpdateSequence(returnedSequence));
}
return returnedSequence;
} catch (MongoException ex) {
throw new StorageException("Cannot update sequence " + sequence, ex);
}
}
Aggregations