Skip to content
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

Story/cite 172 - From the managed authority page, there should be a link that lists all citations that reference that authority #272

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7d03861
[CITE-172] list all citations that reference that authority
Mar 22, 2022
cfc4a0a
[CITE-172] list all citations that reference that authority
Mar 24, 2022
fb6356c
[CITE-172] list all citations that reference that authority
Mar 25, 2022
ada2f8e
Delete ListAuthoritiesByName.java
TrilekhaMylavarapu Mar 25, 2022
d23444d
[CITE-172] list all citations that reference that authority
Mar 25, 2022
e3d42cb
[CITE-172] list all citations that reference that authority
Mar 25, 2022
24265ef
[CITE-172] list all citations that reference that authority
Mar 29, 2022
344ec06
[CITE-172] list all citations that reference that authority
Mar 29, 2022
0254edc
[CITE-172] list all citations that reference that authority
Mar 31, 2022
157a217
[CITE-172] list all citations that reference that authority
Mar 31, 2022
64c1045
[CITE-172] list all citation for given authority
Apr 19, 2022
48f5262
[CITE-172] list all citation for given authority
Apr 19, 2022
0098c03
[CITE-172] list all citations that reference that authority
May 10, 2022
6df134d
Fixed the bugs found
Jun 14, 2022
0f32ec1
Fixed null pointer issue
Jun 16, 2022
306a1cd
fixing code refactor issues
Jun 20, 2022
46b1928
Update AuthorityItemsController.java
TrilekhaMylavarapu Jun 20, 2022
c514475
Update AuthorityItemsController.java
TrilekhaMylavarapu Jun 20, 2022
5d42efe
Fixing code identation issues
Jun 20, 2022
bbb0210
[CITE-172] Created AuthorityItemsService and moved code from controll…
PradnyaC11 Jun 17, 2024
f54059f
[CITE-172] Added logging to AuthorityItemsController
PradnyaC11 Jun 18, 2024
634fc9c
Merge branch 'develop' into story/CITE-172
PradnyaC11 Jun 18, 2024
7c2eb19
[CITE-172] Resolving error in list.html
PradnyaC11 Jun 18, 2024
9edb72b
[CITE-172] Addressed PR comments
PradnyaC11 Sep 24, 2024
f433b08
Merge branch 'develop' into story/CITE-172
PradnyaC11 Oct 28, 2024
aea3426
[CITE-172] Addressed PR comments
PradnyaC11 Dec 6, 2024
8f675cd
[CITE-172] Addressed PR comments
PradnyaC11 Dec 9, 2024
aa657dc
[CITE-172] Resolved code factor issues
PradnyaC11 Dec 9, 2024
eb898b7
[CITE-172] Addressed PR comments
PradnyaC11 Jan 9, 2025
40d2942
[CITE-172] Addressed PR comments
PradnyaC11 Jan 10, 2025
8c2aa6d
[CITE-172] Updated citesphere-model version
PradnyaC11 Jan 10, 2025
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
16 changes: 8 additions & 8 deletions citesphere/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<spring.kafka.version>2.2.6.RELEASE</spring.kafka.version>
<spring-social-zotero.version>0.12</spring-social-zotero.version>
<citesphere.messages.version>0.4</citesphere.messages.version>
<citesphere.model.version>1.19</citesphere.model.version>
<citesphere.model.version>1.23</citesphere.model.version>

<admin.password>$2a$04$oQo44vqcDIFRoYKiAXoNheurzkwX9dcNmowvTX/hsWuBMwijqn44i</admin.password>

Expand Down Expand Up @@ -377,7 +377,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
<version>8.0.33</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -410,27 +410,27 @@
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-template</artifactId>
<version>3.0.1</version>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>3.0.1</version>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>3.0.1</version>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-servlet</artifactId>
<version>3.0.1</version>
<version>3.0.8</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>3.0.1</version>
<version>3.0.8</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -563,7 +563,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.14.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
import edu.asu.diging.citesphere.core.exceptions.ZoteroHttpStatusException;
import edu.asu.diging.citesphere.core.exceptions.ZoteroItemCreationFailedException;
import edu.asu.diging.citesphere.core.service.impl.CitationPage;
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.ItemType;
import edu.asu.diging.citesphere.model.bib.impl.BibField;
import edu.asu.diging.citesphere.model.bib.impl.CitationResults;
import edu.asu.diging.citesphere.model.transfer.impl.Citations;
import edu.asu.diging.citesphere.user.IUser;

public interface ICitationManager {
Expand Down Expand Up @@ -86,6 +88,8 @@ CloseableIterator<ICitation> getAllGroupItems(IUser user, String groupId, String

void deleteLocalGroupCitations(String groupId);

Citations findAuthorityCitations(IAuthorityEntry entry, IUser user);

ICitation addCitationToReferences(IUser user, ICitation citation, String zoteroGroupId, String referenceCitationKey,
String reference) throws SelfCitationException, ZoteroConnectionException, CitationIsOutdatedException,
ZoteroHttpStatusException, ZoteroItemCreationFailedException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.function.BiFunction;
import java.util.stream.Collectors;

import javax.annotation.PostConstruct;
import javax.transaction.Transactional;

import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
Expand Down Expand Up @@ -41,6 +43,7 @@
import edu.asu.diging.citesphere.core.zotero.IZoteroManager;
import edu.asu.diging.citesphere.data.bib.CitationGroupRepository;
import edu.asu.diging.citesphere.data.bib.ICitationDao;
import edu.asu.diging.citesphere.model.authority.IAuthorityEntry;
import edu.asu.diging.citesphere.model.bib.ICitation;
import edu.asu.diging.citesphere.model.bib.ICitationCollection;
import edu.asu.diging.citesphere.model.bib.ICitationGroup;
Expand All @@ -49,6 +52,7 @@
import edu.asu.diging.citesphere.model.bib.impl.BibField;
import edu.asu.diging.citesphere.model.bib.impl.CitationGroup;
import edu.asu.diging.citesphere.model.bib.impl.CitationResults;
import edu.asu.diging.citesphere.model.transfer.impl.Citations;
import edu.asu.diging.citesphere.model.bib.impl.Reference;
import edu.asu.diging.citesphere.user.IUser;

Expand Down Expand Up @@ -506,6 +510,23 @@ public CitationPage getPrevAndNextCitation(IUser user, String groupId, String co
public void deleteLocalGroupCitations(String groupId) {
citationStore.deleteCitationByGroupId(groupId);
}

@Override
public Citations findAuthorityCitations(IAuthorityEntry entry, IUser user) {
List<ICitationGroup> groups = getGroups(user);

if (groups == null || groups.isEmpty()) {
return null;
}

Set<String> groupIds = groups.stream()
.map(group -> group.getKey().toString())
.collect(Collectors.toSet());

Citations citations = citationDao.findCitationsByPersonUri(entry.getUri(), groupIds);

return citations;
}

@Override
public ICitation addCitationToReferences(IUser user, ICitation citation, String zoteroGroupId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package edu.asu.diging.citesphere.web.user.authorities;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import edu.asu.diging.citesphere.core.service.IAuthorityService;
import edu.asu.diging.citesphere.core.service.ICitationManager;
import edu.asu.diging.citesphere.model.authority.IAuthorityEntry;
import edu.asu.diging.citesphere.model.bib.ICitation;
import edu.asu.diging.citesphere.model.transfer.impl.Citations;
import edu.asu.diging.citesphere.user.IUser;

@Controller
public class AuthorityItemsController {

private final Logger logger = LoggerFactory.getLogger(getClass());

@Autowired
private IAuthorityService authorityService;

@Autowired
private ICitationManager citationManager;


@RequestMapping("/auth/authority/items")
public String showPage(Model model, @RequestParam("uri") String uri, Authentication authentication) {
List<IAuthorityEntry> authorityEntries = authorityService.findByUri((IUser) authentication.getPrincipal(), uri);

if(authorityEntries == null || authorityEntries.isEmpty()) {
model.addAttribute("error", "No entry found for URI: " + uri);
} else if (authorityEntries.size() > 1) {
logger.error("Found multiple entries for URI: " + uri);
model.addAttribute("error", "Found multiple entries for URI: " + uri);
} else {
Citations citations = citationManager.findAuthorityCitations(authorityEntries.get(0), (IUser) authentication.getPrincipal());
if (citations != null) {
model.addAttribute("items", citations.getCitations());
} else {
model.addAttribute("items", new ArrayList<ICitation>());
}
}
return "auth/authorities/showItemsByName";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<html layout:decorate="~{layouts/main}">
<head></head>
<body>
<div layout:fragment="content">
<ol class="breadcrumb">
<li><a th:href="@{/}">Home</a></li>
<li><a th:href="@{/auth/authority/list}">Managed Authority Entries</a></li>
</ol>
<div id="wrapper">
<div class="col-md-10" id="citationBlock">

<table class="table table-striped table-bordered">
<tr>
<th>Title</th>
</tr>
<tr th:id="'tr-'+${entry.key}" data-action='draggable' class="items" th:each="entry,loop : ${items}">
<td th:data-key="${entry.key}" th:data-index="${loop.index}">
<a class="bib-entry" th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}|}">
<em style="color: black">[[${entry.title}]]</em>
</a>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h2>Managed Authority Entries</h2>
<td><span th:with="importerId=${#strings.toLowerCase(authority.importerId)}"
th:text="${@environment.getProperty('_importer_name_' + importerId)}"></span>
</td>
<td><span th:text="${authority.name}"/></td>
<td><a th:href="@{|/auth/authority/items?uri=${#uris.escapePath(authority.uri)}|}"><span th:text="${authority.name}"/></td>
<td><span class="date" th:text="${authority.createdOn}"/></td>
<td>
<span th:if="${#lists.isEmpty(authority.groups)}"> - </span>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<html layout:decorate="~{layouts/main}">

<head>
<script src="https://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
</head>

<body>
<div layout:fragment="content">
<div class="col-md-10" id="citationBlock">
<table class="table table-striped table-bordered">
<tr>
<th>Type</th>
<th>Authors</th>
<th>Title</th>
<th>Date</th>
<th>URL</th>
<th>Files</th>
</tr>
<tr th:id="'tr-'+${entry.key}" data-action='draggable' class="items"
th:each="entry,loop : ${items}">
<td><span class="text-warning">
<div
th:with="iconClass=${@iconsResource.getProperty(entry.itemType + '_icon')}
, iconLabel=${@iconsResource.getProperty(entry.itemType + '_label')}">
<i
th:classappend="${!#strings.isEmpty(iconClass)} ? ${iconClass} : 'icon-docs'"></i>
[[${iconLabel} ?: ${entry.itemType}]]
</div>
</span></td>
<td th:data-key="${entry.key}" th:data-index="${loop.index}">
<a class="bib-entry" th:if="${!#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&collectionId=${collectionId}&page=${currentPage}&sortBy=${sort}|}">
<th:block th:each="author,status : ${entry.authors}">
<strong style="color: black">[[${author.lastName}]]<span
style="color: black"
th:if="${!#strings.isEmpty(author.firstName)}">,
[[${author.firstName}]]</span></strong>
<span th:if="${!status.last}">; </span>
</th:block>
</a> <a class="bib-entry" th:if="${!#strings.isEmpty(searchTerm)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?searchTerm=${searchTerm}&index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
<th:block th:each="author,status : ${entry.authors}">
<strong style="color: black">[[${author.lastName}]]<span
style="color: black"
th:if="${!#strings.isEmpty(author.firstName)}">,
[[${author.firstName}]]</span></strong>
<span th:if="${!status.last}">; </span>
</th:block>
</a> <a class="bib-entry"
th:unless="${!#strings.isEmpty(searchTerm) or !#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
<th:block th:each="author,status : ${entry.authors}">
<strong style="color: black">[[${author.lastName}]]<span
style="color: black"
th:if="${!#strings.isEmpty(author.firstName)}">,
[[${author.firstName}]]</span></strong>
<span th:if="${!status.last}">; </span>
</th:block>
</a>
</td>

<td th:data-key="${entry.key}" th:data-index="${loop.index}">
<a class="bib-entry"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}|}">
<em style="color: black">[[${entry.title}]]</em>
</a>
</td>
<td th:data-key="${entry.key}" th:data-index="${loop.index}">
<a class="bib-entry" style="color: black"
th:if="${!#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&collectionId=${collectionId}&page=${currentPage}&sortBy=${sort}|}">
[[${entry.dateFreetext}]] </a> <a class="bib-entry"
style="color: black" th:if="${!#strings.isEmpty(searchTerm)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?searchTerm=${searchTerm}&index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
[[${entry.dateFreetext}]] </a> <a class="bib-entry"
style="color: black"
th:unless="${!#strings.isEmpty(searchTerm) or !#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
[[${entry.dateFreetext}]] </a>
</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>
</span></td>
<td><span th:if="${!#sets.isEmpty(entry.gilesUploads)}">
<a class="bib-entry" th:if="${!#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&collectionId=${collectionId}&page=${currentPage}&sortBy=${sort}|}">
<i class="icon-multiple-doc"></i>
</a> <a class="bib-entry" th:if="${!#strings.isEmpty(searchTerm)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?searchTerm=${searchTerm}&index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
<i class="icon-multiple-doc"></i>
</a> <a class="bib-entry"
th:unless="${!#strings.isEmpty(searchTerm) or !#strings.isEmpty(collectionId)}"
th:href="@{|/auth/group/${entry.group}/items/${entry.key}?index=${loop.index}&page=${currentPage}&sortBy=${sort}|}">
<i class="icon-multiple-doc"></i>
</a>
</span></td>
</tr>
</table>
</div>
</div>
</body>

</html>
Loading