The workableDays must only be updated when the changes are accepted
FEA: ItEr61OTS04PlanificacionHaciaAtras
This commit is contained in:
parent
3c192e0cf8
commit
830ac89f0a
7 changed files with 48 additions and 36 deletions
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.business.planner.entities;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static org.navalplanner.business.workingday.EffortDuration.min;
|
||||
import static org.navalplanner.business.workingday.EffortDuration.zero;
|
||||
|
||||
|
|
@ -369,12 +370,13 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
}
|
||||
|
||||
public void mergeAllocation(Scenario scenario, final IntraDayDate start,
|
||||
final IntraDayDate end,
|
||||
final IntraDayDate end, BigDecimal newWorkableDays,
|
||||
CalculatedValue calculatedValue,
|
||||
List<ResourceAllocation<?>> newAllocations,
|
||||
List<ModifiedAllocation> modifications,
|
||||
Collection<? extends ResourceAllocation<?>> toRemove) {
|
||||
this.calculatedValue = calculatedValue;
|
||||
this.workableDays = newWorkableDays;
|
||||
setIntraDayStartDate(start);
|
||||
setIntraDayEndDate(end);
|
||||
for (ModifiedAllocation pair : modifications) {
|
||||
|
|
@ -542,12 +544,14 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
default:
|
||||
throw new RuntimeException("cant handle: " + calculatedValue);
|
||||
}
|
||||
|
||||
updateDerived(copied);
|
||||
|
||||
List<ResourceAllocation<?>> newAllocations = emptyList(),
|
||||
modifiedAllocations = emptyList();
|
||||
mergeAllocation(onScenario, getIntraDayStartDate(),
|
||||
getIntraDayEndDate(),
|
||||
calculatedValue, Collections
|
||||
.<ResourceAllocation<?>> emptyList(), copied,
|
||||
Collections.<ResourceAllocation<?>> emptyList());
|
||||
getIntraDayEndDate(), workableDays, calculatedValue,
|
||||
newAllocations, copied, modifiedAllocations);
|
||||
}
|
||||
|
||||
private void updateDerived(List<ModifiedAllocation> allocations) {
|
||||
|
|
@ -691,10 +695,6 @@ public class Task extends TaskElement implements ITaskLeafConstraint {
|
|||
return getIntraDayStartDate();
|
||||
}
|
||||
|
||||
public void setWorkableDays(BigDecimal workableDays) {
|
||||
this.workableDays = workableDays;
|
||||
}
|
||||
|
||||
public BigDecimal getWorkableDays() {
|
||||
return workableDays;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -44,13 +45,14 @@ import org.navalplanner.business.workingday.IntraDayDate;
|
|||
public class AllocationResult {
|
||||
|
||||
public static AllocationResult create(Task task,
|
||||
CalculatedValue calculatedValue, List<AllocationRow> rows) {
|
||||
CalculatedValue calculatedValue, List<AllocationRow> rows,
|
||||
BigDecimal newWorkableDays) {
|
||||
List<ResourceAllocation<?>> newAllocations = AllocationRow
|
||||
.getNewFrom(rows);
|
||||
List<ModifiedAllocation> modified = AllocationRow.getModifiedFrom(rows);
|
||||
return new AllocationResult(task, calculatedValue, createAggregate(
|
||||
newAllocations, modified),
|
||||
newAllocations, modified);
|
||||
return new AllocationResult(task, newWorkableDays, calculatedValue,
|
||||
createAggregate(newAllocations, modified), newAllocations,
|
||||
modified);
|
||||
}
|
||||
|
||||
private static AggregateOfResourceAllocations createAggregate(
|
||||
|
|
@ -69,7 +71,8 @@ public class AllocationResult {
|
|||
scenario, resourceAllocations);
|
||||
AggregateOfResourceAllocations aggregate = new AggregateOfResourceAllocations(
|
||||
ModifiedAllocation.modified(modifiedAllocations));
|
||||
return new AllocationResult(task, task.getCalculatedValue(), aggregate,
|
||||
return new AllocationResult(task, task.getWorkableDays(),
|
||||
task.getCalculatedValue(), aggregate,
|
||||
Collections.<ResourceAllocation<?>> emptyList(),
|
||||
modifiedAllocations);
|
||||
|
||||
|
|
@ -87,8 +90,13 @@ public class AllocationResult {
|
|||
|
||||
private final IntraDayDate end;
|
||||
|
||||
private AllocationResult(
|
||||
Task task,
|
||||
/**
|
||||
* The number of workable days with wich the allocation has been done. Can
|
||||
* be <code>null</code>
|
||||
*/
|
||||
private final BigDecimal newWorkableDays;
|
||||
|
||||
private AllocationResult(Task task, BigDecimal newWorkableDays,
|
||||
CalculatedValue calculatedValue,
|
||||
AggregateOfResourceAllocations aggregate,
|
||||
List<ResourceAllocation<?>> newAllocations,
|
||||
|
|
@ -97,6 +105,7 @@ public class AllocationResult {
|
|||
Validate.notNull(calculatedValue);
|
||||
Validate.notNull(task);
|
||||
this.task = task;
|
||||
this.newWorkableDays = newWorkableDays;
|
||||
this.calculatedValue = calculatedValue;
|
||||
this.aggregate = aggregate;
|
||||
this.end = aggregate.isEmpty() ? null : aggregate.getEnd();
|
||||
|
|
@ -127,8 +136,9 @@ public class AllocationResult {
|
|||
}
|
||||
final IntraDayDate start = task.getIntraDayStartDate();
|
||||
final IntraDayDate end = aggregate.getEnd();
|
||||
task.mergeAllocation(scenario, start, end, getCalculatedValue(),
|
||||
getNew(), modified, getNotModified(originals(modified)));
|
||||
task.mergeAllocation(scenario, start, end, newWorkableDays,
|
||||
getCalculatedValue(), getNew(), modified,
|
||||
getNotModified(originals(modified)));
|
||||
}
|
||||
|
||||
private List<ResourceAllocation<?>> originals(
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
|
|
@ -246,7 +247,7 @@ public class AllocationRowsHandler {
|
|||
}
|
||||
createDerived();
|
||||
AllocationResult result = AllocationResult.create(task,
|
||||
calculatedValue, currentRows);
|
||||
calculatedValue, currentRows, getWorkableDaysIfApplyable());
|
||||
AllocationRow.loadDataFromLast(currentRows);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -288,6 +289,19 @@ public class AllocationRowsHandler {
|
|||
formBinder.getAllocationEnd());
|
||||
}
|
||||
|
||||
private BigDecimal getWorkableDaysIfApplyable() {
|
||||
switch (calculatedValue) {
|
||||
case NUMBER_OF_HOURS:
|
||||
case RESOURCES_PER_DAY:
|
||||
return formBinder.getWorkableDays();
|
||||
case WORKABLE_DAYS:
|
||||
return null;
|
||||
default:
|
||||
throw new RuntimeException("unexpected calculatedValue: "
|
||||
+ calculatedValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void createDerived() {
|
||||
List<ResourceAllocation<?>> lastFrom = AllocationRow
|
||||
.getTemporalFrom(currentRows);
|
||||
|
|
|
|||
|
|
@ -437,7 +437,11 @@ public class FormBinder {
|
|||
|
||||
public LocalDate getAllocationEnd() {
|
||||
LocalDate result = new LocalDate(taskStartDate);
|
||||
return result.plusDays(taskWorkableDays.getValue().intValue());
|
||||
return result.plusDays(getWorkableDays().intValue());
|
||||
}
|
||||
|
||||
public BigDecimal getWorkableDays() {
|
||||
return taskWorkableDays.getValue();
|
||||
}
|
||||
|
||||
public void setDeleteButtonFor(AllocationRow row,
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -80,6 +79,4 @@ public interface IResourceAllocationModel extends INewAllocationsAdder {
|
|||
|
||||
Date getTaskEnd();
|
||||
|
||||
void setWorkableDays(BigDecimal decimal);
|
||||
|
||||
}
|
||||
|
|
@ -277,7 +277,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Decimalbox decimalbox = (Decimalbox) event.getTarget();
|
||||
setTaskWorkableDays(decimalbox.getValue());
|
||||
setPlannedTaskEnd(calculateEndDate(getDuration(decimalbox)));
|
||||
updateTaskEndDateInTaskPropertiesPanel(getPlannedTaskEnd());
|
||||
Util.reloadBindings(lbTaskEnd);
|
||||
|
|
@ -316,10 +315,6 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
this.plannedTaskEnd = taskEnd;
|
||||
}
|
||||
|
||||
private void setTaskWorkableDays(BigDecimal decimal) {
|
||||
resourceAllocationModel.setWorkableDays(decimal);
|
||||
}
|
||||
|
||||
public enum HoursRendererColumn {
|
||||
|
||||
CRITERIONS {
|
||||
|
|
|
|||
|
|
@ -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.Date;
|
||||
|
|
@ -412,11 +411,4 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkableDays(BigDecimal decimal) {
|
||||
if (task != null) {
|
||||
task.setWorkableDays(decimal);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue