Package com.mongodb

Examples of com.mongodb.DBObject.keySet()


      return dbo;
    }

    BasicDBObjectBuilder dboBuilder = new BasicDBObjectBuilder();

    for (String key : dbo.keySet()) {
      dboBuilder.add(dotPath + "." + key, dbo.get(key));
    }
    return dboBuilder.get();
  }
View Full Code Here


      return object;
    }

    DBObject dbObject = (DBObject) object;
    String keyToRemove = null;
    for (String key : dbObject.keySet()) {

      if (typeMapper.isTypeKey(key)) {
        keyToRemove = key;
      }
View Full Code Here

   */
  public DBObject getMappedFields(DBObject fieldsObject, MongoPersistentEntity<?> entity) {

    DBObject mappedFields = fieldsObject != null ? getMappedObject(fieldsObject, entity) : new BasicDBObject();
    mapMetaAttributes(mappedFields, entity, MetaMapping.FORCE);
    return mappedFields.keySet().isEmpty() ? null : mappedFields;
  }

  private void mapMetaAttributes(DBObject source, MongoPersistentEntity<?> entity, MetaMapping metaMapping) {

    if (entity == null || source == null) {
View Full Code Here

    }

    if (property.isMap()) {
      BasicDBObject result = new BasicDBObject();
      DBObject dbObject = (DBObject) source;
      for (String key : dbObject.keySet()) {
        result.put(key, createDbRefFor(dbObject.get(key), property));
      }
      return result;
    }
View Full Code Here

        List<IndexInfo> indexInfoList = new ArrayList<IndexInfo>();

        for (DBObject ix : dbObjectList) {

          DBObject keyDbObject = (DBObject) ix.get("key");
          int numberOfElements = keyDbObject.keySet().size();

          List<IndexField> indexFields = new ArrayList<IndexField>(numberOfElements);

          for (String key : keyDbObject.keySet()) {
View Full Code Here

          DBObject keyDbObject = (DBObject) ix.get("key");
          int numberOfElements = keyDbObject.keySet().size();

          List<IndexField> indexFields = new ArrayList<IndexField>(numberOfElements);

          for (String key : keyDbObject.keySet()) {

            Object value = keyDbObject.get(key);

            if (TWO_D_IDENTIFIERS.contains(value)) {
              indexFields.add(IndexField.geo(key));
View Full Code Here

            if (TWO_D_IDENTIFIERS.contains(value)) {
              indexFields.add(IndexField.geo(key));
            } else if ("text".equals(value)) {

              DBObject weights = (DBObject) ix.get("weights");
              for (String fieldName : weights.keySet()) {
                indexFields.add(IndexField.text(fieldName, Float.valueOf(weights.get(fieldName).toString())));
              }

            } else {
View Full Code Here

  public void usesEntityMetadataInOr() {

    Query query = query(new Criteria().orOperator(where("foo").is("bar")));
    DBObject result = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Sample.class));

    assertThat(result.keySet(), hasSize(1));
    assertThat(result.keySet(), hasItem("$or"));

    BasicDBList ors = getAsDBList(result, "$or");
    assertThat(ors, hasSize(1));
    DBObject criterias = getAsDBObject(ors, 0);
View Full Code Here

    Query query = query(new Criteria().orOperator(where("foo").is("bar")));
    DBObject result = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Sample.class));

    assertThat(result.keySet(), hasSize(1));
    assertThat(result.keySet(), hasItem("$or"));

    BasicDBList ors = getAsDBList(result, "$or");
    assertThat(ors, hasSize(1));
    DBObject criterias = getAsDBObject(ors, 0);
    assertThat(criterias.keySet(), hasSize(1));
View Full Code Here

    assertThat(result.keySet(), hasItem("$or"));

    BasicDBList ors = getAsDBList(result, "$or");
    assertThat(ors, hasSize(1));
    DBObject criterias = getAsDBObject(ors, 0);
    assertThat(criterias.keySet(), hasSize(1));
    assertThat(criterias.get("_id"), is(notNullValue()));
    assertThat(criterias.get("foo"), is(nullValue()));
  }

  @Test
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.