private void setListeners() { widthProperty() .addListener( (InvalidationListener) (listener) -> { confDoc.append("width", width.get()); // save(); DBUtils.getCollection() .updateOne( Filters.eq("_id", "conf"), new Document("$set", new Document("width", width.get()))); }); heightProperty() .addListener( (InvalidationListener) (listener) -> { confDoc.append("height", height.get()); DBUtils.getCollection() .updateOne( Filters.eq("_id", "conf"), new Document("$set", new Document("height", height.get()))); }); lastDocProperty() .addListener( (InvalidationListener) (listener) -> { confDoc.append("lastDoc", lastDoc.get()); DBUtils.getCollection() .updateOne( Filters.eq("_id", "conf"), new Document("$set", new Document("lastDoc", lastDoc.get()))); }); }
public final void setTraductorVisible(final boolean traductorVisible) { this.traductorVisibleProperty().set(traductorVisible); DBUtils.getCollection() .updateOne( Filters.eq("_id", "conf"), new Document("$set", new Document("traductor", traductorVisible))); }
public final void setLastDoc(final org.bson.Document lastDoc) { this.lastDocProperty().set(lastDoc); confDoc.append("lastDoc", lastDoc); DBUtils.getCollection() .updateOne( Filters.eq("_id", "conf"), new Document("$set", new Document("lastDoc", lastDoc))); }
@Override public void run() { System.out.println("notifications job running"); List<User> users = userService.queryUsers(Filters.eq("notifications", true)); for (User user : users) { String query = user.getNotificationQuery(); query = query + "&createdOn[$gt]=" + user.getLastNotificationAt(); List<Document> documents = adService.queryAds(query); if (!documents.isEmpty()) { List<BaseAd> adsList = adService.getListAs(BaseAd.class, documents); twilioService.sendSMS(user.getMobile(), "New ads for your query"); user.setLastNotificationAt(ZonedDateTime.now().toEpochSecond()); userService.updateUser(user); } } }
public static void main(String[] args) { MongoClient client = new MongoClient(); MongoDatabase db = client.getDatabase("course"); MongoCollection<Document> coll = db.getCollection("findWithSortTest"); coll.drop(); for (int i = 0; i < 8; i++) { coll.insertOne(new Document().append("_id", i)); } // coll.deleteMany(Filters.gt("_id", 4)); coll.deleteOne(Filters.eq("_id", 4)); for (Document cur : coll.find().into(new ArrayList<Document>())) { System.out.println(cur); } }