Commit 521d6ac1 authored by Matija Obreza's avatar Matija Obreza

Display audited changes to accession data

- New taglibs: taxonName, country, display, auditlog-changes
parent d6dda6db
......@@ -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()));
......
......@@ -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
......@@ -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' // →
}
// [dir="rtl"] &::before {
// content: '\2190' // ←
// }
}
......@@ -3,45 +3,46 @@
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<html>
<head>
<title><spring:message code="accession.page.profile.title" arguments="${accession.accessionName}"
argumentSeparator="|"
/></title>
<local:content-headers description="${jspHelper.htmlToText(blurp.summary, 150)}" title="${accession.accessionName} | ${accession.instituteCode}" keywords="${accession.accessionName}" />
</head>
<body class="accession-page" typeof="germplasm:GermplasmAccession">
<h1 class="green-bg">
<span property="dwc:catalogNumber">
<c:out value="${accession.accessionName}" />
</span>
<small property="dwc:institutionCode" datatype="germplasmType:wiewsInstituteID"><c:out value="${accession.instituteCode}" /></small>
</h1>
<head>
<title><spring:message code="accession.page.profile.title" arguments="${accession.accessionName}" argumentSeparator="|"/></title>
<local:content-headers description="${jspHelper.htmlToText(blurp.summary, 150)}" title="${accession.accessionName} | ${accession.instituteCode}" keywords="${accession.accessionName}"/>
</head>
<body class="accession-page" typeof="germplasm:GermplasmAccession">
<h1 class="green-bg">
<span property="dwc:catalogNumber">
<c:out value="${accession.accessionName}"/>
</span>
<small property="dwc:institutionCode" datatype="germplasmType:wiewsInstituteID"><c:out value="${accession.instituteCode}"/></small>
</h1>
<div class="row main-col-header acn">
<div class="sel" x-aid="${accession.id}">
<a class="add" href=""><spring:message code="selection.add" arguments="${accession.accessionName}" /></a>
<a class="remove" href=""><spring:message code="selection.remove" arguments="${accession.accessionName}" /></a>
</div>
</div>
<div class="row main-col-header acn">
<div class="sel" x-aid="${accession.id}">
<a class="add" href=""><spring:message code="selection.add" arguments="${accession.accessionName}"/></a>
<a class="remove" href=""><spring:message code="selection.remove" arguments="${accession.accessionName}"/></a>
</div>
</div>
<gui:alert type="warning" display="${accession.historic eq true or accession.getClass().simpleName eq 'AccessionHistoric'}">
<spring:message code="accession.this-is-a-historic-entry"/>
</gui:alert>
<gui:alert type="warning" display="${accession.historic eq true or accession.getClass().simpleName eq 'AccessionHistoric'}">
<spring:message code="accession.this-is-a-historic-entry" />
</gui:alert>
<gui:alert type="info" display="${accession.inTrust eq true}">
<spring:message code="accession.inTrust.true"/>
</gui:alert>
<gui:alert type="info" display="${accession.inTrust eq true}">
<spring:message code="accession.inTrust.true" />
</gui:alert>
<gui:alert type="info" display="${accession.inSvalbard eq true}">
<spring:message code="accession.inSvalbard.true"/>
</gui:alert>
<gui:alert type="info" display="${accession.inSvalbard eq true}">
<spring:message code="accession.inSvalbard.true" />
</gui:alert>
<gui:alert type="info" display="${accession.mlsStatus eq true}">
<spring:message code="accession.mlsStatus.true"/>
</gui:alert>
<gui:alert type="info" display="${accession.mlsStatus eq true}">
<spring:message code="accession.mlsStatus.true" />
</gui:alert>
<%-- <p>
${auditAccession}
</p> --%>
<%--
<%--
<gui:alert type="warning" display="${accession.availability eq false}">
<spring:message code="accession.not-available-for-distribution" />
</gui:alert>
......@@ -50,587 +51,613 @@
</gui:alert>
--%>
<!--basic info section-->
<div class="crop-details">
<div class="collect-info basic-info">
<h4 class="section-heading">
<spring:message code="accession.page.profile.title" arguments="${accession.accessionName}" argumentSeparator="|" /></h4>
<div class="section-inner-content">
<c:if test="${accession.doi ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.doi" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p property="dc:identifier">
<c:if test="${accession.doi ne null}">
<a href="<c:url value="https://dx.doi.org/${accession.doi}" />"><c:out value="${accession.doi}" /></a>
</c:if>
</p>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.holdingInstitute" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p><span property="dwc:institutionCode"><c:out value="${accession.institute.code}" /></span>
<a href="<c:url value="/wiews/${accession.instituteCode}" />"><c:out value="${accession.institute.fullName}" /></a>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.holdingCountry" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out value="${accession.institute.country.getName(pageContext.response.locale)}" /></a>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.accessionName" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<c:out value="${accession.accessionName}" />
</p>
</div>
</div>
<c:if test="${accession.countryOfOrigin ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.origin" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<img class="flag" src="<c:url value="${cdnFlagsUrl}" />/${accession.origin.toUpperCase()}.svg" /> <a href="<c:url value="/geo/${accession.origin}" />"> <c:out
value="${accession.countryOfOrigin.getName(pageContext.response.locale)}" />
</a>
</p>
</div>
</div>
</c:if>
<!--basic info section-->
<div class="crop-details">
<div class="collect-info basic-info">
<h4 class="section-heading">
<spring:message code="accession.page.profile.title" arguments="${accession.accessionName}" argumentSeparator="|"/></h4>
<div class="section-inner-content">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.genus" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12" property="dwc:genus">
<p>
<a href="<c:url value="/acn/t/${accession.taxonomy.genus}" />"><span dir="ltr" class="sci-name">
<i><c:out value="${accession.taxonomy.genus}" /></i>
</span></a>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.species" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><span class="sci-name" dir="ltr">
<i><c:out value="${accession.taxonomy.genus} ${accession.taxonomy.species}" /></i>
</span></a> &mdash; <a href="<c:url value="/wiews/${accession.institute.code}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><spring:message code="accession.taxonomy-at-institute" htmlEscape="false"
arguments="<i>${accession.taxonomy.genus} ${accession.taxonomy.species}</i>|||${accession.institute.code}" argumentSeparator="|||" /></a>
</p>
</div>
</div>
<c:if test="${accession.doi ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.doi"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p property="dc:identifier">
<c:if test="${accession.doi ne null}">
<a href="<c:url value=" https://dx.doi.org/${accession.doi}" />"><c:out value="${accession.doi}"/></a>
</c:if>
</p>
<local:auditlog-changes auditLogs="${auditAccession['doi']}"/>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.taxonName" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<span dir="ltr" class="sci-name">
<c:out escapeXml="false" value="${accession.taxonomy.taxonNameHtml}" />
</span>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.holdingInstitute"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<span property="dwc:institutionCode"><c:out value="${accession.institute.code}"/></span>
<a href="<c:url value=" /wiews/${accession.instituteCode}" />"><c:out value="${accession.institute.fullName}"/></a>
</p>
<local:auditlog-changes auditLogs="${auditAccession['institute']}"/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.holdingCountry"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<local:country country="${accession.institute.country}"/>
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.accessionName"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<c:out value="${accession.accessionName}"/>
</p>
<local:auditlog-changes auditLogs="${auditAccession['accessionName']}"/>
</div>
</div>
<c:if test="${crops ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.crop" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<c:forEach items="${crops}" var="crop">
<a href="<c:url value="/c/${crop.shortName}" />"><c:out value="${crop.getName(pageContext.response.locale)}" /></a>
</c:forEach>
</p>
</div>
</div>
</c:if>
<c:if test="${accession.countryOfOrigin ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.origin"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<local:country flag="true" country="${accession.countryOfOrigin}"/>
</p>
<local:auditlog-changes auditLogs="${auditAccession['countryOfOrigin']}"/>
</div>
</div>
</c:if>
<c:if test="${accession.cropName ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.cropName" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p><c:out value="${accession.cropName}" /></p>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.genus"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12" property="dwc:genus">
<p>
<a href="<c:url value=" /acn/t/${accession.taxonomy.genus}" />">
<span dir="ltr" class="sci-name">
<i><c:out value="${accession.taxonomy.genus}"/></i>
</span>
</a>
</p>
<local:auditlog-changes auditLogs="${auditAccession['taxonomy']}" property="genus"/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.species"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<a href="<c:url value=" /acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />">
<span class="sci-name" dir="ltr">
<i><c:out value="${accession.taxonomy.genus} ${accession.taxonomy.species}"/></i>
</span>
</a>
&mdash;
<a href="<c:url value=" /wiews/${accession.institute.code}/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><spring:message code="accession.taxonomy-at-institute" htmlEscape="false" arguments="<i>${accession.taxonomy.genus} ${accession.taxonomy.species}</i>|||${accession.institute.code}" argumentSeparator="|||"/></a>
</p>
<local:auditlog-changes auditLogs="${auditAccession['taxonomy']}" property="species"/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.sampleStatus" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12" property="germplasm:biologicalStatus">
<p>
<spring:message code="accession.sampleStatus.${accession.sampleStatus}" />
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="taxonomy.taxonName"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<local:taxonName taxon="${accession.taxonomy}"/>
</p>
<local:auditlog-changes auditLogs="${auditAccession['taxonomy']}"/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.storage" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<c:forEach items="${accession.stoRage}" var="storage">
<p>
<spring:message code="accession.storage.${storage}" />
</p>
</c:forEach>
</div>
</div>
<c:if test="${crops ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.crop"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<c:forEach items="${crops}" var="crop">
<a href="<c:url value=" /c/${crop.shortName}" />"><c:out value="${crop.getName(pageContext.response.locale)}"/></a>
</c:forEach>
</p>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.acqDate" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<c:out value="${accession.acquisitionDate}" />
</p>
</div>
</div>
<c:if test="${accession.cropName ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.cropName"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p><c:out value="${accession.cropName}"/></p>
<local:auditlog-changes auditLogs="${auditAccession['cropName']}"/>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.availability" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.availability.${accession.availability}" />
</p>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.sampleStatus"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12" property="germplasm:biologicalStatus">
<p>
<spring:message code="accession.sampleStatus.${accession.sampleStatus}"/>
</p>
<local:auditlog-changes auditLogs="${auditAccession['sampleStatus']}" i18n="accession.sampleStatus"/>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.otherNames" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<c:forEach items="${accessionAliases}" var="accessionAlias">
<p>
<c:out value="${accessionAlias.name}" />
<c:if test="${accessionAlias.instCode != ''}">
<a href="<c:url value="/wiews/${accessionAlias.instCode}" />"><c:out value="${accessionAlias.instCode}" /></a>
</c:if>
<c:if test="${accessionAlias.usedBy != ''}">
<c:out value="${accessionAlias.usedBy}" />
</c:if>
<c:if test="${accessionAlias.lang != ''}">
<c:out value="${accessionAlias.lang}" />
</c:if>
<spring:message code="accession.aliasType.${accessionAlias.aliasType}" />
</p>
</c:forEach>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.storage"/>
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<c:forEach items="${accession.stoRage}" var="storage">
<p>
<spring:message code="accession.storage.${storage}"/>
</p>
</c:forEach>
<local:auditlog-changes auditLogs="${auditAccession['storage']}"/>
</div>
</div>
<c:if test="${accession.duplSite ne null}">
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message code="accession.duplSite" />
</p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<c:forEach items="${accession.duplSite.split('[;,]')}" var="duplSite">
<p>
<spring:message code="${duplSite}" />
</p>
</c:forEach>
</div>
</div>
</c:if>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<p>
<spring:message