Skip to content

Commit bb1e0ee

Browse files
committed
work in progress
1 parent 45155a0 commit bb1e0ee

File tree

8 files changed

+220
-72
lines changed

8 files changed

+220
-72
lines changed

src/main/java/org/woehlke/simpleworklist/project/ProjectController.java

Lines changed: 72 additions & 22 deletions
Large diffs are not rendered by default.

src/main/java/org/woehlke/simpleworklist/project/ProjectControllerRoot.java

Lines changed: 67 additions & 22 deletions
Large diffs are not rendered by default.

src/main/java/org/woehlke/simpleworklist/project/ProjectControllerServiceImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public void addNewProjectToProjectIdForm(
4949
log.info("addNewProject projectId="+projectId);
5050
UserAccount userAccount = context.getUserAccount();
5151
userSession.setLastProjectId(projectId);
52-
model.addAttribute("userSession",userSession);
5352
Project thisProject = projectService.findByProjectId(projectId);
5453
Project project = Project.newProjectFactoryForParentProject(thisProject);
5554
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForShowOneProject(thisProject,locale);
5655
model.addAttribute("breadcrumb", breadcrumb);
5756
model.addAttribute("thisProject", thisProject);
5857
model.addAttribute("project", project);
58+
model.addAttribute("userSession", userSession);
5959
}
6060

