Example usage for com.mongodb.client MongoCursor hasNext

List of usage examples for com.mongodb.client MongoCursor hasNext

Introduction

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

Prototype

@Override
    boolean hasNext();

Source Link

Usage

From source file:dto.Dto.java

public String listarTesis() {
    String cadena = "";
    MongoCollection<Document> col = c.getConnection("universo_tesis");
    MongoCursor<Document> cursor = col.find().sort(Sorts.orderBy(Sorts.descending("ao"))).iterator();
    Document doc;//from  w w  w.  ja va  2  s  . co  m
    try {
        while (cursor.hasNext()) {
            doc = cursor.next();
            cadena += "<tr>" + "<td width='20%'>" + doc.getString("titulo").toUpperCase().trim() + "</td>"
                    + "<td width='20%'>" + doc.getString("ao") + "</td>" + "<td width='20%'>"
                    + doc.getString("estado").toUpperCase().trim() + "</td>" + "</tr>";
        }
    } catch (Exception e) {
        System.out.println("listarTesis universo: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:dto.Dto.java

public String listarActas() {
    String cadena = "";
    MongoCollection<Document> col = c.getConnection("actas");
    MongoCursor<Document> cursor = col.find(eq("estado", "pendiente")).iterator();
    Document doc;/* w w w.  java2 s  .c  om*/
    try {
        while (cursor.hasNext()) {
            doc = cursor.next();
            cadena += "<tr>" + "<td width='20%'>" + doc.getString("tema").toUpperCase().trim() + "</td>"
                    + "<td width='20%'>" + doc.getString("temas") + "</td>" + "<td width='20%'>"
                    + doc.getString("reco").toUpperCase().trim() + "</td>" + "<td width='20%'>"
                    + getNombreAlumno(doc.getString("idAlumno")) + "</td>";
            if (doc.getString("estado").equalsIgnoreCase("pendiente")) {
                cadena += "<td width='20%'><button onclick='aceptarActa(" + doc.getString("_id")
                        + ")'>OK</button>" + "<button onclick='rechazarActa(" + doc.getString("_id")
                        + ")'>X</button></td><tr>";
            } else {
                cadena += "<td width='20%'></td><tr>";
            }
        }
    } catch (Exception e) {
        cadena = "No tiene actas pendientes";
        System.out.println("listarActas: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:dto.Dto.java

public String listarTesisAsesor(String id) {
    String cadena = "";
    MongoCollection<Document> col = c.getConnection("tesis_alumno_asesor");
    MongoCursor<Document> cursor = col.find(and(eq("estadoA", "pendiente"), eq("idAsesor", id))).iterator();
    Document doc;//from w  w w  .j a v a 2s . c  om
    try {

        while (cursor.hasNext()) {
            System.out.println("while asessor");
            doc = cursor.next();
            cadena += "<tr>" + "<td width='20%'>" + doc.getString("titulo").toUpperCase().trim() + "</td>"
                    + "<td width='20%'>" + getNombreAlumno(doc.getString("idAlumno")) + "</td>";
            if (doc.getString("estadoA").equalsIgnoreCase("pendiente")) {
                cadena += "<td width='20%'><button onclick='aceptarSolicitud(" + doc.getString("_id")
                        + ")'>OK</button>" + "<button onclick='rechazarSolicitud(" + doc.getString("_id")
                        + ")'>X</button></td><tr>";
            } else {
                cadena += "<td width='20%'></td><tr>";
            }
            //System.out.println(doc);               
        }
        //p = doc.getString("nombre");
    } catch (NullPointerException e) {
        System.out.println("tesisAsesor: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:dto.Dto.java

public String listarTesisProfesor(String seccion) {
    MongoCollection<Document> col = c.getConnection("tesis_alumno_asesor");
    MongoCursor<Document> cursor = col.find(eq("seccion", seccion)).iterator();
    Document doc;//from ww w . j a v  a  2s  .  c  om
    String cadena = "";
    try {

        while (cursor.hasNext()) {
            doc = cursor.next();
            cadena += "<tr>" + "<td width='20%'>" + doc.getString("titulo").toUpperCase().trim() + "</td>"
                    + "<td width='20%'>" + getNombreAlumno(doc.getString("idAlumno")) + "</td>";
            if (doc.getString("estadoP").equalsIgnoreCase("pendiente")) {
                cadena += "<td width='20%'><button onclick='aceptarTesis(" + doc.getString("_id")
                        + ")'>OK</button>" + "<button onclick='rechazarTesis(" + doc.getString("_id")
                        + ")'>X</button></td><tr>";
            } else {
                cadena += "<td width='20%'></td><tr>";
            }
            //System.out.println(doc);               
        }
        //p = doc.getString("nombre");
    } catch (NullPointerException e) {
        System.out.println("listar tesis: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:dto.Dto.java

public String listarTesisSinAsesor(String seccion) {
    MongoCollection<Document> col = c.getConnection("tesis_alumno_asesor");
    MongoCursor<Document> cursor = col.find(and(eq("seccion", (seccion)), eq("idAsesor", "0"))).iterator();
    Document doc;/*from   ww w .j a  v a2 s.  c o m*/
    String cadena = "";
    try {

        while (cursor.hasNext()) {
            doc = cursor.next();
            cadena += "<tr>" + "<td width='20%'>" + doc.getString("titulo").toUpperCase().trim() + "</td>"
                    + "<td width='20%'><select id='sel' style='display:inline'><option>*** Seleccione asesor ***</option></select></td>"
                    + "<td><button onclick='enviarSolicitud(" + doc.getString("_id")
                    + ")'>Enviar</button></td></tr>";
            //System.out.println(doc);               
        }
        //p = doc.getString("nombre");
    } catch (NullPointerException e) {
        System.out.println("listar sin asesor: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:dto.Dto.java

public String listarAsesores() {
    String cadena = "";
    MongoCollection<Document> col = c.getConnection("profesores");
    MongoCursor<Document> cursor = col.find().iterator();
    Document doc;// www.  j a  va 2  s.co m
    try {
        while (cursor.hasNext()) {
            doc = cursor.next();
            cadena += "<option value='" + doc.getString("_id") + "'>" + doc.getString("nombre") + "</option>";
        }
    } catch (Exception e) {
        System.out.println("listarTesisAsesores: " + e);
    } finally {
        cursor.close();
    }
    return cadena;
}

From source file:edu.ucuenca.storage.services.MongoServiceImpl.java

License:Apache License

@Override
public Document getCluster(String... uri) {
    List<Bson> ls = new ArrayList<>();
    List<Document> c = new ArrayList<>();
    for (String p : uri) {
        Bson eq = eq("_id", p);
        ls.add(eq);//from w  w  w.ja v a2  s.  c  o m
    }
    FindIterable<Document> sort = clusters.find(or(ls)).projection(include("subclusters"))
            .sort(ascending("label-en"));
    MongoCursor<Document> it = sort.iterator();
    while (it.hasNext()) {
        c.add(it.next());
    }
    Document parse = new Document();

    if (c.size() == 1) {
        parse = c.get(0);
    } else {
        parse.put("data", c);
    }
    return parse;

}

From source file:edu.ucuenca.storage.services.MongoServiceImpl.java

License:Apache License

@Override
public List<Document> getClusters() {
    List<Document> c = new ArrayList<>();
    FindIterable<Document> cls = clusters.find().projection(exclude("subclusters"))
            .sort(ascending("label-en", "label-es"));
    MongoCursor<Document> it = cls.iterator();
    while (it.hasNext()) {
        c.add(it.next());//from  w ww  . j a v a2s. co  m
    }
    return c;
}

From source file:edu.ucuenca.storage.services.MongoServiceImpl.java

License:Apache License

@Override
public List<Document> getCountries() {
    List<Document> c = new ArrayList<>();
    FindIterable<Document> cls = countries.find();
    MongoCursor<Document> it = cls.iterator();
    while (it.hasNext()) {
        c.add(it.next());/*  ww w  .j  av  a2 s.  co m*/
    }
    return c;
}

From source file:edu.ucuenca.storage.services.MongoServiceImpl.java

License:Apache License

@Override
public List<Document> getClustersTotals() {
    List<Document> c = new ArrayList<>();
    MongoCursor<Document> it = clustersTotals.find().iterator();
    while (it.hasNext()) {
        c.add(it.next());/*w  ww. jav a 2 s. c o m*/
    }
    return c;
}