ItEr29S06CUAsignacionGrupoRecursosAPlanificacionItEr28S06: IAllocatable supports allocating hours on interval
This commit is contained in:
parent
c4bd06fbd0
commit
b933bc022c
4 changed files with 56 additions and 23 deletions
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
package org.navalplanner.business.planner.entities;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* This interface represents an object that can be do an allocation based on an
|
||||
* amount of {@link ResourcesPerDay}
|
||||
|
|
@ -27,4 +29,6 @@ package org.navalplanner.business.planner.entities;
|
|||
*/
|
||||
public interface IAllocatable {
|
||||
public void allocate(ResourcesPerDay resourcesPerDay);
|
||||
|
||||
public IAllocateHoursOnInterval onInterval(LocalDate start, LocalDate end);
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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;
|
||||
|
||||
public interface IAllocateHoursOnInterval {
|
||||
void allocateHours(int hours);
|
||||
}
|
||||
|
|
@ -296,7 +296,32 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
return result;
|
||||
}
|
||||
|
||||
void allocate(LocalDate startInclusive, LocalDate endExclusive, int hours) {
|
||||
private class AllocateHoursOnInterval implements
|
||||
IAllocateHoursOnInterval {
|
||||
|
||||
private final LocalDate start;
|
||||
private final LocalDate end;
|
||||
|
||||
AllocateHoursOnInterval(LocalDate start, LocalDate end) {
|
||||
Validate.isTrue(start.compareTo(end) <= 0,
|
||||
"the end must be equal or posterior than start");
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public void allocateHours(int hours) {
|
||||
allocate(start, end, hours);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllocateHoursOnInterval onInterval(LocalDate start,
|
||||
LocalDate end) {
|
||||
return new AllocateHoursOnInterval(start, end);
|
||||
}
|
||||
|
||||
private void allocate(LocalDate startInclusive, LocalDate endExclusive,
|
||||
int hours) {
|
||||
Validate.isTrue(hours >= 0);
|
||||
Validate.isTrue(startInclusive.compareTo(endExclusive) <= 0,
|
||||
"the end must be equal or posterior than start");
|
||||
|
|
|
|||
|
|
@ -123,29 +123,9 @@ public class SpecificResourceAllocation extends
|
|||
}
|
||||
}
|
||||
|
||||
public interface IAllocateHoursOnInterval {
|
||||
void allocateHours(int hours);
|
||||
}
|
||||
|
||||
private class AllocateHoursOnInterval implements IAllocateHoursOnInterval {
|
||||
|
||||
private final LocalDate start;
|
||||
private final LocalDate end;
|
||||
|
||||
AllocateHoursOnInterval(LocalDate start, LocalDate end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public void allocateHours(int hours) {
|
||||
new SpecificAssignmentsAllocation().allocate(start, end, hours);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAllocateHoursOnInterval onInterval(LocalDate start, LocalDate end) {
|
||||
Validate.isTrue(start.compareTo(end) <= 0,
|
||||
"the end must be equal or posterior than start");
|
||||
return new AllocateHoursOnInterval(start, end);
|
||||
return new SpecificAssignmentsAllocation().onInterval(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue