Calculate 'Absolute Margin with Deadline'
FEA: ItEr76S15OrganizingPerProjectDashboard
This commit is contained in:
parent
7fd13ef646
commit
a6a1173203
4 changed files with 59 additions and 12 deletions
|
|
@ -99,17 +99,33 @@ public class DashboardController extends GenericForwardComposer {
|
|||
}
|
||||
|
||||
private void renderMarginWithDeadline() {
|
||||
marginWithDeadline("lblRelative",
|
||||
dashboardModel.getMarginWithDeadLine());
|
||||
// FIXME: Calculate absolute days margin
|
||||
marginWithDeadline("lblAbsolute", BigDecimal.ZERO);
|
||||
marginWithDeadline(dashboardModel.getMarginWithDeadLine());
|
||||
absoluteMarginWithDeadline(dashboardModel
|
||||
.getAbsoluteMarginWithDeadLine());
|
||||
}
|
||||
|
||||
private void marginWithDeadline(String key, BigDecimal value) {
|
||||
Label label = (Label) gridMarginWithDeadline.getFellowIfAny(key);
|
||||
private void marginWithDeadline(BigDecimal value) {
|
||||
Label label = (Label) gridMarginWithDeadline
|
||||
.getFellowIfAny("lblRelative");
|
||||
if (label != null) {
|
||||
value = value != null ? value : BigDecimal.ZERO;
|
||||
label.setValue(String.format(_("%.2f days"), value.doubleValue()));
|
||||
if (value != null) {
|
||||
label.setValue(String.format(_("%.2f %%"),
|
||||
value.doubleValue() * 100));
|
||||
} else {
|
||||
label.setValue(_("<No deadline>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void absoluteMarginWithDeadline(Integer value) {
|
||||
Label label = (Label) gridMarginWithDeadline
|
||||
.getFellowIfAny("lblAbsolute");
|
||||
if (label != null) {
|
||||
if (value != null) {
|
||||
label.setValue(String.format(_("%d days"), value));
|
||||
} else {
|
||||
label.setValue(_("<No deadline>"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import java.math.MathContext;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -74,6 +75,7 @@ public class DashboardModel implements IDashboardModel {
|
|||
private final Map<TaskDeadlineViolationStatusEnum, BigDecimal> taskDeadlineViolationStatusStats;
|
||||
private List<Double> taskEstimationAccuracyHistogram;
|
||||
private BigDecimal marginWithDeadLine;
|
||||
private Integer absoluteMarginWithDeadLine;
|
||||
private List<Double> lagInTaskCompletionHistogram;
|
||||
|
||||
public DashboardModel() {
|
||||
|
|
@ -230,6 +232,33 @@ public class DashboardModel implements IDashboardModel {
|
|||
BigDecimal.ROUND_HALF_EVEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getAbsoluteMarginWithDeadLine() {
|
||||
if (absoluteMarginWithDeadLine == null) {
|
||||
calculateAbsoluteMarginWithDeadLine();
|
||||
}
|
||||
return absoluteMarginWithDeadLine;
|
||||
}
|
||||
|
||||
private void calculateAbsoluteMarginWithDeadLine() {
|
||||
TaskElement rootTask = getRootTask();
|
||||
Date deadline = currentOrder.getDeadline();
|
||||
|
||||
if (rootTask == null) {
|
||||
throw new RuntimeException("Root task is null");
|
||||
}
|
||||
if (deadline == null) {
|
||||
this.absoluteMarginWithDeadLine = null;
|
||||
return;
|
||||
}
|
||||
absoluteMarginWithDeadLine = daysBetween(rootTask.getEndAsLocalDate(),
|
||||
LocalDate.fromDateFields(deadline));
|
||||
}
|
||||
|
||||
private int daysBetween(LocalDate start, LocalDate end) {
|
||||
return Days.daysBetween(start, end).getDays();
|
||||
}
|
||||
|
||||
/* Time KPI: Estimation accuracy */
|
||||
@Override
|
||||
public List<Double> getFinishedTasksEstimationAccuracyHistogram() {
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ interface IDashboardModel {
|
|||
/* Time KPI: "Margin with deadline" */
|
||||
BigDecimal getMarginWithDeadLine();
|
||||
|
||||
Integer getAbsoluteMarginWithDeadLine();
|
||||
|
||||
/* Time KPI: "Estimation accuracy" */
|
||||
List<Double> getFinishedTasksEstimationAccuracyHistogram();
|
||||
|
||||
|
|
|
|||
|
|
@ -93,14 +93,14 @@
|
|||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Relative')}:"/>
|
||||
<label id="lblRelative" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Absolute')}:"/>
|
||||
<label id="lblAbsolute" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Relative')}:"/>
|
||||
<label id="lblRelative" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</hbox>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue