public class WGContentNavigator
extends java.lang.Object
Utility object to navigate the content hierarchy. The WGContentNavigator in most methods takes a content as parameter and determines a content position in the site hierarchy relative to this content, e.g. the parent content or a sibling content. The return is always a valid and released content object of the same language (except in those cases, where something different is configured - as described below). So this object is used by the navigation elements of WebTML to quickly determine the content links to display.
If a content position does not provide a valid content as requested, the navigator searches further along the given direction (e.g. when searching parent, goes further up the hierarchy, when searching sibling, goes to the nex sibling) and tries to return a valid content from there. If the hierarchy ends in that direction without finding valid content, methods return null.
WGContentNavigator also takes into account visibility settings and automatically ignores contents that are not visible. Therefor the constructor takes a displaytype parameter, telling the navigator to behave like a (WebTML-Navigator), a sitemap or a search, so contents hidden from one of these facilities can be ignored.
Modifier and Type | Class and Description |
---|---|
class |
WGContentNavigator.Iterator |
static interface |
WGContentNavigator.IteratorCreator
Class capable of producing iterators for a content collection
|
Constructor and Description |
---|
WGContentNavigator(java.lang.String displayType,
WGLanguageChooser chooser)
Public constructor for WGContentNavigator.
|
Modifier and Type | Method and Description |
---|---|
WGContent |
chooseRelevantContent(WGContent retrievedContent,
WGContent previewContent)
Chooses the relevant content between a retrieved content, and a content currently previewed as draft, review or archived doc.
|
java.util.List<WGContent> |
collectRelevantContents(WGStructEntryList siblings)
Given a list of struct entry siblings this method retrieves the relevant contents for all siblings.
|
WGContentNavigator.IteratorCreator |
createChildContentIterable(WGContent relContent,
int pageSize)
Creates an
Iterable for the child contents of the given content |
WGContentNavigator.IteratorCreator |
createChildContentIterable(WGContent relContent,
int pageSize,
java.lang.String orderExpression)
Creates an
Iterable for the child contents of the given content |
WGContentNavigator.Iterator |
createContentIterator(WGStructEntryIterator structs)
Creates a content iterator for contents of the struct entries, returned by the given
WGStructEntryIterator
The iterator will choose contents based on the settings in this content navigator. |
WGContentNavigator.IteratorCreator |
createParentContentIterable(WGContent relContent,
int pageSize)
Creates an
Iterable for the parent contents of the given content |
WGContentNavigator.IteratorCreator |
createParentContentIterable(WGContent relContent,
int pageSize,
java.lang.String orderExpression)
Creates an
Iterable for the parent contents of the given content |
WGContentNavigator.IteratorCreator |
createSiblingContentIterable(WGContent relContent,
int pageSize)
Creates an
Iterable for the sibling contents of the given content |
WGContentNavigator.IteratorCreator |
createSiblingContentIterable(WGContent relContent,
int pageSize,
java.lang.String orderExpression)
Creates an
Iterable for the sibling contents of the given content |
WGContent |
getChildContent(WGContent relContent,
int idx)
Returns the nth child content of a parent content with the same language.
|
WGContent |
getChildContent(WGContent relContent,
int idx,
int searchOrder)
Deprecated.
searchOrder argument is ineffective. Use
getChildContent(WGContent, int) instead. |
java.lang.Integer |
getContentLevel(WGContent relContent)
Retrieves the hierarchical level of a content document.
|
java.lang.String |
getDisplayType()
Gets the display type (i.e. role in WebTML), that this content navigator uses to determine contents to show.
|
WGContentList |
getLanguagesContent(WGContent relContent,
boolean includeThisOne)
Returns all available languages for the the given content as content list.
|
WGContent |
getNextSibling(WGContent relContent)
Gets the next siblings content with the same language.
|
WGContent |
getParentContent(WGContent relContent)
Gets the parent content to the given content with the same language.
|
WGContent |
getPreviousSibling(WGContent relContent)
Gets the previous siblings content with the same language.
|
WGContent |
getRelevantContent(WGStructEntry entry)
Returns the "relevant" content of a struct entry.
|
WGContent |
getRootContent(WGArea relArea)
Returns the first root content of an area in the given language.
|
WGContent |
getRootContent(WGContent relContent)
Returns the root content for a given content in the same language
|
WGContent |
getSiblingContent(WGContent relContent,
int idx,
boolean relative)
Returns a sibling content of the given content that is at a certain index position in the siblings list and has the same language.
|
int |
getSiblingsCount(WGContent relContent)
Returns the number of siblings (of the same language) of a content.
|
java.lang.Integer |
getSiblingsIndex(WGContent relContent)
Returns the absolute index position of a given content among its siblings
|
boolean |
hasContentChildren(WGContent relContent)
Returns, if the given context has released child contexts in the same language.
|
boolean |
isOnlyPublished()
Returns if only published contents are to be retrieved
|
void |
setDisplayType(java.lang.String displayType)
Sets the display type (i.e. role in WebTML) that this navigator should use.
|
void |
setOnlyPublished(boolean onlyPublished)
Sets if only published contents are to be retrieved
|
public WGContentNavigator(java.lang.String displayType, WGLanguageChooser chooser) throws WGAPIException
displayType
- The display type (i.e. role in WebTML) this navigator works for. Use constants WGContent.DISPLAYTYPE_...chooser
- A language chooser choosing the relevant language version for pagesWGAPIException
public WGContent getRootContent(WGContent relContent) throws WGAPIException
relContent
- The content to find root content forWGAPIException
public WGContent getRootContent(WGArea relArea) throws WGAPIException
relArea
- The area to search for the first root content.WGAPIException
public WGContent getRelevantContent(WGStructEntry entry) throws WGAPIException
entry
- Entry to search for relevant contentWGAPIException
public java.lang.String getDisplayType()
public void setDisplayType(java.lang.String displayType)
displayType
- The display type. Use constants WGContent.DISPLAYTYPE....public WGContent getSiblingContent(WGContent relContent, int idx, boolean relative) throws WGAPIException
relContent
- The content whose sibling is to be found.idx
- The index position at which to find the sibling.relative
- If true, the index position is regarded relative, i.e. +1 will fetch the next sibling, -1 the previous sibling. If false, the index position is regarded absolute, where 0 denotes the first siblingWGAPIException
public WGContent getPreviousSibling(WGContent relContent) throws WGAPIException
relContent
- The content to find the sibling forWGAPIException
public WGContent getNextSibling(WGContent relContent) throws WGAPIException
relContent
- The content to find the sibling forWGAPIException
public WGContent getChildContent(WGContent relContent, int idx, int searchOrder) throws WGAPIException
getChildContent(WGContent, int)
instead.relContent
- The parent contentidx
- The index position of the needed child content (!= the struct entries position metadata!)searchOrder
- The search order. Use constants WGContent.SEARCHORDER_.... INEFFECTIVE SINCE OPENWGA 6.1WGAPIException
public WGContent getChildContent(WGContent relContent, int idx) throws WGAPIException
relContent
- The parent contentidx
- The index position of the needed child content (!= the struct entries position metadata!), 0 denoting the first oneWGAPIException
public WGContentList getLanguagesContent(WGContent relContent, boolean includeThisOne) throws WGAPIException
relContent
- The content to retrieve languages for.includeThisOne
- If true, the given content will be included in the list, if false won'tWGAPIException
public WGContent getParentContent(WGContent relContent) throws WGAPIException
relContent
- content to find parent forWGAPIException
public java.lang.Integer getSiblingsIndex(WGContent relContent) throws WGAPIException
relContent
- The context, whose index position is evaluatedWGAPIException
public int getSiblingsCount(WGContent relContent) throws WGAPIException
relContent
- The content to find the siblings count for.WGAPIException
public WGContent chooseRelevantContent(WGContent retrievedContent, WGContent previewContent) throws WGAPIException
retrievedContent
- The retrieved content, that under normal conditions should be shownpreviewContent
- The previewed content, that should be shown when the retrieved content is the released version of itWGAPIException
public java.lang.Integer getContentLevel(WGContent relContent) throws WGAPIException
relContent
- The content, whose level is requested.WGAPIException
public boolean hasContentChildren(WGContent relContent) throws WGAPIException
relContent
- WGAPIException
public boolean isOnlyPublished()
public void setOnlyPublished(boolean onlyPublished)
public java.util.List<WGContent> collectRelevantContents(WGStructEntryList siblings) throws WGAPIException
siblings
- The siblings of type WGStructEntry
WGContent
objectsWGAPIException
public WGContentNavigator.Iterator createContentIterator(WGStructEntryIterator structs)
WGStructEntryIterator
The iterator will choose contents based on the settings in this content navigator.structs
- The struct entry iteratorpublic WGContentNavigator.IteratorCreator createChildContentIterable(WGContent relContent, int pageSize) throws WGAPIException
Iterable
for the child contents of the given contentrelContent
- The contentpageSize
- The fetch size for the iterable, determining how many contents will be fetched at onceWGAPIException
public WGContentNavigator.IteratorCreator createChildContentIterable(WGContent relContent, int pageSize, java.lang.String orderExpression) throws WGAPIException
Iterable
for the child contents of the given contentrelContent
- The contentpageSize
- The fetch size for the iterable, determining how many contents will be fetched at onceorderExpression
- A column set expression denoting the order in which to return contents, null for default oder (position, title, both ascending)WGAPIException
public WGContentNavigator.IteratorCreator createSiblingContentIterable(WGContent relContent, int pageSize) throws WGAPIException
Iterable
for the sibling contents of the given contentrelContent
- The contentpageSize
- The fetch size for the iterable, determining how many contents will be fetched at onceWGAPIException
public WGContentNavigator.IteratorCreator createSiblingContentIterable(WGContent relContent, int pageSize, java.lang.String orderExpression) throws WGAPIException
Iterable
for the sibling contents of the given contentrelContent
- The contentpageSize
- The fetch size for the iterable, determining how many contents will be fetched at onceorderExpression
- A column set expression denoting the order in which to return contents, null for default oder (position, title, both ascending)WGAPIException
public WGContentNavigator.IteratorCreator createParentContentIterable(WGContent relContent, int pageSize) throws WGAPIException
Iterable
for the parent contents of the given contentrelContent
- The contentWGAPIException
public WGContentNavigator.IteratorCreator createParentContentIterable(WGContent relContent, int pageSize, java.lang.String orderExpression) throws WGAPIException
Iterable
for the parent contents of the given contentrelContent
- The contentpageSize
- The fetch size for the iterable, determining how many contents will be fetched at onceWGAPIException