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 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; }