diff --git a/citesphere/src/main/java/edu/asu/diging/citesphere/web/user/authorities/AuthorityItemsController.java b/citesphere/src/main/java/edu/asu/diging/citesphere/web/user/authorities/AuthorityItemsController.java index e9c58b0fc..7e3ff00e8 100644 --- a/citesphere/src/main/java/edu/asu/diging/citesphere/web/user/authorities/AuthorityItemsController.java +++ b/citesphere/src/main/java/edu/asu/diging/citesphere/web/user/authorities/AuthorityItemsController.java @@ -1,7 +1,8 @@ package edu.asu.diging.citesphere.web.user.authorities; -import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,8 +15,12 @@ import edu.asu.diging.citesphere.core.service.IAuthorityService; import edu.asu.diging.citesphere.core.service.ICitationManager; +import edu.asu.diging.citesphere.core.service.IGroupManager; +import edu.asu.diging.citesphere.core.service.ICitationCollectionManager; import edu.asu.diging.citesphere.model.authority.IAuthorityEntry; import edu.asu.diging.citesphere.model.bib.ICitation; +import edu.asu.diging.citesphere.model.bib.ICitationGroup; +import edu.asu.diging.citesphere.model.bib.ICitationCollection; import edu.asu.diging.citesphere.model.transfer.impl.Citations; import edu.asu.diging.citesphere.user.IUser; @@ -29,6 +34,12 @@ public class AuthorityItemsController { @Autowired private ICitationManager citationManager; + + @Autowired + private IGroupManager groupManager; + + @Autowired + private ICitationCollectionManager collectionManager; @RequestMapping("/auth/authority/items") @@ -45,6 +56,41 @@ public String showPage(Model model, @RequestParam("uri") String uri, Citations citations = citationManager.findAuthorityCitations(authorityEntries.get(0), (IUser) authentication.getPrincipal()); if (citations != null) { model.addAttribute("items", citations.getCitations()); + + // Create maps to store group and collection information for each citation + Map groupNames = new HashMap<>(); + Map collectionNames = new HashMap<>(); + + // Add group and collection information for each citation + for (ICitation citation : citations.getCitations()) { + String citationKey = citation.getKey(); + + // Get group name + ICitationGroup group = groupManager.getGroup((IUser) authentication.getPrincipal(), citation.getGroup()); + if (group != null) { + groupNames.put(citationKey, group.getName()); + } + + // Get collection names if any + if (citation.getCollections() != null && !citation.getCollections().isEmpty()) { + StringBuilder collectionNamesStr = new StringBuilder(); + for (String collectionId : citation.getCollections()) { + ICitationCollection collection = collectionManager.getCollection((IUser) authentication.getPrincipal(), citation.getGroup(), collectionId); + if (collection != null) { + if (collectionNamesStr.length() > 0) { + collectionNamesStr.append(", "); + } + collectionNamesStr.append(collection.getName()); + } + } + if (collectionNamesStr.length() > 0) { + collectionNames.put(citationKey, collectionNamesStr.toString()); + } + } + } + + model.addAttribute("groupNames", groupNames); + model.addAttribute("collectionNames", collectionNames); } else { model.addAttribute("error", "This authority is not used for any citations."); } diff --git a/citesphere/src/main/webapp/WEB-INF/views/auth/authorities/showItemsByName.html b/citesphere/src/main/webapp/WEB-INF/views/auth/authorities/showItemsByName.html index c8fe9e3c5..b7545f29f 100644 --- a/citesphere/src/main/webapp/WEB-INF/views/auth/authorities/showItemsByName.html +++ b/citesphere/src/main/webapp/WEB-INF/views/auth/authorities/showItemsByName.html @@ -28,6 +28,8 @@

[[${authName}]]

Authors Title Date + Group + Collection URL Files @@ -93,6 +95,8 @@

[[${authName}]]

th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}|}"> [[${entry.dateFreetext}]] + [[${groupNames[entry.key]}]] + [[${collectionNames[entry.key]}]]