Package io.goobi.viewer.model.cms
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the visibility rules that determine for which users a navigation item is rendered. -
Constructor Summary
ConstructorsConstructorDescriptionEmpty constructor.CMSNavigationItem(CMSNavigationItem original) Created a copy of the passed item ignoring all data concerning the item hierarchy (order, child and parent items).CMSNavigationItem(CMSPage cmsPage) Creates a new CMSNavigationItem instance.CMSNavigationItem(String targetUrl, String label) Creates a new CMSNavigationItem instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChildItem(CMSNavigationItem child) addChildItem.booleancheckAccess(HttpServletRequest request) intbooleangetActiveChildItems(HttpServletRequest request) Getter for the fieldassociatedTheme.Getter for the fieldchildItems.Getter for the fieldcmsPage.Getter for the fielddisplayRule.getId()Getter for the fieldid.Getter for the fielditemLabel.intgetLevel()Returns the hierarchy level of this item, i.e. the number of ancestor itemsgetMeWithDescendants.getNavigationUrl.getOrder()Getter for the fieldorder.Getter for the fieldpageUrl.Getter for the fieldparentItem.Getter for the fieldsortingListId.booleanhasCmsPage.booleanhasDeletedCmsPage.inthashCode()booleanhasUnpublishedCmsPage.booleanisAbsoluteLink.booleanbooleanbooleanisDisplayForAdminsOnly.booleanisDisplayForUsersOnly.booleanisOpenInNewWindow.booleanisShouldDisplay.booleanisValid()isValid.booleanisVisible.booleanmatchesLabel(String currentPage) Check to highlight this item as 'currentPage'.booleanmatchesPage(String page) voidremoveChildItem(CMSNavigationItem child) removeChildItem.voidsetAbsoluteLink(boolean absoluteLink) Setter for the fieldabsoluteLink.voidsetAssociatedTheme(String associatedTheme) Sets theassociatedThemeto the given theme, or to null if the given theme is empty or blank.voidsetChildItems(List<CMSNavigationItem> childItems) Setter for the fieldchildItems.voidsetCmsPage(CMSPage cmsPage) Setter for the fieldcmsPage.voidsetDisplayForAdminsOnly(boolean display) setDisplayForAdminsOnly.voidsetDisplayForUsersOnly(boolean display) setDisplayForUsersOnly.voidSetter for the fielddisplayRule.voidSetter for the fieldid.voidsetItemLabel(String itemLabel) Setter for the fielditemLabel.voidsetOpenInNewWindow(boolean openInNewWindow) Setter for the fieldopenInNewWindow.voidSetter for the fieldorder.voidsetPageUrl(String pageUrl) Setter for the fieldpageUrl.voidsetParentItem(CMSNavigationItem parentItem) Setter for the fieldparentItem.voidsetSortingListId(Integer sortingListId) Setter for the fieldsortingListId.toString()
-
Constructor Details
-
CMSNavigationItem
public CMSNavigationItem()Empty constructor. -
CMSNavigationItem
Creates a new CMSNavigationItem instance.- Parameters:
targetUrl- relative or absolute URL this item points tolabel- display label for this navigation item
-
CMSNavigationItem
Creates a new CMSNavigationItem instance.- Parameters:
cmsPage- CMS page this navigation item links to
-
-
Method Details
-
hashCode
public int hashCode() -
equals
-
getId
Getter for the fieldid.- Returns:
- the database primary key of this navigation item, or null if not persisted
-
setId
Setter for the fieldid.- Parameters:
id- database primary key for this navigation item
-
getItemLabel
Getter for the fielditemLabel.- Returns:
- the display label for this navigation item, using the CMS page menu title if linked
-
setItemLabel
Setter for the fielditemLabel.- Parameters:
itemLabel- display label for this navigation item
-
getOrder
Getter for the fieldorder.- Returns:
- the sort position of this navigation item within its parent or the top-level menu
-
setOrder
Setter for the fieldorder.- Parameters:
order- the sort position of this navigation item within its parent or the top-level menu
-
getParentItem
Getter for the fieldparentItem.- Returns:
- the parent navigation item, or null if this is a top-level item
-
getChildItems
Getter for the fieldchildItems.- Returns:
- a list of direct child navigation items of this item
-
setChildItems
Setter for the fieldchildItems.- Parameters:
childItems- list of child navigation items to set
-
getActiveChildItems
- Returns:
- Visible child items
-
getActiveChildItems
- Parameters:
request- HTTP servlet request used for access checks- Returns:
- Visible child items
-
getCmsPage
Getter for the fieldcmsPage.- Returns:
- the CMS page this navigation item links to, or null if none is set
-
setCmsPage
Setter for the fieldcmsPage.- Parameters:
cmsPage- CMS page this navigation item links to
-
getPageUrl
Getter for the fieldpageUrl.- Returns:
- the relative URL path for this navigation item, using the linked CMS page URL if available
-
setPageUrl
Setter for the fieldpageUrl.- 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
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
Getter for the fieldsortingListId.- Returns:
- the temporary ID used to identify this item in the navigation menu hierarchy
-
setSortingListId
Setter for the fieldsortingListId.- 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 fieldabsoluteLink.- 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
-
getDisplayRule
Getter for the fielddisplayRule.- 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
Sets theassociatedThemeto 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
Getter for the fieldassociatedTheme.- Returns:
- the associatedTheme; null if no associated theme exists
-
setOpenInNewWindow
public void setOpenInNewWindow(boolean openInNewWindow) Setter for the fieldopenInNewWindow.- 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
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
-
matchesPage
-
isAccessGranted
public boolean isAccessGranted() -
checkAccess
- Parameters:
request- HTTP servlet request used for access checks- Returns:
- true if access granted; false otherwise
-