@ Override public boolean commit ( ) { final CoreRemoteMongoCollection < DocumentT > collection = getCollection ( ) ; final List < WriteModel < DocumentT > > writeModels = getBulkWriteModels ( ) ; // define success as any one operation succeeding for now boolean success = true ; for ( final WriteModel < DocumentT > write : writeModels ) { if ( write instanceof ReplaceOneModel ) { final ReplaceOneModel < DocumentT > replaceModel = ( ( ReplaceOneModel ) write ) ; final RemoteUpdateResult result = collection . updateOne ( replaceModel . getFilter ( ) , ( Bson ) replaceModel . getReplacement ( ) ) ; success = success && ( result != null && result . getModifiedCount ( ) == result . getMatchedCount ( ) ) ; } else if ( write instanceof UpdateOneModel ) { final UpdateOneModel < DocumentT > updateModel = ( ( UpdateOneModel ) write ) ; final RemoteUpdateResult result = collection . updateOne ( updateModel . getFilter ( ) , updateModel . getUpdate ( ) ) ; success = success && ( result != null && result . getModifiedCount ( ) == result . getMatchedCount ( ) ) ; } else if ( write instanceof UpdateManyModel ) { final UpdateManyModel < DocumentT > updateModel = ( ( UpdateManyModel ) write ) ; final RemoteUpdateResult result = collection . updateMany ( updateModel . getFilter ( ) , updateModel . getUpdate ( ) ) ; success = success && ( result != null && result . getModifiedCount ( ) == result . getMatchedCount ( ) ) ; } } return success ; }
Commits the writes to the remote collection .