Example usage for com.mongodb DBCursor hasNext

List of usage examples for com.mongodb DBCursor hasNext

Introduction

In this page you can find the example usage for com.mongodb DBCursor hasNext.

Prototype

@Override
public boolean hasNext() 

Source Link

Document

Checks if there is another object available.

Usage

From source file:backend.facades.UserController.java

public List<UserEntity> getSubscribersList() {
    UserEntity userEntity = null;//from  w  ww  .j a  v  a  2  s  . co  m
    List<UserEntity> userList = new ArrayList<UserEntity>();
    BasicDBObject query = new BasicDBObject();
    query.put("subscribe", StatusTypes.ACCEPT_SUBSCRB);
    DBCursor cursor = userCollection.find(query);
    try {
        while (cursor.hasNext()) {
            DBObject document = cursor.next();
            userEntity = new UserEntity();
            userEntity.setId((Long) document.get("_id"));
            userEntity.setUsername((String) document.get("username"));
            userEntity.setEmail((String) document.get("email"));
            userEntity.setFirstname((String) document.get("firstname"));
            userEntity.setPasswd((String) document.get("passwd"));
            userEntity.setLastname((String) document.get("lastname"));
            userEntity.setStatus((Integer) document.get("status"));
            userEntity.setImageId((String) document.get("imageId"));
            userEntity.setRegisteredDate((Date) document.get("registeredDate"));
            userEntity.setLastLoginDate((Date) document.get("lastLoginDate"));
            userEntity.setLanguageCode((String) document.get("languageCode"));
            userEntity.setUserRole((Integer) document.get("userRole"));
            userEntity.setModeratorValue((Integer) document.get("moderator"));
            userEntity.setPersonalWebPage((String) document.get("webpage"));
            Integer value = (Integer) document.get("subscribe");
            if (value != null && value.equals(StatusTypes.ACCEPT_LICENSE)) {
                userEntity.setAcceptSubscr(true);
            } else {
                userEntity.setAcceptSubscr(false);
            }
            userList.add(userEntity);
        }
    } finally {
        cursor.close();
    }
    return userList;
}

From source file:bd.DArticulo.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CArticulo x = new CArticulo();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {/*from ww w.java 2  s .c om*/
        while (cursor.hasNext()) {
            x = new CArticulo();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DArticulo.java

@Override
public Object buscar_id(String id_find) {
    ArrayList datos = new ArrayList();
    CArticulo x = new CArticulo();
    conecion con = new conecion(table);
    System.out.println(id_find + "warrennnnn");
    BasicDBObject id = new BasicDBObject("_id", new ObjectId(id_find));
    DBCursor cursor = con.get_colletion().find(id);

    try {//from   w w w  . ja v  a  2s.c  om
        while (cursor.hasNext()) {
            x = new CArticulo();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    if (datos.size() == 0)
        return null;
    return datos.get(0);
}

From source file:bd.DArticulo.java

@Override
public ArrayList listar(String clave, String valor) {
    ArrayList datos = new ArrayList();
    CArticulo x = new CArticulo();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(clave, valor);
    DBCursor cursor = con.get_colletion().find(id);

    try {// www  .jav a2  s  .co  m
        while (cursor.hasNext()) {
            x = new CArticulo();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DArticulo.java

@Override
public ArrayList listar(HashMap map) {
    ArrayList datos = new ArrayList();
    CArticulo x = new CArticulo();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(map);
    DBCursor cursor = con.get_colletion().find(id);

    try {//ww  w  .  j a v  a2  s . c  o  m
        while (cursor.hasNext()) {
            x = new CArticulo();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DCategoria.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CCategoria x = new CCategoria();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {//from   w ww  .  j  a v a 2  s .c o m
        while (cursor.hasNext()) {
            x = new CCategoria();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}

From source file:bd.DCategoria.java

@Override
public Object buscar_id(String id_find) {

    ArrayList datos = new ArrayList();
    CCategoria x = new CCategoria();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject("_id", new ObjectId(id_find));
    DBCursor cursor = con.get_colletion().find(id);

    try {/*  w w  w  .  j av  a2s  .  c  om*/
        while (cursor.hasNext()) {
            x = new CCategoria();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    System.out.println(id_find + "lllll" + datos.size());
    if (datos.size() == 0)
        return null;
    return datos.get(0);
}

From source file:bd.DCategoria.java

@Override
public ArrayList listar(String clave, String valor) {
    ArrayList datos = new ArrayList();
    CCategoria x = new CCategoria();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(clave, valor);
    DBCursor cursor = con.get_colletion().find(id);

    try {//from  w w  w.  j  a  v a2 s .c  o m
        while (cursor.hasNext()) {
            x = new CCategoria();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DCategoria.java

@Override
public ArrayList listar(HashMap map) {
    ArrayList datos = new ArrayList();
    CCategoria x = new CCategoria();
    conecion con = new conecion(table);
    BasicDBObject id = new BasicDBObject(map);
    DBCursor cursor = con.get_colletion().find(id);

    try {/*from w  w w . j a  va  2s  .c o m*/
        while (cursor.hasNext()) {
            x = new CCategoria();
            x.set_datos((HashMap) cursor.next().toMap());
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();

    return datos;
}

From source file:bd.DPersona.java

@Override
public ArrayList listar() {
    ArrayList datos = new ArrayList();
    CPersona x = new CPersona();
    conecion con = new conecion(table);
    DBCursor cursor = con.get_colletion().find();
    try {//from   w w w  . j  a  va2 s  . c  o m
        while (cursor.hasNext()) {
            x = new CPersona();
            BasicDBObject agg = (BasicDBObject) cursor.next();
            x.set_datos((HashMap) agg.toMap());
            x.setId((String) agg.getString("_id"));
            datos.add(x);
        }
    } finally {
        cursor.close();
    }
    con.end();
    return datos;
}