Remove FlatFunction class as it is not used anymore

FEA: ItEr75S23FixAllocationModel
This commit is contained in:
Manuel Rego Casasnovas 2011-09-01 14:10:44 +02:00
parent 588cb380b1
commit 27257c17ff
4 changed files with 15 additions and 87 deletions

View file

@ -1,71 +0,0 @@
/*
* 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;
import org.navalplanner.business.workingday.EffortDuration;
/**
* Calculate hours per day for resource based on total amount of hours to be
* done and number of resources per day using a flat allocation
*
* @author Diego Pino García <dpino@igalia.com>
*/
public class FlatFunction extends AssignmentFunction {
public static FlatFunction create() {
return create(new FlatFunction());
}
protected FlatFunction() {
}
public String getName() {
return AssignmentFunctionName.FLAT.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(EffortDuration.hours(hours));
}
@Override
public boolean isManual() {
return false;
}
}

View file

@ -87,8 +87,6 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
private static final Log LOG = LogFactory.getLog(ResourceAllocation.class);
private static final FlatFunction FLAT_FUNCTION = FlatFunction.create();
public static <T extends ResourceAllocation<?>> List<T> getSatisfied(
Collection<T> resourceAllocations) {
Validate.notNull(resourceAllocations);
@ -1418,16 +1416,17 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
return assignmentFunction;
}
public void setAssignmentFunction(AssignmentFunction assignmentFunction) {
// If the assignment function is empty, avoid creating an association
// between the resource allocation and the assignment function
if (assignmentFunction == null) {
this.assignmentFunction = null;
FLAT_FUNCTION.applyTo(this);
return;
}
/**
* If {@link AssignmentFunction} is null, it's just set and nothing is
* applied
*
* @param assignmentFunction
*/
public void setAssignmentFunctionAndApplyIfNotFlat(AssignmentFunction assignmentFunction) {
this.assignmentFunction = assignmentFunction;
this.assignmentFunction.applyTo(this);
if (this.assignmentFunction != null) {
this.assignmentFunction.applyTo(this);
}
}
public void setAssignmentFunctionWithoutApply(AssignmentFunction assignmentFunction) {

View file

@ -1388,7 +1388,7 @@ class Row {
@Override
public void applyOn(ResourceAllocation<?> resourceAllocation) {
resourceAllocation.setAssignmentFunction(ManualFunction.create());
resourceAllocation.setAssignmentFunctionAndApplyIfNotFlat(ManualFunction.create());
}
@Override
@ -1490,7 +1490,7 @@ class Row {
@Override
public void applyOn(
ResourceAllocation<?> resourceAllocation) {
resourceAllocation.setAssignmentFunction(SigmoidFunction.create());
resourceAllocation.setAssignmentFunctionAndApplyIfNotFlat(SigmoidFunction.create());
reloadEfforts();
}
@ -1655,7 +1655,7 @@ class Row {
.setSelectedFunction(AssignmentFunctionName.MANUAL.toString());
ResourceAllocation<?> allocation = getAllocation();
if (!(allocation.getAssignmentFunction() instanceof ManualFunction)) {
allocation.setAssignmentFunction(ManualFunction.create());
allocation.setAssignmentFunctionAndApplyIfNotFlat(ManualFunction.create());
}
}

View file

@ -58,7 +58,7 @@ public abstract class StrechesFunctionConfiguration implements
int exitStatus = stretchesFunctionController.showWindow();
if (exitStatus == Messagebox.OK) {
getAllocation().setAssignmentFunction(
getAllocation().setAssignmentFunctionAndApplyIfNotFlat(
stretchesFunctionController.getAssignmentFunction());
assignmentFunctionChanged();
}
@ -94,7 +94,7 @@ public abstract class StrechesFunctionConfiguration implements
@Override
public void applyOn(ResourceAllocation<?> resourceAllocation) {
resourceAllocation.setAssignmentFunction(StretchesFunction.create());
resourceAllocation.setAssignmentFunctionAndApplyIfNotFlat(StretchesFunction.create());
}
@Override