コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 @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();
 }
コード例 #5
0
 @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;
 }
コード例 #6
0
 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);
 }
コード例 #7
0
  @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;
  }
コード例 #8
0
ファイル: SeasonDaoImpl.java プロジェクト: ppk19052014/ppk
 @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) {
     }
   }
 }
コード例 #9
0
  @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;
  }