Package com.mongodb

Examples of com.mongodb.QueryBuilder$NullObject


    }

    @Nonnull
    private static QueryBuilder createQueryForUpdate(UpdateOp updateOp,
                                              boolean checkConditions) {
        QueryBuilder query = getByKeyQuery(updateOp.getId());

        for (Entry<Key, Operation> entry : updateOp.getChanges().entrySet()) {
            Key k = entry.getKey();
            Operation op = entry.getValue();
            switch (op.type) {
                case CONTAINS_MAP_ENTRY: {
                    if (checkConditions) {
                        query.and(k.toString()).exists(op.value);
                    }
                    break;
                }
            }
        }
View Full Code Here


        }
        return blob;
    }

    private static DBObject getBlobQuery(String id, long lastMod) {
        QueryBuilder queryBuilder = new QueryBuilder();
        if (id != null) {
            queryBuilder = queryBuilder.and(MongoBlob.KEY_ID).is(id);
        }
        if (lastMod > 0) {
            queryBuilder = queryBuilder.and(MongoBlob.KEY_LAST_MOD).lessThan(lastMod);
        }
        return queryBuilder.get();
    }
View Full Code Here

          MongoSchema.class,
          Object.class,
          JSON_MAPPER);
   
    // Build the query
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the schema ID.
    queryBuilder.and(MongoSchema.JSON_KEY_ID).is(schemaId);
   
    // Add the schema version.
    queryBuilder.and(MongoSchema.JSON_KEY_VERSION).is(schemaVersion);
   
    // Execute query.
    DBCursor<MongoSchema> result = collection.find(queryBuilder.get());
   
    // Return null or the schema based on what the query returned.
    if(result.count() == 0) {
      return null;
    }
View Full Code Here

            .getDb()
            .getCollection(DB_NAME),
          MongoAuthorizationCode.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the authorization code to the query.
    queryBuilder.and(AuthorizationCode.JSON_KEY_CODE).is(code);
   
    // Execute query.
    DBCursor<MongoAuthorizationCode> result =
      collection.find(queryBuilder.get());
   
    // If multiple authorization codes were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

    JacksonDBCollection<MongoData, Object> collection =
      JacksonDBCollection
        .wrap(db.getCollection(DB_NAME), MongoData.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Only select data for a single user.
    queryBuilder.and(Data.JSON_KEY_OWNER).is(owner);
   
    // Only select data for a given schema.
    queryBuilder.and(Schema.JSON_KEY_ID).is(schemaId);
   
    // Only select data for a given version of the the given schema.
    queryBuilder.and(Schema.JSON_KEY_VERSION).is(version);
   
    // Create the projection.
    DBObject projection = new BasicDBObject();
    // Add the owner field.
    projection.put(Data.JSON_KEY_OWNER, 1);
    // Add the schema ID field.
    projection.put(Schema.JSON_KEY_ID, 1);
    // Add the schema version.
    projection.put(Schema.JSON_KEY_VERSION, 1);
    // Add the meta-data field.
    projection.put(Data.JSON_KEY_METADATA, 1);
    // Add all of the data or add only the specified columns if given.
    if(columnList.size() == 0) {
      projection.put(Data.JSON_KEY_DATA, 1);
    }
    else {
      if((columnList != null) && (columnList.size() > 0)) {
        for(String column : columnList.toList()) {
          projection
            .put(
              Data.JSON_KEY_DATA +
                ColumnList.COLUMN_SEPARATOR +
                column,
              1);
        }
      }
    }
   
    // Build the query.
    DBCursor<MongoData> dbResult =
      collection.find(queryBuilder.get(), projection);
   
    // Build the sort field by sorting in reverse chronological order.
    DBObject sort = new BasicDBObject();
    sort.put(
      Data.JSON_KEY_METADATA +
View Full Code Here

          MongoUser.class,
          Object.class,
          JSON_MAPPER);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the authentication token to the query
    queryBuilder.and(MongoUser.JSON_KEY_USERNAME).is(username);
   
    // Execute query.
    DBCursor<MongoUser> result = collection.find(queryBuilder.get());
   
    // If multiple authentication tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

          MongoUser.class,
          Object.class,
          JSON_MAPPER);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the authentication token to the query
    queryBuilder
      .and(MongoUser.JSON_KEY_REGISTRATION_KEY)
      .is(registrationId);
   
    // Execute query.
    DBCursor<MongoUser> result = collection.find(queryBuilder.get());
   
    // If multiple authentication tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

            .getDb()
            .getCollection(DB_NAME),
          MongoAuthorizationCodeResponse.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the authentication code to the query.
    queryBuilder
      .and(AuthorizationCodeResponse.JSON_KEY_AUTHORIZATION_CODE)
      .is(code);
   
    // Execute query.
    DBCursor<MongoAuthorizationCodeResponse> result =
      collection.find(queryBuilder.get());
   
    // If multiple responses of the same authorization code were returned,
    // that is a violation of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

            .getDb()
            .getCollection(DB_NAME),
          MongoAuthorizationToken.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the access token to the query.
    queryBuilder
      .and(AuthorizationToken.JSON_KEY_ACCESS_TOKEN).is(accessToken);
   
    // Execute query.
    DBCursor<MongoAuthorizationToken> result =
      collection.find(queryBuilder.get());
   
    // If multiple authorization tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

            .getDb()
            .getCollection(DB_NAME),
          MongoAuthorizationToken.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the refresh token to the query.
    queryBuilder
      .and(AuthorizationToken.JSON_KEY_REFRESH_TOKEN).is(refreshToken);
   
    // Execute query.
    DBCursor<MongoAuthorizationToken> result =
      collection.find(queryBuilder.get());
   
    // If multiple authorization tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

TOP

Related Classes of com.mongodb.QueryBuilder$NullObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.