Package com.mongodb

Examples of com.mongodb.DBObject.keySet()


public class DiffStrategy extends UpdateStrategy {

    @Override
    public void update(DBObject initialValue, DBObject updatedValue, DBCollection collection) {
        final DBObject diff = new DbObjectDiff(initialValue).compareWith(updatedValue);
        if (!diff.keySet().isEmpty()) {
            final DBObject q = updateQuery(initialValue);
            final DBObject pull = (DBObject) diff.get(DbObjectDiff.Modifier.PULL.toString());
            diff.removeField(DbObjectDiff.Modifier.PULL.toString());
            LOGGER.debug("Updating : collection {} : query {} : modifiers : {}", collection.getName(), q, diff);
            collection.update(q, diff);
View Full Code Here


            return "";
        }
        DBObject bsonObject = (DBObject) JSON.parse(object);

        BasicBSONObject newObject = new BasicBSONObject();
        for (String key : bsonObject.keySet()) {
            if (add) {
                newObject.put(prefix + key, bsonObject.get(key));
            } else {
                if (key.startsWith(prefix)) {
                    newObject.put(key.substring(prefix.length()), bsonObject.get(key));
View Full Code Here

        String objectId = getObjectIdFromOplogEntry(entry);
        if (operation == Operation.DELETE) {
            // Include only _id in data, as vanilla MongoDB does, so
            // transformation scripts won't be broken by Toku
            if (object.containsField(MongoDBRiver.MONGODB_ID_FIELD)) {
                if (object.keySet().size() > 1) {
                    entry.put(MongoDBRiver.OPLOG_OBJECT, object = new BasicDBObject(MongoDBRiver.MONGODB_ID_FIELD, objectId));
                }
            } else {
                throw new NullPointerException(MongoDBRiver.MONGODB_ID_FIELD);
            }
View Full Code Here

    for (Entry<String, Object> capability : capabilitiesObj.entrySet()) {
      EventType eventType = EventType.valueOf(capability.getKey());
      List<Context> contexts = CollectionUtils.newArrayList();
      DBObject capabilityObj = (DBObject) capability.getValue();
      DBObject contextsObj = (DBObject) capabilityObj.get(CAPABILITY_CONTEXTS_FIELD);
      for (String contextId : contextsObj.keySet()) {
        contexts.add(Context.valueOf((String) contextsObj.get(contextId)));
      }
      String filter = (String) capabilityObj.get(CAPABILITY_FILTER_FIELD);

      capabilities.put(eventType, new Capability(eventType, contexts, filter));
View Full Code Here

            if (dbObj != null) {
                if (!shouldSaveClassName(fieldValue, dbObj, mf)) {
                    dbObj.removeField(Mapper.CLASS_NAME_FIELDNAME);
                }

                if (!dbObj.keySet().isEmpty() || mapper.getOptions().isStoreEmpties()) {
                    dbObject.put(name, dbObj);
                }
            }
        }
    }
View Full Code Here

    }
    if ("map".equals(type)) {
      DBObject data = (DBObject) this.data;
      HashMap<String, Object> map = new HashMap<String, Object>();
      for (String key : data.keySet())
        map.put(key, new SessionValue((DBObject) data.get(key)));
      return map;
    }
    throw Lang.impossible();
  }
View Full Code Here

          throw Lang.makeThrow("Unknown sort command '{%s:%s}'", key, ele.value());
        }
      }
    });
    // 设置排序
    if (!sort.keySet().isEmpty()) {
      cur.sort(sort);
    }
  }

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