public Sprint findSprintinProject(
     String username, String projectName, String projectType, String sprintName)
     throws NullMongoTemplateException {
   Sprint sprint = null;
   MongoOperations mongoOperations = getMongoOperationInstance();
   if (mongoOperations == null) {
     throw new NullMongoTemplateException();
   }
   ProjectScrum project =
       mongoOperations.findOne(
           query(
               where("projectname")
                   .is(projectName)
                   .and("ownername")
                   .is(username)
                   .and("projecttype")
                   .is(projectType)),
           ProjectScrum.class);
   if (project != null) {
     List<Sprint> sprints = project.getSprints();
     if (sprints.size() == 0) {
       return null;
     }
     for (Sprint sprint1 : sprints) {
       if (sprint1.getSprintName().equals(sprintName)) {
         sprint = sprint1;
         break;
       }
     }
   }
   return sprint;
 }
 public int getHoursRemaining(String projectid, String projecttype)
     throws NullMongoTemplateException {
   MongoOperations mongoOperations = getMongoOperationInstance();
   if (mongoOperations == null) {
     throw new NullMongoTemplateException();
   }
   ProjectScrum project =
       mongoOperations.findOne(query(where("_id").is(projectid)), ProjectScrum.class, "project");
   int totalHours = 0;
   int hoursCompleted = 0;
   List<Sprint> sprints = project.getSprints();
   for (Sprint sprint : sprints) {
     List<TaskScrum> tasks = sprint.getTasks();
     for (TaskScrum task : tasks) {
       totalHours = totalHours + task.getHoursAllotted();
       hoursCompleted = hoursCompleted + task.getHoursCompleted();
     }
   }
   int hoursRemaining = totalHours - hoursCompleted;
   return hoursRemaining;
 }
 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);
 }