Commit bbfd3c93 authored by Matija Obreza's avatar Matija Obreza

Display active accession count on /welcome

parent f4b8e6e6
......@@ -124,4 +124,6 @@ public interface AccessionRepository extends JpaRepository<Accession, Long> {
@Query("select a from Accession a")
Stream<Accession> streamAll();
public long countByHistoric(boolean historic);
}
......@@ -181,6 +181,10 @@ public interface GenesysService {
long countAll();
long countAllActive();
long countAllHistoric();
/**
* For institutes with {@link FaoInstitute#uniqueAcceNumbs}
*
......@@ -264,4 +268,5 @@ public interface GenesysService {
void regenerateAccessionSequentialNumber();
}
......@@ -28,6 +28,8 @@ public interface StatisticsService {
long numberOfInstitutes();
long numberOfAccessions();
long numberOfActiveAccessions();
long numberOfHistoricAccessions();
PDCIStatistics statisticsPDCI(FaoInstitute faoInstitute);
......@@ -35,4 +37,5 @@ public interface StatisticsService {
PhenoStatistics statisticsPheno(FaoInstitute faoInstitute);
}
......@@ -224,6 +224,16 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
return accessionRepository.count();
}
@Override
public long countAllActive() {
return accessionRepository.countByHistoric(false);
}
@Override
public long countAllHistoric() {
return accessionRepository.countByHistoric(true);
}
@Override
public long countByInstitute(FaoInstitute institute) {
return accessionRepository.countByInstitute(institute);
......@@ -1095,7 +1105,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos.putNextEntry(metaEntry);
final BufferedWriter osw = new BufferedWriter(new OutputStreamWriter(zos));
osw.write("<?xml version='1.0' encoding='utf-8'?>\n");
osw.write("<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write("<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>core.csv</location></files>\n");
osw.write("\t<id index=\"0\" />\n");
......@@ -1362,7 +1373,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos.putNextEntry(metaEntry);
final BufferedWriter osw = new BufferedWriter(new OutputStreamWriter(zos));
osw.write("<?xml version='1.0' encoding='utf-8'?>\n");
osw.write("<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write(
"<archive xmlns=\"http://rs.tdwg.org/dwc/text/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://rs.tdwg.org/dwc/text/ http://rs.tdwg.org/dwc/text/tdwg_dwc_text.xsd\">\n");
osw.write("<core encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>core.csv</location></files>\n");
osw.write("\t<id index=\"0\" />\n");
......@@ -1374,7 +1386,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
for (int i = 0; i < metadataMethods.size(); i++) {
final Method method = metadataMethods.get(i);
osw.write("<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write(
"<extension encoding=\"UTF-8\" fieldsTerminatedBy=\",\" linesTerminatedBy=\"\\n\" fieldsEnclosedBy=\"&quot;\" ignoreHeaderLines=\"0\">\n");
osw.write("\t<files><location>");
osw.write(method.getFieldName().toLowerCase());
osw.write(".csv</location></files>\n");
......@@ -1646,7 +1659,7 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
pdci = new PDCI();
pdci.setAccession(accessionIdRepository.findOne(accessionId));
}
return repoPdci.save(pdciCalculator.updatePdci(pdci, accessionId));
}
......
......@@ -62,6 +62,18 @@ public class StatisticsServiceImpl implements StatisticsService {
public long numberOfAccessions() {
return genesysService.countAll();
}
@Override
@Cacheable(value = "statistics", key = "'stats.' + #root.methodName")
public long numberOfActiveAccessions() {
return genesysService.countAllActive();
}
@Override
@Cacheable(value = "statistics", key = "'stats.' + #root.methodName")
public long numberOfHistoricAccessions() {
return genesysService.countAllHistoric();
}
@Override
@Cacheable(unless = "#result == null", value = "statistics", key = "'stats.' + #root.methodName + '-' + #faoInstitute.id")
......
......@@ -105,6 +105,8 @@ public class HtmlController extends BaseController {
model.addAttribute("numberOfCountries", statisticsService.numberOfCountries());
model.addAttribute("numberOfInstitutes", statisticsService.numberOfInstitutes());
model.addAttribute("numberOfAccessions", statisticsService.numberOfAccessions());
model.addAttribute("numberOfActiveAccessions", statisticsService.numberOfActiveAccessions());
model.addAttribute("numberOfHistoricAccessions", statisticsService.numberOfHistoricAccessions());
model.addAttribute("organizations", organizationService.list(new PageRequest(0, 5)));
......
......@@ -633,6 +633,7 @@ autocomplete.genus=Find Genus...
stats.number-of-countries={0} Countries
stats.number-of-institutes={0} Institutes
stats.number-of-accessions={0} Accessions
stats.number-of-historic-accessions={0} Historic accessions
navigate.back=Back
......
......@@ -40,9 +40,14 @@
<%-- <div class="one-stat"><a href="<c:url value="/geo/" />"><spring:message code="stats.number-of-countries" arguments="${numberOfCountries}" /></a></div> --%>
<div class="one-stat">
<a href="<c:url value="/explore" />">
<spring:message code="stats.number-of-accessions" arguments="${numberOfAccessions}" />
<spring:message code="stats.number-of-accessions" arguments="${numberOfActiveAccessions}" />
</a>
</div>
<%-- <div class="one-stat">
<a href="<c:url value="/explore"><c:param name="filter" value='{"historic":[true]}' /></c:url>">
<spring:message code="stats.number-of-historic-accessions" arguments="${numberOfHistoricAccessions}" />
</a>
</div> --%>
<div class="one-stat">
<a href="<c:url value="/wiews/active" />">
<spring:message code="stats.number-of-institutes" arguments="${numberOfInstitutes}" />
......
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