List of usage examples for com.mongodb.client MongoCollection find
FindIterable<TDocument> find(ClientSession clientSession);
From source file:data.ProjectMember.java
License:Open Source License
public static ProjectMember getByPrimaryKey(String userLoginName, int projectId, DBManagerMongo manager) throws Exception { MongoCollection<Document> coll = manager.getDb().getCollection("project_member"); FindIterable<Document> doc = coll .find(and(eq("user_login_name", userLoginName), eq("project_id", projectId))); MongoCursor<Document> cursor = doc.iterator(); if (!cursor.hasNext()) throw new Exception("no such record"); return extractMember(cursor.next(), manager); }
From source file:data.ProjectMember.java
License:Open Source License
public static ArrayList<ProjectMember> getMembersByProjectId(int projectId, DBManagerMongo manager) throws Exception { ArrayList<ProjectMember> list = new ArrayList<>(); MongoCollection<Document> coll = manager.getDb().getCollection("project_member"); FindIterable<Document> doc = coll.find(eq("project_id", projectId)); MongoCursor<Document> cursor = doc.iterator(); while (cursor.hasNext()) list.add(extractMember(cursor.next(), manager)); return list;/*from ww w.j a va 2 s .co m*/ }
From source file:data.ProjectMember.java
License:Open Source License
public static ArrayList<ProjectMember> getInvolvedProjects(String loginName, DBManagerMongo manager) throws Exception { ArrayList<ProjectMember> list = new ArrayList<>(); MongoCollection<Document> coll = manager.getDb().getCollection("project_member"); FindIterable<Document> doc = coll.find(and(eq("user_login_name", loginName), eq("role", "MEMBER"))); MongoCursor<Document> cursor = doc.iterator(); while (cursor.hasNext()) list.add(extractMember(cursor.next(), manager)); return list;/*from ww w . j av a 2 s.co m*/ }
From source file:data.ProjectMember.java
License:Open Source License
public static ArrayList<ProjectMember> getOwnedProject(String loginName, DBManagerMongo manager) throws Exception { ArrayList<ProjectMember> list = new ArrayList<>(); MongoCollection<Document> coll = manager.getDb().getCollection("project_member"); FindIterable<Document> doc = coll.find(and(eq("user_login_name", loginName), eq("role", "LEADER"))); MongoCursor<Document> cursor = doc.iterator(); while (cursor.hasNext()) list.add(extractMember(cursor.next(), manager)); return list;// w w w. j ava2s .c o m }
From source file:data.ProjectPhase.java
License:Open Source License
public static ProjectPhase getByPrimaryKey(int id, DBManagerMongo manager) throws Exception { MongoCollection<Document> coll = manager.getDb().getCollection("project_phase"); FindIterable<Document> doc = coll.find(eq("id", id)); MongoCursor<Document> cursor = doc.iterator(); if (!cursor.hasNext()) throw new Exception("no such record"); return extractPhase(cursor.next(), manager); }
From source file:data.ProjectPhase.java
License:Open Source License
public static ArrayList<ProjectPhase> getByProjectId(int projectId, DBManagerMongo manager) throws Exception { ArrayList<ProjectPhase> list = new ArrayList<>(); MongoCollection<Document> coll = manager.getDb().getCollection("project_phase"); FindIterable<Document> doc = coll.find(eq("project_id", projectId)); MongoCursor<Document> cursor = doc.iterator(); while (cursor.hasNext()) list.add(extractPhase(cursor.next(), manager)); return list;/*from w w w . ja va 2 s . c om*/ }
From source file:data.User.java
License:Open Source License
public static User getByPrimaryKey(String loginName, DBManagerMongo manager) throws Exception { MongoCollection<Document> coll = manager.getDb().getCollection("user"); FindIterable<Document> doc = coll.find(eq("login_name", loginName)); MongoCursor<Document> cursor = doc.iterator(); if (!cursor.hasNext()) throw new Exception("no such record"); return extractUser(cursor.next()); }
From source file:dipu.familytree.models.Person.java
public static Person findOne(Bson filter) { // get collection MongoCollection<Document> col = App.instance.mongo().collection(COLLECTION); // search existing person Document doc = col.find(filter).first(); // return person return Person.fromDocument(doc); }
From source file:dipu.familytree.models.Person.java
public static List<Person> find(Bson filter, boolean populate) { // get collection MongoCollection<Document> col = App.instance.mongo().collection(COLLECTION); // build person list List<Person> persons = new ArrayList<>(); // search existing person col.find(filter).forEach((Consumer<? super Document>) (Document doc) -> { Person person = Person.fromDocument(doc); if (populate) { person.populate();// w w w .j a va 2 s .c o m } persons.add(person); }); // return person list return persons; }
From source file:dto.Dto.java
public String getNombreAsesor(String idA) { String nombre = ""; MongoCollection<Document> col = c.getConnection("tesis_alumno_asesor"); Document doc = col.find(and(eq("_id", idA), eq("estadoA", "aceptado"))).first(); String idP = doc.getString("idAsesor"); MongoCollection<Document> col2 = c.getConnection("profesores"); Document doc2 = col2.find(eq("_id", idP)).first(); nombre = doc2.getString("nombre"); return nombre; }