ItEr18S09CUCreacionProxectoPlanificacionItEr17S10: splitting a task keeps its share of hours if present
This commit is contained in:
parent
73a37d7e81
commit
d9e424f56f
5 changed files with 34 additions and 10 deletions
|
|
@ -35,8 +35,6 @@ public class Task extends TaskElement {
|
|||
|
||||
private Set<ResourceAllocation> resourceAllocations = new HashSet<ResourceAllocation>();
|
||||
|
||||
private Integer shareOfHours;
|
||||
|
||||
/**
|
||||
* For hibernate, DO NOT USE
|
||||
*/
|
||||
|
|
@ -177,9 +175,7 @@ public class Task extends TaskElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getWorkHours() {
|
||||
if (shareOfHours != null)
|
||||
return shareOfHours;
|
||||
public Integer defaultWorkHours() {
|
||||
return hoursGroup.getWorkingHours();
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +186,7 @@ public class Task extends TaskElement {
|
|||
"the shares don't sum up the work hours");
|
||||
TaskGroup result = new TaskGroup();
|
||||
result.copyPropertiesFrom(this);
|
||||
result.shareOfHours = this.shareOfHours;
|
||||
if (this.getParent() != null) {
|
||||
this.getParent().addTaskElement(result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ public abstract class TaskElement {
|
|||
|
||||
private TaskGroup parent;
|
||||
|
||||
protected Integer shareOfHours;
|
||||
|
||||
@NotNull
|
||||
private OrderElement orderElement;
|
||||
|
||||
|
|
@ -38,7 +40,13 @@ public abstract class TaskElement {
|
|||
|
||||
private Set<Dependency> dependenciesWithThisDestination = new HashSet<Dependency>();
|
||||
|
||||
public abstract Integer getWorkHours();
|
||||
public Integer getWorkHours() {
|
||||
if (shareOfHours != null)
|
||||
return shareOfHours;
|
||||
return defaultWorkHours();
|
||||
}
|
||||
|
||||
protected abstract Integer defaultWorkHours();
|
||||
|
||||
protected void copyPropertiesFrom(Task task) {
|
||||
this.name = task.getName();
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ public class TaskGroup extends TaskElement {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Integer getWorkHours() {
|
||||
public Integer defaultWorkHours() {
|
||||
return getOrderElement().getWorkHours();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
<generator class="native" />
|
||||
</id>
|
||||
<version name="version" type="long"></version>
|
||||
<property name="shareOfHours"></property>
|
||||
<property name="name" />
|
||||
<property name="notes"/>
|
||||
<property name="startDate" type="timestamp" />
|
||||
|
|
@ -28,7 +29,6 @@
|
|||
|
||||
<joined-subclass name="Task">
|
||||
<key column="TASK_ELEMENT_ID"></key>
|
||||
<property name="shareOfHours"></property>
|
||||
<many-to-one name="hoursGroup" cascade="none"/>
|
||||
<property name="fixedDuration" />
|
||||
<property name="duration" />
|
||||
|
|
|
|||
|
|
@ -125,6 +125,25 @@ public class TaskElementTest {
|
|||
assertThat(third.getWorkHours(), equalTo(50));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splittingATaskKeepsItsShareOfHoursIfPresent() {
|
||||
HoursGroup hoursGroup = new HoursGroup();
|
||||
Task initial = Task.createTask(hoursGroup);
|
||||
initial.setName("prueba");
|
||||
initial.setNotes("blabla");
|
||||
initial.setStartDate(new Date());
|
||||
OrderLine orderLine = new OrderLine();
|
||||
hoursGroup.setWorkingHours(100);
|
||||
orderLine.addHoursGroup(hoursGroup);
|
||||
initial.setOrderElement(orderLine);
|
||||
int[] shares = { 50, 50 };
|
||||
TaskGroup group = initial.split(shares);
|
||||
Task t = (Task) group.getChildren().get(0);
|
||||
TaskGroup childSplittedGroup = t.split(new int[] { 25, 25 });
|
||||
assertThat("the work hours must be the same that it had",
|
||||
childSplittedGroup.getWorkHours(), equalTo(50));
|
||||
}
|
||||
|
||||
private void checkPopertiesAreKept(Task taskBeingSplitted,
|
||||
TaskElement oneOfTheResult) {
|
||||
assertThat(oneOfTheResult.getName(), equalTo(taskBeingSplitted
|
||||
|
|
@ -208,8 +227,8 @@ public class TaskElementTest {
|
|||
taskToDetach.setStartDate(new Date());
|
||||
Dependency.createDependency(sourceDependencyTask, taskToDetach,
|
||||
Type.END_START);
|
||||
Dependency.createDependency(taskToDetach,
|
||||
destinationDependencyTask, Type.END_START);
|
||||
Dependency.createDependency(taskToDetach, destinationDependencyTask,
|
||||
Type.END_START);
|
||||
taskToDetach.detach();
|
||||
assertThat(sourceDependencyTask.getDependenciesWithThisOrigin().size(),
|
||||
equalTo(0));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue