-
Notifications
You must be signed in to change notification settings - Fork 4
Story/cite 185 - Managed authorities page should be filterable by import source #302
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
base: develop
Are you sure you want to change the base?
Changes from 5 commits
c6fc3d9
d5dd829
607768c
a6f98c8
624b205
b780297
0f875d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,8 @@ public String list(Model model, Authentication authentication, | |
| Page<IAuthorityEntry> authoritiesPage = authorityService.getAll(user, | ||
| userGroups.stream().map(group -> group.getGroupId()).collect(Collectors.toList()),pageInt, authorityPageSize); | ||
| List<IAuthorityEntry> authorities = authoritiesPage.getContent(); | ||
| model.addAttribute("importedAuthoritySources", authorities.stream() | ||
| .map(authorityEntry -> authorityEntry.getImporterId()).distinct().collect(Collectors.toList())); | ||
| model.addAttribute("authorities", authorities); | ||
| model.addAttribute("groups", userGroups); | ||
| model.addAttribute("displayBy", "all"); | ||
|
|
@@ -73,8 +75,12 @@ public String getAuthoritiesForGroup(Model model, Authentication authentication, | |
| pageInt = (pageInt - 1) < 0 ? 0 : pageInt - 1; | ||
| IUser user = (IUser)authentication.getPrincipal(); | ||
| Page<IAuthorityEntry> authoritiesPage = authorityService.getAuthoritiesByGroup(Long.valueOf(zoteroGroupId), pageInt, authorityPageSize); | ||
| model.addAttribute("authorities", authoritiesPage.getContent()); | ||
| model.addAttribute("groups", citationManager.getGroups((IUser)authentication.getPrincipal())); | ||
| List<IAuthorityEntry> authorities = authoritiesPage.getContent(); | ||
|
|
||
| model.addAttribute("importedAuthoritySources", authorities.stream() | ||
| .map(authorityEntry -> authorityEntry.getImporterId()).distinct().collect(Collectors.toList())); | ||
| model.addAttribute("authorities", authorities); | ||
| model.addAttribute("groups", citationManager.getGroups(user)); | ||
| model.addAttribute("displayBy", zoteroGroupId); | ||
| model.addAttribute("username", user.getUsername()); | ||
| model.addAttribute("total", authoritiesPage.getTotalElements()); | ||
|
|
@@ -95,13 +101,46 @@ public String getAuthoritiesForUser(Model model, Authentication authentication, | |
| pageInt = (pageInt - 1) < 0 ? 0 : pageInt - 1; | ||
| IUser user = (IUser)authentication.getPrincipal(); | ||
| Page<IAuthorityEntry> authoritiesPage = authorityService.getUserSpecificAuthorities(user, pageInt, authorityPageSize); | ||
| model.addAttribute("authorities", authoritiesPage.getContent()); | ||
| model.addAttribute("groups", citationManager.getGroups((IUser)authentication.getPrincipal())); | ||
| List<IAuthorityEntry> authorities = authoritiesPage.getContent(); | ||
|
|
||
| model.addAttribute("importedAuthoritySources", authorities.stream() | ||
| .map(authorityEntry -> authorityEntry.getImporterId()).distinct().collect(Collectors.toList())); | ||
| model.addAttribute("authorities", authorities); | ||
| model.addAttribute("groups", citationManager.getGroups(user)); | ||
| model.addAttribute("displayBy", "userSpecific"); | ||
| model.addAttribute("username", user.getUsername()); | ||
| model.addAttribute("total", authoritiesPage.getTotalElements()); | ||
| model.addAttribute("totalPages", authoritiesPage.getTotalPages() > 0 ? authoritiesPage.getTotalPages() : 1); | ||
| model.addAttribute("currentPage", page); | ||
| return "auth/authorities/list"; | ||
| } | ||
|
|
||
| @RequestMapping("/auth/authority/list/{source}") | ||
| public String getAuthoritiesForSource(Model model, Authentication authentication, | ||
| @PathVariable("source") String source, @RequestParam(defaultValue = "1", required = false, value = "page") String page) { | ||
| System.out.println(source); | ||
| Integer pageInt = 1; | ||
| try { | ||
| pageInt = new Integer(page); | ||
| } catch (NumberFormatException ex) { | ||
| logger.error("Trying to access invalid page number: ", ex); | ||
| } | ||
| pageInt = (pageInt - 1) < 0 ? 0 : pageInt - 1; | ||
| IUser user = (IUser) authentication.getPrincipal(); | ||
| List<ICitationGroup> userGroups = citationManager.getGroups(user); | ||
| Page<IAuthorityEntry> authoritiesPage = authorityService.getAll(user, | ||
| userGroups.stream().map(group -> group.getGroupId()).collect(Collectors.toList()),pageInt, authorityPageSize); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see my comment below. This could for example be formatted something like: |
||
| List<IAuthorityEntry> authorities = authoritiesPage.getContent(); | ||
| model.addAttribute("importedAuthoritySources", authorities.stream() | ||
| .map(authorityEntry -> authorityEntry.getImporterId()).distinct().collect(Collectors.toList())); | ||
| model.addAttribute("authorities", | ||
| authorityService.getAuthoritiesBySource(user, source.equals("null") ? null : source)); | ||
| model.addAttribute("groups", userGroups); | ||
| model.addAttribute("displayBy", "source-" + source); | ||
| model.addAttribute("username", user.getUsername()); | ||
| model.addAttribute("total", authoritiesPage.getTotalElements()); | ||
| model.addAttribute("totalPages", authoritiesPage.getTotalPages() > 0 ? authoritiesPage.getTotalPages() : 1); | ||
| model.addAttribute("currentPage", page); | ||
| return "auth/authorities/list"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code should be cleaned up with intentional empty lines to organize blocks and intentional newlines for parameters of long method calls. |
||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove