Commit d818569a authored by Matija Obreza's avatar Matija Obreza

Display last updates of passport data by date and institute

parent 8b8d5d50
......@@ -38,7 +38,11 @@ import javax.persistence.UniqueConstraint;
*
*/
@Entity
@Table(name = "accession", uniqueConstraints = { @UniqueConstraint(name = "UQ_accession_genus_inst", columnNames = { "instituteId", "taxGenus", "acceNumb" }) }, indexes = { @Index(name = "IX_seqNo", columnList = "seqNo") })
@Table(name = "accession",
// Unique constraints
uniqueConstraints = { @UniqueConstraint(name = "UQ_accession_genus_inst", columnNames = { "instituteId", "taxGenus", "acceNumb" }) },
// Indexes
indexes = { @Index(name = "IX_seqNo", columnList = "seqNo"), @Index(name = "IX_accession_lastModifiedDate", columnList = "lastModifiedDate") })
public class Accession extends AccessionData {
/**
*
......
......@@ -141,4 +141,9 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Modifying
public void updateCrop(Accession accession, Crop crop);
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute, count(a) from Accession a group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), a.institute order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc, a.institute.code")
public List<Object[]> lastUpdatedStatistics();
@Query("select year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate), count(a) from Accession a where a.institute = ?1 group by year(a.lastModifiedDate), month(a.lastModifiedDate), day(a.lastModifiedDate) order by year(a.lastModifiedDate) desc, month(a.lastModifiedDate) desc, day(a.lastModifiedDate) desc")
public List<Object[]> lastUpdatedStatistics(FaoInstitute faoInstitute);
}
......@@ -51,7 +51,6 @@ import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.Organization;
import org.genesys2.server.service.impl.FilterHandler.AppliedFilters;
import org.genesys2.server.service.impl.NoSuchAccessionException;
import org.genesys2.spring.ResourceNotFoundException;
import org.genesys2.server.service.impl.NonUniqueAccessionException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -270,4 +269,8 @@ public interface GenesysService {
AccessionDetails getAccession(UUID accessionUuid) throws NoSuchAccessionException;
List<Object[]> getLastUpdatedStatistics();
List<Object[]> getLastUpdatedStatistics(FaoInstitute faoInstitute);
}
......@@ -1833,4 +1833,16 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
}
return accessions;
}
@Override
@Cacheable(value = "statistics", unless = "#result == null", key = "'stats.' + #root.methodName")
public List<Object[]> getLastUpdatedStatistics() {
return accessionRepository.lastUpdatedStatistics();
}
@Override
@Cacheable(value = "statistics", unless = "#result == null", key = "'stats.' + #root.methodName + '-' + #faoInstitute.code")
public List<Object[]> getLastUpdatedStatistics(FaoInstitute faoInstitute) {
return accessionRepository.lastUpdatedStatistics(faoInstitute);
}
}
......@@ -261,4 +261,9 @@ public class AccessionController extends BaseController {
return "redirect:/explore";
}
@RequestMapping("/updates")
public String updateStats(ModelMap model) {
model.addAttribute("updates", genesysService.getLastUpdatedStatistics());
return "/accession/updates";
}
}
......@@ -147,6 +147,7 @@ public class WiewsController extends BaseController {
model.addAttribute("statisticsGenus", genesysService.statisticsGenusByInstitute(faoInstitute, new PageRequest(0, 5)));
model.addAttribute("statisticsTaxonomy", genesysService.statisticsSpeciesByInstitute(faoInstitute, new PageRequest(0, 5)));
model.addAttribute("statisticsPDCI", statisticsService.statisticsPDCI(faoInstitute));
model.addAttribute("updates", genesysService.getLastUpdatedStatistics(faoInstitute));
if (datasetCount > 0) {
model.addAttribute("statisticsPheno", statisticsService.statisticsPheno(faoInstitute));
......
......@@ -376,6 +376,9 @@ accession.resolve=Multiple accessions with the name ''{0}'' found in Genesys. Se
accession.page.data.title=Accession browser
accession.page.data.intro=Explore the accession data with Genesys. To refine your search, add filters such as country of origin, crop, species, or the latitude and longitude of the collecting site.
accession.taxonomy-at-institute=View {0} at {1}
accession.page.updates.title=Last updates of passport data
accession.page.updates.intro=Updates of passport data by date of last update, institute and number of records updated
accession.page.updated.never=Data provided before 2014
accession.svalbard-data=Svalbard Global Seed Vault duplication data
accession.svalbard-data.taxonomy=Reported scientific name
......
......@@ -1192,7 +1192,7 @@ $light-font-family: 'Roboto-Light';
}
div {
width: 20%;
// width: 20%;
/*text-align: right;*/
}
&:nth-child(odd) {
......@@ -4887,9 +4887,9 @@ table.accessions {
a {
width: 75%;
}
div {
width: 25%;
}
// div {
// width: 25%;
// }
}
}
......
......@@ -50,6 +50,10 @@
<a href="<c:url value="/content/about/history-of-genesys" />"> <spring:message code="menu.history-of-genesys" />
</a>
</li>
<li class="pull-left">
<a href="<c:url value="/acn/updates" />"> <spring:message code="accession.page.updates.title" />
</a>
</li>
<li class="pull-left">
<a href="<c:url value="/content/about/newsletter" />"> <spring:message code="menu.newsletter" />
</a>
......
<!DOCTYPE html>
<%@ include file="/WEB-INF/jsp/init.jsp" %>
<html>
<head>
<title><spring:message code="accession.page.updates.title" /></title>
</head>
<body class="about-page">
<cms:informative-h1 title="accession.page.updates.title" fancy="true" info="accession.page.updates.intro"/>
<spring:eval expression="T(java.text.DateFormatSymbols).getInstance(pageContext.response.locale).getMonths()" var="monthNames" />
<c:set var="year" value="" />
<c:set var="month" value="" />
<c:set var="day" value="" />
<div class="institute-list">
<c:forEach items="${updates}" var="update">
<c:if test="${month ne update[1]}">
<c:set var="month" value="${update[1]}" />
<c:if test="${update[0] eq null}">
<h1><spring:message code="accession.page.updated.never" /></h1>
</c:if>
<c:if test="${update[0] ne null}">
<h1>${monthNames[update[1]-1]} ${update[0]}</h1>
</c:if>
</c:if>
<div class="row">
<div class="col-xs-2"><b>
<c:if test="${update[0] ne null}">
${update[2]} ${monthNames[update[1]-1]} ${update[0]}
</c:if>
<c:if test="${update[0] eq null}">
----
</c:if>
</b></div>
<div class="col-xs-1"><b>${update[3].code}</b></div>
<div class="col-xs-8"><a href="<c:url value='/wiews/${update[3].code}' />">${update[3].fullName}</a></div>
<%-- <div class="col-xs-1">${update[4]}</div> --%>
<div class="col-xs-1 text-right"><b><fmt:formatNumber value="${update[4]}" /></b></div>
</div>
</c:forEach>
</div>
</body>
</html>
\ No newline at end of file
......@@ -462,7 +462,34 @@
</div>
</div>
</c:if>
</div>
<c:if test="${countByInstitute gt 0}">
<spring:eval expression="T(java.text.DateFormatSymbols).getInstance(pageContext.response.locale).getMonths()" var="monthNames" />
<div class="collect-info col-lg-6 col-md-12 col-sm-12 col-xs-12">
<h4 class="row section-heading"><span><spring:message code="accession.page.updates.title" /></span></h4>
<div class="section-inner-content">
<div class="terms-table">
<c:forEach items="${updates}" var="update" varStatus="status">
<div class="row">
<div class="col-lg-8 col-md-6 col-sm-6 col-xs-6">
<c:if test="${update[0] eq null}">
<spring:message code="accession.page.updated.never" />
</c:if>
<c:if test="${update[3] ne null}">
<c:out value="${update[2]} ${monthNames[update[1]-1]} ${update[0]}" />
</c:if>
</div>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-6 text-right">
<fmt:formatNumber value="${update[3]}" />
</div>
</div>
</c:forEach>
</div>
</div>
</div>
</div>
</c:if>
<security:authorize access="hasRole('ADMINISTRATOR') or hasPermission(#faoInstitute, 'ADMINISTRATION')">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<a href="<c:url value="/acl/${faoInstitute.getClass().name}/${faoInstitute.id}/permissions"><c:param name="back">/wiews/${faoInstitute.code}</c:param></c:url>" class="close">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment