List of usage examples for com.mongodb.client MongoCollection find
FindIterable<TDocument> find(ClientSession clientSession);
From source file:dto.Dto.java
public String getSeccion(String id) { String sec = ""; MongoCollection<Document> col = c.getConnection("alumnos"); Document doc = col.find(eq("_id", id)).first(); try {/*from w w w . j a va 2 s . com*/ System.out.println(doc); sec = String.valueOf(doc.getString("seccion")); } catch (Exception e) { System.out.println(e); } return sec; }
From source file:dto.Dto.java
public String loginStudent(String u, String p) { String id;/* www.jav a 2s.c o m*/ JSONObject o = new JSONObject(); MongoCollection<Document> col = c.getConnection("alumnos"); Document doc = col.find(and(eq("usuario", u), eq("psw", p))).first(); try { o.put("nombre", doc.getString("nombre")); o.put("id", doc.getString("_id")); o.put("seccion", doc.getString("seccion")); } catch (NullPointerException e) { System.out.println(e); o.put("nombre", "error"); o.put("id", "error"); o.put("seccion", "error"); } return o.toString(); }
From source file:dto.Dto.java
public String loginTeacher(String u, String p) { String id;/*from w w w. ja v a 2 s .co m*/ JSONObject o = new JSONObject(); MongoCollection<Document> col = c.getConnection("profesores"); Document doc = col.find(and(eq("usuario", u), eq("psw", p))).first(); try { o.put("nombre", doc.getString("nombre")); o.put("id", doc.getString("_id")); o.put("seccion", doc.getString("seccion")); } catch (NullPointerException e) { System.out.println(e); o.put("nombre", "error"); o.put("id", "error"); o.put("seccion", "error"); } return o.toString(); }
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;/*www. j a v a 2 s .c o m*/ 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 getAlumno(String id) { MongoCollection<Document> col = c.getConnection("alumnos"); JSONObject o = new JSONObject(); try {/* w w w .j a v a 2s .com*/ Document doc = col.find(eq("_id", id)).first(); o.put("nombre", doc.getString("nombre")); o.put("id", doc.getString("_id")); o.put("seccion", doc.getString("seccion")); } catch (NullPointerException e) { o.clear(); } return o.toString(); }
From source file:dto.Dto.java
public String getAsesor(String id) { JSONObject o = new JSONObject(); MongoCollection<Document> col = c.getConnection("profesores"); try {/* w ww .j av a 2 s. com*/ Document doc = col.find(eq("_id", id)).first(); o.put("nombre", doc.getString("nombre")); o.put("id", doc.getString("_id")); o.put("seccion", doc.getString("seccion")); //p = doc.getString("nombre"); } catch (NullPointerException e) { o.clear(); } return o.toString(); }
From source file:dto.Dto.java
public String getNombreAlumno(String id) { String nombre = ""; MongoCollection<Document> col = c.getConnection("alumnos"); try {/*from w w w . ja va 2 s. c om*/ Document doc = col.find(eq("_id", id)).first(); nombre = doc.getString("nombre"); //p = doc.getString("nombre"); } catch (NullPointerException e) { nombre = ""; } return nombre; }
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 ww w . j av a 2 s. c o m*/ 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 w w w. j a v a 2s. co m*/ 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 void enviarSolicitud(String idTesis, String idA) { MongoCollection<Document> col = c.getConnection("tesis_alumno_asesor"); Document doc = col.find(eq("_id", idTesis)).first(); col.updateOne(doc, new Document("$set", new Document("estadoA", "pendiente"))); MongoCollection<Document> col1 = c.getConnection("tesis_alumno_asesor"); Document doc1 = col1.find(eq("_id", idTesis)).first(); col.updateOne(doc1, new Document("$set", new Document("idAsesor", idA))); }