ItEr25S07CUAsignacionGrupoRecursosAPlanificacionItEr24S08: Creating invocation and result handling for variable task allocation
This commit is contained in:
parent
0dface5279
commit
00cd61981f
2 changed files with 46 additions and 2 deletions
|
|
@ -11,6 +11,7 @@ import org.joda.time.LocalDate;
|
|||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.SameWorkHoursEveryDay;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.resources.entities.Resource;
|
||||
|
||||
/**
|
||||
* Resources are allocated to planner tasks.
|
||||
|
|
@ -38,6 +39,44 @@ public abstract class ResourceAllocation extends BaseEntity {
|
|||
public ResourcesPerDay getResourcesPerDay() {
|
||||
return resourcesPerDay;
|
||||
}
|
||||
}
|
||||
|
||||
public static AllocationsCurried allocating(
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations) {
|
||||
return new AllocationsCurried(resourceAllocations);
|
||||
}
|
||||
|
||||
public static class AllocationsCurried {
|
||||
|
||||
private final List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations;
|
||||
|
||||
public AllocationsCurried(
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations) {
|
||||
this.resourceAllocations = resourceAllocations;
|
||||
}
|
||||
|
||||
public AllocationsAndResourcesCurried withResources(
|
||||
List<Resource> resources) {
|
||||
return new AllocationsAndResourcesCurried(resources,
|
||||
resourceAllocations);
|
||||
}
|
||||
}
|
||||
|
||||
public static class AllocationsAndResourcesCurried {
|
||||
private List<Resource> resources;
|
||||
|
||||
private List<ResourceAllocationWithDesiredResourcesPerDay> allocations;
|
||||
|
||||
public AllocationsAndResourcesCurried(List<Resource> resources,
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> allocations) {
|
||||
this.resources = resources;
|
||||
this.allocations = allocations;
|
||||
}
|
||||
|
||||
public LocalDate untilAllocating(int hoursToAllocate) {
|
||||
throw new RuntimeException(
|
||||
"TODO: implement allocation for variable length tasks");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -156,4 +195,5 @@ public abstract class ResourceAllocation extends BaseEntity {
|
|||
public ResourcesPerDay getResourcesPerDay() {
|
||||
return resourcesPerDay;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.orders.daos.IHoursGroupDAO;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.planner.daos.IResourceAllocationDAO;
|
||||
|
|
@ -125,8 +126,11 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
if (task.isFixedDuration()) {
|
||||
allocationForFixedTask();
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"TODO: allocation for tasks of variable duration. Now only works with fixed duration tasks");
|
||||
List<ResourceAllocationWithDesiredResourcesPerDay> resourceAllocations = toResourceAllocations();
|
||||
LocalDate end = ResourceAllocation.allocating(resourceAllocations)
|
||||
.withResources(getResourcesMatchingCriterions())
|
||||
.untilAllocating(task.getHours());
|
||||
ganttTask.setEndDate(end.toDateTimeAtStartOfDay().toDate());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue