ItEr26S07CUAsignacionGrupoRecursosAPlanificacionItEr25S07: Replacing setTasks method for init method
This commit is contained in:
parent
6a6c738f4e
commit
36c198c841
3 changed files with 23 additions and 38 deletions
|
|
@ -73,22 +73,6 @@ public interface IResourceAllocationModel {
|
|||
void removeSpecificResourceAllocation(
|
||||
SpecificResourceAllocation resourceAllocation);
|
||||
|
||||
/**
|
||||
* Sets the current Gantt {@link org.zkoss.ganttz.data.Task ganttTask},
|
||||
* where the user is allocating resources.
|
||||
*
|
||||
* @param ganttTask
|
||||
*/
|
||||
void setGanttTask(org.zkoss.ganttz.data.Task ganttTask);
|
||||
|
||||
/**
|
||||
* Sets the current {@link Task}, where the user is allocating resources.
|
||||
*
|
||||
* @param task
|
||||
* A {@link Task}
|
||||
*/
|
||||
void setTask(Task task);
|
||||
|
||||
/**
|
||||
* Cancel operation
|
||||
*/
|
||||
|
|
@ -99,4 +83,11 @@ public interface IResourceAllocationModel {
|
|||
*/
|
||||
void save();
|
||||
|
||||
/**
|
||||
* Starts the use case
|
||||
* @param task
|
||||
* @param ganttTask
|
||||
*/
|
||||
void initAllocationsFor(Task task, org.zkoss.ganttz.data.Task ganttTask);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,7 @@ public class ResourceAllocationController extends GenericForwardComposer {
|
|||
* @param ganttTask
|
||||
*/
|
||||
public void showWindow(Task task, org.zkoss.ganttz.data.Task ganttTask) {
|
||||
resourceAllocationModel.setTask(task);
|
||||
resourceAllocationModel.setGanttTask(ganttTask);
|
||||
|
||||
resourceAllocationModel.initAllocationsFor(task, ganttTask);
|
||||
resourceAllocationModel
|
||||
.addGenericResourceAllocationIfNoAllocationExists();
|
||||
Util.reloadBindings(window);
|
||||
|
|
|
|||
|
|
@ -57,20 +57,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
return task;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void setTask(Task task) {
|
||||
if (!taskElementDAO.exists(task.getId())) {
|
||||
this.task = task;
|
||||
return;
|
||||
}
|
||||
this.task = findFromDB(task);
|
||||
reattachResourceAllocations(this.task.getResourceAllocations());
|
||||
hoursGroupDAO.save(this.task.getHoursGroup());
|
||||
reattachHoursGroup(this.task.getHoursGroup());
|
||||
reattachCriterions(this.task.getHoursGroup().getCriterions());
|
||||
}
|
||||
|
||||
private Task findFromDB(Task task) {
|
||||
try {
|
||||
return (Task) taskElementDAO.find(task.getId());
|
||||
|
|
@ -223,11 +209,6 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGanttTask(org.zkoss.ganttz.data.Task ganttTask) {
|
||||
this.ganttTask = ganttTask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
task.clearResourceAllocations();
|
||||
|
|
@ -239,4 +220,19 @@ public class ResourceAllocationModel implements IResourceAllocationModel {
|
|||
taskElementDAO.save(task);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initAllocationsFor(Task task,
|
||||
org.zkoss.ganttz.data.Task ganttTask) {
|
||||
this.ganttTask = ganttTask;
|
||||
if (!taskElementDAO.exists(task.getId())) {
|
||||
this.task = task;
|
||||
return;
|
||||
}
|
||||
this.task = findFromDB(task);
|
||||
reattachResourceAllocations(this.task.getResourceAllocations());
|
||||
hoursGroupDAO.save(this.task.getHoursGroup());
|
||||
reattachHoursGroup(this.task.getHoursGroup());
|
||||
reattachCriterions(this.task.getHoursGroup().getCriterions());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue