public class

MongoCloudConnector

extends Object
java.lang.Object
   ↳ org.mule.module.mongo.MongoCloudConnector
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

MongoDB is an open source, high-performance, schema-free, document-oriented database that manages collections of BSON documents.

Summary

Constants
String BACKUP_THREADS
String CAPPED_DEFAULT_VALUE
String DEFAULT_OUTPUT_DIRECTORY
String WRITE_CONCERN_DEFAULT_VALUE
Fields
private Boolean autoConnectRetry This controls whether the system retries automatically on connection errors.
private MongoClient client
private Integer connectTimeout The connection timeout in milliseconds; this is for establishing the socket connections (open).
public Integer connectionsPerHost The number of connections allowed per host (the pool size, per host)
private String database
private String host The host of the Mongo server, it can also be a list of comma separated hosts for replicas
private static final Logger logger
public Integer maxWaitTime The max wait time for a blocking thread for a connection from the pool in ms.
private Mongo mongo
private int port The port of the Mongo server
private Integer socketTimeout The socket timeout.
public Integer threadsAllowedToBlockForConnectionMultiplier Multiplier for connectionsPerHost for # of threads that can block
Public Constructors
MongoCloudConnector()
Public Methods
WriteResult addUser(String newUsername, String newPassword)
Adds a new user for this db

static String bsonListToJson(BasicBSONList input)
Convert a BasicBSONList into Json.
void connect(String username, String password, String database)
Method invoked when a MongoSession needs to be created.
String connectionId()
long countObjects(String collection, DBObject query)
Counts the number of objects that match the given query.
long countObjectsUsingQueryMap(String collection, Map<String, Object> queryAttributes)
Counts the number of objects that match the given query.
void createCollection(String collection, boolean capped, Integer maxObjects, Integer size)
Creates a new collection.
DBObject createFileFromPayload(Object payload, String filename, String contentType, DBObject metadata)
Creates a new GridFSFile in the database, saving the given content, filename, contentType, and extraData, and answers it.
void createIndex(String collection, String field, IndexOrder order)
Creates a new index

static Map dbObjectToMap(DBObject input)
Convert a DBObject into Map.
static String dbobjectToJson(DBObject input)
Convert DBObject to Json.
void disconnect()
Method invoked when the MongoSession is to be destroyed.
void dropCollection(String collection)
Deletes a collection and all the objects it contains.
void dropDatabase()
Drop the current database

void dropIndex(String collection, String index)
Drops an existing index

void dump(String outputDirectory, String outputName, boolean zip, boolean oplog, int threads)
Executes a dump of the database to the specified output directory.
void endConsistentRequest()
Ends a consistent request.
DBObject executeCommand(String commandName, String commandValue)
Executes a command on the database

boolean existsCollection(String collection)
Answers if a collection exists given its name

Iterable<DBObject> findFiles(DBObject query)
Lists all the files that match the given query

Iterable<DBObject> findFilesUsingQueryMap(Map<String, Object> queryAttributes)
Lists all the files that match the given query

Iterable<DBObject> findObjects(String collection, DBObject query, List<String> fields, Integer numToSkip, Integer limit, DBObject sortBy)
Finds all objects that match a given query.
Iterable<DBObject> findObjectsUsingQueryMap(String collection, Map<String, Object> queryAttributes, List<String> fields, Integer numToSkip, Integer limit, DBObject sortBy)
Finds all objects that match a given query.
DBObject findOneFile(DBObject query)
Answers the first file that matches the given query.
DBObject findOneFileUsingQueryMap(Map<String, Object> queryAttributes)
Answers the first file that matches the given query.
DBObject findOneObject(String collection, DBObject query, List<String> fields, Boolean failOnNotFound)
Finds the first object that matches a given query.
DBObject findOneObjectUsingQueryMap(String collection, Map<String, Object> queryAttributes, List<String> fields, Boolean failOnNotFound)
Finds the first object that matches a given query.
Boolean getAutoConnectRetry()
Integer getConnectTimeout()
Integer getConnectionsPerHost()
String getDatabase()
InputStream getFileContent(DBObject query)
Answers an inputstream to the contents of the first file that matches the given query.
InputStream getFileContentUsingQueryMap(Map<String, Object> queryAttributes)
Answers an inputstream to the contents of the first file that matches the given queryAttributes.
String getHost()
Integer getMaxWaitTime()
int getPort()
Integer getSocketTimeout()
Integer getThreadsAllowedToBlockForConnectionMultiplier()
void incrementalDump(String outputDirectory, String incrementalTimestampFile)
Executes an incremental dump of the database

String insertObject(String collection, DBObject dbObject, WriteConcern writeConcern)
Inserts an object in a collection, setting its id if necessary.
String insertObjectFromMap(String collection, Map<String, Object> elementAttributes, WriteConcern writeConcern)
Inserts an object in a collection, setting its id if necessary.
boolean isConnected()
static DBObject jsonToDbobject(String input)
Convert JSON to DBObject.
Collection<String> listCollections()
Lists names of collections available at this database

Iterable<DBObject> listFiles(DBObject query)
Lists all the files that match the given query, sorting them by filename.
Iterable<DBObject> listFilesUsingQueryMap(Map<String, Object> queryAttributes)
Lists all the files that match the given query, sorting them by filename.
Collection<DBObject> listIndices(String collection)
List existent indices in a collection

Iterable<DBObject> mapReduceObjects(String collection, String mapFunction, String reduceFunction, String outputCollection)
Transforms a collection into a collection of aggregated groups, by applying a supplied element-mapping function to each element, that transforms each one into a key-value pair, grouping the resulting pairs by key, and finally reducing values in each group applying a suppling 'reduce' function.
static String mongoCollectionToJson(MongoCollection input)
Convert a BasicBSONList into Json.
void removeFiles(DBObject query)
Removes all the files that match the given query.
void removeFilesUsingQueryMap(Map<String, Object> queryAttributes)
Removes all the files that match the given query.
void removeObjects(String collection, DBObject query, WriteConcern writeConcern)
Removes all the objects that match the a given optional query.
void removeObjectsUsingQueryMap(String collection, Map<String, Object> queryAttributes, WriteConcern writeConcern)
Removes all the objects that match the a given optional query.
void restore(String inputPath, boolean drop, boolean oplogReplay)
Takes the output from the dump and restores it.
void saveObject(String collection, DBObject element, WriteConcern writeConcern)
Inserts or updates an object based on its object _id.
void saveObjectFromMap(String collection, Map<String, Object> elementAttributes, WriteConcern writeConcern)
Inserts or updates an object based on its object _id.
void setAutoConnectRetry(Boolean autoConnectRetry)
void setConnectTimeout(Integer connectTimeout)
void setConnectionsPerHost(Integer connectionsPerHost)
void setDatabase(String database)
void setHost(String host)
void setMaxWaitTime(Integer maxWaitTime)
void setPort(int port)
void setSocketTimeout(Integer socketTimeout)
void setThreadsAllowedToBlockForConnectionMultiplier(Integer threadsAllowedToBlockForConnectionMultiplier)
void startConsistentRequest()
Begins a consistent request, which allows you to be sure that each subsequent request to MongoDB happens in sequence.
void updateObjects(String collection, DBObject query, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)
Updates objects that matches the given query.
void updateObjectsByFunction(String collection, String function, DBObject query, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)
Update objects using a mongo function

void updateObjectsByFunctionUsingMap(String collection, String function, Map<String, Object> queryAttributes, Map<String, Object> elementAttributes, boolean upsert, boolean multi, WriteConcern writeConcern)
Update objects using a mongo function

void updateObjectsUsingMap(String collection, Map<String, Object> queryAttributes, Map<String, Object> elementAttributes, boolean upsert, boolean multi, WriteConcern writeConcern)
Updates objects that matches the given query.
void updateObjectsUsingQueryMap(String collection, Map<String, Object> queryAttributes, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)
Updates objects that matches the given query.
Protected Methods
MongoClient adaptClient(MongoClient client)
[Expand]
Inherited Methods
From class java.lang.Object

Constants

private static final String BACKUP_THREADS

Constant Value: "5"

private static final String CAPPED_DEFAULT_VALUE

Constant Value: "false"

private static final String DEFAULT_OUTPUT_DIRECTORY

Constant Value: "dump"

private static final String WRITE_CONCERN_DEFAULT_VALUE

Constant Value: "DATABASE_DEFAULT"

Fields

private Boolean autoConnectRetry

This controls whether the system retries automatically on connection errors.

private MongoClient client

private Integer connectTimeout

The connection timeout in milliseconds; this is for establishing the socket connections (open). 0 is default and infinite.

public Integer connectionsPerHost

The number of connections allowed per host (the pool size, per host)

private String database

private String host

The host of the Mongo server, it can also be a list of comma separated hosts for replicas

private static final Logger logger

public Integer maxWaitTime

The max wait time for a blocking thread for a connection from the pool in ms.

private Mongo mongo

private int port

The port of the Mongo server

private Integer socketTimeout

The socket timeout. 0 is default and infinite.

public Integer threadsAllowedToBlockForConnectionMultiplier

Multiplier for connectionsPerHost for # of threads that can block

Public Constructors

public MongoCloudConnector ()

Public Methods

public WriteResult addUser (String newUsername, String newPassword)

Adds a new user for this db

Parameters
newUsername Name of the user
newPassword Password that will be used for authentication
Returns
  • Result of the operation

public static String bsonListToJson (BasicBSONList input)

Convert a BasicBSONList into Json.

Parameters
input The input for this transformer
Returns
  • the converted string representation

public void connect (String username, String password, String database)

Method invoked when a MongoSession needs to be created.

Parameters
username The username to use for authentication. NOTE: Please use a dummy user if you have disabled Mongo authentication
password The password to use for authentication. If the password is null or whitespaces only the connector won't use authentication.
database Name of the database
Returns
Throws
ConnectionException

public String connectionId ()

public long countObjects (String collection, DBObject query)

Counts the number of objects that match the given query. If no query is passed, returns the number of elements in the collection

Parameters
collection The target collection
query The optional DBObject query for counting objects. Only objects matching it will be counted. If unspecified, all objects are counted.
Returns
  • the amount of objects that matches the query

public long countObjectsUsingQueryMap (String collection, Map<String, Object> queryAttributes)

Counts the number of objects that match the given query. If no query is passed, returns the number of elements in the collection

Parameters
collection The target collection
queryAttributes The optional query for counting objects. Only objects matching it will be counted. If unspecified, all objects are counted.
Returns
  • the amount of objects that matches the query

public void createCollection (String collection, boolean capped, Integer maxObjects, Integer size)

Creates a new collection. If the collection already exists, a MongoException will be thrown.

Parameters
collection The name of the collection to create
capped If the collection will be capped
maxObjects The maximum number of documents the new collection is able to contain
size The maximum size of the new collection

public DBObject createFileFromPayload (Object payload, String filename, String contentType, DBObject metadata)

Creates a new GridFSFile in the database, saving the given content, filename, contentType, and extraData, and answers it.

Parameters
payload The mandatory content of the new gridfs file. It may be a java.io.File, a byte[] or an InputStream.
filename The mandatory name of new file.
contentType The optional content type of the new file
metadata The optional DBObject metadata of the new content type
Returns
  • the new GridFSFile DBObject
Throws
IOException IOException

public void createIndex (String collection, String field, IndexOrder order)

Creates a new index

Parameters
collection The name of the collection where the index will be created
field The name of the field which will be indexed
order The indexing order

public static Map dbObjectToMap (DBObject input)

Convert a DBObject into Map.

Parameters
input The input for this transformer
Returns
  • the converted Map representation

public static String dbobjectToJson (DBObject input)

Convert DBObject to Json.

Parameters
input The input for this transformer
Returns
  • the converted string representation

public void disconnect ()

Method invoked when the MongoSession is to be destroyed.

Throws
IOException in case something goes wrong when disconnecting.

public void dropCollection (String collection)

Deletes a collection and all the objects it contains. If the collection does not exist, does nothing.

Parameters
collection The name of the collection to drop

public void dropDatabase ()

Drop the current database

public void dropIndex (String collection, String index)

Drops an existing index

Parameters
collection The name of the collection where the index is
index The name of the index to drop

public void dump (String outputDirectory, String outputName, boolean zip, boolean oplog, int threads)

Executes a dump of the database to the specified output directory. If no output directory is provided then the default /dump directory is used.

Parameters
outputDirectory Output directory path, if no output directory is provided the default /dump directory is assumed
outputName Output file name, if it's not specified the database name is used
zip Whether to zip the created dump file or not
oplog Point in time backup (requires an oplog)
threads Amount of threads to execute the dump
Throws
IOException if an error occurs during the dump

public void endConsistentRequest ()

Ends a consistent request.

public DBObject executeCommand (String commandName, String commandValue)

Executes a command on the database

Parameters
commandName The command to execute on the database
commandValue The value for the command
Returns
  • The result of the command

