public void updateProjectUpdateTaskInProject(Task task, String projectid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } Query query = new Query(where("_id").is(projectid)); Update update = new Update().pull("tasks", new BasicDBObject("_id", task.getId())); mongoOperations.updateFirst(query, update, Project.class); update = new Update().push("tasks", task); mongoOperations.updateFirst(query, update, Project.class); }
public void updateProjectDeleteStoryFromSprint( String projectid, Sprint sprint, String taskScrumid) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } Query query = new Query(where("_id").is(projectid)); Update update = new Update().pull("sprints", new BasicDBObject("_id", sprint.getId())); mongoOperations.updateFirst(query, update, Project.class); mongoOperations.updateFirst( query(where("_id").is(projectid)), new Update().push("sprints", sprint), Project.class); }
public void updateProjectAddSprint(String projectid, Sprint sprint) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } mongoOperations.updateFirst( query(where("_id").is(projectid)), new Update().push("sprints", sprint), Project.class); }
@Override public int updateActualUserReference(String id, Reference newRef) { Query q = new Query(); q.addCriteria(Criteria.where("id").is(id)); Update u = new Update(); u.set("actualUser", newRef); WriteResult w = mongoOp.updateFirst(q, u, Character.class); return w.getN(); }
@Override public boolean setCover(String characterId, String coverId) { Query q = new Query(); q.addCriteria(Criteria.where("id").is(characterId)); Update u = new Update(); u.set("cover", coverId); WriteResult w = mongoOp.updateFirst(q, u, User.class); if (w.isUpdateOfExisting()) return true; else return false; }
public void updateProjectAddTask(String projectname, String username, Task task) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } mongoOperations.updateFirst( query(where("projectname").is(projectname).and("ownername").is(username)), new Update().push("tasks", task), Resource.class); }
@Override public boolean addPostToCharacter(String id, PostReference postReference) { Query q = new Query(); q.addCriteria(Criteria.where("id").is(id)); Update u = new Update(); u.push("posts", postReference); WriteResult w = mongoOp.updateFirst(q, u, Character.class); if (w.isUpdateOfExisting()) return true; else return false; }
@Override public void update(Season editSeason) { Query searchSeasonQuery = new Query(Criteria.where("id").is(editSeason.getId())); for (Field field : editSeason.getClass().getDeclaredFields()) { field.setAccessible(true); try { mongoOperation.updateFirst( searchSeasonQuery, Update.update(field.getName(), field.get(editSeason)), Season.class); } catch (IllegalAccessException ignored) { } } }
@Override public boolean removePostFromCharacter(String id, String postId) { Query q = new Query(); q.addCriteria(Criteria.where("id").is(id)); PostReference post = new PostReference(); post.setId(postId); Update u = new Update(); u.pull("posts", post); WriteResult w = mongoOp.updateFirst(q, u, Character.class); if (w.isUpdateOfExisting()) return true; else return false; }