Package io.goobi.viewer.model.archives
Class CardCatalogManager
java.lang.Object
io.goobi.viewer.model.archives.CardCatalogManager
Application-wide manager for
card catalog indexes: builds and caches a
compact positional index per card catalog archive and answers the interval, list and register
lookups of the card catalog REST API. Deliberately does not use ArchiveManager's full
archive trees; a card catalog with hundreds of thousands of nodes must never be materialized as
ArchiveEntry objects. Card pages and associated records are queried on demand.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intUpper bound for the number of boundary cards of one zoom step.static final intUpper bound for the number of cards returned by one entries request.static final intUpper bound of pages read when a card has to be located by scanning its drawer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionOptional<org.apache.commons.lang3.tuple.ImmutablePair<CardCatalogDrawer, Integer>> findEntryPosition(CardCatalogIndex index, String entryId) Locates a card within the catalog by its EAD node ID: the drawer containing it and its 1-based position within that drawer.getBackSideFiles(Collection<String> recordPis) Finds the back of each given card record: the first further image in the format of the front.getBoundaryPositions(CardCatalogDrawer drawer, Integer from, Integer to) Returns the boundary cards of one zoom step: zoomFactor + 1 cards evenly distributed over the position interval [from, to] of the given drawer.getCatalog(String pi) Returns the (possibly cached) card catalog index for the given archive resource.getCatalogType(String pi) Returns the catalog type of the archive resource with the given PI if its CMS configuration enables the catalog view.getDrawerRegister(CardCatalogIndex index, CardCatalogDrawer drawer) Returns only the requested drawer's register without computing any other drawer.getEntriesAtPositions(CardCatalogDrawer drawer, List<Integer> positions) Reads the sparse boundary cards in position order and resolves their associated records in one batch.getEntryRange(CardCatalogDrawer drawer, int from, int to) Reads a bounded, 1-based inclusive range of cards in catalog order.static intnormalizeZoomFactor(int zoomFactor) intunloadCatalogs(Collection<String> resourceIds) Removes the cached indexes of the given archive resources, so that they are rebuilt from Solr on next access.
-
Field Details
-
MAX_BOUNDARIES
public static final int MAX_BOUNDARIESUpper bound for the number of boundary cards of one zoom step.- See Also:
-
MAX_ENTRIES_PER_REQUEST
public static final int MAX_ENTRIES_PER_REQUESTUpper bound for the number of cards returned by one entries request.- See Also:
-
MAX_POSITION_SCAN_PAGES
public static final int MAX_POSITION_SCAN_PAGESUpper bound of pages read when a card has to be located by scanning its drawer.- See Also:
-
-
Constructor Details
-
CardCatalogManager
public CardCatalogManager()
-
-
Method Details
-
getCatalog
public Optional<CardCatalogIndex> getCatalog(String pi) throws PresentationException, IndexUnreachableException Returns the (possibly cached) card catalog index for the given archive resource. Staleness against the Solr index is checked via DATEINDEXED, throttled to one lookup per minute per catalog.- Parameters:
pi- PI of the archive resource- Returns:
- the index, or empty if no archive with the given PI is indexed
- Throws:
PresentationExceptionIndexUnreachableException
-
getBoundaryPositions
Returns the boundary cards of one zoom step: zoomFactor + 1 cards evenly distributed over the position interval [from, to] of the given drawer.- Parameters:
drawer- drawer to resolve positions infrom- 1-based start position; values out of range are clampedto- 1-based end position; values out of range are clamped- Returns:
- boundary positions (1-based) in ascending order, without duplicates
-
normalizeZoomFactor
public static int normalizeZoomFactor(int zoomFactor) -
getEntryRange
public List<CardCatalogEntry> getEntryRange(CardCatalogDrawer drawer, int from, int to) throws PresentationException, IndexUnreachableException Reads a bounded, 1-based inclusive range of cards in catalog order. The caller may request at mostMAX_ENTRIES_PER_REQUESTcards; larger ranges are rejected rather than silently truncated. -
getEntriesAtPositions
public List<CardCatalogEntry> getEntriesAtPositions(CardCatalogDrawer drawer, List<Integer> positions) throws PresentationException, IndexUnreachableException Reads the sparse boundary cards in position order and resolves their associated records in one batch. Missing Solr rows are rejected so a stale index cannot return wrong positions. -
getDrawerRegister
public Optional<List<CardCatalogRegisterRange>> getDrawerRegister(CardCatalogIndex index, CardCatalogDrawer drawer) throws PresentationException, IndexUnreachableException Returns only the requested drawer's register without computing any other drawer. -
getCatalogType
Returns the catalog type of the archive resource with the given PI if its CMS configuration enables the catalog view. Results are cached and refreshed periodically, so this is cheap enough for search hit and widget rendering.- Parameters:
pi- PI of the archive resource- Returns:
- the catalog type, or empty if the archive has no catalog view
-
findEntryPosition
public Optional<org.apache.commons.lang3.tuple.ImmutablePair<CardCatalogDrawer,Integer>> findEntryPosition(CardCatalogIndex index, String entryId) throws PresentationException, IndexUnreachableException Locates a card within the catalog by its EAD node ID: the drawer containing it and its 1-based position within that drawer. Current indexes store a dense, zero-based sibling order, which is verified against the sorted card at that position. Otherwise the position is derived from two Solr count queries (siblings sorting before the card) and verified the same way; as a last resort the firstMAX_POSITION_SCAN_PAGESpages of the drawer are scanned.- Parameters:
index- card catalog indexentryId- EAD node ID of the card- Returns:
- drawer and 1-based position; empty if the entry is not part of a drawer of this catalog or could not be located
- Throws:
PresentationExceptionIndexUnreachableException
-
unloadCatalogs
Removes the cached indexes of the given archive resources, so that they are rebuilt from Solr on next access. Called by the message queue handler when records associated with an archive have been (re)indexed.- Parameters:
resourceIds- PIs of the archive resources to unload- Returns:
- number of unloaded indexes
-
getBackSideFiles
public Map<String,String> getBackSideFiles(Collection<String> recordPis) throws PresentationException, IndexUnreachableException Finds the back of each given card record: the first further image in the format of the front. Header strips and other excerpts differ in format and are left out; images without indexed dimensions never count as a back.- Parameters:
recordPis- PIs of card records- Returns:
- file name of the back image per record PI, only for records that have one
- Throws:
PresentationExceptionIndexUnreachableException
-