Klasse DUUIMongoDBStorage
java.lang.Object
org.texttechnologylab.duui.api.storage.DUUIMongoDBStorage
A utility class for setting up and retrieving information about the database including its collections. Also
contains utility methods for database operations.
- Autor:
- Cedric Borkowski
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic com.mongodb.client.MongoCollection<org.bson.Document> Utility functions for fast access to collections in the database.static voidconvertDateToTimestamp(org.bson.Document document, String fieldName) Convert a MongoDB date object to a timestamp.static org.bson.DocumentconvertObjectIdToString(org.bson.Document document) Replaces the ObjectID object by a plain text representation of the id called oid.static org.bson.DocumentconvertObjectIdToString(org.bson.Document document, String field, String newName) Replaces the ObjectID object by a plain text representation of the id.static com.mongodb.client.MongoCollection<org.bson.Document> Utility functions for fast access to collections in the database.static com.mongodb.client.MongoCollection<org.bson.Document> Events()Utility functions for fast access to collections in the database.static com.mongodb.client.MongoClientRetrieve the existingMongoClientor instantiate a new one.static StringRetrieve the connection URI to connect to aMongoClient.getFilterOrDefault(spark.Request request, String queryParameter) For a given filter queryParameter extract the string from the request query parameters (queryParameter=A;B;C;D...) and return aListof filter namesstatic com.mongodb.client.MongoCollection<org.bson.Document> Globals()Utility functions for fast access to collections in the database.static voidInject theConfigfor the application and initialize a.Ungültige Referenz
com.mongodb.MongoClientstatic com.mongodb.client.MongoCollection<org.bson.Document> Utility functions for fast access to collections in the database.static com.mongodb.client.MongoCollection<org.bson.Document> Utility functions for fast access to collections in the database.static voidRefactor all connections in the database to the new structure.static voidupdateDocument(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.bson.conversions.Bson filter, org.bson.Document updates, Set<String> allowedUpdates) static voidupdateDocument(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.bson.conversions.Bson filter, org.bson.Document updates, Set<String> allowedUpdates, boolean skipInvalid) Combine a Document containing key value pairs representing an update action into a merged BSON object.static com.mongodb.client.MongoCollection<org.bson.Document> Users()Utility functions for fast access to collections in the database.
-
Methodendetails
-
convertObjectIdToString
public static org.bson.Document convertObjectIdToString(org.bson.Document document) Replaces the ObjectID object by a plain text representation of the id called oid.- Parameter:
document- The document to convert.
-
convertObjectIdToString
public static org.bson.Document convertObjectIdToString(org.bson.Document document, String field, String newName) Replaces the ObjectID object by a plain text representation of the id.- Parameter:
document- The document to convert.field- The name of the ObjectId field. Usually _id.newName- The new name of the field. Usually oid.
-
convertDateToTimestamp
Convert a MongoDB date object to a timestamp.- Parameter:
document- The document containing the date.
-
getConnectionURI
Retrieve the connection URI to connect to aMongoClient.- Gibt zurück:
- The connection URI.
-
getClient
public static com.mongodb.client.MongoClient getClient()Retrieve the existingMongoClientor instantiate a new one.- Gibt zurück:
- A
MongoClientinstance.
-
init
Inject theConfigfor the application and initialize a.Ungültige Referenz
com.mongodb.MongoClient- Parameter:
config- the configuration for the application.
-
refactorAllConnections
public static void refactorAllConnections()Refactor all connections in the database to the new structure. -
Pipelines
public static com.mongodb.client.MongoCollection<org.bson.Document> Pipelines()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Components
public static com.mongodb.client.MongoCollection<org.bson.Document> Components()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Users
public static com.mongodb.client.MongoCollection<org.bson.Document> Users()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Documents
public static com.mongodb.client.MongoCollection<org.bson.Document> Documents()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Processses
public static com.mongodb.client.MongoCollection<org.bson.Document> Processses()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Events
public static com.mongodb.client.MongoCollection<org.bson.Document> Events()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
Globals
public static com.mongodb.client.MongoCollection<org.bson.Document> Globals()Utility functions for fast access to collections in the database.- Gibt zurück:
- A MongoCollection object.
-
updateDocument
public static void updateDocument(com.mongodb.client.MongoCollection<org.bson.Document> collection, org.bson.conversions.Bson filter, org.bson.Document updates, Set<String> allowedUpdates, boolean skipInvalid) Combine a Document containing key value pairs representing an update action into a merged BSON object.- Parameter:
collection- The collection on which to perform the updatefilter- A set of filters so that only matching documents are updated.updates- The Document containing the updates.allowedUpdates- A Set of field names that are allowed to be updated.skipInvalid- Wether to skip invalid keys or return when encountered. Default true.
-
updateDocument
-
getFilterOrDefault
For a given filter queryParameter extract the string from the request query parameters (queryParameter=A;B;C;D...) and return aListof filter names- Parameter:
request- the request object.queryParameter- the queryParameter of the query parameter- Gibt zurück:
- a list of Strings to filter by.
-