use of io.lumeer.engine.api.event.CreateOrUpdatePayment in project engine by Lumeer.
the class MongoPaymentDao method updatePayment.
private Payment updatePayment(final Organization organization, final Payment payment, final Bson filter) {
FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER);
try {
Bson update = new Document("$set", payment).append("$inc", new Document(PaymentCodec.VERSION, 1L));
final Payment returnedPayment = databaseCollection(organization).findOneAndUpdate(filter, update, options);
if (returnedPayment == null) {
throw new StorageException("Payment '" + payment.getId() + "' has not been updated.");
}
if (createOrUpdatePaymentEvent != null) {
createOrUpdatePaymentEvent.fire(new CreateOrUpdatePayment(organization, returnedPayment));
}
return returnedPayment;
} catch (MongoException ex) {
throw new StorageException("Cannot update payment " + payment, ex);
}
}
use of io.lumeer.engine.api.event.CreateOrUpdatePayment in project engine by Lumeer.
the class MongoPaymentDao method updatePayment.
private Payment updatePayment(final String organizationId, final Payment payment, final Bson filter) {
FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER);
try {
Bson update = new Document("$set", payment).append("$inc", new Document(PaymentCodec.VERSION, 1L));
final Payment returnedPayment = databaseCollection(organizationId).findOneAndUpdate(filter, update, options);
if (returnedPayment == null) {
throw new StorageException("Payment '" + payment.getId() + "' has not been updated.");
}
if (createOrUpdatePaymentEvent != null) {
createOrUpdatePaymentEvent.fire(new CreateOrUpdatePayment(organizationId, returnedPayment));
}
return returnedPayment;
} catch (MongoException ex) {
throw new StorageException("Cannot update payment " + payment, ex);
}
}
Aggregations