From 7377461d249bf7a4f94983c770e9da703861ded7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 14 May 2012 10:21:08 +0200 Subject: [PATCH] Add some Javadoc to AssignedEffortForResource class --- .../entities/AssignedEffortForResource.java | 55 +++++++++++++++++++ .../UntilFillingHoursAllocator.java | 4 +- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/AssignedEffortForResource.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/AssignedEffortForResource.java index b4e7604fc..1080c8426 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/AssignedEffortForResource.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/AssignedEffortForResource.java @@ -29,21 +29,60 @@ import org.libreplan.business.resources.entities.Resource; import org.libreplan.business.workingday.EffortDuration; /** + * This class contains methods to build an {@link IAssignedEffortForResource}. + * * @author Oscar Gonzalez Fernandez */ public class AssignedEffortForResource { + /** + * It allows to know how much load a Resource has at the given day. It's + * used by {@link GenericResourceAllocation} so it distributes new load + * among the least loaded resources. The right object implementing this + * interface is built using factory methods from + * {@link AssignedEffortForResource}. + * + * @see AssignedEffortForResource#sum(IAssignedEffortForResource...) + * @see AssignedEffortForResource#withTheLoadOf(Collection) + */ public interface IAssignedEffortForResource { public EffortDuration getAssignedDurationAt(Resource resource, LocalDate day); } + private AssignedEffortForResource() { + // not instantiable + } + + /** + * It returns a new {@link IAssignedEffortForResource} that looks into + * {@link Resource#dayAssignments} for knowing which load the + * {@link Resource} has for a given day. + * + * Sometimes we have to discount the load of some allocations that are being + * removed or changed. They can be provided to this method. + * + * @param allocations + * The allocations whose load shouldn't be summed. + * @return A {@link IAssignedEffortForResource} that calculates the load + * associated for all allocations but the provided ones. + */ public static IAssignedEffortForResource effortDiscounting( Collection allocations) { return new AssignedEffortDiscounting(allocations); } + /** + * It creates a new {@link IAssignedEffortForResource} that sums all + * provided {@link IAssignedEffortForResource}. Sometimes you have to + * combine several {@link IAssignedEffortForResource} to calculate the right + * effort. + * @param assignedEffortForResources + * The {@link IAssignedEffortForResource} to sum. + * @return a {@link IAssignedEffortForResource} that returns the sum of + * calling all provided assignedEffortForResources. + */ public static IAssignedEffortForResource sum( final IAssignedEffortForResource... assignedEffortForResources) { return new IAssignedEffortForResource() { @@ -64,6 +103,9 @@ public class AssignedEffortForResource { }; } + /** + * @see AssignedEffortForResource#sum(IAssignedEffortForResource...) + */ public static IAssignedEffortForResource sum( Collection assignedEffortForResources) { return sum(assignedEffortForResources @@ -75,6 +117,12 @@ public class AssignedEffortForResource { return new WithTheLoadOf(allocations); } + /** + * This class allows to specify the load of some {@link ResourceAllocation + * resource allocations} which their {@link DayAssignment day assignments} + * aren't associated to a Resource yet. Without this, their load wouldn't be + * noticed. + */ public static class WithTheLoadOf implements IAssignedEffortForResource { private final Set> allocations; @@ -92,6 +140,13 @@ public class AssignedEffortForResource { return implementation.getAssignedDurationAt(resource, day); } + /** + * It returns a {@link IAssignedEffortForResource} that returns the same + * load as this but without the provided + * allocation. When you're doing an allocation you don't + * want to consider the allocation currently being done, so it's + * excluded. + */ public WithTheLoadOf withoutConsidering(ResourceAllocation allocation) { Set> copy = new HashSet>( this.allocations); diff --git a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/UntilFillingHoursAllocator.java b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/UntilFillingHoursAllocator.java index 79e5c105e..0d83f90b5 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/UntilFillingHoursAllocator.java +++ b/libreplan-business/src/main/java/org/libreplan/business/planner/entities/allocationalgorithms/UntilFillingHoursAllocator.java @@ -145,8 +145,8 @@ public abstract class UntilFillingHoursAllocator { } IntraDayDate finish = adjustFinish(resourcesPerDayModification, taken, biggestLastAssignment, current); - // we have to do it now, so the other allocations take into account. At - // the end it's done again with the right end date. + // We have to do it now, so the other allocations take it into account. + // At the end it's done again with the right end date. setNewDataForAllocation(resourcesPerDayModification, resultAssignments .get(resourcesPerDayModification), finish); return finish;