Class PageContentUtils

java.lang.Object
ch.tocco.nice2.optional.cms.impl.utils.PageContentUtils

public final class PageContentUtils extends Object
This utility provides static methods to "navigate" around in the page content entity structure. Entity structure of the page content: Page +- relContent (to 1 Page_content, Reverse: relContent_page) +- relContent_published (to 1 Page_content, Reverse: relContent_published_page) Page_content +- relPage_content_to_section (to n Page_content_to_section) Page_content_to_section +- container_name (String) +- position (Integer, position of this section within the container) +- relSection (to 1 Section)
  • Method Details

    • getPageByPublishedSection

      public static Optional<Entity> getPageByPublishedSection(Entity section)
      Resolve Page from published Section. The Page has two relations to Page_content. One for the published (frozen) content and one to edit. We assume that the given Section entity is a published section and try to resolve the page by going the relation relContent_published_page up to the page. If Optional.empty() is returned, the given section must have been a section entity to edit and getPageByEditSection(Entity) might resolve the page successfully.
      Parameters:
      section - The published Section entity to find the Page entity for.
      Returns:
      the Page entity if the given entity was a published section or Optional.empty().
      See Also:
    • getPageByEditSection

      public static Optional<Entity> getPageByEditSection(Entity section)
      Resolve Page from Section to edit. The Page has two relations to Page_content. One for the published (frozen) content and one to edit. We assume that the given Section entity is a section to edit and try to resolve the page by going the relation relContent_page up to the page. If Optional.empty() is returned, the given section must have been a published section entity and getPageByPublishedSection(Entity) might resolve the page successfully.
      Parameters:
      section - The "edit" Section entity to find the Page entity for.
      Returns:
      the Page entity if the given entity was a section to edit or Optional.empty().
      See Also:
    • getPageByPageContent

      public static Optional<PageContentUtils.PageResolveResult> getPageByPageContent(Entity pageContent)
      Resolve Page from Page_content. The Page has two relations to Page_content. One for the published (frozen) content and one to edit. We try both relations up to the Page (one of them must resolve successfully)
      Parameters:
      pageContent - The Page_content entity to find the Page entity for.
      Returns:
      the page entity and the information if the given Page_content entity was the published content or the one to edit.
    • getPageByPublishedContent

      public static Optional<Entity> getPageByPublishedContent(Entity pageContent)
      Resolve Page from published Page_content. The Page has two relations to Page_content. One for the published (frozen) content and one to edit. We assume that the given Page_content entity is the published Page_content and try to resolve the page by going this relation (relContent_published_page) up to the page. If Optional.empty() is returned, the given page content must have been the content entity to edit and getPageByEditContent(Entity) might resolve the page successfully.
      Parameters:
      pageContent - The published Page_content entity to find the Page entity for.
      Returns:
      the Page entity if the given entity was the published content or Optional.empty().
      See Also:
    • getPageByEditContent

      public static Optional<Entity> getPageByEditContent(Entity pageContent)
      Resolve Page from "edit" Page_content. The Page has two relations to Page_content. One for the published (frozen) content and one to edit. We assume that the given Page_content entity is the Page_content to edit and try to resolve the page by going this relation (relContent_page) up to the page. If Optional.empty() is returned, the given page content must have been a published content entity and getPageByPublishedContent(Entity) might resolve the page successfully.
      Parameters:
      pageContent - The edit Page_content entity to find the Page entity for.
      Returns:
      the Page entity if the given entity was the edit content or Optional.empty().
      See Also:
    • getPageContentBySection

      public static Optional<Entity> getPageContentBySection(Entity section)
      Resolve Page_content from Section. ยง
      Parameters:
      section - The Section entity to find the Page_content entity for.
      Returns:
      the Page_content entity for the given entity (must be exactly one).
    • getPageContentByContentToSection

      public static Entity getPageContentByContentToSection(Entity contentToSection)
      Resolve Page_content from Page_content_to_section.
      Parameters:
      contentToSection - The Page_content_to_section entity to find the Page_content entity for.
      Returns:
      the Page_content entity for the given entity (must be exactly one).
    • getContentToSectionBySection

      public static Optional<Entity> getContentToSectionBySection(Entity section)
      Resolve Page_content_to_section from Section.
      Parameters:
      section - The Section entity to find the Page_content_to_section entity for.
      Returns:
      the Page_content_to_section entity for the given entity (must be exactly one or none (in case of a snippet section)).
    • getSectionByContentToSection

      public static Entity getSectionByContentToSection(Entity contentToSection)
      Resolve Section from Page_content_to_section (either direct or via snippet).
      Parameters:
      contentToSection - The Page_content_to_section entity to find the Section entity for.
      Returns:
      the resolved Section entity.
    • getContentToSectionByContent

      public static EntityList getContentToSectionByContent(Entity content)
      Resolve Page_content_to_section entities which are linked to a Page_content (ordered by position)
      Parameters:
      content - The Page_content entity to find the Page_content_to_section entities for.
      Returns:
      the linked Page_content_to_section entities.