Skip to content

## 2.3.34 #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ public abstract class AbstractController {
@Autowired
protected BreadcrumbService breadcrumbService;

//TODO: rename allCategories to allProjects
@ModelAttribute("allProjects")
public final List<Project> getAllCategories(
@ModelAttribute("userSession") UserSessionBean userSession,
BindingResult result, //TODO: remove
Model model //TODO: remove
) {
userSession = updateUserSession(userSession);
Context context = this.getContext(userSession);
return projectService.findAllProjectsByContext(context);
}

//TODO: rename rootCategories to rootProjects
@ModelAttribute("rootProjects")
public final List<Project> getRootCategories(
@ModelAttribute("userSession") UserSessionBean userSession
) {
userSession = updateUserSession(userSession);
Context context = this.getContext(userSession);
return projectService.findRootProjectsByContext(context);
}
Expand Down Expand Up @@ -117,11 +117,10 @@ public final List<TaskState> getTaskStates(){
@ModelAttribute("context")
public final String getCurrentContext(
@ModelAttribute("userSession") UserSessionBean userSession,
Locale locale
Locale locale,
Model model
){
if(userSession == null){
userSession = new UserSessionBean();
}
userSession = updateUserSession(userSession);
Context context = getContext(userSession);
if(locale == null){
locale = Locale.ENGLISH;
Expand Down Expand Up @@ -154,6 +153,26 @@ protected Context getContext(@NotNull final UserSessionBean userSession){
return context;
}

protected UserSessionBean getNewUserSession(){
UserAccount thisUser = this.getUser();
long userAccountid = thisUser.getId();
long contextId = thisUser.getDefaultContext().getId();
UserSessionBean userSession = new UserSessionBean(userAccountid,contextId);
return userSession;
}

protected UserSessionBean updateUserSession(UserSessionBean userSession){
if(userSession == null){
userSession = getNewUserSession();
} else {
UserAccount thisUser = this.getUser();
long contextId = thisUser.getDefaultContext().getId();
long userAccountid = thisUser.getId();
userSession.update(userAccountid,contextId);
}
return userSession;
}

/*
protected Context getContext(UserSessionBean userSession){
UserAccount thisUser = this.getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ public Breadcrumb getBreadcrumbForShowOneProject(Project thisProject, Locale loc
}

@Override
public Breadcrumb getBreadcrumbForTaskstate(TaskState taskstate, Locale locale, UserSessionBean userSession) {
public Breadcrumb getBreadcrumbForTaskstate(
TaskState taskstate,
Locale locale,
UserSessionBean userSession
) {
log.debug("getBreadcrumbForTaskstate");
Optional<Context> context = contextService.getContextFor(userSession);
Breadcrumb breadcrumb = new Breadcrumb(locale, context.get());
Optional<Context> contextResult = contextService.getContextFor(userSession);
Context context;
if(contextResult.isEmpty()){
context = null;
} else {
context = contextResult.get();
}
Breadcrumb breadcrumb = new Breadcrumb(locale, context);
String code = taskstate.getCode();
String name = messageSource.getMessage(code,null,locale);
breadcrumb.addTaskstate(name,taskstate.getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ public class UserSessionBean implements Serializable {
private String lastSearchterm; //TODO: Make SearchRequest to Entity

public UserSessionBean(){
lastSearchterm=""; //TODO: Make SearchRequest to Entity
lastTaskState=TaskState.INBOX;
lastProjectId=0L;
lastContextId=0L;
lastTaskId=0L;
userAccountid=0L;
this.lastSearchterm=""; //TODO: Make SearchRequest to Entity
this.lastTaskState=TaskState.INBOX;
this.lastProjectId=0L;
this.lastContextId=0L;
this.lastTaskId=0L;
this.userAccountid=0L;
}

public UserSessionBean(long userAccountid, long lastContextId){
this.lastSearchterm=""; //TODO: Make SearchRequest to Entity
this.lastTaskState=TaskState.INBOX;
this.lastProjectId=0L;
this.lastTaskId=0L;
this.userAccountid=userAccountid;
this.lastContextId=lastContextId;
}

@Deprecated
Expand All @@ -45,4 +54,10 @@ public UserSessionBean(long contextId){
userAccountid=0L;
}

public void update(long userAccountid, long contextId) {
this.userAccountid=userAccountid;
if(this.lastContextId == 0L ){
this.lastContextId=contextId;
}
}
}