01: package com.technoetic.xplanner.actions;
02:
03: import net.sf.hibernate.HibernateException;
04:
05: import com.technoetic.xplanner.domain.*;
06:
07: public class TaskContinuer extends Continuer {
08: private TaskDisposition dispositionOfContinuedTasks;
09:
10: protected void doContinueObject(DomainObject fromObject,
11: DomainObject toParent, DomainObject toObject)
12: throws HibernateException {
13:
14: Task fromTask = (Task) fromObject;
15: UserStory toStory = (UserStory) toParent;
16: Task toTask = (Task) toObject;
17:
18: toTask.setCreatedDate(when);
19: toTask.setDisposition(TaskDisposition
20: .fromNameKey(getDispositionOfContinuedTasks(toStory)
21: .getNameKey()));
22: toTask.setAcceptorId(0);
23: toTask.setEstimatedHours(fromTask.getRemainingHours());
24: toTask.setEstimatedOriginalHoursField(0.0);
25: toTask.setTimeEntries(null);
26: fromTask.postpone();
27: }
28:
29: public void setDispositionOfContinuedTasks(
30: TaskDisposition dispositionOfContinuedTasks) {
31: this .dispositionOfContinuedTasks = dispositionOfContinuedTasks;
32: }
33:
34: public TaskDisposition getDispositionOfContinuedTasks(
35: UserStory toStory) throws HibernateException {
36: if (dispositionOfContinuedTasks == null) {
37: determineTaskDisposition(toStory);
38: }
39: return dispositionOfContinuedTasks;
40: }
41:
42: private void determineTaskDisposition(UserStory toStory)
43: throws HibernateException {
44: Iteration iteration = (Iteration) metaDataRepository
45: .getParent(toStory);
46: dispositionOfContinuedTasks = iteration.isActive() ? TaskDisposition.ADDED
47: : TaskDisposition.CARRIED_OVER;
48: }
49: }
|