use of fr.wseduc.mongodb.MongoDb in project statistics by OPEN-ENT-NG.
the class StatisticsController method deleteRegeneratedStatistics.
// delete all the statisticcs from mongoDB who will be generated again.
private void deleteRegeneratedStatistics(Date startDate, Date endDate, Handler<Either<String, JsonArray>> handler) {
MongoDb mongo = MongoDb.getInstance();
JsonObject criteria = new JsonObject();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd 00:00.00.000");
String strStartDate = df.format(startDate);
String strEndDate = df.format(endDate);
// first condition
final JsonArray cond = new JsonArray().addObject(new JsonObject().putObject("date", new JsonObject().putString("$gte", strStartDate)));
// second condition
cond.addObject(new JsonObject().putObject("date", new JsonObject().putString("$lt", strEndDate)));
// query = condition1 AND condition2
final JsonObject query = new JsonObject().putArray("$and", cond);
// launch deletion
mongo.delete("stats", query, MongoDbResult.validResultsHandler(handler));
}
Aggregations