ItEr26S07CUAsignacionGrupoRecursosAPlanificacionItEr25S07: A ResourceAllocation can calculate the assigned hours
This commit is contained in:
parent
3b839d900a
commit
988e1ae666
4 changed files with 29 additions and 0 deletions
|
|
@ -97,4 +97,11 @@ public abstract class DayAssigment extends BaseEntity {
|
|||
};
|
||||
}
|
||||
|
||||
public static <T extends DayAssigment> List<T> orderedByDay(
|
||||
Collection<T> dayAssignments) {
|
||||
List<T> result = new ArrayList<T>(dayAssignments);
|
||||
Collections.sort(result, byDayComparator());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,4 +193,9 @@ public class GenericResourceAllocation extends ResourceAllocation {
|
|||
clearFieldsCalculatedFromAssignments();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends DayAssigment> getAssignments() {
|
||||
return DayAssigment.orderedByDay(genericDayAssigments);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
package org.navalplanner.business.planner.entities;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotNull;
|
||||
|
|
@ -65,4 +66,14 @@ public abstract class ResourceAllocation extends BaseEntity {
|
|||
return assigmentFunction;
|
||||
}
|
||||
|
||||
public int getAssignedHours() {
|
||||
int total = 0;
|
||||
for (DayAssigment dayAssigment : getAssignments()) {
|
||||
total += dayAssigment.getHours();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
protected abstract List<? extends DayAssigment> getAssignments();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package org.navalplanner.business.planner.entities;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.validator.NotNull;
|
||||
|
|
@ -46,4 +47,9 @@ public class SpecificResourceAllocation extends ResourceAllocation {
|
|||
public Set<SpecificDayAssigment> getSpecificDaysAssigment() {
|
||||
return Collections.unmodifiableSet(specificDaysAssigment);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends DayAssigment> getAssignments() {
|
||||
return DayAssigment.orderedByDay(specificDaysAssigment);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue