Beispiel #1
0
 @Override
 public Document findOneAndReplace(Bson arg0, Document arg1, FindOneAndReplaceOptions arg2) {
   if (tx.started()) {
     tx.beforeUpdateOne(coll, arg0);
     return tx.getTxCollection().findOneAndReplace(modifyQuery(arg0), arg1, arg2);
   } else {
     return coll.findOneAndReplace(arg0, arg1, arg2);
   }
 }
Beispiel #2
0
 private static HashMap<String, Object> process(
     MongoCollection<Document> collection, OAuth2Client client, String api) {
   HashMap<String, Object> response = client.get(api);
   List<?> data = (List<?>) response.get("data");
   for (Object object : data) {
     BasicDBObject basicDBObject = new BasicDBObject((HashMap<?, ?>) object);
     basicDBObject.put("_id", basicDBObject.get("id"));
     Bson filter = new BasicDBObject("_id", basicDBObject.get("id"));
     Document replacement = new Document(basicDBObject);
     collection.findOneAndReplace(filter, replacement);
   }
   return response;
 }