Class IndexStatisticsService

java.lang.Object
io.goobi.viewer.model.statistics.index.IndexStatisticsService

public class IndexStatisticsService extends Object
Aggregations over the Solr index for index-level statistic charts. Constructor takes a SolrSearchIndex dependency so unit tests can mock it; production callers use the no-arg constructor that pulls the singleton.

Each method caches its result for one day and throws StatisticsUnavailableException when the upstream is down and no cached snapshot is available, so the resource layer can translate to HTTP 503 instead of silently returning empty data.

  • Constructor Details

    • IndexStatisticsService

      public IndexStatisticsService()
    • IndexStatisticsService

      public IndexStatisticsService(SolrSearchIndex searchIndex)
  • Method Details

    • getPublicationTypes

      public List<PublicationTypeStatistic> getPublicationTypes(Locale locale, String filter) throws StatisticsUnavailableException
      Lists each top-level docstruct type with its record count, with labels translated to the given locale.
      Parameters:
      locale - the user's locale for label translation; falls back to default if null
      filter - optional Lucene sub-query to constrain the docstructs; wrapped in MUST so it can only narrow. null or blank means no constraint.
      Returns:
      DTOs in Solr's facet order (by count, descending), never null
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no cached snapshot exists for this locale+filter
    • getImportTrend

      public List<ImportTrendBucket> getImportTrend(int days, int dataPoints, String filter) throws StatisticsUnavailableException
      Builds a cumulative-count time-series suitable for a line chart.
      Parameters:
      days - size of the look-back window
      dataPoints - number of buckets to produce; capped at days
      filter - optional Lucene sub-query to constrain the time-series; wrapped in MUST so it can only narrow. null or blank means no constraint.
      Returns:
      DTOs ordered newest first, never null
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no compatible cached snapshot exists
    • getImportSummary

      public ImportSummary getImportSummary(String filter) throws StatisticsUnavailableException
      Total page and full-text counts in the index.
      Parameters:
      filter - optional Lucene sub-query to constrain both counts; wrapped in MUST so it can only narrow. null or blank means no constraint.
      Returns:
      summary; both numbers populated from Solr or returned from cache on error
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no cached snapshot exists
    • getPublicationCenturies

      public List<PublicationCenturyStatistic> getPublicationCenturies(String filter) throws StatisticsUnavailableException
      Histogram of works by publication century (e.g. century 18 = 1800–1899). Pre-modern centuries are dropped.
      Parameters:
      filter - optional Lucene sub-query to constrain the histogram; wrapped in MUST so it can only narrow.
      Returns:
      DTOs ordered chronologically (oldest century first), never null
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no cached snapshot exists for this filter
    • getLanguages

      public List<LanguageStatistic> getLanguages(Locale locale, String filter) throws StatisticsUnavailableException
      Distribution of works by language with locale-translated display names.
      Parameters:
      locale - the user's locale for label translation; falls back to default if null
      filter - optional Lucene sub-query to constrain the distribution; wrapped in MUST.
      Returns:
      DTOs in Solr's facet order (by count, descending), never null
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no cached snapshot exists
    • getTopCollections

      public List<CollectionStatistic> getTopCollections(int size, Locale locale, String filter) throws StatisticsUnavailableException
      Top size collections by record count, with locale-translated labels.
      Parameters:
      size - maximum number of collections to return
      locale - the user's locale for label translation; falls back to default if null
      filter - optional Lucene sub-query to constrain the collections; wrapped in MUST.
      Returns:
      DTOs in Solr's facet order (by count, descending), never null
      Throws:
      StatisticsUnavailableException - if Solr is unreachable and no cached snapshot exists