Package backend.database
Class MongoDBHandler
java.lang.Object
backend.database.MongoDBHandler
- Author:
- Philipp Hein
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.mongodb.client.AggregateIterable<org.bson.Document>aggregateDocuments(String collectionName, List<org.bson.conversions.Bson> pipeline) voidclose()com.mongodb.client.MongoDatabaseconnect()longcountDocuments(String collectionName, org.bson.conversions.Bson filter) com.mongodb.client.result.DeleteResultdeleteDocuments(String collectionName, org.bson.conversions.Bson filter) List<org.bson.Document>Gibt alle Dokumente der angegebenen Collection zurück.List<org.bson.Document>findDocuments(String collectionName, org.bson.conversions.Bson filter) org.bson.DocumentGibt das erste Dokument zurück, das dem angegebenen Filter in der Collection entspricht.com.mongodb.client.MongoCollection<org.bson.Document>getCollection(String collectionName) Get a collection by namecom.mongodb.client.gridfs.GridFSBucketstatic MongoDBHandlerGet the singleton instance with connection poolingcom.mongodb.client.MongoCollection<org.bson.Document>com.mongodb.client.MongoCollection<org.bson.Document>com.mongodb.client.MongoCollection<org.bson.Document>com.mongodb.client.MongoCollection<org.bson.Document>com.mongodb.client.MongoCollection<org.bson.Document>com.mongodb.client.MongoCollection<org.bson.Document>voidinsertDocument(String collectionName, org.bson.Document document) static voidshutdown()Shutdown the connection pool when application exitscom.mongodb.client.result.UpdateResultupdateDocuments(String collectionName, org.bson.conversions.Bson filter, org.bson.conversions.Bson update)
-
Constructor Details
-
MongoDBHandler
Standardkonstruktor- Throws:
IOException- falls die config.properties nicht gelesen werden kann.
-
-
Method Details
-
getInstance
Get the singleton instance with connection pooling- Returns:
- The shared MongoDBHandler instance
- Throws:
IOException- If there's an error initializing
-
shutdown
public static void shutdown()Shutdown the connection pool when application exits -
connect
public com.mongodb.client.MongoDatabase connect() -
close
public void close() -
getPlenarprotocolsCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getPlenarprotocolsCollection()- Returns:
- MongoCollection für plenarprotokolle
-
getSpeakerCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getSpeakerCollection()- Returns:
- MongoCollection für speaker
-
getSpeechCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getSpeechCollection()- Returns:
- MongoCollection für speech.
-
getLinguisticFeaturesTranskriptCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getLinguisticFeaturesTranskriptCollection()- Returns:
- MongoCollection für "linguistic_features".
-
getLinguisticFeaturesCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getLinguisticFeaturesCollection()- Returns:
- MongoCollection für "linguistic_features".
-
getTopicsCollection
public com.mongodb.client.MongoCollection<org.bson.Document> getTopicsCollection()- Returns:
- MongoCollection für "topics".
-
getCollection
Get a collection by name- Parameters:
collectionName- The name of the collection- Returns:
- The MongoDB collection
-
insertDocument
- Parameters:
collectionName- Name der Collection.document- Das zu speichernde Dokument.
-
findDocuments
public List<org.bson.Document> findDocuments(String collectionName, org.bson.conversions.Bson filter) - Parameters:
collectionName- Name der Collection.filter- bsp: -> Filters.eq("key", "value")- Returns:
- Liste der gefundenen Dokumente.
-
findOne
Gibt das erste Dokument zurück, das dem angegebenen Filter in der Collection entspricht.- Parameters:
collectionName- Name der Collection.filter- Filter -> Bsp: Filters.eq("key", "value")- Returns:
- Das erste gefundene Dokument oder null, falls keines gefunden wurde.
-
findAll
Gibt alle Dokumente der angegebenen Collection zurück.- Parameters:
collectionName- Name der Collection.- Returns:
- Liste aller Dokumente in der Collection.
-
updateDocuments
public com.mongodb.client.result.UpdateResult updateDocuments(String collectionName, org.bson.conversions.Bson filter, org.bson.conversions.Bson update) - Parameters:
collectionName- Name der Collection.filter- um die zu löschenden Dokumente auszuwählenupdate- Update -> Updates.set(feld, wert).- Returns:
- UpdateResult mit Informationen über die durchgeführte Operation.
-
deleteDocuments
public com.mongodb.client.result.DeleteResult deleteDocuments(String collectionName, org.bson.conversions.Bson filter) - Parameters:
collectionName- Name der Collection.filter- um die zu löschenden Dokumente auszuwählen- Returns:
- DeleteResult
-
aggregateDocuments
public com.mongodb.client.AggregateIterable<org.bson.Document> aggregateDocuments(String collectionName, List<org.bson.conversions.Bson> pipeline) - Parameters:
collectionName- Name der Collection.pipeline- Liste von Aggregations Schritten.- Returns:
- Die Ergebnisse der Aggregation.
-
countDocuments
- Parameters:
collectionName- Name der Collection.filter- -> Filters.eq("key", "value").- Returns:
- Anzahl der Dokumente, die dem Filter entsprechen.
-
getGridFSBucket
public com.mongodb.client.gridfs.GridFSBucket getGridFSBucket()
-