From 89b1519d4bc01a2cd7a90c04d2420d2b08c7b91d Mon Sep 17 00:00:00 2001 From: Diego Pino Garcia Date: Thu, 14 Apr 2011 13:09:49 +0200 Subject: [PATCH] Moved StretchesFunction$Type to its own file * Renamed it as StretchesFunctionTypeEnum * Renamed StretechesFunctionTypeEnum.DEFAULT to STRETCHES FEA: ItEr74S04BugFixing --- .../planner/entities/StretchesFunction.java | 168 +-------------- .../entities/StretchesFunctionTypeEnum.java | 191 ++++++++++++++++++ .../entities/ResourceAllocations.hbm.xml | 2 +- .../AdvancedAllocationController.java | 11 +- .../streches/GraphicForStreches.java | 8 +- .../streches/IStretchesFunctionModel.java | 5 +- .../StrechesFunctionConfiguration.java | 4 +- .../streches/StretchesFunctionController.java | 4 +- .../streches/StretchesFunctionModel.java | 6 +- 9 files changed, 219 insertions(+), 180 deletions(-) create mode 100644 navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunctionTypeEnum.java diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java index 21eeb55f9..6b589d0b2 100644 --- a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunction.java @@ -31,14 +31,10 @@ import java.util.Iterator; import java.util.List; import org.apache.commons.lang.Validate; -import org.apache.commons.math.FunctionEvaluationException; -import org.apache.commons.math.analysis.SplineInterpolator; -import org.apache.commons.math.analysis.UnivariateRealFunction; import org.hibernate.validator.AssertTrue; import org.hibernate.validator.Valid; import org.joda.time.Days; import org.joda.time.LocalDate; -import org.navalplanner.business.common.ProportionalDistributor; /** * Assignment function by stretches. @@ -46,146 +42,6 @@ import org.navalplanner.business.common.ProportionalDistributor; */ public class StretchesFunction extends AssignmentFunction { - public enum Type { - DEFAULT { - @Override - public void apply(ResourceAllocation allocation, - List intervalsDefinedByStreches, - LocalDate startInclusive, LocalDate endExclusive, - int totalHours) { - Interval.apply(allocation, intervalsDefinedByStreches, - startInclusive, endExclusive, totalHours); - - } - }, - INTERPOLATED { - @Override - public void apply(ResourceAllocation allocation, - List intervalsDefinedByStreches, - LocalDate startInclusive, LocalDate endExclusive, - int totalHours) { - double[] x = Interval.getDayPointsFor(startInclusive, - intervalsDefinedByStreches); - assert x.length == 1 + intervalsDefinedByStreches.size(); - double[] y = Interval.getHoursPointsFor(totalHours, - intervalsDefinedByStreches); - assert y.length == 1 + intervalsDefinedByStreches.size(); - int[] hoursForEachDay = hoursForEachDayUsingSplines(x, y, - startInclusive, endExclusive); - int[] reallyAssigned = getReallyAssigned(allocation, - startInclusive, hoursForEachDay); - // Because of calendars, really assigned hours can be less than - // the hours for each day specified by the interpolation. The - // remainder must be distributed. - distributeRemainder(allocation, startInclusive, totalHours, - reallyAssigned); - - } - - private int[] getReallyAssigned(ResourceAllocation allocation, - LocalDate startInclusive, int[] hoursForEachDay) { - int[] reallyAssigned = new int[hoursForEachDay.length]; - for (int i = 0; i < hoursForEachDay.length; i++) { - LocalDate day = startInclusive.plusDays(i); - LocalDate nextDay = day.plusDays(1); - allocation.withPreviousAssociatedResources() - .onIntervalWithinTask(day, nextDay) - .allocateHours(hoursForEachDay[i]); - reallyAssigned[i] = allocation.getAssignedHours(day, - nextDay); - } - return reallyAssigned; - } - - private void distributeRemainder(ResourceAllocation allocation, - LocalDate startInclusive, int totalHours, - int[] reallyAssigned) { - final int remainder = totalHours - sum(reallyAssigned); - if (remainder == 0) { - return; - } - int[] perDay = distributeRemainder(reallyAssigned, remainder); - for (int i = 0; i < perDay.length; i++) { - if (perDay[i] == 0) { - continue; - } - final int newHours = perDay[i] + reallyAssigned[i]; - LocalDate day = startInclusive.plusDays(i); - LocalDate nextDay = day.plusDays(1); - allocation.withPreviousAssociatedResources() - .onIntervalWithinTask(day, nextDay) - .allocateHours(newHours); - } - } - - private int[] distributeRemainder(int[] hoursForEachDay, - int remainder) { - ProportionalDistributor remainderDistributor = ProportionalDistributor - .create(hoursForEachDay); - return remainderDistributor.distribute(remainder); - } - }; - - public static int[] hoursForEachDayUsingSplines(double[] x, double[] y, - LocalDate startInclusive, LocalDate endExclusive) { - UnivariateRealFunction accumulatingFunction = new SplineInterpolator() - .interpolate(x, y); - int[] extractAccumulated = extractAccumulated(accumulatingFunction, - startInclusive, endExclusive); - return extractHoursShouldAssignForEachDay(ValleyFiller - .fillValley(extractAccumulated)); - } - - private static int[] extractAccumulated( - UnivariateRealFunction accumulatedFunction, - LocalDate startInclusive, LocalDate endExclusive) { - int[] result = new int[Days.daysBetween(startInclusive, - endExclusive).getDays()]; - for (int i = 0; i < result.length; i++) { - result[i] = evaluate(accumulatedFunction, i + 1); - } - return result; - } - - private static int[] extractHoursShouldAssignForEachDay( - int[] accumulated) { - int[] result = new int[accumulated.length]; - int previous = 0; - for (int i = 0; i < result.length; i++) { - final int current = accumulated[i]; - result[i] = current - previous; - previous = current; - } - return result; - } - - private static int evaluate(UnivariateRealFunction accumulatedFunction, - int x) { - try { - return (int) accumulatedFunction.value(x); - } catch (FunctionEvaluationException e) { - throw new RuntimeException(e); - } - } - - - public void applyTo(ResourceAllocation resourceAllocation, - StretchesFunction stretchesFunction) { - List intervalsDefinedByStreches = stretchesFunction - .getIntervalsDefinedByStreches(); - int totalHours = resourceAllocation.getAssignedHours(); - Task task = resourceAllocation.getTask(); - LocalDate start = LocalDate.fromDateFields(task.getStartDate()); - LocalDate end = LocalDate.fromDateFields(task.getEndDate()); - apply(resourceAllocation, intervalsDefinedByStreches, start, end, - totalHours); - } - - protected abstract void apply(ResourceAllocation allocation, - List intervalsDefinedByStreches, - LocalDate startInclusive, LocalDate endExclusive, int totalHours); - } - public static class Interval { private LocalDate start; @@ -306,14 +162,6 @@ public class StretchesFunction extends AssignmentFunction { } - private static int sum(int[] array) { - int result = 0; - for (int each : array) { - result += each; - } - return result; - } - public static StretchesFunction create() { return (StretchesFunction) create(new StretchesFunction()); } @@ -347,12 +195,12 @@ public class StretchesFunction extends AssignmentFunction { private List stretches = new ArrayList(); - private Type type; + private StretchesFunctionTypeEnum type; /** * This is a transient field. Not stored */ - private Type desiredType; + private StretchesFunctionTypeEnum desiredType; public StretchesFunction copy() { StretchesFunction result = StretchesFunction.create(); @@ -393,15 +241,15 @@ public class StretchesFunction extends AssignmentFunction { return Collections.unmodifiableList(stretches); } - public Type getType() { - return type == null ? Type.DEFAULT : type; + public StretchesFunctionTypeEnum getType() { + return type == null ? StretchesFunctionTypeEnum.STRETCHES : type; } - public Type getDesiredType() { + public StretchesFunctionTypeEnum getDesiredType() { return desiredType == null ? getType() : desiredType; } - public void changeTypeTo(Type type) { + public void changeTypeTo(StretchesFunctionTypeEnum type) { desiredType = type; } @@ -481,7 +329,7 @@ public class StretchesFunction extends AssignmentFunction { @Override public String getName() { - if (StretchesFunction.Type.INTERPOLATED.equals(type)) { + if (StretchesFunctionTypeEnum.INTERPOLATED.equals(type)) { return ASSIGNMENT_FUNCTION_NAME.INTERPOLATION.toString(); } else { return ASSIGNMENT_FUNCTION_NAME.STRETCHES.toString(); @@ -509,7 +357,7 @@ public class StretchesFunction extends AssignmentFunction { } public boolean ifInterpolatedMustHaveAtLeastTwoStreches() { - return getDesiredType() != Type.INTERPOLATED || stretches.size() >= 2; + return getDesiredType() != StretchesFunctionTypeEnum.INTERPOLATED || stretches.size() >= 2; } } diff --git a/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunctionTypeEnum.java b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunctionTypeEnum.java new file mode 100644 index 000000000..8684fdf0a --- /dev/null +++ b/navalplanner-business/src/main/java/org/navalplanner/business/planner/entities/StretchesFunctionTypeEnum.java @@ -0,0 +1,191 @@ +/* + * 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 . + */ + +package org.navalplanner.business.planner.entities; + +import java.util.List; + +import org.apache.commons.math.FunctionEvaluationException; +import org.apache.commons.math.analysis.SplineInterpolator; +import org.apache.commons.math.analysis.UnivariateRealFunction; +import org.joda.time.Days; +import org.joda.time.LocalDate; +import org.navalplanner.business.common.ProportionalDistributor; +import org.navalplanner.business.planner.entities.StretchesFunction.Interval; + +/** + * + * @author Manuel Rego Casasnovas + * @author Diego Pino García + * + */ +public enum StretchesFunctionTypeEnum { + + STRETCHES { + + @Override + public void apply(ResourceAllocation allocation, + List intervalsDefinedByStreches, + LocalDate startInclusive, LocalDate endExclusive, + int totalHours) { + Interval.apply(allocation, intervalsDefinedByStreches, + startInclusive, endExclusive, totalHours); + + } + }, + INTERPOLATED { + + @Override + public void apply(ResourceAllocation allocation, + List intervalsDefinedByStreches, + LocalDate startInclusive, LocalDate endExclusive, + int totalHours) { + double[] x = Interval.getDayPointsFor(startInclusive, + intervalsDefinedByStreches); + assert x.length == 1 + intervalsDefinedByStreches.size(); + double[] y = Interval.getHoursPointsFor(totalHours, + intervalsDefinedByStreches); + assert y.length == 1 + intervalsDefinedByStreches.size(); + int[] hoursForEachDay = hoursForEachDayUsingSplines(x, y, + startInclusive, endExclusive); + int[] reallyAssigned = getReallyAssigned(allocation, + startInclusive, hoursForEachDay); + // Because of calendars, really assigned hours can be less than + // the hours for each day specified by the interpolation. The + // remainder must be distributed. + distributeRemainder(allocation, startInclusive, totalHours, + reallyAssigned); + + } + + private int[] getReallyAssigned(ResourceAllocation allocation, + LocalDate startInclusive, int[] hoursForEachDay) { + int[] reallyAssigned = new int[hoursForEachDay.length]; + for (int i = 0; i < hoursForEachDay.length; i++) { + LocalDate day = startInclusive.plusDays(i); + LocalDate nextDay = day.plusDays(1); + allocation.withPreviousAssociatedResources() + .onIntervalWithinTask(day, nextDay) + .allocateHours(hoursForEachDay[i]); + reallyAssigned[i] = allocation.getAssignedHours(day, + nextDay); + } + return reallyAssigned; + } + + private void distributeRemainder(ResourceAllocation allocation, + LocalDate startInclusive, int totalHours, + int[] reallyAssigned) { + final int remainder = totalHours - sum(reallyAssigned); + if (remainder == 0) { + return; + } + int[] perDay = distributeRemainder(reallyAssigned, remainder); + for (int i = 0; i < perDay.length; i++) { + if (perDay[i] == 0) { + continue; + } + final int newHours = perDay[i] + reallyAssigned[i]; + LocalDate day = startInclusive.plusDays(i); + LocalDate nextDay = day.plusDays(1); + allocation.withPreviousAssociatedResources() + .onIntervalWithinTask(day, nextDay) + .allocateHours(newHours); + } + } + + private int sum(int[] array) { + int result = 0; + for (int each : array) { + result += each; + } + return result; + } + + private int[] distributeRemainder(int[] hoursForEachDay, + int remainder) { + ProportionalDistributor remainderDistributor = ProportionalDistributor + .create(hoursForEachDay); + return remainderDistributor.distribute(remainder); + } + + }; + + public static int[] hoursForEachDayUsingSplines(double[] x, double[] y, + LocalDate startInclusive, LocalDate endExclusive) { + UnivariateRealFunction accumulatingFunction = new SplineInterpolator() + .interpolate(x, y); + int[] extractAccumulated = extractAccumulated(accumulatingFunction, + startInclusive, endExclusive); + return extractHoursShouldAssignForEachDay(ValleyFiller + .fillValley(extractAccumulated)); + } + + private static int[] extractAccumulated( + UnivariateRealFunction accumulatedFunction, + LocalDate startInclusive, LocalDate endExclusive) { + int[] result = new int[Days.daysBetween(startInclusive, + endExclusive).getDays()]; + for (int i = 0; i < result.length; i++) { + result[i] = evaluate(accumulatedFunction, i + 1); + } + return result; + } + + private static int[] extractHoursShouldAssignForEachDay( + int[] accumulated) { + int[] result = new int[accumulated.length]; + int previous = 0; + for (int i = 0; i < result.length; i++) { + final int current = accumulated[i]; + result[i] = current - previous; + previous = current; + } + return result; + } + + private static int evaluate(UnivariateRealFunction accumulatedFunction, + int x) { + try { + return (int) accumulatedFunction.value(x); + } catch (FunctionEvaluationException e) { + throw new RuntimeException(e); + } + } + + + public void applyTo(ResourceAllocation resourceAllocation, + StretchesFunction stretchesFunction) { + List intervalsDefinedByStreches = stretchesFunction + .getIntervalsDefinedByStreches(); + int totalHours = resourceAllocation.getAssignedHours(); + Task task = resourceAllocation.getTask(); + LocalDate start = LocalDate.fromDateFields(task.getStartDate()); + LocalDate end = LocalDate.fromDateFields(task.getEndDate()); + apply(resourceAllocation, intervalsDefinedByStreches, start, end, + totalHours); + } + + protected abstract void apply(ResourceAllocation allocation, + List intervalsDefinedByStreches, + LocalDate startInclusive, LocalDate endExclusive, int totalHours); + +} diff --git a/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/ResourceAllocations.hbm.xml b/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/ResourceAllocations.hbm.xml index 7b3c58d22..3584b6f04 100644 --- a/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/ResourceAllocations.hbm.xml +++ b/navalplanner-business/src/main/resources/org/navalplanner/business/planner/entities/ResourceAllocations.hbm.xml @@ -312,7 +312,7 @@ - org.navalplanner.business.planner.entities.StretchesFunction$Type + org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java index 7d6f5032a..855f8bbf3 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/AdvancedAllocationController.java @@ -48,11 +48,10 @@ 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; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; import org.navalplanner.business.planner.entities.Task; import org.navalplanner.business.planner.entities.TaskElement; import org.navalplanner.business.resources.entities.Criterion; @@ -1356,8 +1355,8 @@ class Row { } @Override - protected Type getType() { - return Type.DEFAULT; + protected StretchesFunctionTypeEnum getType() { + return StretchesFunctionTypeEnum.STRETCHES; } @Override @@ -1379,8 +1378,8 @@ class Row { } @Override - protected Type getType() { - return Type.INTERPOLATED; + protected StretchesFunctionTypeEnum getType() { + return StretchesFunctionTypeEnum.INTERPOLATED; } @Override diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java index 40977f5c7..f64bdb669 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/GraphicForStreches.java @@ -30,7 +30,7 @@ import org.navalplanner.business.calendars.entities.BaseCalendar; import org.navalplanner.business.planner.entities.Stretch; import org.navalplanner.business.planner.entities.StretchesFunction; import org.navalplanner.business.planner.entities.StretchesFunction.Interval; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; import org.navalplanner.web.planner.allocation.streches.StretchesFunctionController.IGraphicGenerator; import org.zkoss.zul.SimpleXYModel; import org.zkoss.zul.XYModel; @@ -41,9 +41,9 @@ import org.zkoss.zul.XYModel; */ public abstract class GraphicForStreches implements IGraphicGenerator { - public static IGraphicGenerator forType(Type type) { + public static IGraphicGenerator forType(StretchesFunctionTypeEnum type) { switch (type) { - case DEFAULT: + case STRETCHES: return new ForDefaultStreches(); case INTERPOLATED: return new ForInterpolation(); @@ -204,7 +204,7 @@ public abstract class GraphicForStreches implements IGraphicGenerator { double[] hourPoints = Interval.getHoursPointsFor(taskHours .intValue(), intervals); final Stretch lastStretch = stretches.get(stretches.size() - 1); - return StretchesFunction.Type.hoursForEachDayUsingSplines( + return StretchesFunctionTypeEnum.hoursForEachDayUsingSplines( dayPoints, hourPoints, startDate, lastStretch.getDate()); } diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/IStretchesFunctionModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/IStretchesFunctionModel.java index 71edf3f94..4b7e6346b 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/IStretchesFunctionModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/IStretchesFunctionModel.java @@ -32,7 +32,7 @@ import org.navalplanner.business.planner.entities.AssignmentFunction; import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.Stretch; import org.navalplanner.business.planner.entities.StretchesFunction; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; @@ -48,7 +48,8 @@ public interface IStretchesFunctionModel { */ void init(StretchesFunction stretchesFunction, - ResourceAllocation resourceAllocation, Type type); + ResourceAllocation resourceAllocation, + StretchesFunctionTypeEnum type); /* * Intermediate conversation steps diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java index ee79fa2a9..704a6f791 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StrechesFunctionConfiguration.java @@ -25,7 +25,7 @@ import java.util.HashMap; import org.navalplanner.business.planner.entities.AssignmentFunction; import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.StretchesFunction; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; import org.navalplanner.web.common.Util; import org.navalplanner.web.planner.allocation.IAssignmentFunctionConfiguration; import org.navalplanner.web.planner.allocation.streches.StretchesFunctionController.IGraphicGenerator; @@ -69,7 +69,7 @@ public abstract class StrechesFunctionConfiguration implements return GraphicForStreches.forType(getType()); } - protected abstract Type getType(); + protected abstract StretchesFunctionTypeEnum getType(); protected abstract boolean getChartsEnabled(); diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java index a6d9ebfad..917396054 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java @@ -34,7 +34,7 @@ import org.navalplanner.business.planner.entities.AssignmentFunction; import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.Stretch; import org.navalplanner.business.planner.entities.StretchesFunction; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; import org.navalplanner.web.common.Util; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.SuspendNotAllowedException; @@ -94,7 +94,7 @@ public class StretchesFunctionController extends GenericForwardComposer { } public void setResourceAllocation(ResourceAllocation resourceAllocation, - Type type) { + StretchesFunctionTypeEnum type) { AssignmentFunction assignmentFunction = resourceAllocation .getAssignmentFunction(); stretchesFunctionModel.init((StretchesFunction) assignmentFunction, diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionModel.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionModel.java index 9e3ce311b..9ba80c951 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionModel.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionModel.java @@ -41,7 +41,7 @@ import org.navalplanner.business.planner.entities.ResourceAllocation; import org.navalplanner.business.planner.entities.Stretch; import org.navalplanner.business.planner.entities.StretchesFunction; import org.navalplanner.business.planner.entities.StretchesFunction.Interval; -import org.navalplanner.business.planner.entities.StretchesFunction.Type; +import org.navalplanner.business.planner.entities.StretchesFunctionTypeEnum; import org.navalplanner.business.planner.entities.Task; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.BeanDefinition; @@ -96,7 +96,7 @@ public class StretchesFunctionModel implements IStretchesFunctionModel { public void init( StretchesFunction stretchesFunction, ResourceAllocation resourceAllocation, - org.navalplanner.business.planner.entities.StretchesFunction.Type type) { + StretchesFunctionTypeEnum type) { if (stretchesFunction != null) { assignmentFunctionDAO.reattach(stretchesFunction); this.originalStretchesFunction = stretchesFunction; @@ -145,7 +145,7 @@ public class StretchesFunctionModel implements IStretchesFunctionModel { throw new ValidationException( _("For interpolation at least two stretches are needed")); } - if (stretchesFunction.getDesiredType() == Type.INTERPOLATED) { + if (stretchesFunction.getDesiredType() == StretchesFunctionTypeEnum.INTERPOLATED) { if (!atLeastTwoStreches(getStretches())) { throw new ValidationException( _("There must be at least 2 stretches for doing interpolation"));