public int getPercentageComplete(String projectid, String projecttype) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectKanban project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectKanban.class, "project"); List<Task> tasks = project.getTasks(); int countReady = 0; int countInProgress = 0; int countComplete = 0; for (Task task : tasks) { if (task.getStatus().equals("Ready")) { countReady++; } else if (task.getStatus().equals("Inprogress")) { countInProgress++; } else { countComplete++; } } int totalCount = countComplete + countReady + countInProgress; System.out.println(countComplete + countReady + countInProgress); int percentageComplete = (1 / 3) * 100; return percentageComplete; }
public Map<String, Integer> getQueuesOverLimit(String projectid, String projecttype) throws NullMongoTemplateException { MongoOperations mongoOperations = getMongoOperationInstance(); if (mongoOperations == null) { throw new NullMongoTemplateException(); } ProjectWF project = mongoOperations.findOne(query(where("_id").is(projectid)), ProjectWF.class, "project"); List<Task> tasks = project.getTasks(); int countReady = 0; int countInProgress = 0; int countComplete = 0; for (Task task : tasks) { if (task.getStatus().equals("1")) { countReady++; } else if (task.getStatus().equals("2")) { countInProgress++; } else { countComplete++; } } Map<String, Integer> table = new Hashtable<>(); table.put("Ready", countReady); table.put("Inprogress", countInProgress); table.put("Completed", countComplete); return table; }
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); }