public boolean existsCollection (String collection)

Answers if a collection exists given its name

Parameters
collection The name of the collection
Returns
  • if the collection exists

public Iterable<DBObject> findFiles (DBObject query)

Lists all the files that match the given query

Parameters
query A DBObject query the optional query
Returns
  • a DBObject files iterable

public Iterable<DBObject> findFilesUsingQueryMap (Map<String, Object> queryAttributes)

Lists all the files that match the given query

Parameters
queryAttributes The optional query attributes
Returns
  • a DBObject files iterable

public Iterable<DBObject> findObjects (String collection, DBObject query, List<String> fields, Integer numToSkip, Integer limit, DBObject sortBy)

Finds all objects that match a given query. If no query is specified, all objects of the collection are retrieved. If no fields object is specified, all fields are retrieved.

Parameters
collection The target collection
query The optional DBObject query object. If unspecified, all documents are returned.
fields Alternative way of passing fields as a literal List
numToSkip Number of objects skip (offset)
limit Limit of objects to return
sortBy Indicates the DBObject used to sort the results
Returns
  • an iterable of DBObject

public Iterable<DBObject> findObjectsUsingQueryMap (String collection, Map<String, Object> queryAttributes, List<String> fields, Integer numToSkip, Integer limit, DBObject sortBy)

Finds all objects that match a given query. If no query is specified, all objects of the collection are retrieved. If no fields object is specified, all fields are retrieved.

Parameters
collection The target collection
queryAttributes The optional query object. If unspecified, all documents are returned.
fields Alternative way of passing fields as a literal List
numToSkip Number of objects skip (offset)
limit Limit of objects to return
sortBy Indicates the DBObject used to sort the results
Returns
  • an iterable of DBObject

public DBObject findOneFile (DBObject query)

Answers the first file that matches the given query. If no object matches it, a MongoException is thrown.

Parameters
query The DBObject mandatory query
Returns
  • a DBObject

public DBObject findOneFileUsingQueryMap (Map<String, Object> queryAttributes)

Answers the first file that matches the given query. If no object matches it, a MongoException is thrown.

Parameters
queryAttributes The mandatory query
Returns
  • a DBObject

public DBObject findOneObject (String collection, DBObject query, List<String> fields, Boolean failOnNotFound)

Finds the first object that matches a given query. Throws a MongoException if no one matches the given query

Parameters
collection The target collection
query The mandatory DBObject query object that the returned object matches.
fields Alternative way of passing fields as a literal List
failOnNotFound Flag to specify if an exception will be thrown when no object is found. For backward compatibility the default value is true.
Returns
  • a DBObject that matches the query. If nothing matches and the failOnNotFound is set to false, null will be returned

public DBObject findOneObjectUsingQueryMap (String collection, Map<String, Object> queryAttributes, List<String> fields, Boolean failOnNotFound)

Finds the first object that matches a given query. Throws a MongoException if no one matches the given query

Parameters
collection The target collection
queryAttributes The mandatory query object that the returned object matches.
fields Alternative way of passing fields as a literal List
failOnNotFound Flag to specify if an exception will be thrown when no object is found. For backward compatibility the default value is true.
Returns
  • a DBObject that matches the query. If nothing matches and the failOnNotFound is set to false, null will be returned

public Boolean getAutoConnectRetry ()

public Integer getConnectTimeout ()

public Integer getConnectionsPerHost ()

public String getDatabase ()

public InputStream getFileContent (DBObject query)

Answers an inputstream to the contents of the first file that matches the given query. If no object matches it, a MongoException is thrown.

Parameters
query The DBObject mandatory query
Returns
  • an InputStream to the file contents

public InputStream getFileContentUsingQueryMap (Map<String, Object> queryAttributes)

Answers an inputstream to the contents of the first file that matches the given queryAttributes. If no object matches it, a MongoException is thrown.

Parameters
queryAttributes The mandatory query attributes
Returns
  • an InputStream to the file contents

public String getHost ()

public Integer getMaxWaitTime ()

public int getPort ()

public Integer getSocketTimeout ()

public Integer getThreadsAllowedToBlockForConnectionMultiplier ()

public void incrementalDump (String outputDirectory, String incrementalTimestampFile)

Executes an incremental dump of the database

Parameters
outputDirectory Output directory path, if no output directory is provided the default /dump directory is assumed
incrementalTimestampFile File that keeps track of the last timestamp processed, if no file is provided one is created on the output directory
Throws
IOException if an error occurs during the incremental dump

public String insertObject (String collection, DBObject dbObject, WriteConcern writeConcern)

Inserts an object in a collection, setting its id if necessary.

Parameters
collection The name of the collection where to insert the given object
dbObject A DBObject instance.
writeConcern The optional write concern of insertion
Returns
  • the id that was just insterted

public String insertObjectFromMap (String collection, Map<String, Object> elementAttributes, WriteConcern writeConcern)

Inserts an object in a collection, setting its id if necessary.

A shallow conversion into DBObject is performed - that is, no conversion is performed to its values.

Parameters
collection The name of the collection where to insert the given object
elementAttributes Alternative way of specifying the element as a literal Map inside a Mule Flow
writeConcern The optional write concern of insertion
Returns
  • the id that was just insterted

public boolean isConnected ()

public static DBObject jsonToDbobject (String input)

Convert JSON to DBObject.

Parameters
input The input for this transformer
Returns
  • the converted DBObject

public Collection<String> listCollections ()

Lists names of collections available at this database

Returns
  • the list of names of collections available at this database

public Iterable<DBObject> listFiles (DBObject query)

Lists all the files that match the given query, sorting them by filename. If no query is specified, all files are listed.

Parameters
query The DBObject optional query
Returns
  • an iterable of DBObject

public Iterable<DBObject> listFilesUsingQueryMap (Map<String, Object> queryAttributes)

Lists all the files that match the given query, sorting them by filename. If no query is specified, all files are listed.

Parameters
queryAttributes The optional query
Returns
  • an iterable of DBObject

public Collection<DBObject> listIndices (String collection)

List existent indices in a collection

Parameters
collection The name of the collection
Returns
  • a collection of DBObject with indices information

public Iterable<DBObject> mapReduceObjects (String collection, String mapFunction, String reduceFunction, String outputCollection)

Transforms a collection into a collection of aggregated groups, by applying a supplied element-mapping function to each element, that transforms each one into a key-value pair, grouping the resulting pairs by key, and finally reducing values in each group applying a suppling 'reduce' function.

Each supplied function is coded in JavaScript.

Note that the correct way of writing those functions may not be obvious; please consult MongoDB documentation for writing them.

Parameters
collection The name of the collection to map and reduce
mapFunction A JavaScript encoded mapping function
reduceFunction A JavaScript encoded reducing function
outputCollection The name of the output collection to write the results, replacing previous collection if existed, mandatory when results may be larger than 16MB. If outputCollection is unspecified, the computation is performed in-memory and not persisted.
Returns
  • an iterable that retrieves the resulting collection of DBObject

public static String mongoCollectionToJson (MongoCollection input)

Convert a BasicBSONList into Json.

Parameters
input The input for this transformer
Returns
  • the converted string representation

public void removeFiles (DBObject query)

Removes all the files that match the given query. If no query is specified, all files are removed

Parameters
query The DBObject optional query

public void removeFilesUsingQueryMap (Map<String, Object> queryAttributes)

Removes all the files that match the given query. If no query is specified, all files are removed

Parameters
queryAttributes The optional query

public void removeObjects (String collection, DBObject query, WriteConcern writeConcern)

Removes all the objects that match the a given optional query. If query is not specified, all objects are removed. However, please notice that this is normally less performant that dropping the collection and creating it and its indices again

Parameters
collection The collection whose elements will be removed
query The optional DBObject query object. Objects that match it will be removed.
writeConcern The write concern used to remove the object

public void removeObjectsUsingQueryMap (String collection, Map<String, Object> queryAttributes, WriteConcern writeConcern)

Removes all the objects that match the a given optional query. If query is not specified, all objects are removed. However, please notice that this is normally less performant that dropping the collection and creating it and its indices again

Parameters
collection The collection whose elements will be removed
queryAttributes The query object. Objects that match it will be removed.
writeConcern The write concern used to remove the object

public void restore (String inputPath, boolean drop, boolean oplogReplay)

Takes the output from the dump and restores it. Indexes will be created on a restore. It only does inserts with the data to restore, if existing data is there, it will not be replaced.

Parameters
inputPath Input path to the dump files, it can be a directory, a zip file or just a bson file
drop Whether to drop existing collections before restore
oplogReplay Replay oplog for point-in-time restore
Throws
IOException if an error occurs during restore of the database

