Class TOC

java.lang.Object
io.goobi.viewer.model.toc.TOC
All Implemented Interfaces:
Serializable

public class TOC extends Object implements Serializable
Table of contents and associated functionality for a record.
See Also:
  • Constructor Details

    • TOC

      public TOC()
      Creates a new TOC instance.
  • Method Details

    • generate

      public void generate(StructElement structElement, boolean addAllSiblings, String mimeType, int tocCurrentPage) throws PresentationException, IndexUnreachableException, DAOException, ViewerConfigurationException
      generate.
      Parameters:
      structElement - root struct element for TOC generation
      addAllSiblings - if true, sibling elements are included in the TOC
      mimeType - MIME type of the record
      tocCurrentPage - current paginator page of anchor group elements
      Throws:
      PresentationException - if any.
      IndexUnreachableException - if any.
      DAOException - if any.
      ViewerConfigurationException - if any.
    • getGroupNames

      public List<String> getGroupNames()
      getGroupNames.
      Returns:
      a list of TOC group names available in this table of contents
    • getViewForGroup

      public List<TOCElement> getViewForGroup(String group)
      getViewForGroup.
      Parameters:
      group - TOC group name to retrieve elements for
      Returns:
      a list of TOC elements belonging to the given group, or null if none found
    • getTreeViewForGroup

      public List<TOCElement> getTreeViewForGroup(String group)
      getTreeViewForGroup.
      Parameters:
      group - TOC group name to build the tree for
      Returns:
      a list of TOC elements for the given group with tree nesting applied
    • getFlatView

      public List<TOCElement> getFlatView()
      getFlatView.
      Returns:
      a flat list of all TOC elements in the default group
    • getTreeView

      public List<TOCElement> getTreeView()
      getTreeView.
      Returns:
      a list of TOC elements for the default group with tree nesting applied
    • buildTree

      protected void buildTree(String group, int visibleLevel, int collapseThreshold, int lowestLevelToCollapse, String currentElementIdDoc)
      Parameters:
      group - TOC group name to build the tree for
      visibleLevel - maximum hierarchy level shown expanded initially
      collapseThreshold - sibling count above which a level is auto-collapsed
      lowestLevelToCollapse - minimum hierarchy level eligible for length-based collapse
      currentElementIdDoc - IDDOC of the currently displayed struct element
    • getActiveElement

      public TOCElement getActiveElement()
      Recalculates the visibility of TOC elements after a +/- button has been pressed.
      Returns:
      the TOCElement that was expanded or collapsed after processing the pending visibility change, or null if none was pending
    • expandAll

      public void expandAll()
      expandAll.
    • collapseAll

      public void collapseAll()
      collapseAll.
    • setChildVisible

      public void setChildVisible(int id)
      setChildVisible.
      Parameters:
      id - index of the TOC element to expand
    • setChildInvisible

      public void setChildInvisible(int id)
      setChildInvisible.
      Parameters:
      id - index of the TOC element to collapse
    • getTocElements

      public List<TOCElement> getTocElements()
      getTocElements.
      Returns:
      a list of all TOC elements in the default group
    • findTocElementIndexByIddoc

      public int findTocElementIndexByIddoc(String iddoc)
      Parameters:
      iddoc - IDDOC of the element to find
      Returns:
      Index of the element with the matching IDDOC within the list of elements; -1 if none found
    • getTocVisible

      public int getTocVisible()
      Getter for the field tocVisible.
      Returns:
      the number of visible TOC entries on the current page
    • setTocVisible

      public void setTocVisible(int tocVisible)
      Setter for the field tocVisible.
      Parameters:
      tocVisible - the number of visible TOC entries on the current page to set
    • getTocInvisible

      public int getTocInvisible()
      Getter for the field tocInvisible.
      Returns:
      the number of hidden (collapsed) TOC entries on the current page
    • setTocInvisible

      public void setTocInvisible(int tocInvisible)
      Setter for the field tocInvisible.
      Parameters:
      tocInvisible - the number of hidden (collapsed) TOC entries on the current page to set
    • getMaxTocDepth

      public int getMaxTocDepth()
      Getter for the field maxTocDepth.
      Returns:
      the maximum nesting depth of the TOC tree
    • setMaxTocDepth

      public void setMaxTocDepth(int maxTocDepth)
      Setter for the field maxTocDepth.
      Parameters:
      maxTocDepth - the maximum nesting depth of the TOC tree to set
    • getTotalTocSize

      public int getTotalTocSize()
      Getter for the field totalTocSize.
      Returns:
      the total number of TOC entries across all pages
    • setTotalTocSize

      public void setTotalTocSize(int totalTocSize)
      Setter for the field totalTocSize.
      Parameters:
      totalTocSize - the total number of TOC entries across all pages to set
    • getCurrentPage

      public int getCurrentPage()
      Getter for the field currentPage.
      Returns:
      the 1-based page number of the currently displayed TOC page
    • setCurrentPage

      public void setCurrentPage(int currentPage)
      Setter for the field currentPage.
      Parameters:
      currentPage - the 1-based page number of the TOC page to display
    • getNumPages

      public int getNumPages()
      Returns the number of paginator pages for the given TOC size and elements per page.
      Returns:
      a int.
    • isHasChildren

      public boolean isHasChildren()
      hasChildren.
      Returns:
      true if the TOC contains more than one element or any element has child entries, false otherwise
    • getLabel

      public String getLabel(String pi)
      Returns the label of the first found TOCElement that has the given PI as its topStructPi.
      Parameters:
      pi - persistent identifier of the record
      Returns:
      the label of the matching TOC element, or null if none found
    • getLabel

      public String getLabel(String pi, String language)
      Returns the label in the given language of the first found TOCElement that has the given PI as its topStructPi.
      Parameters:
      pi - persistent identifier of the record
      language - ISO 639-1 language code for the desired label
      Returns:
      the language-specific label of the matching TOC element, or null if none found
    • getLabel

      public String getLabel(String pi, Locale locale)
      Returns the label in the given locale of the first found TOCElement that has the given PI as its topStructPi.
      Parameters:
      pi - persistent identifier of the record
      locale - locale for the desired label language
      Returns:
      the locale-specific label of the matching TOC element, or null if none found