Exemple #1
0
  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())));
                });
  }
Exemple #2
0
 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)));
 }
Exemple #3
0
 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)));
 }
Exemple #4
0
 @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);
     }
   }
 }
Exemple #5
0
  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);
    }
  }
  /** Creates each document for pipeline using helper classes included in driver */
  private void fromHelperClasses() {

    Bson totalPop = Aggregates.group("$state", Accumulators.sum("totalPop", "$pop"));
    Bson gtOneMillion = Aggregates.match(Filters.gte("totalPop", 1000000));

    //
    // Compose aggregation pipeline
    List<Bson> pipeline = Arrays.asList(totalPop, gtOneMillion);

    //
    // Executes aggregation query
    List<Document> results =
        DBHelper.getZipCodesCollection().aggregate(pipeline).into(new ArrayList<Document>());

    //
    // Display aggregation results
    System.out.println("\nStates with population greater than one million");
    for (Document result : results) {
      System.out.println(result.toJson());
    }
  }
 public Document findByFile(long filehash, String commit, Bson projection) {
   Bson clause1 = new BasicDBObject("filehash", filehash);
   Bson clause2 = new BasicDBObject("commit", commit);
   return findOne(Filters.and(clause1, clause2), projection);
 }
 public Document findByClasses(String[] classes, String commit, Bson projection) {
   Bson clause1 = Filters.in("bugs.class", classes);
   Bson clause2 = new BasicDBObject("commit", commit);
   return findOne(Filters.and(clause1, clause2), projection);
 }