[Bug #974] Do standard resource allocation when user selects NONE in AdvanceAllocation
FEA: ItEr74S04BugFixing
This commit is contained in:
parent
494955a9d5
commit
ca8783bd87
3 changed files with 85 additions and 3 deletions
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.planner.entities;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.planner.entities.allocationalgorithms.ResourcesPerDayModification;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino García <dpino@igalia.com>
|
||||
*
|
||||
* Calculate hours per day for resource based on total amount of hours to
|
||||
* be done and number of resources per day
|
||||
*
|
||||
*/
|
||||
public class NoneFunction extends AssignmentFunction {
|
||||
|
||||
public static NoneFunction create() {
|
||||
return create(new NoneFunction());
|
||||
}
|
||||
|
||||
protected NoneFunction() {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return ASSIGNMENT_FUNCTION_NAME.NONE.toString();
|
||||
}
|
||||
|
||||
|
||||
public void applyTo(ResourceAllocation<?> resourceAllocation) {
|
||||
apply(resourceAllocation);
|
||||
}
|
||||
|
||||
private void apply(ResourceAllocation<?> resourceAllocation) {
|
||||
int hours = resourceAllocation.getAssignedHours();
|
||||
|
||||
List<ResourcesPerDayModification> resourcesPerDayModification = Arrays.asList(resourceAllocation
|
||||
.asResourcesPerDayModification());
|
||||
|
||||
ResourceAllocation
|
||||
.allocating(resourcesPerDayModification)
|
||||
.untilAllocating(hours);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -82,6 +82,8 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
|
||||
private static final Log LOG = LogFactory.getLog(ResourceAllocation.class);
|
||||
|
||||
private static final NoneFunction NONE_FUNCTION = NoneFunction.create();
|
||||
|
||||
public static <T extends ResourceAllocation<?>> List<T> getSatisfied(
|
||||
Collection<T> resourceAllocations) {
|
||||
Validate.notNull(resourceAllocations);
|
||||
|
|
@ -1243,10 +1245,14 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
}
|
||||
|
||||
public void setAssignmentFunction(AssignmentFunction assignmentFunction) {
|
||||
this.assignmentFunction = assignmentFunction;
|
||||
if (this.assignmentFunction != null) {
|
||||
this.assignmentFunction.applyTo(this);
|
||||
// If the assignment function is empty, avoid creating an association
|
||||
// between the resource allocation and the assignment function
|
||||
if (assignmentFunction == null) {
|
||||
NONE_FUNCTION.applyTo(this);
|
||||
return;
|
||||
}
|
||||
this.assignmentFunction = assignmentFunction;
|
||||
this.assignmentFunction.applyTo(this);
|
||||
}
|
||||
|
||||
private void setWithoutApply(AssignmentFunction assignmentFunction) {
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import org.navalplanner.business.planner.entities.AssignmentFunction;
|
|||
import org.navalplanner.business.planner.entities.AssignmentFunction.ASSIGNMENT_FUNCTION_NAME;
|
||||
import org.navalplanner.business.planner.entities.CalculatedValue;
|
||||
import org.navalplanner.business.planner.entities.GenericResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.NoneFunction;
|
||||
import org.navalplanner.business.planner.entities.ResourceAllocation;
|
||||
import org.navalplanner.business.planner.entities.SigmoidFunction;
|
||||
import org.navalplanner.business.planner.entities.SpecificResourceAllocation;
|
||||
|
|
@ -1308,7 +1309,15 @@ class Row {
|
|||
public void applyDefaultFunction(
|
||||
ResourceAllocation<?> resourceAllocation) {
|
||||
resourceAllocation.setAssignmentFunction(null);
|
||||
reloadHours();
|
||||
}
|
||||
|
||||
private void reloadHours() {
|
||||
reloadHoursSameRowForDetailItems();
|
||||
reloadAllHours();
|
||||
fireCellChanged();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private abstract class CommonStrechesConfiguration extends
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue