Permalink
Browse files

Stories in projects and products with you as responsible in one or mo…

…re tasks to be visible in daily work
  • Loading branch information...
1 parent c70326b commit 247f0f4ecc8416be654acfb12450a757c18dcae0 Ville Seppä committed Mar 26, 2013
@@ -178,7 +178,7 @@ public AssignedWorkTO getAssignedWorkFor(User user) {
DateTime dayEnd = dayStart.plusDays(1);
Interval interval = new Interval(dayStart, dayEnd);
- Collection<Task> tasks = taskDAO.getAllIterationAndStoryTasks(user, interval);
+ Collection<Task> tasks = taskDAO.getAllTasks(user, interval);
Collection<Story> stories = storyDAO.getAllIterationStoriesByResponsibleAndInterval(user, interval);
AssignedWorkTO returnable = transferObjectBusiness.constructAssignedWorkTO(tasks, stories);
@@ -63,6 +63,21 @@
* Search interval for the container iteration.
*/
public List<Task> getAllIterationAndStoryTasks(User user, Interval interval);
+
+ /**
+ * Lookup tasks that are assigned to the given user and are either directly
+ * attached to an iteration, or whose story is attached to any
+ * backlog (iteration, project or product).
+ * Selects only tasks from iterations that overlap with the given interval,
+ * or whose story timeframe overlaps with the given interval. Only
+ * returns tasks that are not yet done.
+ *
+ * @param user
+ * Assignee or one of the assignees for the searched tasks.
+ * @param interval
+ * Search interval for the container backlog.
+ */
+ public List<Task> getAllTasks(User user, Interval interval);
/**
@@ -127,6 +127,53 @@ public TaskDAOHibernate() {
return tasks;
}
+
+ public List<Task> getAllTasks(User user, Interval interval) {
+ List<Task> tasks = new ArrayList<Task>();
+
+ Criteria crit = this.createCriteria(Task.class);
+ crit.createCriteria("responsibles")
+ .add(Restrictions.idEq(user.getId()));
+
+ Criteria iteration = crit.createCriteria("iteration");
+ iteration.setFetchMode("parent", FetchMode.SELECT);
+ IterationDAOHelpers.addIterationIntervalLimit(iteration, interval);
+ crit.add(Restrictions.isNull("story"));
+ crit.add(Restrictions.ne("state", TaskState.DONE));
+ crit.setFetchMode("creator", FetchMode.SELECT);
+
+ List<Task> dummy = asList(crit);
+ tasks.addAll(dummy);
+
+ crit = this.createCriteria(Task.class);
+ crit.createCriteria("responsibles")
+ .add(Restrictions.idEq(user.getId()));
+ crit.add(Restrictions.ne("state", TaskState.DONE));
+
+ Criteria storyIteration = crit.createCriteria("story").createCriteria("iteration");
+ storyIteration.setFetchMode("parent",FetchMode.SELECT);
+ IterationDAOHelpers.addIterationIntervalLimit(storyIteration, interval);
+ crit.setFetchMode("creator", FetchMode.SELECT);
+
+ dummy = asList(crit);
+ tasks.addAll(dummy);
+
+ crit = this.createCriteria(Task.class);
+ crit.createCriteria("responsibles")
+ .add(Restrictions.idEq(user.getId()));
+ crit.add(Restrictions.ne("state", TaskState.DONE));
+ crit.add(Restrictions.isNull("iteration"));
+
+ Criteria storyBacklog = crit.createCriteria("story").createCriteria("backlog");
+ storyBacklog.setFetchMode("parent",FetchMode.SELECT);
+ IterationDAOHelpers.addBacklogIntervalLimit(storyBacklog, interval);
+ crit.setFetchMode("creator", FetchMode.SELECT);
+
+ dummy = asList(crit);
+ tasks.addAll(dummy);
+
+ return tasks;
+ }
public List<UnassignedLoadTO> getUnassignedStoryTasksWithEffortLeft(User user,
Interval interval) {
@@ -130,7 +130,7 @@ public void testGetAssignedWorkFor() {
Capture<Interval> interval = new Capture<Interval>();
Capture<Interval> interval2 = new Capture<Interval>();
- expect(taskDAO.getAllIterationAndStoryTasks(EasyMock.eq(user),
+ expect(taskDAO.getAllTasks(EasyMock.eq(user),
EasyMock.and(EasyMock.capture(interval), EasyMock.isA(Interval.class)))).andReturn(tasks);
expect(storyDAO.getAllIterationStoriesByResponsibleAndInterval(EasyMock.eq(user),
EasyMock.and(EasyMock.capture(interval2), EasyMock.isA(Interval.class)))).andReturn(stories);

0 comments on commit 247f0f4

Please sign in to comment.