public void calculateProjectMetrics(Product product) { if (product != null && product.getProjects() != null && product.getProjects().size() > 0) { // ProjectData projectDataMap for (Project p : product.getProjects()) { ProjectMetrics metrics = new ProjectMetrics(); metrics.setAssignees(backlogBusiness.getNumberOfAssignedUsers(p)); if (p.getIterations() != null) { metrics.setNumberOfAllIterations(p.getIterations().size()); int ongoingIters = 0; Date current = Calendar.getInstance().getTime(); for (Iteration iter : p.getIterations()) { if (iter.getStartDate().getTime() < current.getTime() && iter.getEndDate().getTime() > current.getTime()) { ongoingIters++; } } metrics.setNumberOfOngoingIterations(ongoingIters); } else { metrics.setNumberOfAllIterations(0); metrics.setNumberOfOngoingIterations(0); } p.setMetrics(metrics); } } }
/** {@inheritDoc} */ public ProjectMetrics getProjectMetrics(Project proj) { ProjectMetrics metrics = new ProjectMetrics(); metrics = projectDAO.getProjectBLIMetrics(proj); if (metrics == null) { metrics = new ProjectMetrics(); } if (metrics.getTotalItems() > 0) { metrics.setCompletedItems(projectDAO.getDoneBLIs(proj)); } BacklogMetrics projMetrics = backlogBusiness.calculateLimitedBacklogMetrics(proj); if (metrics.getEffortLeft() != null) { metrics.getEffortLeft().add(projMetrics.getEffortLeft()); } else { metrics.setEffortLeft(projMetrics.getEffortLeft()); } if (metrics.getOriginalEstimate() != null) { metrics.getOriginalEstimate().add(projMetrics.getOriginalEstimate()); } else { metrics.setOriginalEstimate(projMetrics.getOriginalEstimate()); } metrics.setTotalItems(metrics.getTotalItems() + projMetrics.getTotalItems()); if (metrics.getCompletedItems() != null) { metrics.setCompletedItems(metrics.getCompletedItems() + projMetrics.getCompletedItems()); } else { metrics.setCompletedItems(projMetrics.getCompletedItems()); } if (metrics.getTotalItems() > 0) { metrics.setPercentDone( Math.round( 100.0f * (float) metrics.getCompletedItems() / (float) metrics.getTotalItems())); } return metrics; }