Package com.mongodb

Examples of com.mongodb.DBObject.toMap()


    if (value instanceof List) {
      return value;
    }
    if (value instanceof DBObject) {
      DBObject basicDBObject = (DBObject) value;
      return basicDBObject.toMap();
    }
    return value;
  }

}
View Full Code Here


   *      Mongo Object IDs</a>
   */
  public String fromIdToLong(String id, boolean isUser) {
    DBObject objectIdLong = collectionMap.findOne(new BasicDBObject("element_id", id));
    if (objectIdLong != null) {
      Map<String,Object> idLong = (Map<String,Object>) objectIdLong.toMap();
      Object value = idLong.get("long_value");
      return value == null ? null : value.toString();
    } else {
      objectIdLong = new BasicDBObject();
      String longValue = Long.toString(idCounter++);
View Full Code Here

   * @see <a href="http://www.mongodb.org/display/DOCS/Object%20IDs">
   *      Mongo Object IDs</a>
   */
  public String fromLongToId(long id) {
    DBObject objectIdLong = collectionMap.findOne(new BasicDBObject("long_value", Long.toString(id)));
    Map<String,Object> idLong = (Map<String,Object>) objectIdLong.toMap();
    Object value = idLong.get("element_id");
    return value == null ? null : value.toString();
  }

  /**
 
View Full Code Here

            }
            ChunkInfo chunkInfo = new ChunkInfo(Arrays.asList(hosts), chunkId);
            DBObject minObj = (BasicDBObject) chunkObj.get(MIN);

            Map<String, Object> minFilters = Maps.newHashMap();
            Map minMap = minObj.toMap();
            Set keySet = minMap.keySet();
            for (Object keyObj : keySet) {
              Object object = minMap.get(keyObj);
              if (!(object instanceof MinKey)) {
                minFilters.put(keyObj.toString(), object);
View Full Code Here

            }
            chunkInfo.setMinFilters(minFilters);

            DBObject maxObj = (BasicDBObject) chunkObj.get(MAX);
            Map<String, Object> maxFilters = Maps.newHashMap();
            Map maxMap = maxObj.toMap();
            keySet = maxMap.keySet();
            for (Object keyObj : keySet) {
              Object object = maxMap.get(keyObj);
              if (!(object instanceof MaxKey)) {
                maxFilters.put(keyObj.toString(), object);
View Full Code Here

   *      Mongo Object IDs</a>
   */
  public String fromIdToLong(String id, boolean isUser) {
    DBObject objectIdLong = collectionMap.findOne(new BasicDBObject("element_id", id));
    if (objectIdLong != null) {
      Map<String,Object> idLong = (Map<String,Object>) objectIdLong.toMap();
      Object value = idLong.get("long_value");
      return value == null ? null : value.toString();
    } else {
      objectIdLong = new BasicDBObject();
      String longValue = Long.toString(idCounter++);
View Full Code Here

   * @see <a href="http://www.mongodb.org/display/DOCS/Object%20IDs">
   *      Mongo Object IDs</a>
   */
  public String fromLongToId(long id) {
    DBObject objectIdLong = collectionMap.findOne(new BasicDBObject("long_value", Long.toString(id)));
    Map<String,Object> idLong = (Map<String,Object>) objectIdLong.toMap();
    Object value = idLong.get("element_id");
    return value == null ? null : value.toString();
  }

  /**
 
View Full Code Here

            else {
                queryResult = collection.findOne(q);
            }

            if (queryResult != null) {
                result.putAll(queryResult.toMap());
            }
            return queryResult != null ? 0 : 1;
        }
        catch (Exception e) {
            System.err.println(e.toString());
View Full Code Here

      throw new IllegalStateException("Expected only one result but received " + cursor.count() + " entries");
    }
    DBObject dbObject = mongoTemplate.getCollection(collectionName).findOne();
    Map<String, String> result = null;
    if (dbObject != null) {
      result = dbObject.toMap();
    }
    return result;
  }

}
View Full Code Here

            : collection.update(queryObj, updateObj, upsert, multi, writeConcernToUse);

        if (entity != null && entity.hasVersionProperty() && !multi) {
          if (writeResult.getN() == 0 && dbObjectContainsVersionProperty(queryObj, entity)) {
            throw new OptimisticLockingFailureException("Optimistic lock exception on saving entity: "
                + updateObj.toMap().toString() + " to collection " + collectionName);
          }
        }

        handleAnyWriteResultErrors(writeResult, queryObj, MongoActionOperation.UPDATE);
        return writeResult;
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.