If a task has manual allocation and is moved then reset to flat

* Add function isManual in AssignmentFunction
* Modified AssignmentFunction::applyAssignmentFunctionsIfAny in order to
  reset to flat if manual allocation was applied

FEA: ItEr75S23FixAllocationModel
This commit is contained in:
Manuel Rego Casasnovas 2011-08-26 09:33:17 +02:00
parent 5e2f50d082
commit 568cb354b6
6 changed files with 33 additions and 2 deletions

View file

@ -38,6 +38,10 @@ public abstract class AssignmentFunction extends BaseEntity {
* This method goes over the {@link ResourceAllocation} list and apply the
* assignment function if it is defined.
*
* As this is called at the end of {@link Task#doAllocation} and a flat
* allocation was already applied before. If assignment function was set to
* manual it is reseted to flat again.
*
* @param resourceAllocations
* List of {@link ResourceAllocation}
*/
@ -47,7 +51,12 @@ public abstract class AssignmentFunction extends BaseEntity {
AssignmentFunction assignmentFunction = resourceAllocation
.getAssignmentFunction();
if (assignmentFunction != null) {
assignmentFunction.applyTo(resourceAllocation);
if (assignmentFunction.isManual()) {
// reset to flat
resourceAllocation.setWithoutApply(null);
} else {
assignmentFunction.applyTo(resourceAllocation);
}
}
}
}
@ -61,6 +70,8 @@ public abstract class AssignmentFunction extends BaseEntity {
public abstract String getName();
public abstract boolean isManual();
public enum AssignmentFunctionName {
FLAT(_("Flat")),
MANUAL(_("Manual")),

View file

@ -63,4 +63,9 @@ public class FlatFunction extends AssignmentFunction {
.untilAllocating(EffortDuration.hours(hours));
}
@Override
public boolean isManual() {
return false;
}
}

View file

@ -41,4 +41,9 @@ public class ManualFunction extends AssignmentFunction {
// Do nothing
}
@Override
public boolean isManual() {
return true;
}
}

View file

@ -1429,7 +1429,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
this.assignmentFunction.applyTo(this);
}
private void setWithoutApply(AssignmentFunction assignmentFunction) {
protected void setWithoutApply(AssignmentFunction assignmentFunction) {
this.assignmentFunction = assignmentFunction;
}

View file

@ -266,4 +266,9 @@ public class SigmoidFunction extends AssignmentFunction {
PRECISSION, ROUND_MODE);
}
@Override
public boolean isManual() {
return false;
}
}

View file

@ -476,4 +476,9 @@ public class StretchesFunction extends AssignmentFunction {
}
}
@Override
public boolean isManual() {
return false;
}
}