6161
public String addNewProjectToProjectIdPersist(
@@ -76,6 +76,7 @@ public String addNewProjectToProjectIdPersist(
7676
model.addAttribute("breadcrumb", breadcrumb);
7777
model.addAttribute("thisProject", thisProject);
7878
model.addAttribute("project", project);
79+
model.addAttribute("userSession", userSession);
7980
return "project/id/show";
8081
} else {
8182
Project thisProject = projectService.findByProjectId(projectId);
@@ -84,6 +85,7 @@ public String addNewProjectToProjectIdPersist(
8485
thisProject = projectService.update(thisProject);
8586
log.info("project: "+ project.toString());
8687
log.info("thisProject: "+ thisProject.toString());
88+
model.addAttribute("userSession", userSession);
8789
return thisProject.getUrl();
8890
}
8991
}
@@ -114,6 +116,7 @@ public void addNewProjectToProjectRootForm(
114116
model.addAttribute("thisProjectId", project.getId());
115117
model.addAttribute("breadcrumb", breadcrumb);
116118
userSession.setLastProjectId(rootProjectId);
119+
model.addAttribute("userSession", userSession);
117120
}
118121

119122
@Override
@@ -128,6 +131,7 @@ public String addNewProjectToProjectRootPersist(
128131
log.info("addNewProjectToRootPersist");
129132
project = projectService.add(project);
130133
userSession.setLastProjectId(project.getId());
134+
model.addAttribute("userSession", userSession);
131135
return project.getUrl();
132136
}
133137

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package org.woehlke.simpleworklist.task;
22

3+
import org.springframework.ui.Model;
4+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
5+
36
public interface TaskProjektService {
47

5-
String transformTaskIntoProjectGet(Task task);
8+
String transformTaskIntoProjectGet(Task task, UserSessionBean userSession, Model model);
69
}

src/main/java/org/woehlke/simpleworklist/task/TaskProjektServiceImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import lombok.extern.slf4j.Slf4j;
55
import org.springframework.beans.factory.annotation.Autowired;
66
import org.springframework.stereotype.Service;
7+
import org.springframework.ui.Model;
78
import org.woehlke.simpleworklist.project.Project;
89
import org.woehlke.simpleworklist.project.ProjectService;
10+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
911

1012
import javax.validation.constraints.NotNull;
1113

@@ -23,7 +25,9 @@ public TaskProjektServiceImpl(ProjectService projectService, TaskService taskSer
2325
}
2426

2527
@Override
26-
public String transformTaskIntoProjectGet(@NotNull Task task) {
28+
public String transformTaskIntoProjectGet(
29+
@NotNull Task task, @NotNull UserSessionBean userSession, @NotNull Model model
30+
) {
2731
log.info("transformTaskIntoProjectGet");
2832
Project thisProject = new Project();
2933
thisProject.setName(task.getTitle());
@@ -39,8 +43,9 @@ public String transformTaskIntoProjectGet(@NotNull Task task) {
3943
task.setProject(null);
4044
task.moveToTrash();
4145
task.emptyTrash();
42-
taskService.updatedViaTaskstate(task);
46+
task = taskService.updatedViaTaskstate(task);
4347
log.info("tried to transform Task " + task.getId() + " to new Project " + thisProject.getId());
48+
model.addAttribute("userSession", userSession);
4449
return thisProject.getUrl();
4550
}
4651
}

src/main/java/org/woehlke/simpleworklist/task/TaskStateTaskController.java

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public final String addNewTaskToInboxGet(
6767
model.addAttribute("mustChooseArea", mustChooseContext);
6868
model.addAttribute("breadcrumb", breadcrumb);
6969
model.addAttribute("task", task);
70+
model.addAttribute("userSession", userSession);
7071
return "taskstate/task/add";
7172
}
7273

@@ -90,10 +91,12 @@ public final String addNewTaskToInboxPost(
9091
model.addAttribute("mustChooseArea", mustChooseArea);
9192
model.addAttribute("breadcrumb", breadcrumb);
9293
model.addAttribute("task", task);
94+
model.addAttribute("userSession", userSession);
9395
return "taskstate/task/add";
9496
} else {
9597
task = taskService.addToInbox(task);
9698
log.info(task.toString());
99+
model.addAttribute("userSession", userSession);
97100
return "redirect:/taskstate/" + task.getTaskState().name().toLowerCase();
98101
}
99102
}
@@ -105,27 +108,24 @@ public final String editTaskGet(
105108
Locale locale, Model model
106109
) {
107110
log.info("editTaskGet");
108-
if(task != null) {
109-
UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser();
110-
List<Context> contexts = contextService.getAllForUser(userAccount);
111-
Project thisProject;
112-
if (task.getContext() == null) {
113-
thisProject = new Project();
114-
thisProject.setId(0L);
115-
} else {
116-
thisProject = task.getProject();
117-
}
118-
Context thisContext = task.getContext();
119-
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForTaskstate(task.getTaskState(),locale);
120-
model.addAttribute("breadcrumb", breadcrumb);
121-
model.addAttribute("thisProject", thisProject);
122-
model.addAttribute("thisContext", thisContext);
123-
model.addAttribute("task", task);
124-
model.addAttribute("contextss", contexts);
125-
return "taskstate/task/edit";
111+
UserAccount userAccount = userAccountLoginSuccessService.retrieveCurrentUser();
112+
List<Context> contexts = contextService.getAllForUser(userAccount);
113+
Project thisProject;
114+
if (task.getContext() == null) {
115+
thisProject = new Project();
116+
thisProject.setId(0L);
126117
} else {
127-
return "redirect:/taskstate/inbox";
118+
thisProject = task.getProject();
128119
}
120+
Context thisContext = task.getContext();
121+
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForTaskstate(task.getTaskState(),locale);
122+
model.addAttribute("breadcrumb", breadcrumb);
123+
model.addAttribute("thisProject", thisProject);
124+
model.addAttribute("thisContext", thisContext);
125+
model.addAttribute("task", task);
126+
model.addAttribute("contexts", contexts);
127+
model.addAttribute("userSession", userSession);
128+
return "taskstate/task/edit";
129129
}
130130

131131
@RequestMapping(path = "/{taskId}/edit", method = RequestMethod.POST)
@@ -172,13 +172,15 @@ public final String editTaskPost(
172172
model.addAttribute("thisContext", thisContext);
173173
model.addAttribute("task", task);
174174
model.addAttribute("contexts", contexts);
175+
model.addAttribute("userSession", userSession);
175176
return "taskstate/task/edit";
176177
} else {
177178
task.unsetFocus();
178179
task.setRootProject();
179180
Task persistentTask = taskService.findOne(task.getId());
180181
persistentTask.merge(task);
181182
task = taskService.updatedViaTaskstate(persistentTask);
183+
model.addAttribute("userSession", userSession);
182184
return task.getTaskState().getUrl();
183185
}
184186
}
@@ -222,6 +224,7 @@ public final String moveTaskToInbox(
222224
) {
223225
log.info("dragged and dropped "+task.getId()+" to inbox");
224226
task = taskService.moveTaskToInbox(task);
227+
model.addAttribute("userSession", userSession);
225228
return task.getTaskState().getUrl();
226229
}
227230

@@ -233,6 +236,7 @@ public final String moveTaskToToday(
233236
) {
234237
log.info("dragged and dropped "+task.getId()+" to today");
235238
task = taskService.moveTaskToToday(task);
239+
model.addAttribute("userSession", userSession);
236240
return task.getTaskState().getUrl();
237241
}
238242

@@ -244,6 +248,7 @@ public final String moveTaskToNext(
244248
) {
245249
log.info("dragged and dropped "+task.getId()+" to next");
246250
task = taskService.moveTaskToNext(task);
251+
model.addAttribute("userSession", userSession);
247252
return task.getTaskState().getUrl();
248253
}
249254

@@ -255,6 +260,7 @@ public final String moveTaskToWaiting(
255260
) {
256261
log.info("dragged and dropped "+task.getId()+" to waiting");
257262
task = taskService.moveTaskToWaiting(task);
263+
model.addAttribute("userSession", userSession);
258264
return task.getTaskState().getUrl();
259265
}
260266

@@ -266,6 +272,7 @@ public final String moveTaskToSomeday(
266272
) {
267273
log.info("dragged and dropped "+task.getId()+" to someday");
268274
task = taskService.moveTaskToSomeday(task);
275+
model.addAttribute("userSession", userSession);
269276
return task.getTaskState().getUrl();
270277
}
271278

@@ -277,6 +284,7 @@ public final String moveTaskToFocus(
277284
) {
278285
log.info("dragged and dropped "+task.getId()+" to focus");
279286
task = taskService.moveTaskToFocus(task);
287+
model.addAttribute("userSession", userSession);
280288
return task.getTaskState().getUrl();
281289
}
282290

@@ -288,6 +296,7 @@ public final String moveTaskToCompleted(
288296
) {
289297
log.info("dragged and dropped "+task.getId()+" to completed");
290298
task = taskService.moveTaskToCompleted(task);
299+
model.addAttribute("userSession", userSession);
291300
return task.getTaskState().getUrl();
292301
}
293302

@@ -299,6 +308,7 @@ public final String moveTaskToTrash(
299308
) {
300309
log.info("dragged and dropped "+task.getId()+" to trash");
301310
task = taskService.moveTaskToTrash(task);
311+
model.addAttribute("userSession", userSession);
302312
return task.getTaskState().getUrl();
303313
}
304314

@@ -309,6 +319,7 @@ public final String moveAllCompletedToTrash(
309319
) {
310320
Context context = super.getContext(userSession);
311321
taskService.moveAllCompletedToTrash(context);
322+
model.addAttribute("userSession", userSession);
312323
return "redirect:/taskstate/trash";
313324
}
314325

@@ -319,6 +330,7 @@ public final String emptyTrash(
319330
) {
320331
Context context = super.getContext(userSession);
321332
taskService.emptyTrash(context);
333+
model.addAttribute("userSession", userSession);
322334
return "redirect:/taskstate/trash";
323335
}
324336

@@ -330,10 +342,9 @@ public final String deleteTaskGet(
330342
Model model
331343
) {
332344
log.info("deleteTaskGet");
333-
if(task!= null){
334-
task.delete();
335-
taskService.updatedViaTaskstate(task);
336-
}
345+
task.delete();
346+
taskService.updatedViaTaskstate(task);
347+
model.addAttribute("userSession", userSession);
337348
return "redirect:/taskstate/trash";
338349
}
339350

@@ -346,6 +357,7 @@ public final String undeleteTaskGet(
346357
log.info("undeleteTaskGet");
347358
task.undelete();
348359
taskService.updatedViaTaskstate(task);
360+
model.addAttribute("userSession", userSession);
349361
return "redirect:/taskstate/completed";
350362
}
351363

@@ -356,7 +368,7 @@ public final String transformTaskIntoProjectGet(
356368
Model model
357369
) {
358370
log.info("transformTaskIntoProjectGet");
359-
return taskProjektService.transformTaskIntoProjectGet(task);
371+
return taskProjektService.transformTaskIntoProjectGet(task, userSession, model);
360372
}
361373

362374
@RequestMapping(path = "/{taskId}/complete", method = RequestMethod.GET)
@@ -369,6 +381,7 @@ public final String setDoneTaskGet(
369381
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(TaskState.COMPLETED,task.getContext());
370382
task.setOrderIdTaskState(++maxOrderIdTaskState);
371383
task = taskService.updatedViaTaskstate(task);
384+
model.addAttribute("userSession", userSession);
372385
return task.getUrl();
373386
}
374387

@@ -382,6 +395,7 @@ public final String unsetDoneTaskGet(
382395
long maxOrderIdTaskState = taskService.getMaxOrderIdTaskState(task.getTaskState(),task.getContext());
383396
task.setOrderIdTaskState(++maxOrderIdTaskState);
384397
task = taskService.updatedViaTaskstate(task);
398+
model.addAttribute("userSession", userSession);
385399
return task.getUrl();
386400
}
387401

@@ -393,6 +407,7 @@ public final String setFocusGet(
393407
){
394408
task.setFocus();
395409
task = taskService.updatedViaTaskstate(task);
410+
model.addAttribute("userSession", userSession);
396411
return task.getUrl();
397412
}
398413

@@ -404,6 +419,7 @@ public final String unsetFocusGet(
404419
){
405420
task.unsetFocus();
406421
task = taskService.updatedViaTaskstate(task);
422+
model.addAttribute("userSession", userSession);
407423
return task.getUrl();
408424
}
409425
}

src/main/java/org/woehlke/simpleworklist/user/chat/User2UserMessageController.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public final String getLastMessagesBetweenCurrentAndOtherUser(
5151
model.addAttribute("refreshMessages",true);
5252
Breadcrumb breadcrumb = breadcrumbService.getBreadcrumbForMessagesBetweenCurrentAndOtherUser(locale);
5353
model.addAttribute("breadcrumb",breadcrumb);
54+
model.addAttribute("userSession", userSession);
5455
return "user/messages/all";
5556
}
5657

@@ -78,9 +79,11 @@ public final String sendNewMessageToOtherUser(
7879
Page<User2UserMessage> user2UserMessagePage = user2UserMessageService.readAllMessagesBetweenCurrentAndOtherUser(thisUser,otherUser,request);
7980
model.addAttribute("otherUser", otherUser);
8081
model.addAttribute("user2UserMessagePage", user2UserMessagePage);
82+
model.addAttribute("userSession", userSession);
8183
return "user/messages/all";
8284
} else {
8385
user2UserMessageService.sendNewUserMessage(thisUser, otherUser, user2UserMessageFormBean);
86+
model.addAttribute("userSession", userSession);
8487
return "redirect:/user/messages/" + otherUser.getId();
8588
}
8689
}

0 commit comments

Comments
 (0)