public void saveObject (String collection, DBObject element, WriteConcern writeConcern)

Inserts or updates an object based on its object _id.

Parameters
collection The collection where to insert the object
element The mandatory DBObject object to insert.
writeConcern The write concern used to persist the object

public void saveObjectFromMap (String collection, Map<String, Object> elementAttributes, WriteConcern writeConcern)

Inserts or updates an object based on its object _id.

Parameters
collection The collection where to insert the object
elementAttributes The mandatory object to insert.
writeConcern The write concern used to persist the object

public void setAutoConnectRetry (Boolean autoConnectRetry)

Parameters
autoConnectRetry

public void setConnectTimeout (Integer connectTimeout)

Parameters
connectTimeout

public void setConnectionsPerHost (Integer connectionsPerHost)

Parameters
connectionsPerHost

public void setDatabase (String database)

Parameters
database

public void setHost (String host)

Parameters
host

public void setMaxWaitTime (Integer maxWaitTime)

Parameters
maxWaitTime

public void setPort (int port)

Parameters
port

public void setSocketTimeout (Integer socketTimeout)

Parameters
socketTimeout

public void setThreadsAllowedToBlockForConnectionMultiplier (Integer threadsAllowedToBlockForConnectionMultiplier)

Parameters
threadsAllowedToBlockForConnectionMultiplier

public void startConsistentRequest ()

Begins a consistent request, which allows you to be sure that each subsequent request to MongoDB happens in sequence.

public void updateObjects (String collection, DBObject query, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)

Updates objects that matches the given query. If parameter multi is set to false, only the first document matching it will be updated. Otherwise, all the documents matching it will be updated.

Parameters
collection The name of the collection to update
query The DBObject query object used to detect the element to update. If the object Id is an instance of ObjectId you need to specify the value pair as map with the following structure: { "_id" : "ObjectId(OBJECT_ID_VALUE)"}
element The DBObject mandatory object that will replace that one which matches the query.
upsert If the database should create the element if it does not exist
multi If all or just the first object matching the query will be updated
writeConcern The write concern used to update

public void updateObjectsByFunction (String collection, String function, DBObject query, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)

Update objects using a mongo function

Parameters
collection The name of the collection to update
function The function used to execute the update
query The DBObject query object used to detect the element to update.
element The DBObject mandatory object that will replace that one which matches the query.
upsert If the database should create the element if it does not exist
multi If all or just the first object matching the query will be updated
writeConcern The write concern used to update

public void updateObjectsByFunctionUsingMap (String collection, String function, Map<String, Object> queryAttributes, Map<String, Object> elementAttributes, boolean upsert, boolean multi, WriteConcern writeConcern)

Update objects using a mongo function

Parameters
collection The name of the collection to update
function The function used to execute the update
queryAttributes The query object used to detect the element to update.
elementAttributes The mandatory object that will replace that one which matches the query.
upsert If the database should create the element if it does not exist
multi If all or just the first object matching the query will be updated
writeConcern The write concern used to update

public void updateObjectsUsingMap (String collection, Map<String, Object> queryAttributes, Map<String, Object> elementAttributes, boolean upsert, boolean multi, WriteConcern writeConcern)

Updates objects that matches the given query. If parameter multi is set to false, only the first document matching it will be updated. Otherwise, all the documents matching it will be updated.

Parameters
collection The name of the collection to update
queryAttributes The query object used to detect the element to update.
elementAttributes The mandatory object that will replace that one which matches the query.
upsert If the database should create the element if it does not exist
multi If all or just the first object matching the query will be updated
writeConcern The write concern used to update

public void updateObjectsUsingQueryMap (String collection, Map<String, Object> queryAttributes, DBObject element, boolean upsert, boolean multi, WriteConcern writeConcern)

Updates objects that matches the given query. If parameter multi is set to false, only the first document matching it will be updated. Otherwise, all the documents matching it will be updated.

Parameters
collection The name of the collection to update
queryAttributes The query object used to detect the element to update. If the object Id is an instance of ObjectId you need to specify the value pair as map with the following structure: { "_id" : "ObjectId(OBJECT_ID_VALUE)"}
element The DBObject mandatory object that will replace that one which matches the query.
upsert If the database should create the element if it does not exist
multi If all or just the first object matching the query will be updated
writeConcern The write concern used to update

Protected Methods

protected MongoClient adaptClient (MongoClient client)

Parameters
client