Workable days are stored as an integer

Using a decimal would require that IAllocatable could receive dates as
IntraDayDates instead of LocalDates and this is not supported yet.

FEA: ItEr61OTS04PlanificacionHaciaAtras
This commit is contained in:
Óscar González Fernández 2010-11-08 18:54:44 +01:00
parent f4a2565c55
commit 4aaf896d73
6 changed files with 20 additions and 27 deletions

View file

@ -24,7 +24,6 @@ import static java.util.Collections.emptyList;
import static org.navalplanner.business.workingday.EffortDuration.min;
import static org.navalplanner.business.workingday.EffortDuration.zero;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -118,7 +117,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
private Consolidation consolidation;
private BigDecimal workableDays;
private Integer workableDays;
/**
* Constructor for hibernate. Do not use!
@ -363,7 +362,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
}
public void mergeAllocation(Scenario scenario, final IntraDayDate start,
final IntraDayDate end, BigDecimal newWorkableDays,
final IntraDayDate end, Integer newWorkableDays,
CalculatedValue calculatedValue,
List<ResourceAllocation<?>> newAllocations,
List<ModifiedAllocation> modifications,
@ -688,7 +687,7 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
return getIntraDayStartDate();
}
public BigDecimal getWorkableDays() {
public Integer getWorkableDays() {
return workableDays;
}

View file

@ -19,7 +19,6 @@
*/
package org.navalplanner.web.planner.allocation;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@ -46,7 +45,7 @@ public class AllocationResult {
public static AllocationResult create(Task task,
CalculatedValue calculatedValue, List<AllocationRow> rows,
BigDecimal newWorkableDays) {
Integer newWorkableDays) {
List<ResourceAllocation<?>> newAllocations = AllocationRow
.getNewFrom(rows);
List<ModifiedAllocation> modified = AllocationRow.getModifiedFrom(rows);
@ -94,9 +93,9 @@ public class AllocationResult {
* The number of workable days with wich the allocation has been done. Can
* be <code>null</code>
*/
private final BigDecimal newWorkableDays;
private final Integer newWorkableDays;
private AllocationResult(Task task, BigDecimal newWorkableDays,
private AllocationResult(Task task, Integer newWorkableDays,
CalculatedValue calculatedValue,
AggregateOfResourceAllocations aggregate,
List<ResourceAllocation<?>> newAllocations,

View file

@ -20,7 +20,6 @@
package org.navalplanner.web.planner.allocation;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@ -289,7 +288,7 @@ public class AllocationRowsHandler {
formBinder.getAllocationEnd());
}
private BigDecimal getWorkableDaysIfApplyable() {
private Integer getWorkableDaysIfApplyable() {
switch (calculatedValue) {
case NUMBER_OF_HOURS:
case RESOURCES_PER_DAY:

View file

@ -111,7 +111,7 @@ public class FormBinder {
private List<AllocationRow> rows = Collections.emptyList();
private Decimalbox taskWorkableDays;
private Intbox taskWorkableDays;
private Date taskStartDate;
@ -287,7 +287,7 @@ public class FormBinder {
this.taskStartDate = startDate;
}
public void setWorkableDays(Decimalbox duration) {
public void setWorkableDays(Intbox duration) {
this.taskWorkableDays = duration;
taskDurationDisabilityRule();
onChangeEnableApply(taskWorkableDays);
@ -440,7 +440,7 @@ public class FormBinder {
return result.plusDays(getWorkableDays().intValue());
}
public BigDecimal getWorkableDays() {
public Integer getWorkableDays() {
return taskWorkableDays.getValue();
}

View file

@ -22,7 +22,6 @@ package org.navalplanner.web.planner.allocation;
import static org.navalplanner.web.I18nHelper._;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -114,7 +113,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
private Checkbox extendedViewCheckbox;
private Decimalbox dbTaskWorkableDays;
private Intbox taskWorkableDays;
// Orientative task end according to number of workable days
private Date plannedTaskEnd;
@ -240,7 +239,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
.setAllConsolidatedResourcesPerDay(allConsolidatedResourcesPerDay);
formBinder.setAllResourcesPerDay(allResourcesPerDay);
formBinder.setWorkableDays(dbTaskWorkableDays);
formBinder.setWorkableDays(taskWorkableDays);
formBinder.setApplyButton(applyButton);
formBinder.setAllocationsGrid(allocationsGrid);
formBinder.setMessagesForUser(messagesForUser);
@ -269,23 +268,20 @@ public class ResourceAllocationController extends GenericForwardComposer {
private Label lbTaskEnd;
private void initTaskWorkableDays(org.navalplanner.business.planner.entities.Task task) {
dbTaskWorkableDays.setValue(new BigDecimal(task.getDaysDuration()));
taskWorkableDays.setValue(task.getDaysDuration());
plannedTaskEnd = resourceAllocationModel.getTaskEnd();
dbTaskWorkableDays.setValue(new BigDecimal(task.getDaysDuration()));
dbTaskWorkableDays.addEventListener(Events.ON_CHANGE, new EventListener() {
taskWorkableDays.setValue(task.getDaysDuration());
taskWorkableDays.addEventListener(Events.ON_CHANGE,
new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
Decimalbox decimalbox = (Decimalbox) event.getTarget();
setPlannedTaskEnd(calculateEndDate(getDuration(decimalbox)));
setPlannedTaskEnd(calculateEndDate(taskWorkableDays
.getValue()));
updateTaskEndDateInTaskPropertiesPanel(getPlannedTaskEnd());
Util.reloadBindings(lbTaskEnd);
}
private int getDuration(Decimalbox decimalbox) {
return decimalbox.getValue() != null ? decimalbox.getValue().toBigInteger().intValue() : 0;
}
private void updateTaskEndDateInTaskPropertiesPanel(Date endDate) {
editTaskController.getTaskPropertiesController().updateTaskEndDate(endDate);
}
@ -448,7 +444,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
@Override
public Component input(
ResourceAllocationController resourceAllocationController) {
return resourceAllocationController.dbTaskWorkableDays;
return resourceAllocationController.taskWorkableDays;
}
},
NUMBER_OF_HOURS(CalculatedValue.NUMBER_OF_HOURS) {

View file

@ -83,7 +83,7 @@
</hbox>
<!-- Planned Workable Days -->
<label style="font-weight: bold" value="${i18n:_('Planned workable days :')}" />
<decimalbox id="dbTaskWorkableDays" width="90px" />
<intbox id="taskWorkableDays" width="90px" />
<hbox>
</hbox>