Skip to content

Commit 2afe17a

Browse files
committed
## 2.3.34
* Issue #317 switch Context is broken * fixed #326 add Context to Breadcrumb
1 parent 8653fd7 commit 2afe17a

15 files changed

+155
-100
lines changed

etc/TODO.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
## 2.3.34
6464
* Issue #317 switch Context is broken
65-
* Issue add Context to Breadcrumb
65+
* fixed #326 add Context to Breadcrumb
6666

6767
## 2.3.35
6868
* Issue #234 Taskstate: Task Edit Form -> change Project via DropDown

src/main/java/org/woehlke/simpleworklist/domain/breadcrumb/Breadcrumb.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import lombok.EqualsAndHashCode;
44
import lombok.Getter;
55
import lombok.ToString;
6+
import org.woehlke.simpleworklist.domain.context.Context;
67
import org.woehlke.simpleworklist.domain.project.Project;
78
import org.woehlke.simpleworklist.domain.task.Task;
89

@@ -21,17 +22,22 @@ public class Breadcrumb implements Serializable {
2122
private List<BreadcrumbItem> breadcrumb;
2223
private final Locale locale;
2324

24-
public Breadcrumb(Locale locale) {
25+
public Breadcrumb(Locale locale, Context context) {
2526
this.locale = locale;
2627
List<BreadcrumbItem> breadcrumb = new ArrayList<>();
27-
String homeString;
28+
String homeString,contextItemString;
2829
if(locale == Locale.GERMAN){
2930
homeString = "Start";
31+
contextItemString = context.getNameDe();
3032
} else {
3133
homeString = "Home";
34+
contextItemString =context.getNameEn();
3235
}
36+
contextItemString = " [ " + contextItemString + " ] ";
3337
BreadcrumbItem home = new BreadcrumbItem(homeString,"/");
3438
breadcrumb.add(home);
39+
BreadcrumbItem contextItem = new BreadcrumbItem(contextItemString,"/");
40+
breadcrumb.add(contextItem);
3541
this.breadcrumb = breadcrumb;
3642
}
3743

src/main/java/org/woehlke/simpleworklist/domain/breadcrumb/BreadcrumbService.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,43 @@
55
import org.woehlke.simpleworklist.domain.project.Project;
66
import org.woehlke.simpleworklist.domain.task.Task;
77
import org.woehlke.simpleworklist.domain.task.TaskState;
8+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
89

10+
import javax.validation.constraints.NotNull;
911
import java.util.Locale;
1012

1113
public interface BreadcrumbService {
1214

13-
Breadcrumb getBreadcrumbForShowRootProject(Locale locale);
15+
Breadcrumb getBreadcrumbForShowRootProject(Locale locale, UserSessionBean userSession);
1416

15-
Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale locale);
17+
Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale locale, UserSessionBean userSession);
1618

17-
Breadcrumb getBreadcrumbForTaskstate(TaskState taskstate, Locale locale);
19+
Breadcrumb getBreadcrumbForTaskstate(TaskState taskstate, Locale locale, UserSessionBean userSession);
1820

19-
Breadcrumb getBreadcrumbForTaskstateAll(Locale locale);
21+
Breadcrumb getBreadcrumbForTaskstateAll(Locale locale, UserSessionBean userSession);
2022

21-
Breadcrumb getBreadcrumbForTaskInTaskstate(String taskstate, Task task, Locale locale);
23+
Breadcrumb getBreadcrumbForTaskInTaskstate(String taskstate, Task task, Locale locale, UserSessionBean userSession);
2224

23-
Breadcrumb getBreadcrumbForTaskInProject(Project thisProject, Task task, Locale locale);
25+
Breadcrumb getBreadcrumbForTaskInProject(Project thisProject, Task task, Locale local, UserSessionBean userSession);
2426

25-
Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale);
27+
Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale,UserSessionBean userSession);
2628

27-
Breadcrumb getBreadcrumbForUserChangeName(Locale locale);
29+
Breadcrumb getBreadcrumbForUserChangeName(Locale locale, UserSessionBean userSession);
2830

29-
Breadcrumb getBreadcrumbForUserChangePassword(Locale locale);
31+
Breadcrumb getBreadcrumbForUserChangePassword(Locale locale, UserSessionBean userSession);
3032

31-
Breadcrumb getBreadcrumbForUserContexts(Locale locale);
33+
Breadcrumb getBreadcrumbForUserContexts(Locale locale, UserSessionBean userSession);
3234

33-
Breadcrumb getBreadcrumbForUserContextAdd(Locale locale);
35+
Breadcrumb getBreadcrumbForUserContextAdd(Locale locale,UserSessionBean userSession);
3436

35-
Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context);
37+
Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context, UserSessionBean userSession);
3638

37-
Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context context);
39+
Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context context, UserSessionBean userSession);
3840

39-
Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale);
41+
Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale, UserSessionBean userSession);
4042

41-
Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale locale);
43+
Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale locale, UserSessionBean userSession);
4244

43-
Breadcrumb getBreadcrumbForSearchResults(Locale locale);
45+
Breadcrumb getBreadcrumbForSearchResults(Locale locale, UserSessionBean userSession);
4446

4547
}

src/main/java/org/woehlke/simpleworklist/domain/breadcrumb/BreadcrumbServiceImpl.java

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
import org.springframework.stereotype.Service;
77
import org.springframework.transaction.annotation.Propagation;
88
import org.springframework.transaction.annotation.Transactional;
9-
import org.woehlke.simpleworklist.domain.breadcrumb.Breadcrumb;
10-
import org.woehlke.simpleworklist.domain.breadcrumb.BreadcrumbService;
119
import org.woehlke.simpleworklist.domain.context.Context;
10+
import org.woehlke.simpleworklist.domain.context.ContextService;
1211
import org.woehlke.simpleworklist.domain.project.Project;
1312
import org.woehlke.simpleworklist.domain.task.Task;
1413
import org.woehlke.simpleworklist.domain.task.TaskState;
14+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
1515

1616
import java.util.Locale;
17+
import java.util.Optional;
1718
import java.util.Stack;
1819

1920
@Slf4j
@@ -22,24 +23,28 @@
2223
public class BreadcrumbServiceImpl implements BreadcrumbService {
2324

2425
private final MessageSource messageSource;
26+
private final ContextService contextService;
2527

2628
@Autowired
27-
public BreadcrumbServiceImpl(MessageSource messageSource) {
29+
public BreadcrumbServiceImpl(MessageSource messageSource, ContextService contextService) {
2830
this.messageSource=messageSource;
31+
this.contextService = contextService;
2932
}
3033

3134
@Override
32-
public Breadcrumb getBreadcrumbForShowRootProject(Locale locale) {
35+
public Breadcrumb getBreadcrumbForShowRootProject(Locale locale, UserSessionBean userSession) {
3336
log.debug("getBreadcrumbForShowRootProject");
34-
Breadcrumb breadcrumb = new Breadcrumb(locale);
37+
Optional<Context> context = contextService.getContextFor(userSession);
38+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
3539
breadcrumb.addProjectRoot();
3640
return breadcrumb;
3741
}
3842

3943
@Override
40-
public Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale locale) {
44+
public Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale locale, UserSessionBean userSession) {
4145
log.debug("getBreadcrumbForShowOneProject");
42-
Breadcrumb breadcrumb = new Breadcrumb(locale);
46+
Optional<Context> context = contextService.getContextFor(userSession);
47+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
4348
breadcrumb.addProjectRoot();
4449
if(thisProject == null){
4550
return breadcrumb;
@@ -60,28 +65,31 @@ public Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale loc
6065
}
6166

6267
@Override
63-
public Breadcrumb getBreadcrumbForTaskstate(TaskState taskstate, Locale locale) {
68+
public Breadcrumb getBreadcrumbForTaskstate(TaskState taskstate, Locale locale, UserSessionBean userSession) {
6469
log.debug("getBreadcrumbForTaskstate");
65-
Breadcrumb breadcrumb = new Breadcrumb(locale);
70+
Optional<Context> context = contextService.getContextFor(userSession);
71+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
6672
String code = taskstate.getCode();
6773
String name = messageSource.getMessage(code,null,locale);
6874
breadcrumb.addTaskstate(name,taskstate.getUrl());
6975
return breadcrumb;
7076
}
7177

7278
@Override
73-
public Breadcrumb getBreadcrumbForTaskInTaskstate(String taskstate, Task task, Locale locale) {
79+
public Breadcrumb getBreadcrumbForTaskInTaskstate(String taskstate, Task task, Locale locale, UserSessionBean userSession) {
7480
log.debug("getBreadcrumbForTaskInTaskstate");
75-
Breadcrumb breadcrumb = new Breadcrumb(locale);
81+
Optional<Context> context = contextService.getContextFor(userSession);
82+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
7683
breadcrumb.addTaskstate(taskstate);
7784
breadcrumb.addTask(task);
7885
return breadcrumb;
7986
}
8087

8188
@Override
82-
public Breadcrumb getBreadcrumbForTaskstateAll(Locale locale) {
89+
public Breadcrumb getBreadcrumbForTaskstateAll(Locale locale, UserSessionBean userSession) {
8390
log.debug("getBreadcrumbForTaskstateAll");
84-
Breadcrumb breadcrumb = new Breadcrumb(locale);
91+
Optional<Context> context = contextService.getContextFor(userSession);
92+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
8593
String code="layout.page.all";
8694
String name= messageSource.getMessage(code,null,locale);
8795
String url="/taskstate/all";
@@ -90,18 +98,19 @@ public Breadcrumb getBreadcrumbForTaskstateAll(Locale locale) {
9098
}
9199

92100
@Override
93-
public Breadcrumb getBreadcrumbForTaskInProject(Project thisProject, Task task, Locale locale) {
101+
public Breadcrumb getBreadcrumbForTaskInProject(Project thisProject, Task task, Locale locale, UserSessionBean userSession) {
94102
log.debug("getBreadcrumbForTaskInProject");
95-
Breadcrumb breadcrumb = new Breadcrumb(locale);
103+
Breadcrumb breadcrumb = new Breadcrumb(locale,thisProject.getContext());
96104
breadcrumb.addProject(thisProject);
97105
breadcrumb.addTask(task);
98106
return breadcrumb;
99107
}
100108

101109
@Override
102-
public Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale) {
110+
public Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale, UserSessionBean userSession) {
103111
log.debug("getBreadcrumbForUserProfileAndMenu");
104-
Breadcrumb breadcrumb = new Breadcrumb(locale);
112+
Optional<Context> context = contextService.getContextFor(userSession);
113+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
105114
String code="pages.user.profile";
106115
String name= messageSource.getMessage(code,null,locale);
107116
String url="/user/selfservice/profile";
@@ -110,9 +119,10 @@ public Breadcrumb getBreadcrumbForUserProfileAndMenu(Locale locale) {
110119
}
111120

112121
@Override
113-
public Breadcrumb getBreadcrumbForUserChangeName(Locale locale) {
122+
public Breadcrumb getBreadcrumbForUserChangeName(Locale locale,UserSessionBean userSession) {
114123
log.debug("getBreadcrumbForUserChangeName");
115-
Breadcrumb breadcrumb = new Breadcrumb(locale);
124+
Optional<Context> context = contextService.getContextFor(userSession);
125+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
116126
String code="pages.user.profile";
117127
String name= messageSource.getMessage(code,null,locale);
118128
String url="/user/selfservice/profile";
@@ -125,9 +135,10 @@ public Breadcrumb getBreadcrumbForUserChangeName(Locale locale) {
125135
}
126136

127137
@Override
128-
public Breadcrumb getBreadcrumbForUserChangePassword(Locale locale) {
138+
public Breadcrumb getBreadcrumbForUserChangePassword(Locale locale, UserSessionBean userSession) {
129139
log.debug("getBreadcrumbForUserChangePassword");
130-
Breadcrumb breadcrumb = new Breadcrumb(locale);
140+
Optional<Context> context = contextService.getContextFor(userSession);
141+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
131142
String code="pages.user.profile";
132143
String name= messageSource.getMessage(code,null,locale);
133144
String url="/user/selfservice/profile";
@@ -140,9 +151,10 @@ public Breadcrumb getBreadcrumbForUserChangePassword(Locale locale) {
140151
}
141152

142153
@Override
143-
public Breadcrumb getBreadcrumbForUserContexts(Locale locale) {
154+
public Breadcrumb getBreadcrumbForUserContexts(Locale locale,UserSessionBean userSession) {
144155
log.debug("getBreadcrumbForUserContexts");
145-
Breadcrumb breadcrumb = new Breadcrumb(locale);
156+
Optional<Context> context = contextService.getContextFor(userSession);
157+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
146158
String code="pages.user.profile";
147159
String name= messageSource.getMessage(code,null,locale);
148160
String url="/user/selfservice/profile";
@@ -155,9 +167,10 @@ public Breadcrumb getBreadcrumbForUserContexts(Locale locale) {
155167
}
156168

157169
@Override
158-
public Breadcrumb getBreadcrumbForUserContextAdd(Locale locale) {
170+
public Breadcrumb getBreadcrumbForUserContextAdd(Locale locale,UserSessionBean userSession) {
159171
log.debug("getBreadcrumbForUserContextAdd");
160-
Breadcrumb breadcrumb = new Breadcrumb(locale);
172+
Optional<Context> context = contextService.getContextFor(userSession);
173+
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
161174
String code="pages.user.profile";
162175
String name= messageSource.getMessage(code,null,locale);
163176
String url="/user/selfservice/profile";
@@ -170,9 +183,10 @@ public Breadcrumb getBreadcrumbForUserContextAdd(Locale locale) {
170183
}
171184

172185
@Override
173-
public Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context) {
186+
public Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context, UserSessionBean userSession) {
174187
log.debug("getBreadcrumbForUserContextEdit");
175-
Breadcrumb breadcrumb = new Breadcrumb(locale);
188+
Optional<Context> contextFromSession = contextService.getContextFor(userSession);
189+
Breadcrumb breadcrumb = new Breadcrumb(locale, contextFromSession.get());
176190
String code="pages.user.profile";
177191
String name= messageSource.getMessage(code,null,locale);
178192
String url="/user/selfservice/profile";
@@ -185,9 +199,10 @@ public Breadcrumb getBreadcrumbForUserContextEdit(Locale locale, Context context
185199
}
186200

187201
@Override
188-
public Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context context) {
202+
public Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context context, UserSessionBean userSession) {
189203
log.debug("getBreadcrumbForUserContextDelete");
190-
Breadcrumb breadcrumb = new Breadcrumb(locale);
204+
Optional<Context> contextFromSession = contextService.getContextFor(userSession);
205+
Breadcrumb breadcrumb = new Breadcrumb(locale, contextFromSession.get());
191206
String code="pages.user.profile";
192207
String name= messageSource.getMessage(code,null,locale);
193208
String url="/user/selfservice/profile";
@@ -200,9 +215,10 @@ public Breadcrumb getBreadcrumbForUserContextDelete(Locale locale, Context conte
200215
}
201216

202217
@Override
203-
public Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale) {
218+
public Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale, UserSessionBean userSession) {
204219
log.debug("getBreadcrumbForUserChangeLanguage");
205-
Breadcrumb breadcrumb = new Breadcrumb(locale);
220+
Optional<Context> contextFromSession = contextService.getContextFor(userSession);
221+
Breadcrumb breadcrumb = new Breadcrumb(locale, contextFromSession.get());
206222
String code="pages.user.profile";
207223
String name= messageSource.getMessage(code,null,locale);
208224
String url="/user/selfservice/profile";
@@ -215,9 +231,10 @@ public Breadcrumb getBreadcrumbForUserChangeLanguage(Locale locale) {
215231
}
216232

217233
@Override
218-
public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale locale) {
234+
public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale locale, UserSessionBean userSession) {
219235
log.debug("getBreadcrumbForMessagesBetweenCurrentAndOtherUser");
220-
Breadcrumb breadcrumb = new Breadcrumb(locale);
236+
Optional<Context> contextFromSession = contextService.getContextFor(userSession);
237+
Breadcrumb breadcrumb = new Breadcrumb(locale, contextFromSession.get());
221238
String code="pages.user.profile";
222239
String name= messageSource.getMessage(code,null,locale);
223240
String url="/user/selfservice/profile";
@@ -230,9 +247,10 @@ public Breadcrumb getBreadcrumbForMessagesBetweenCurrentAndOtherUser(Locale loca
230247
}
231248

232249
@Override
233-
public Breadcrumb getBreadcrumbForSearchResults(Locale locale) {
250+
public Breadcrumb getBreadcrumbForSearchResults(Locale locale, UserSessionBean userSession) {
234251
log.debug("getBreadcrumbForSearchResults");
235-
Breadcrumb breadcrumb = new Breadcrumb(locale);
252+
Optional<Context> contextFromSession = contextService.getContextFor(userSession);
253+
Breadcrumb breadcrumb = new Breadcrumb(locale, contextFromSession.get());
236254
String code="pages.user.profile";
237255
String name= messageSource.getMessage(code,null,locale);
238256
String url="/user/selfservice/profile";

src/main/java/org/woehlke/simpleworklist/domain/context/ContextService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.woehlke.simpleworklist.domain.context;
22

33
import org.woehlke.simpleworklist.user.domain.account.UserAccount;
4+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
45

56
import java.util.List;
7+
import java.util.Optional;
68

79
/**
810
* Created by tw on 13.03.16.
@@ -24,4 +26,6 @@ public interface ContextService {
2426
boolean delete(Context context);
2527

2628
boolean contextHasItems(Context context);
29+
30+
Optional<Context> getContextFor(UserSessionBean userSession);
2731
}

src/main/java/org/woehlke/simpleworklist/domain/context/ContextServiceImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
import org.woehlke.simpleworklist.domain.task.TaskRepository;
1010

1111
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.woehlke.simpleworklist.user.session.UserSessionBean;
13+
1214
import java.util.List;
15+
import java.util.Optional;
1316

1417
/**
1518
* Created by tw on 13.03.16.
@@ -79,4 +82,10 @@ public boolean contextHasItems(Context context) {
7982
int numberOfProjects = projectRepository.findByContext(context).size();
8083
return ((numberOfTasks + numberOfProjects) > 0);
8184
}
85+
86+
@Override
87+
public Optional<Context> getContextFor(UserSessionBean userSession) {
88+
Long id = userSession.getLastContextId();
89+
return contextRepository.findById(id);
90+
}
8291
}

0 commit comments

Comments
 (0)