[Bug #1115] Fix bug and add new ProgressType for spread progress
Calculation done for progress of all tasks it was really showing the spread progress. Then a new ProgressType is created and calculation is fixed. FEA: ItEr75S04BugFixing
This commit is contained in:
parent
a91f9108ca
commit
f031dd5a7f
8 changed files with 89 additions and 23 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
package org.navalplanner.business.common.entities;
|
||||
|
||||
import static org.navalplanner.business.i18n.I18nHelper.*;
|
||||
import static org.navalplanner.business.i18n.I18nHelper._;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
|
@ -33,7 +33,8 @@ import java.util.List;
|
|||
*/
|
||||
public enum ProgressType {
|
||||
|
||||
SPREAD_PROGRESS(_("Progress with all tasks by hours")),
|
||||
SPREAD_PROGRESS(_("Spreading progress")),
|
||||
ALL_NUMHOURS(_("Progress with all tasks by hours")),
|
||||
CRITICAL_PATH_DURATION(_("Progress with critical path tasks by hours")),
|
||||
CRITICAL_PATH_NUMHOURS(_("Progress with critical path tasks by duration"));
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ public class PlanningData extends BaseEntity {
|
|||
|
||||
private TaskGroup rootTask;
|
||||
|
||||
private BigDecimal progressAllByNumHours;
|
||||
|
||||
private BigDecimal progressByDuration;
|
||||
|
||||
private BigDecimal progressByNumHours;
|
||||
|
|
@ -55,6 +57,10 @@ public class PlanningData extends BaseEntity {
|
|||
|
||||
}
|
||||
|
||||
public BigDecimal getProgressAllByNumHours() {
|
||||
return progressAllByNumHours;
|
||||
}
|
||||
|
||||
public BigDecimal getProgressByDuration() {
|
||||
return progressByDuration;
|
||||
}
|
||||
|
|
@ -72,6 +78,8 @@ public class PlanningData extends BaseEntity {
|
|||
LOG.warn("it can't be updated because the critical path provided is empty");
|
||||
return;
|
||||
}
|
||||
progressAllByNumHours = rootTask.getOrderElement()
|
||||
.getAdvancePercentageChildren();
|
||||
progressByDuration = calculateByDuration(criticalPath);
|
||||
progressByNumHours = calculateByNumHours(criticalPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -625,6 +625,12 @@ public abstract class TaskElement extends BaseEntity {
|
|||
: advancePercentage;
|
||||
}
|
||||
|
||||
/**
|
||||
* For common tasks it just return the spread progress.
|
||||
*
|
||||
* It's overridden in {@link TaskGroup} to return different progresses
|
||||
* depending on parameter
|
||||
*/
|
||||
public BigDecimal getAdvancePercentage(ProgressType progressType) {
|
||||
if (progressType.equals(ProgressType.SPREAD_PROGRESS)) {
|
||||
return advancePercentage;
|
||||
|
|
@ -676,4 +682,4 @@ public abstract class TaskElement extends BaseEntity {
|
|||
return getName();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,6 +74,13 @@ public class TaskGroup extends TaskElement {
|
|||
return planningData.getProgressByNumHours();
|
||||
}
|
||||
|
||||
public BigDecimal getProgressAllByNumHours() {
|
||||
if (planningData == null) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
return planningData.getProgressAllByNumHours();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@AssertTrue(message = "order element associated to a task group must be not null")
|
||||
private boolean theOrderElementMustBeNotNull() {
|
||||
|
|
@ -270,10 +277,12 @@ public class TaskGroup extends TaskElement {
|
|||
*/
|
||||
public BigDecimal getAdvancePercentage(ProgressType progressType) {
|
||||
if (isTaskRoot(this)) {
|
||||
if (progressType.equals(ProgressType.CRITICAL_PATH_DURATION)) {
|
||||
switch (progressType) {
|
||||
case ALL_NUMHOURS:
|
||||
return getProgressAllByNumHours();
|
||||
case CRITICAL_PATH_DURATION:
|
||||
return getCriticalPathProgressByDuration();
|
||||
}
|
||||
if (progressType.equals(ProgressType.CRITICAL_PATH_NUMHOURS)) {
|
||||
case CRITICAL_PATH_NUMHOURS:
|
||||
return getCriticalPathProgressByNumHours();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,4 +216,11 @@
|
|||
<dropColumn tableName="configuration_roles_ldap" columnName="role_matching_id" />
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="add-column-progress_all_by_num_hours-in-planning_data" author="mrego">
|
||||
<comment>Add column progress_all_by_num_hours in planning_data</comment>
|
||||
<addColumn tableName="planning_data">
|
||||
<column name="progress_all_by_num_hours" type="numeric(19,6)" />
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
</databaseChangeLog>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@
|
|||
</id>
|
||||
<one-to-one name="rootTask" class="TaskGroup" constrained="true"
|
||||
cascade="all" lazy="false" />
|
||||
<property name="progressAllByNumHours" column="progress_all_by_num_hours" scale="6" />
|
||||
<property name="progressByDuration" column="progress_by_duration" scale="6" />
|
||||
<property name="progressByNumHours" column="progress_by_num_hours" scale="6" />
|
||||
</class>
|
||||
|
|
|
|||
|
|
@ -1459,14 +1459,19 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
|
||||
private Label lbCriticalPathByNumHours;
|
||||
|
||||
private Progressmeter progressAdvancePercentage;
|
||||
private Progressmeter progressSpread;
|
||||
|
||||
private Label lbAdvancePercentage;
|
||||
private Label lbProgressSpread;
|
||||
|
||||
private Progressmeter progressAllByNumHours;
|
||||
|
||||
private Label lbProgressAllByNumHours;
|
||||
|
||||
public OverAllProgressContent(Tabpanel tabpanel) {
|
||||
initializeProgressCriticalPathByDuration(tabpanel);
|
||||
initializeProgressCriticalPathByNumHours(tabpanel);
|
||||
initializeProgressAdvancePercentage(tabpanel);
|
||||
initializeProgressSpread(tabpanel);
|
||||
initializeProgressAllByNumHours(tabpanel);
|
||||
|
||||
tabpanel.setVariable("overall_progress_content", this, true);
|
||||
}
|
||||
|
|
@ -1489,22 +1494,31 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
.setValue(_(ProgressType.CRITICAL_PATH_DURATION.toString()));
|
||||
}
|
||||
|
||||
public void initializeProgressAdvancePercentage(Tabpanel tabpanel) {
|
||||
progressAdvancePercentage = (Progressmeter) tabpanel
|
||||
.getFellow("progressAdvancePercentage");
|
||||
lbAdvancePercentage = (Label) tabpanel
|
||||
.getFellow("lbAdvancePercentage");
|
||||
((Label) tabpanel.getFellow("textAdvancePercentage"))
|
||||
public void initializeProgressSpread(Tabpanel tabpanel) {
|
||||
progressSpread = (Progressmeter) tabpanel
|
||||
.getFellow("progressSpread");
|
||||
lbProgressSpread = (Label) tabpanel.getFellow("lbProgressSpread");
|
||||
((Label) tabpanel.getFellow("textProgressSpread"))
|
||||
.setValue(_(ProgressType.SPREAD_PROGRESS.toString()));
|
||||
}
|
||||
|
||||
public void initializeProgressAllByNumHours(Tabpanel tabpanel) {
|
||||
progressAllByNumHours = (Progressmeter) tabpanel
|
||||
.getFellow("progressAllByNumHours");
|
||||
lbProgressAllByNumHours = (Label) tabpanel
|
||||
.getFellow("lbProgressAllByNumHours");
|
||||
((Label) tabpanel.getFellow("textProgressAllByNumHours"))
|
||||
.setValue(_(ProgressType.ALL_NUMHOURS.toString()));
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (planningState.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
TaskGroup rootTask = planningState.getRootTask();
|
||||
|
||||
setAdvancePercentage(rootTask.getAdvancePercentage());
|
||||
setProgressSpread(rootTask.getAdvancePercentage());
|
||||
setProgressAllByNumHours(rootTask.getProgressAllByNumHours());
|
||||
setCriticalPathByDuration(rootTask
|
||||
.getCriticalPathProgressByDuration());
|
||||
setCriticalPathByNumHours(rootTask
|
||||
|
|
@ -1528,14 +1542,24 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void setAdvancePercentage(BigDecimal value) {
|
||||
private void setProgressSpread(BigDecimal value) {
|
||||
if (value == null) {
|
||||
value = BigDecimal.ZERO;
|
||||
}
|
||||
value = value.multiply(BigDecimal.valueOf(100));
|
||||
value = value.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
lbAdvancePercentage.setValue(value.toString() + " %");
|
||||
progressAdvancePercentage.setValue(value.intValue());
|
||||
lbProgressSpread.setValue(value.toString() + " %");
|
||||
progressSpread.setValue(value.intValue());
|
||||
}
|
||||
|
||||
private void setProgressAllByNumHours(BigDecimal value) {
|
||||
if (value == null) {
|
||||
value = BigDecimal.ZERO;
|
||||
}
|
||||
value = value.multiply(BigDecimal.valueOf(100));
|
||||
value = value.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||
lbProgressAllByNumHours.setValue(value.toString() + " %");
|
||||
progressAllByNumHours.setValue(value.intValue());
|
||||
}
|
||||
|
||||
public void setCriticalPathByDuration(BigDecimal value) {
|
||||
|
|
|
|||
|
|
@ -27,12 +27,22 @@
|
|||
|
||||
<separator />
|
||||
|
||||
<!-- Progress with all task tasks by hours -->
|
||||
<label id="textAdvancePercentage" style="font-weight: regular; font-size: 11px" />
|
||||
<!-- Spreading progress -->
|
||||
<label id="textProgressSpread" style="font-weight: regular; font-size: 11px" />
|
||||
|
||||
<hbox style="margin-top: 5px">
|
||||
<progressmeter id="progressAdvancePercentage" style="margin-right: 5px" width="400px" />
|
||||
<label id="lbAdvancePercentage" style="font-weight: regular; font-size: 11px" />
|
||||
<progressmeter id="progressSpread" style="margin-right: 5px" width="400px" />
|
||||
<label id="lbProgressSpread" style="font-weight: regular; font-size: 11px" />
|
||||
</hbox>
|
||||
|
||||
<separator />
|
||||
|
||||
<!-- Progress with all task tasks by hours -->
|
||||
<label id="textProgressAllByNumHours" style="font-weight: regular; font-size: 11px" />
|
||||
|
||||
<hbox style="margin-top: 5px">
|
||||
<progressmeter id="progressAllByNumHours" style="margin-right: 5px" width="400px" />
|
||||
<label id="lbProgressAllByNumHours" style="font-weight: regular; font-size: 11px" />
|
||||
</hbox>
|
||||
|
||||
<separator />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue