2323import org .woehlke .simpleworklist .user .services .UserAccountAccessService ;
2424import org .woehlke .simpleworklist .user .services .UserAccountLoginSuccessService ;
2525
26+ import javax .validation .constraints .NotNull ;
2627import java .util .ArrayList ;
2728import java .util .List ;
2829import java .util .Locale ;
@@ -76,9 +77,7 @@ public final List<Project> getAllCategories(
7677 //TODO: rename rootCategories to rootProjects
7778 @ ModelAttribute ("rootCategories" )
7879 public final List <Project > getRootCategories (
79- @ ModelAttribute ("userSession" ) UserSessionBean userSession ,
80- BindingResult result , //TODO: remove
81- Model model //TODO: remove
80+ @ ModelAttribute ("userSession" ) UserSessionBean userSession
8281 ) {
8382 Context context = this .getContext (userSession );
8483 return projectService .findRootProjectsByContext (context );
@@ -143,6 +142,20 @@ protected UserAccount getUser() {
143142 return this .userAccountLoginSuccessService .retrieveCurrentUser ();
144143 }
145144
145+ protected Context getContext (@ NotNull final UserSessionBean userSession ){
146+ UserAccount thisUser = this .getUser ();
147+ //if(userSession == null){
148+ // userSession = new UserSessionBean();
149+ //}
150+ long defaultContextId = thisUser .getDefaultContext ().getId ();
151+ //userSession.setLastContextId(defaultContextId);
152+ Context context = contextService .findByIdAndUserAccount (userSession .getLastContextId (), thisUser );
153+ //userSession.setLastContextId(context.getId());
154+ //userSession.setUserAccountid(thisUser.getId());
155+ return context ;
156+ }
157+
158+ /*
146159 protected Context getContext(UserSessionBean userSession){
147160 UserAccount thisUser = this.getUser();
148161 if(userSession == null){
@@ -155,5 +168,6 @@ protected Context getContext(UserSessionBean userSession){
155168 userSession.setUserAccountid(thisUser.getId());
156169 return context;
157170 }
171+ */
158172
159173}
0 commit comments