Skip to content
Open
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
@@ -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;
Expand All @@ -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;

Expand All @@ -29,6 +34,12 @@ public class AuthorityItemsController {

@Autowired
private ICitationManager citationManager;

@Autowired
private IGroupManager groupManager;

@Autowired
private ICitationCollectionManager collectionManager;


@RequestMapping("/auth/authority/items")
Expand All @@ -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<String, String> groupNames = new HashMap<>();
Map<String, String> 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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ <h2 >[[${authName}]]</h2>
<th>Authors</th>
<th>Title</th>
<th>Date</th>
<th>Group</th>
<th>Collection</th>
<th>URL</th>
<th>Files</th>
</tr>
Expand Down Expand Up @@ -93,6 +95,8 @@ <h2 >[[${authName}]]</h2>
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}|}">
[[${entry.dateFreetext}]] </a>
</td>
<td>[[${groupNames[entry.key]}]]</td>
<td>[[${collectionNames[entry.key]}]]</td>
<td><span th:if="${!#strings.isEmpty(entry.url)}"> <a
href="${entry.url}" target="_blank" th:title="${entry.url} "><i
class="icon-www"></i></a>
Expand Down