ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: The task adjusts its size after the advanced allocation
This commit is contained in:
parent
8bf680aff0
commit
6610cc2bb6
4 changed files with 45 additions and 11 deletions
|
|
@ -81,4 +81,32 @@ public class AggregateOfResourceAllocations {
|
|||
return sum;
|
||||
}
|
||||
|
||||
public LocalDate getStart() {
|
||||
if(isEmpty()){
|
||||
throw new IllegalStateException("the aggregate is empty");
|
||||
}
|
||||
return getAllocationsSortedByStartDate().get(0).getStartDate();
|
||||
}
|
||||
|
||||
public LocalDate getEnd(){
|
||||
if(isEmpty()){
|
||||
throw new IllegalStateException("the aggregate is empty");
|
||||
}
|
||||
LocalDate result = null;
|
||||
for (ResourceAllocation<?> allocation : resourceAllocations) {
|
||||
result = bigger(allocation.getEndDate(), result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private LocalDate bigger(LocalDate one, LocalDate other) {
|
||||
if (one == null) {
|
||||
return other;
|
||||
}
|
||||
if (other == null) {
|
||||
return one;
|
||||
}
|
||||
return one.compareTo(other) > 0 ? one : other;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.apache.commons.lang.Validate;
|
|||
import org.hibernate.validator.NotNull;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Days;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
|
@ -246,10 +247,14 @@ public class Task extends TaskElement {
|
|||
}
|
||||
|
||||
public void mergeAllocation(CalculatedValue calculatedValue,
|
||||
Integer daysDuration, List<ResourceAllocation<?>> newAllocations,
|
||||
AggregateOfResourceAllocations aggregate,
|
||||
List<ResourceAllocation<?>> newAllocations,
|
||||
List<ModifiedAllocation> modifications) {
|
||||
this.calculatedValue = calculatedValue;
|
||||
setDaysDuration(daysDuration);
|
||||
final LocalDate start = aggregate.getStart();
|
||||
final LocalDate end = aggregate.getEnd();
|
||||
setStartDate(start.toDateTimeAtStartOfDay().toDate());
|
||||
setDaysDuration(Days.daysBetween(start, end).getDays());
|
||||
addAllocations(newAllocations);
|
||||
for (ModifiedAllocation pair : modifications) {
|
||||
Validate.isTrue(resourceAllocations.contains(pair.getOriginal()));
|
||||
|
|
|
|||
|
|
@ -62,8 +62,6 @@ public class AllocationResult {
|
|||
|
||||
private final CalculatedValue calculatedValue;
|
||||
|
||||
private List<ResourceAllocation<?>> allSortedByStartDate;
|
||||
|
||||
private final Task task;
|
||||
|
||||
AllocationResult(
|
||||
|
|
@ -119,16 +117,12 @@ public class AllocationResult {
|
|||
}
|
||||
|
||||
public void applyTo(Task task) {
|
||||
task.mergeAllocation(getCalculatedValue(), getDaysDuration(), getNew(),
|
||||
task.mergeAllocation(getCalculatedValue(), aggregate, getNew(),
|
||||
getModified());
|
||||
}
|
||||
|
||||
public List<ResourceAllocation<?>> getAllSortedByStartDate() {
|
||||
if (allSortedByStartDate != null) {
|
||||
return allSortedByStartDate;
|
||||
}
|
||||
return allSortedByStartDate = aggregate
|
||||
.getAllocationsSortedByStartDate();
|
||||
return aggregate.getAllocationsSortedByStartDate();
|
||||
}
|
||||
|
||||
public Task getTask() {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.web.planner.allocation;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
@ -130,7 +131,13 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
|
||||
private void doTheAllocation(AllocationResult allocationResult) {
|
||||
allocationResult.applyTo(task);
|
||||
ganttTask.setEndDate(task.getEndDate());
|
||||
ganttTask.setBeginDate(toDate(allocationResult.getAggregate()
|
||||
.getStart()));
|
||||
ganttTask.setEndDate(toDate(allocationResult.getAggregate().getEnd()));
|
||||
}
|
||||
|
||||
private Date toDate(LocalDate start) {
|
||||
return start.toDateTimeAtStartOfDay().toDate();
|
||||
}
|
||||
|
||||
private List<Resource> getResourcesMatchingCriterions() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue