Class CMSNavigationItem

java.lang.Object
io.goobi.viewer.model.cms.CMSNavigationItem
All Implemented Interfaces:
Serializable, Comparable<CMSNavigationItem>
Direct Known Subclasses:
SelectableNavigationItem

@Entity public class CMSNavigationItem extends Object implements Comparable<CMSNavigationItem>, Serializable
Represents a single item in the CMS navigation menu with label, target URL, and child items.
See Also:
  • Constructor Details

    • CMSNavigationItem

      public CMSNavigationItem()
      Empty constructor.
    • CMSNavigationItem

      public CMSNavigationItem(CMSNavigationItem original)
      Created a copy of the passed item ignoring all data concerning the item hierarchy (order, child and parent items).
      Parameters:
      original - navigation item to copy fields from
    • CMSNavigationItem

      public CMSNavigationItem(String targetUrl, String label)
      Creates a new CMSNavigationItem instance.
      Parameters:
      targetUrl - relative or absolute URL this item points to
      label - display label for this navigation item
    • CMSNavigationItem

      public CMSNavigationItem(CMSPage cmsPage)
      Creates a new CMSNavigationItem instance.
      Parameters:
      cmsPage - CMS page this navigation item links to
  • Method Details

    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(CMSNavigationItem o)
      Specified by:
      compareTo in interface Comparable<CMSNavigationItem>
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key of this navigation item, or null if not persisted
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - database primary key for this navigation item
    • getItemLabel

      public String getItemLabel()
      Getter for the field itemLabel.
      Returns:
      the display label for this navigation item, using the CMS page menu title if linked
    • setItemLabel

      public void setItemLabel(String itemLabel)
      Setter for the field itemLabel.
      Parameters:
      itemLabel - display label for this navigation item
    • getOrder

      public Integer getOrder()
      Getter for the field order.
      Returns:
      the sort position of this navigation item within its parent or the top-level menu
    • setOrder

      public void setOrder(Integer order)
      Setter for the field order.
      Parameters:
      order - the sort position of this navigation item within its parent or the top-level menu
    • getParentItem

      public CMSNavigationItem getParentItem()
      Getter for the field parentItem.
      Returns:
      the parent navigation item, or null if this is a top-level item
    • setParentItem

      public void setParentItem(CMSNavigationItem parentItem)
      Setter for the field parentItem.
      Parameters:
      parentItem - the parent navigation item; also registers this item as a child of the parent
    • getChildItems

      public List<CMSNavigationItem> getChildItems()
      Getter for the field childItems.
      Returns:
      a list of direct child navigation items of this item
    • setChildItems

      public void setChildItems(List<CMSNavigationItem> childItems)
      Setter for the field childItems.
      Parameters:
      childItems - list of child navigation items to set
    • getActiveChildItems

      public List<CMSNavigationItem> getActiveChildItems()
      Returns:
      Visible child items
    • getActiveChildItems

      public List<CMSNavigationItem> getActiveChildItems(HttpServletRequest request)
      Parameters:
      request - HTTP servlet request used for access checks
      Returns:
      Visible child items
    • addChildItem

      public void addChildItem(CMSNavigationItem child)
      addChildItem.
      Parameters:
      child - navigation item to add as a child
    • removeChildItem

      public void removeChildItem(CMSNavigationItem child)
      removeChildItem.
      Parameters:
      child - navigation item to remove from children
    • getCmsPage

      public CMSPage getCmsPage()
      Getter for the field cmsPage.
      Returns:
      the CMS page this navigation item links to, or null if none is set
    • setCmsPage

      public void setCmsPage(CMSPage cmsPage)
      Setter for the field cmsPage.
      Parameters:
      cmsPage - CMS page this navigation item links to
    • getNavigationUrl

      public String getNavigationUrl()
      getNavigationUrl.
      Returns:
      the fully qualified navigation URL for this item, including the servlet context path if needed
    • getPageUrl

      public String getPageUrl()
      Getter for the field pageUrl.
      Returns:
      the relative URL path for this navigation item, using the linked CMS page URL if available
    • setPageUrl

      public void setPageUrl(String pageUrl)
      Setter for the field pageUrl.
      Parameters:
      pageUrl - relative or absolute URL for this navigation item
    • hasUnpublishedCmsPage

      public boolean hasUnpublishedCmsPage()
      hasUnpublishedCmsPage.
      Returns:
      true if this item has an associated cmsPage and this page's status is unpublished
    • isValid

      public boolean isValid()
      isValid.
      Returns:
      true if this navigation item has no unpublished and no deleted CMS page, false otherwise
    • isShouldDisplay

      public boolean isShouldDisplay()
      isShouldDisplay.
      Returns:
      true if this navigation item should be displayed to the current user according to its display rule, false otherwise
    • hasDeletedCmsPage

      public boolean hasDeletedCmsPage()
      hasDeletedCmsPage.
      Returns:
      true if this item has no associated cmsPage, but the url is that of a cms page or is empty
    • hasCmsPage

      public boolean hasCmsPage()
      hasCmsPage.
      Returns:
      true if this navigation item has an associated CMS page, false otherwise
    • matchesLabel

      public boolean matchesLabel(String currentPage)
      Check to highlight this item as 'currentPage'. Checks both the items label and all child labels whether they equal currentPage
      Parameters:
      currentPage - navigation page identifier to match against this item and its children
      Returns:
      true if this item's label or any child item's label equals the given page identifier, false otherwise
    • getLevel

      public int getLevel()
      Returns the hierarchy level of this item, i.e. the number of ancestor items
      Returns:
      a int.
    • getSortingListId

      public Integer getSortingListId()
      Getter for the field sortingListId.
      Returns:
      the temporary ID used to identify this item in the navigation menu hierarchy
    • setSortingListId

      public void setSortingListId(Integer sortingListId)
      Setter for the field sortingListId.
      Parameters:
      sortingListId - the ID used to associate this item with a specific sorting list group
    • isAbsoluteLink

      public boolean isAbsoluteLink()
      isAbsoluteLink.
      Returns:
      true if the URL of this navigation item is an absolute link, false otherwise
    • setAbsoluteLink

      public void setAbsoluteLink(boolean absoluteLink)
      Setter for the field absoluteLink.
      Parameters:
      absoluteLink - a boolean.
    • isVisible

      public boolean isVisible()
      isVisible.
      Returns:
      true if this navigation item is visible (always returns true for the base implementation), false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setDisplayRule

      public void setDisplayRule(CMSNavigationItem.DisplayRule rule)
      Setter for the field displayRule.
      Parameters:
      rule - visibility rule controlling when this item is shown
    • getDisplayRule

      public CMSNavigationItem.DisplayRule getDisplayRule()
      Getter for the field displayRule.
      Returns:
      the display rule controlling when this navigation item is shown; defaults to CMSNavigationItem.DisplayRule.ALWAYS
    • setDisplayForUsersOnly

      public void setDisplayForUsersOnly(boolean display)
      setDisplayForUsersOnly.
      Parameters:
      display - true to restrict visibility to logged-in users
    • isDisplayForUsersOnly

      public boolean isDisplayForUsersOnly()
      isDisplayForUsersOnly.
      Returns:
      true if this item is restricted to logged-in users or administrators, false if it is always visible
    • setDisplayForAdminsOnly

      public void setDisplayForAdminsOnly(boolean display)
      setDisplayForAdminsOnly.
      Parameters:
      display - true to restrict visibility to administrators only
    • isDisplayForAdminsOnly

      public boolean isDisplayForAdminsOnly()
      isDisplayForAdminsOnly.
      Returns:
      true if this item is restricted to administrators only, false otherwise
    • setAssociatedTheme

      public void setAssociatedTheme(String associatedTheme)
      Sets the associatedTheme to the given theme, or to null if the given theme is empty or blank.
      Parameters:
      associatedTheme - the theme name to associate with this navigation item, or blank/null to clear the association
    • getAssociatedTheme

      public String getAssociatedTheme()
      Getter for the field associatedTheme.
      Returns:
      the associatedTheme; null if no associated theme exists
    • setOpenInNewWindow

      public void setOpenInNewWindow(boolean openInNewWindow)
      Setter for the field openInNewWindow.
      Parameters:
      openInNewWindow - if the link should open in a new tab/window
    • isOpenInNewWindow

      public boolean isOpenInNewWindow()
      isOpenInNewWindow.
      Returns:
      if the link should open in a new tab/window
    • getMeWithDescendants

      public List<CMSNavigationItem> getMeWithDescendants()
      getMeWithDescendants.
      Returns:
      a list containing this item followed by all of its descendant navigation items
    • isAssociatedWithSubtheme

      public boolean isAssociatedWithSubtheme()
      Returns:
      true if the item links to a cmsPage and that page has a subtheme associated with it.
    • getAssociatedSubtheme

      public String getAssociatedSubtheme()
    • matchesPage

      public boolean matchesPage(String page)
    • isAccessGranted

      public boolean isAccessGranted()
    • checkAccess

      public boolean checkAccess(HttpServletRequest request)
      Parameters:
      request - HTTP servlet request used for access checks
      Returns:
      true if access granted; false otherwise