public void commit(Saga saga) {
if (!saga.isActive()) {
deleteSaga(saga);
} else {
final String sagaType = typeOf(saga.getClass());
final AssociationValues associationValues = saga.getAssociationValues();
for (AssociationValue associationValue : associationValues.addedAssociations()) {
storeAssociationValue(associationValue, sagaType, saga.getSagaIdentifier());
}
for (AssociationValue associationValue : associationValues.removedAssociations()) {
removeAssociationValue(associationValue, sagaType, saga.getSagaIdentifier());
}
associationValues.commit();
updateSaga(saga);
}
}