java.lang.Object
io.goobi.viewer.model.iiif.presentation.v3.builder.DataRetriever

public class DataRetriever extends Object
Responsible for retrieving data from Index to build any IIIF resources.
Author:
Florian Alpers
  • Field Details

    • CONTAINED_WORKS_QUERY_FIELDS

      public static final String[] CONTAINED_WORKS_QUERY_FIELDS
      Required field to create manifest stubs for works in collection.
    • REQUIRED_SOLR_FIELDS

      public static final String[] REQUIRED_SOLR_FIELDS
      Required fields to create manifests with structure.
  • Constructor Details

    • DataRetriever

      public DataRetriever()
  • Method Details

    • getDocumentWithChildren

      public List<StructElement> getDocumentWithChildren(String pi) throws PresentationException, IndexUnreachableException
      Queries all DocStructs which have the given PI as PI_TOPSTRUCT or anchor (or are the anchor themselves). Works are sorted by a StructElementComparator If no hits are found, an empty list is returned
      Parameters:
      pi - persistent identifier of the record to retrieve
      Returns:
      A list of all docstructs with the given pi or children thereof. An empty list if no hits are found
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getTopLevelCollections

      public List<CollectionResult> getTopLevelCollections(String solrField) throws IndexUnreachableException
      Get all top level collections (i.e. those without splitting-char) along with the number of contained works and direct children
      Parameters:
      solrField - Solr field used to store the collection hierarchy
      Returns:
      List (immutable!)
      Throws:
      IndexUnreachableException
    • getChildCollections

      public List<CollectionResult> getChildCollections(String solrField, String collectionName) throws IndexUnreachableException
      Gets all collections which are direct children of the given collection along with the number of contained works and direct children.
      Parameters:
      solrField - Solr field used to store the collection hierarchy
      collectionName - name of the parent collection whose children to retrieve
      Returns:
      List (immutable!)
      Throws:
      IndexUnreachableException
    • getContainedRecords

      public List<StructElement> getContainedRecords(String solrField, String collectionName) throws IndexUnreachableException, PresentationException
      Gets all records directly belonging to the given collection, only the fields in CONTAINED_WORKS_QUERY_FIELDS are returned.
      Parameters:
      solrField - Solr field used to store the collection hierarchy
      collectionName - name of the collection whose records to retrieve
      Returns:
      List (immutable!)
      Throws:
      IndexUnreachableException
      PresentationException
    • countContainedRecords

      public long countContainedRecords(String solrField, String collectionName) throws IndexUnreachableException, PresentationException
      Throws:
      IndexUnreachableException
      PresentationException
    • addEventMetadataToWorkElement

      protected void addEventMetadataToWorkElement(List<StructElement> eles, List<org.apache.solr.common.SolrDocument> events)
      Adds all metadata from the given events to the first work document contained in eles. All metadata will be attached twice, once in the form "/[fieldName]" and once in the form "[eventType]/[fieldName]"
      Parameters:
      eles - The list of StructElements from which to select the first work document. All metadata are attached to this document
      events - The list of event SolrDocuments from which to take the metadata
    • getEventFields

      protected Map<String,List<String>> getEventFields()
      getEventFields.
      Returns:
      a map of event type names to their associated Solr field names, as configured for IIIF
    • getDocument

      getDocument.
      Parameters:
      pi - persistent identifier of the record to retrieve
      Returns:
      the StructElement for the given PI, or null if the document was not found
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
    • getSolrFieldList

      public List<String> getSolrFieldList()
      getSolrFieldList.
      Returns:
      a list of Solr field names required for IIIF presentation data retrieval
    • addLanguageFields

      protected static List<String> addLanguageFields(List<String> displayFields, List<Locale> locales)
      Parameters:
      displayFields - base list of Solr field names to expand with language variants
      locales - locales for which to add language-specific field variants
      Returns:
      List (immutable!)