Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
521d6ac1
Commit
521d6ac1
authored
Oct 18, 2017
by
Matija Obreza
Browse files
Display audited changes to accession data
- New taglibs: taxonName, country, display, auditlog-changes
parent
d6dda6db
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/AccessionController.java
View file @
521d6ac1
...
...
@@ -25,12 +25,17 @@ import java.util.UUID;
import
javax.servlet.http.HttpServletResponse
;
import
org.genesys.blocks.auditlog.service.AuditTrailService
;
import
org.genesys.blocks.security.SecurityContextUtil
;
import
org.genesys.filerepository.InvalidRepositoryPathException
;
import
org.genesys.filerepository.model.ImageGallery
;
import
org.genesys.filerepository.service.ImageGalleryService
;
import
org.genesys2.server.model.dataset.DS
;
import
org.genesys2.server.model.elastic.AccessionDetails
;
import
org.genesys2.server.model.genesys.Accession
;
import
org.genesys2.server.model.genesys.AccessionBreeding
;
import
org.genesys2.server.model.genesys.AccessionCollect
;
import
org.genesys2.server.model.genesys.AccessionExchange
;
import
org.genesys2.server.model.genesys.AccessionGeo
;
import
org.genesys2.server.model.genesys.PDCI
;
import
org.genesys2.server.model.genesys.Taxonomy2
;
...
...
@@ -52,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
...
@@ -98,6 +104,9 @@ public class AccessionController extends BaseController {
@Autowired
private
DownloadService
downloadService
;
@Autowired
private
AuditTrailService
auditService
;
@Value
(
"${base.url}"
)
private
String
baseUrl
;
...
...
@@ -138,13 +147,31 @@ public class AccessionController extends BaseController {
*/
public
ModelAndView
displayAccession
(
ModelMap
model
,
Accession
accession
)
{
model
.
addAttribute
(
"accession"
,
accession
);
model
.
addAttribute
(
"auditAccession"
,
auditService
.
auditLogs
(
accession
));
model
.
addAttribute
(
"accessionNames"
,
genesysService
.
listAccessionNames
(
accession
.
getAccessionId
()));
model
.
addAttribute
(
"accessionAliases"
,
genesysService
.
listAccessionAliases
(
accession
.
getAccessionId
()));
model
.
addAttribute
(
"accessionExchange"
,
genesysService
.
listAccessionExchange
(
accession
.
getAccessionId
()));
model
.
addAttribute
(
"accessionCollect"
,
genesysService
.
listAccessionCollect
(
accession
.
getAccessionId
()));
model
.
addAttribute
(
"accessionBreeding"
,
genesysService
.
listAccessionBreeding
(
accession
.
getAccessionId
()));
AccessionGeo
accessionGeo
=
genesysService
.
listAccessionGeo
(
accession
.
getAccessionId
());
AccessionExchange
accessionExchange
=
genesysService
.
getAccessionExchange
(
accession
.
getAccessionId
());
model
.
addAttribute
(
"accessionExchange"
,
accessionExchange
);
AccessionCollect
accessionCollect
=
genesysService
.
getAccessionCollect
(
accession
.
getAccessionId
());
model
.
addAttribute
(
"accessionCollect"
,
accessionCollect
);
AccessionBreeding
accessionBreeding
=
genesysService
.
getAccessionBreeding
(
accession
.
getAccessionId
());
model
.
addAttribute
(
"accessionBreeding"
,
accessionBreeding
);
AccessionGeo
accessionGeo
=
genesysService
.
getAccessionGeo
(
accession
.
getAccessionId
());
model
.
addAttribute
(
"accessionGeo"
,
accessionGeo
);
if
(
SecurityContextHolder
.
getContext
().
getAuthentication
().
isAuthenticated
())
{
// only for authenticated users
model
.
addAttribute
(
"auditAccessionExchange"
,
auditService
.
auditLogs
(
accessionExchange
));
model
.
addAttribute
(
"auditAccessionCollect"
,
auditService
.
auditLogs
(
accessionCollect
));
model
.
addAttribute
(
"auditAccessionBreeding"
,
auditService
.
auditLogs
(
accessionBreeding
));
model
.
addAttribute
(
"auditAccessionGeo"
,
auditService
.
auditLogs
(
accessionGeo
));
}
model
.
addAttribute
(
"svalbardDeposits"
,
genesysService
.
getSvalbardData
(
accession
.
getAccessionId
()));
model
.
addAttribute
(
"accessionRemarks"
,
genesysService
.
listAccessionRemarks
(
accession
.
getAccessionId
()));
...
...
src/main/resources/content/language.properties
View file @
521d6ac1
...
...
@@ -886,3 +886,5 @@ geo.country=Country:
article.is.template
=
Is template:
article.template.false
=
Article is not a template.
article.template.true
=
This is a template.
auditLog.no-value
=
No value
src/main/sourceapp/1/styles/genesys.scss
View file @
521d6ac1
...
...
@@ -6539,3 +6539,17 @@ table.accessions {
.margin-top-20
{
margin-top
:
20px
;
}
.margin-top-25
{
margin-top
:
25px
;
}
.margin-top-30
{
margin-top
:
30px
;
}
.auditlog-entries
{
opacity
:
.5
;
}
.change-arrow
{
// [dir="ltr"]
&
::before
{
content
:
'\2192'
//
&
rarr
;
}
// [dir="rtl"] &::before {
// content: '\2190' // ←
// }
}
src/main/webapp/WEB-INF/jsp/accession/details.jsp
View file @
521d6ac1
This diff is collapsed.
Click to expand it.
src/main/webapp/WEB-INF/jsp/accession/explore2.jsp
View file @
521d6ac1
...
...
@@ -191,7 +191,7 @@
<td
class=
"notimportant
<c:if
test=
'
${
i
.
count
ge
2
}
'
>
hidden-xs
</c:if>
<c:if
test=
'
${
i
.
count
gt
2
}
'
>
hidden-sm
</c:if>
"
>
<p>
<c:if
test=
"
${
accession
.
doi
ne
null
}
"
>
<a
href=
"
<c:url
value=
"
${
baseUrl
}
/${accession.doi}"
/>
"
><c:out
value=
"
${
accession
.
doi
}
"
/></a>
<a
href=
"
<c:url
value=
"/${accession.doi}"
/>
"
><c:out
value=
"
${
accession
.
doi
}
"
/></a>
</c:if>
</p>
</td>
...
...
@@ -1129,5 +1129,3 @@
</content>
</body>
</html>
\ No newline at end of file
src/main/webapp/WEB-INF/tags/auditlog-changes.tag
0 → 100644
View file @
521d6ac1
<%@ tag description="Displays audit log for a single property" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="local" tagdir="/WEB-INF/tags" %>
<%@ attribute name="auditLogs" required="true" type="java.util.List" %>
<%@ attribute name="property" required="false" type="java.lang.String" %>
<%@ attribute name="i18n" required="false" type="java.lang.String" %>
<%-- <p>
<small>
Logs=${auditLogs}
</small>
</p> --%>
<security:authorize access="isAuthenticated()">
<c:if test="${auditLogs.size() gt 0}">
<div class="auditlog-entries">
<c:forEach items="${auditLogs}" var="auditLog">
<p>
<span dir="ltr">
<c:if test="${auditLog.referencedEntity == null}">
<local:display value="${auditLog.previousState}" i18n="${i18n}" />
<span class="change-arrow"></span>
<local:display value="${auditLog.newState}" i18n="${i18n}" />
</c:if>
<c:if test="${auditLog.referencedEntity != null}">
<local:display value="${auditLog.previousEntity}" property="${property}" i18n="${i18n}" />
<span class="change-arrow"></span>
<local:display value="${auditLog.newEntity}" property="${property}" i18n="${i18n}" />
</c:if>
</span>
<span class="pull-right">
<local:prettyTime date="${auditLog.logDate}" locale="${pageContext.response.locale}" />
</span>
</p>
</c:forEach>
</div>
</c:if>
</security:authorize>
src/main/webapp/WEB-INF/tags/country.tag
0 → 100644
View file @
521d6ac1
<%@ tag description="Pretty print taxon name" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="country" required="true" type="org.genesys2.server.model.impl.Country" %>
<%@ attribute name="flag" required="false" type="java.lang.Boolean" %>
<c:if test="${country ne null}">
<c:if test="${! flag}">
<a href="<c:url value="/geo/${country.code3}" />"><c:out value="${country.getName(pageContext.response.locale)}" /></a>
</c:if>
<c:if test="${flag}">
<img class="flag" src="<c:url value="${cdnFlagsUrl}" />/${country.code3.toUpperCase()}.svg" />
<a href="<c:url value="/geo/${country.code3}" />">
<c:out value="${country.getName(pageContext.response.locale)}" />
</a>
</c:if>
</c:if>
src/main/webapp/WEB-INF/tags/display.tag
0 → 100644
View file @
521d6ac1
<%@ tag description="Displays stuff" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="local" tagdir="/WEB-INF/tags" %>
<%@ attribute name="value" required="true" type="java.lang.Object" %>
<%@ attribute name="property" required="false" type="java.lang.String" %>
<%@ attribute name="i18n" required="false" type="java.lang.String" %>
<c:if test="${value eq null}">
<code><spring:message code="auditLog.no-value" /></code>
</c:if>
<c:if test="${value ne null}">
<c:if test="${property eq '' or property eq null}">
<c:set var="clazz" value="${value.getClass().name}" />
<%-- No prop --%>
<c:choose>
<c:when test="${clazz == 'org.genesys2.server.model.genesys.Taxonomy2'}">
<local:taxonName taxon="${value}" />
</c:when>
<c:when test="${clazz == 'org.genesys2.server.model.impl.Country'}">
<local:country country="${value}" />
</c:when>
<c:otherwise>
<c:if test="${i18n eq '' or i18n eq null}">
<c:out value="${value}" />
</c:if>
<c:if test="${i18n ne ''}">
<spring:message code="${i18n.concat('.').concat(value)}" />
</c:if>
</c:otherwise>
</c:choose>
</c:if>
<c:if test="${property ne '' and property ne null}">
<%-- Prop='${property}' --%>
<c:if test="${i18n eq '' or i18n eq null}">
<c:out value="${value[property]}" />
</c:if>
<c:if test="${i18n ne '' and i18n ne null}">
<%-- i18n=${i18n}.${value[property]} --%>
<spring:message code="${i18n}.${value[property]}" />
</c:if>
</c:if>
</c:if>
src/main/webapp/WEB-INF/tags/taxonName.tag
0 → 100644
View file @
521d6ac1
<%@ tag description="Pretty print taxon name" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="taxon" required="true" type="org.genesys2.server.model.genesys.Taxonomy2" %>
<span dir="ltr" class="sci-name">
<c:out escapeXml="false" value="${taxon.taxonNameHtml}" />
</span>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment