Package com.mongodb

Examples of com.mongodb.DBObject.toMap()


        final DBObject o = findOne(InputImpl.class, new BasicDBObject("$and", query));
        if (o == null) {
            throw new NotFoundException();
        } else {
            return new InputImpl((ObjectId) o.get("_id"), o.toMap());
        }
    }

    @Override
    public void addExtractor(Input input, Extractor extractor) throws ValidationException {
View Full Code Here


        DBObject result = findOne(MongoDbSession.class, query);
        if (result == null) {
            return null;
        }
        final Object objectId = result.get("_id");
        return new MongoDbSession((ObjectId) objectId, result.toMap());
    }

    @Override
    public Collection<MongoDbSession> loadAll() {
        DBObject query = new BasicDBObject();
View Full Code Here

        DBObject dbo = findOne(IndexRangeImpl.class, new BasicDBObject("index", index));

        if (dbo == null)
            throw new NotFoundException("Index " + index + " not found.");

        return new IndexRangeImpl((ObjectId) dbo.get("_id"), dbo.toMap());
    }

    @Override
    public List<IndexRange> getFrom(int timestamp) {
        List<IndexRange> ranges = Lists.newArrayList();
View Full Code Here

            LOG.error("Multiple access tokens found, this is a serious bug.");
            throw new IllegalStateException("Access tokens collection has no unique index!");
        }
        final DBObject tokenObject = objects.get(0);
        final Object id = tokenObject.get("_id");
        return new AccessTokenImpl((ObjectId) id, tokenObject.toMap());
    }

    @Override
    @SuppressWarnings("unchecked")
    public List<AccessToken> loadAll(String username) {
View Full Code Here

        final DBObject userObject = result.get(0);
        final Object userId = userObject.get("_id");

        LOG.debug("Loaded user {}/{} from MongoDB", username, userId);
        return new UserImpl((ObjectId) userId, userObject.toMap());
    }

    @Override
    public User create() {
        return new UserImpl(Maps.<String, Object>newHashMap());
View Full Code Here

        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

    public CenterUser getCenterUser(String id, String centerId) {
        CenterUser user = null;
        DBObject obj = coll.findOne(new ObjectId(id), null);
        if (obj != null && obj.get(CenterUserKeys.centerId).equals(centerId)) {
            user = factory.createUser(obj.toMap());
        }
        return user;
    }

    public int getCenterUsersOnPage() {
View Full Code Here

        }
    }

    public CenterUser getCenterUserByMail(String email, String centerId) {
        DBObject obj = coll.findOne(new BasicDBObject(CenterUserKeys.centerId, centerId));
        return (obj != null) ? factory.createUser(obj.toMap()) : null;
    }
   
    @Override
    public List<String> getGroupsMail(String listeWithSeparator, String separator) {
        List<String> emails = Collections.EMPTY_LIST;
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.