public Issue createIssue(Issue p) { System.out.println("inside createIssue"); DBObject doc = IssueConverter.toDBObject(p); this.col.insert(doc); ObjectId id = (ObjectId) doc.get("_id"); p.setId(id.toString()); return p; }
public List<Issue> readAllIssue() { System.out.println("inside read all Issue"); List<Issue> data = new ArrayList<Issue>(); DBCursor cursor = col.find(); while (cursor.hasNext()) { DBObject doc = cursor.next(); Issue p = IssueConverter.toIssue(doc); System.out.println(p.getId()); System.out.println(p.getDescription()); System.out.println(p.getStatus()); System.out.println(p.getSeverity()); data.add(p); } System.out.println("read all success"); return data; }
public Issue readIssue(Issue p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getId())).get(); DBObject data = this.col.findOne(query); return IssueConverter.toIssue(data); }
public void updateIssue(Issue p) { DBObject query = BasicDBObjectBuilder.start().append("_id", new ObjectId(p.getId())).get(); this.col.update(query, IssueConverter.toDBObject(p)); }