Examples of BasicDBObject


Examples of com.mongodb.BasicDBObject

    }
    int queries = Helper.getQueries(exchange);
    World[] worlds = new World[queries];
    for (int i = 0; i < queries; i++) {
      int id = Helper.randomWorld();
      DBObject key = new BasicDBObject("_id", id);
      //
      // The requirements for the test dictate that we must fetch the World
      // object from the data store and read its randomNumber field, even though
      // we could technically avoid doing either of those things and still
      // produce the correct output and side effects.
View Full Code Here

Examples of com.mongodb.BasicDBObject

  public Object dbTest(@QueryParam("queries") Optional<String> queries)
  {
    final Random random = new Random(System.currentTimeMillis());
    if (!queries.isPresent())
    {
      DBObject query = new BasicDBObject();
      query.put("_id", (random.nextInt(10000) + 1));
      DBCursor<World> dbCursor = collection.find(query);
      return (dbCursor.hasNext()) ? dbCursor.next() : null;
    }
    Integer totalQueries = Ints.tryParse(queries.orNull());
    if (totalQueries != null)
    {
      if (totalQueries > 500)
      {
        totalQueries = 500;
      }
      else if (totalQueries < 1)
      {
        totalQueries = 1;
      }
    }
    else
    {
      totalQueries = 1;
    }
    final World[] worlds = new World[totalQueries];
    for (int i = 0; i < totalQueries; i++)
    {
      DBObject query = new BasicDBObject();
      query.put("_id", (random.nextInt(10000) + 1));
      DBCursor<World> dbCursor = collection.find(query);
      worlds[i] = (dbCursor.hasNext()) ? dbCursor.next() : null;
    }
    return worlds;
  }
View Full Code Here

Examples of com.mongodb.BasicDBObject

  @Test
  public void canSerializeAndDeserialize() throws Exception {
    MongoDBQueryDescriptor descriptor = new MongoDBQueryDescriptor(
        "test",
        Operation.FIND,
        new BasicDBObject( "foo", "bar" ),
        new BasicDBObject( "foo", 1 ),
        new BasicDBObject( "bar", 1 )
    );

    byte[] bytes = serialize( descriptor );
    MongoDBQueryDescriptor deserializedDescriptor = deserialize( bytes );
View Full Code Here

Examples of com.mongodb.BasicDBObject

  @Override
  @SuppressWarnings("unchecked")
  public Map<String, Object> extractEntityTuple(SessionFactory sessionFactory, EntityKey key) {
    MongoDBDatastoreProvider provider = MongoDBTestHelper.getProvider( sessionFactory );
    DBObject finder = new BasicDBObject( MongoDBDialect.ID_FIELDNAME, key.getColumnValues()[0] );
    DBObject result = provider.getDatabase().getCollection( key.getTable() ).findOne( finder );
    replaceIdentifierColumnName( result, key );
    return result.toMap();
  }
View Full Code Here

Examples of com.mongodb.BasicDBObject

  private DBObject getProjectionDBObject() {
    if ( projections.isEmpty() ) {
      return null;
    }

    DBObject projectionDBObject = new BasicDBObject();

    for ( String projection : projections ) {
      projectionDBObject.put( projection, 1 );
    }

    return projectionDBObject;
  }
View Full Code Here

Examples of com.mongodb.BasicDBObject

  }

  @Override
  protected void addSortField(PropertyPath propertyPath, String collateName, boolean isAscending) {
    if ( orderBy == null ) {
      orderBy = new BasicDBObject();
    }

    String columnName = propertyHelper.getColumnName( targetType, propertyPath.asStringPathWithoutAlias() );

    // BasicDBObject is essentially a LinkedHashMap, so in case of several sort keys they'll be evaluated in the
View Full Code Here

Examples of com.mongodb.BasicDBObject

    MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) this.getService( DatastoreProvider.class );

    DB database = provider.getDatabase();
    DBCollection collection = database.getCollection( collectionName );
    BasicDBObject water = new BasicDBObject();
    water.put( "_id", "1234" );
    water.put( "name", "Water" );
    water.put( "volume", "1L" );
    collection.insert( water );

    List<String> selectedColumns = new ArrayList<String>();
    selectedColumns.add( "name" );
    Tuple tuple = this.getTuple( collectionName, "1234", selectedColumns );
View Full Code Here

Examples of com.mongodb.BasicDBObject

   */
  protected void addExtraColumn() {
    MongoDBDatastoreProvider provider = (MongoDBDatastoreProvider) this.getService( DatastoreProvider.class );
    DB database = provider.getDatabase();
    DBCollection collection = database.getCollection( "associations_Project_Module" );
    BasicDBObject query = new BasicDBObject( 1 );
    query.put( "_id", new BasicDBObject( "Project_id", "projectID" ) );

    BasicDBObject updater = new BasicDBObject( 1 );
    updater.put( "$push", new BasicDBObject( "extraColumn", 1 ) );
    collection.update( query, updater );
  }
View Full Code Here

Examples of com.mongodb.BasicDBObject

  }

  @Test
  public void shouldApplyConfiguredReadPreferenceForGettingEmbeddedAssociation() {
    // given a persisted player with one associated golf course
    BasicDBObject player = getPlayer();
    player.put( "playedCourses", getPlayedCoursesAssociationEmbedded() );

    MockMongoClient mockClient = mockClient()
        .insert( "GolfPlayer", player )
        .insert( "GolfCourse", getGolfCourse() )
        .build();
View Full Code Here

Examples of com.mongodb.BasicDBObject

    sessions = configuration.buildSessionFactory();
  }

  private BasicDBObject getGolfCourse() {
    BasicDBObject bepplePeach = new BasicDBObject();
    bepplePeach.put( "_id", 1L );
    bepplePeach.put( "name", "Bepple Peach" );
    return bepplePeach;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.