Package com.mongodb

Examples of com.mongodb.DBCursor


        }
        return result;
    }

    public boolean deleteCenterUsers(String centerId) {
        DBCursor cursor = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get());
        boolean result = false;
        if (cursor.count() > 0) {
            coll.remove(cursor.next());
            result = true;
        }
        return result;
    }
View Full Code Here


        List<DBObject> objects = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get()).skip(offset * page).limit(offset).toArray();
        return objects.isEmpty() ? Collections.EMPTY_LIST : dbObjectsToCenterUsers(objects);
    }

    public Collection<CenterUser> getCenterUsersForReport(String centerId) {
        DBCursor cursor = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get());
        List<DBObject> objects = new ArrayList<DBObject>();
        while (cursor.hasNext()) {
            objects.add(cursor.next());
        }
        return objects.isEmpty() ? Collections.EMPTY_LIST : dbObjectsToCenterUsers(objects);
    }
View Full Code Here

        }
        return objects.isEmpty() ? Collections.EMPTY_LIST : dbObjectsToCenterUsers(objects);
    }

    public Collection<String> getCenterUsersMail(String centerId) {
        DBCursor cursor = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get(), BasicDBObjectBuilder.start().add(CenterUserKeys.email, "").get());
        List<String> mails = new ArrayList<String>();
        while (cursor.hasNext()) {
            DBObject obj = cursor.next();
            mails.add(obj.get(CenterUserKeys.email).toString());
        }
        return mails;
    }
View Full Code Here

        }
        return mails;
    }

    public Collection<String> getCenterUsersMobile(String centerId) {
        DBCursor cursor = coll.find(new BasicDBObject(), BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get());
        List<String> mobile = new ArrayList<String>();
        while (cursor.hasNext()) {
            mobile.add(cursor.next().get(CenterUserKeys.mobile).toString());
        }
        return mobile;
    }
View Full Code Here

            coll.insert(new BasicDBObject(centerUser.toMap()));
        }
    }

    public void updateCenterUsers(Collection<String> ids, String groupId, String centerId) {
        DBCursor cursor = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get());
        while (cursor.hasNext()) {
            coll.update(cursor.next(), new BasicDBObject("$set", new BasicDBObject(CenterUserKeys.groupId, groupId)), false, false);
        }
    }
View Full Code Here

            coll.update(cursor.next(), new BasicDBObject("$set", new BasicDBObject(CenterUserKeys.groupId, groupId)), false, false);
        }
    }

    public void updateDeleteGroup(String centerId, String groupId) {
        DBCursor cursor = coll.find(BasicDBObjectBuilder.start().add(CenterUserKeys.centerId, centerId).get());
        while (cursor.hasNext()) {
            coll.update(cursor.next(), new BasicDBObject("$set", new BasicDBObject(CenterUserKeys.groupId, "")), false, false);
        }
    }
View Full Code Here

        List<String> emails = Collections.EMPTY_LIST;
        List<String> groups = extractGroups(listeWithSeparator, separator);
        if (!groups.isEmpty()) {
            emails = new FastList<String>();
            for (String current : groups) {
                DBCursor cursor = coll.find(new BasicDBObject(CenterUserKeys.groupId, current));
                while (cursor.hasNext()) {
                    emails.add(cursor.next().get(CenterUserKeys.email).toString());
                }
            }
        }
        return emails;
    }
View Full Code Here

    }

    @Override
    public boolean deleteAllGroupsCenter(String centerId) throws DataAccessException {
        boolean result = false;
        DBCursor cursor = coll.find(new BasicDBObject(GroupKeys.centerId, centerId));
        if (cursor.hasNext()) {
            DBObject obj = cursor.next();
            coll.remove(obj);
            result = true;
        }
        return result;
    }
View Full Code Here

    }

    @Override
    public List<CenterGroup> getGroupsCenter(String id) throws DataAccessException {
        List groups = null;
        DBCursor cursor = coll.find(new BasicDBObject(GroupKeys.centerId, id));
        if (cursor.hasNext())
            groups = new FastList<CenterGroup>();
        if (cursor.hasNext()) {
            groups.add(factory.createCenterGroup(cursor.next().toMap()));
        }
        return groups != null ? groups : Collections.EMPTY_LIST;
    }
View Full Code Here

  

    @Override
    public List<String> getGroupsName() {
        List<String> names = null;
        DBCursor cursor = coll.find();
        if (cursor.hasNext())
            names = new FastList<String>();
        while (cursor.hasNext()) {
            names.add(cursor.next().get(GroupKeys.name).toString());
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of com.mongodb.DBCursor

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.