Package com.mongodb

Examples of com.mongodb.DBObject


      String.class);
  }

  @Override
  public List<User> fetchUsers(int page, int pageSize) {
    DBObject orderBy = new BasicDBObject("_id", -1);
    int skip = page * pageSize;
    return usersCollection.find().sort(orderBy).skip(skip).limit(pageSize).toArray();
  }
View Full Code Here


  }

  @Override
  public Optional<User> getBySessionToken(UUID sessionToken) {

    DBObject query = new BasicDBObject("sessionToken", sessionToken);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

    return Optional.fromNullable(user);
  }

  @Override
  public Optional<User> getByOpenIDIdentifier(String openIDIdentifier) {
    DBObject query = new BasicDBObject("openIDIdentifier", openIDIdentifier);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

    return Optional.fromNullable(user);
  }

  @Override
  public Optional<User> getByEmailAddress(String emailAddress) {
    DBObject query = new BasicDBObject("emailAddress", emailAddress);
    User user = usersCollection.findOne(query);
    return Optional.fromNullable(user);
  }
View Full Code Here

            final boolean deleted = this.deletedResources.remove(path);
            final MongoDBResource oldResource = (MongoDBResource)this.getResource(resolver, path, info);
            if ( !deleted && oldResource != null ) {
                throw new PersistenceException("Resource already exists at " + path, null, path, null);
            }
            final DBObject dbObj = new BasicDBObject();
            dbObj.put(getPROP_PATH(), info[1]);
            if ( properties != null ) {
                for(Map.Entry<String, Object> entry : properties.entrySet()) {
                    final String key = propNameToKey(entry.getKey());
                    dbObj.put(key, entry.getValue());
                }
            }
            if ( deleted && oldResource != null ) {
                dbObj.put(PROP_ID, oldResource.getProperties().get(PROP_ID));
            }
            final MongoDBResource rsrc = new MongoDBResource(resolver, path, info[0], dbObj, this);
            this.changedResources.put(path, rsrc);

            return rsrc;
View Full Code Here

                    this.changedResources.remove(path);

                    final DBCollection col = this.getCollection(info[0]);
                    final String pattern = "^" + Pattern.quote(info[1]) + "/";

                    final DBObject query = QueryBuilder.start(getPROP_PATH()).regex(Pattern.compile(pattern)).get();
                    final DBCursor cur = col.find(query);
                    while ( cur.hasNext() ) {
                        final DBObject dbObj = cur.next();
                        final String childPath = info[0] + '/' + dbObj.get(getPROP_PATH());
                        this.deletedResources.add(childPath);
                        this.changedResources.remove(childPath);
                    }
                    deletedResource = true;
                }
View Full Code Here

                    pattern = "^([^/])*$";
                } else {
                    pattern = "^" + Pattern.quote(info[1]) + "/([^/])*$";
                }

                final DBObject query = QueryBuilder.start(getPROP_PATH()).regex(Pattern.compile(pattern)).get();
                final DBCursor cur = col.find(query).
                        sort(BasicDBObjectBuilder.start(getPROP_PATH(), 1).get());
                return new Iterator<Resource>() {

                    public boolean hasNext() {
                        return cur.hasNext();
                    }

                    public Resource next() {
                        final DBObject obj = cur.next();
                        final String objPath = obj.get(getPROP_PATH()).toString();
                        final int lastSlash = objPath.lastIndexOf('/');
                        final String name;
                        if (lastSlash == -1) {
                            name = objPath;
                        } else {
View Full Code Here

            return null;
        }
        logger.debug("Searching {} in {}", info[1], info[0]);
        final DBCollection col = this.getCollection(info[0]);
        if ( col != null ) {
            final DBObject obj = col.findOne(QueryBuilder.start(getPROP_PATH()).is(info[1]).get());
            logger.debug("Found {}", obj);
            if ( obj != null ) {
                return new MongoDBResource(resourceResolver,
                        path,
                        info[0],
View Full Code Here

        final String collectionName = query.substring( 0, query.indexOf( ".find(" ) );
        DBCollection col = this.getCollection( collectionName );
        if ( col != null )
        {
            String criteria = query.trim().substring( query.indexOf( ".find(" ) + 6, query.length() - 1 );
            DBObject dbObject = (DBObject) JSON.parse( criteria );
            final DBCursor cur = col.find( dbObject );
            final String rootPath = context.getRootWithSlash();
           
            return new Iterator<Resource>() {

                public boolean hasNext() {
                    return cur.hasNext();
                }

                public Resource next() {
                    final DBObject obj = cur.next();
                    final String objPath = obj.get(getPROP_PATH()).toString();
                    final int lastSlash = objPath.lastIndexOf('/');
                    final String name;
                    if (lastSlash == -1) {
                        name = objPath;
                    } else {
View Full Code Here

      String.class);
  }

  @Override
  public List<SoilData> fetchNewestSoilData(int page, int pageSize) {
    DBObject orderBy = new BasicDBObject("_id", -1);
    int skip = page * pageSize;
    return soilDataCollection.find().sort(orderBy).skip(skip).limit(pageSize).toArray();
  }
View Full Code Here

TOP

Related Classes of com.mongodb.DBObject

Copyright © 2018 www.massapicom. 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.