Skip to content

Commit 269bc69

Browse files
committed
work
1 parent 7ec84a6 commit 269bc69

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/main/java/org/woehlke/java/simpleworklist/domain/task/Task.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@
8585
+ " where t.orderIdProject > :lowerOrderIdProject and t.orderIdProject < :higherOrderIdProject"
8686
+ " and t.project is null and t.context = :context ",
8787
lockMode = LockModeType.READ
88+
),
89+
@NamedQuery(
90+
name = "findByTaskStateTrashAndContext",
91+
query = "select t from Task t " +
92+
"where t.taskState = org.woehlke.java.simpleworklist.domain.taskworkflow.TaskState.TRASH " +
93+
"or t.taskState = org.woehlke.java.simpleworklist.domain.taskworkflow.TaskState.DELETED " +
94+
"and t.context = :context",
95+
lockMode = LockModeType.READ
8896
)
8997
})
9098
@Getter

src/main/java/org/woehlke/java/simpleworklist/domain/task/TaskRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public interface TaskRepository extends JpaRepository<Task, Long> {
3030
List<Task> findByTaskStateAndContext(TaskState taskState, Context context);
3131
Page<Task> findByTaskStateAndContext(TaskState taskState, Context context, Pageable request);
3232

33+
@Query(name="findByTaskStateTrashAndContext")
34+
Page<Task> findByTaskStateTrashAndContext(@Param("context") Context context, Pageable request);
35+
3336
List<Task> findByTaskStateAndContextOrderByOrderIdTaskStateAsc(
3437
TaskState taskState, Context context
3538
);

src/main/java/org/woehlke/java/simpleworklist/domain/task/TaskServiceImpl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ public Page<Task> findbyTaskstate(
4444
@NotNull Context context,
4545
@NotNull Pageable request
4646
) {
47-
if(taskState == TaskState.FOCUS){
48-
return taskRepository.findByFocusAndContext(true,context,request);
49-
}else {
50-
return taskRepository.findByTaskStateAndContext(taskState, context, request);
51-
}
47+
switch (taskState){
48+
case FOCUS:
49+
return taskRepository.findByFocusAndContext(true, context, request);
50+
case TRASH:
51+
case DELETED:
52+
return taskRepository.findByTaskStateTrashAndContext(context, request);
53+
default:
54+
return taskRepository.findByTaskStateAndContext(taskState, context, request);
55+
}
5256
}
5357

5458
@Override

src/main/java/org/woehlke/java/simpleworklist/domain/taskworkflow/TaskStateTabController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,16 @@ public final String trash(
131131
context, pageable, userSession, locale, model);
132132
}
133133

134+
@RequestMapping(path = "/deleted", method = RequestMethod.GET)
135+
public final String deleted(
136+
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,
137+
@NotNull @ModelAttribute("userSession") UserSessionBean userSession,
138+
Locale locale,
139+
Model model
140+
) {
141+
return trash(pageable, userSession, locale, model);
142+
}
143+
134144
@RequestMapping(path = "/focus", method = RequestMethod.GET)
135145
public final String focus(
136146
@PageableDefault(sort = "orderIdTaskState", direction = Sort.Direction.DESC) Pageable pageable,

0 commit comments

Comments
 (0)