diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java index ea4af45f7..1873c1355 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardController.java @@ -35,7 +35,6 @@ import org.springframework.stereotype.Component; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zul.Div; -import org.zkoss.zul.Grid; import org.zkoss.zul.Label; import br.com.digilabs.jqplot.Chart; @@ -56,7 +55,6 @@ public class DashboardController extends GenericForwardComposer { private IDashboardModel dashboardModel; - private Grid gridTasksSummary; private Label lblOvertimeRatio; private Label lblAvailabilityRatio; private Label lblAbsolute; diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java index 38426594d..9e6720ee9 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/DashboardModel.java @@ -22,7 +22,6 @@ package org.libreplan.web.dashboard; import java.math.BigDecimal; import java.math.MathContext; import java.math.RoundingMode; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -55,10 +54,12 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** - * Model for UI operations related to Order Dashboard View - * * @author Nacho Barrientos * @author Lorenzo Tilve Álvaro + * @author Diego Pino García + * + * Model for UI operations related to Order Dashboard View + * */ @Component @Scope(BeanDefinition.SCOPE_PROTOTYPE) @@ -83,10 +84,8 @@ public class DashboardModel implements IDashboardModel { private final Map taskStatusStats; private final Map taskDeadlineViolationStatusStats; - private List taskEstimationAccuracyHistogram; private BigDecimal marginWithDeadLine; private Integer absoluteMarginWithDeadLine; - private List lagInTaskCompletionHistogram; public DashboardModel() { taskStatusStats = new EnumMap( @@ -104,8 +103,6 @@ public class DashboardModel implements IDashboardModel { this.calculateTaskViolationStatusStatistics(); this.calculateAbsoluteMarginWithDeadLine(); this.calculateMarginWithDeadLine(); - this.calculateFinishedTasksEstimationAccuracyHistogram(); - this.calculateLagInTaskCompletionHistogram(); } } @@ -266,86 +263,6 @@ public class DashboardModel implements IDashboardModel { return Days.daysBetween(start, end).getDays(); } - /* Time KPI: Estimation accuracy */ - @Override - public List getFinishedTasksEstimationAccuracyHistogram() { - return this.taskEstimationAccuracyHistogram; - } - - private void calculateFinishedTasksEstimationAccuracyHistogram() { - if (this.getRootTask() == null) { - throw new RuntimeException("Root task is null"); - } - CalculateFinishedTasksEstimationDeviationVisitor visitor = new CalculateFinishedTasksEstimationDeviationVisitor(); - TaskElement rootTask = getRootTask(); - rootTask.acceptVisitor(visitor); - List deviations = visitor.getDeviations(); - - // [-100, -90), [-90, -80), ..., [190, 200), [200, inf) - this.taskEstimationAccuracyHistogram = createHistogram( - EA_STRETCHES_MIN_VALUE, EA_STRETCHES_MAX_VALUE, - EA_STRETCHES_PERCENTAGE_STEP, deviations); - } - - /* Time KPI: Lead/Lag in task completion */ - @Override - public List getLagInTaskCompletionHistogram() { - return this.lagInTaskCompletionHistogram; - } - - private void calculateLagInTaskCompletionHistogram() { - if (this.getRootTask() == null) { - throw new RuntimeException("Root task is null"); - } - CalculateFinishedTasksLagInCompletionVisitor visitor = new CalculateFinishedTasksLagInCompletionVisitor(); - TaskElement rootTask = getRootTask(); - rootTask.acceptVisitor(visitor); - List deviations = visitor.getDeviations(); - - if (deviations.isEmpty()) { - LTC_STRETCHES_MIN_VALUE = 0; - LTC_STRETCHES_MAX_VALUE = 0; - } else { - LTC_STRETCHES_MIN_VALUE = Collections.min(deviations); - LTC_STRETCHES_MAX_VALUE = Collections.max(deviations); - } - LTC_STRETCHES_STEP = (LTC_STRETCHES_MAX_VALUE - LTC_STRETCHES_MIN_VALUE) - / LTC_NUMBER_OF_INTERVALS; - this.lagInTaskCompletionHistogram = createHistogram( - LTC_STRETCHES_MIN_VALUE, LTC_STRETCHES_MAX_VALUE, - LTC_STRETCHES_STEP, deviations); - } - - private List createHistogram(double lowBound, double highBound, - double intervalStep, List values) { - double variableRange = highBound - lowBound; - /* TODO: What if highBound == lowBound? */ - int numberOfClasses = (int) (variableRange / intervalStep); - int[] classes = new int[numberOfClasses + 1]; - - for (Double value : values) { - int index; - if (value >= highBound) { - index = numberOfClasses; - } else { - index = (int) (numberOfClasses * (((value.doubleValue() - lowBound)) / variableRange)); - } - classes[index]++; - } - - List histogram = new ArrayList(); - int numberOfConsideredTasks = values.size(); - for (int numberOfElementsInClass : classes) { - Double relativeCount = new Double(0.0); - if (numberOfConsideredTasks > 0) { - relativeCount = new Double(1.0 * numberOfElementsInClass - / numberOfConsideredTasks); - } - histogram.add(relativeCount); - } - return histogram; - } - /** * Calculates the task completation deviations for the current order * @@ -635,4 +552,4 @@ public class DashboardModel implements IDashboardModel { RoundingMode.HALF_UP); } -} \ No newline at end of file +} diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/IDashboardModel.java b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/IDashboardModel.java index 2258b3a40..c9fa5fff4 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/IDashboardModel.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/dashboard/IDashboardModel.java @@ -20,7 +20,6 @@ package org.libreplan.web.dashboard; import java.math.BigDecimal; -import java.util.List; import java.util.Map; import org.libreplan.business.orders.entities.Order; @@ -34,6 +33,8 @@ interface IDashboardModel { boolean tasksAvailable(); /* Progress KPI: "Number of tasks by status" */ + Map calculateTaskStatus(); + BigDecimal getPercentageOfFinishedTasks(); BigDecimal getPercentageOfInProgressTasks(); @@ -68,17 +69,12 @@ interface IDashboardModel { Integer getAbsoluteMarginWithDeadLine(); /* Time KPI: "Estimation accuracy" */ - List getFinishedTasksEstimationAccuracyHistogram(); + Map calculateEstimationAccuracy(); /* Time KPI: "Lead/Lag in task completion" */ - List getLagInTaskCompletionHistogram(); - - Map calculateTaskStatus(); - Map calculateTaskCompletion(); /* Resources KPI: "Overtime Ratio" */ - Map calculateEstimationAccuracy(); // (Load + Overload) / Load BigDecimal getOvertimeRatio();