Class CMSPageTemplate

java.lang.Object
io.goobi.viewer.model.cms.pages.CMSPageTemplate
All Implemented Interfaces:
IPolyglott, Serializable, Comparable<CMSPageTemplate>

@Entity public class CMSPageTemplate extends Object implements Comparable<CMSPageTemplate>, IPolyglott, Serializable
Template to create a CMSPage. Contains some general information about the template as well as a list of components and sidebar widgets to be included in the page
See Also:
  • Constructor Details

    • CMSPageTemplate

      public CMSPageTemplate()
      Creates a new CMSPage instance.
    • CMSPageTemplate

      public CMSPageTemplate(CMSPageTemplate original)
      Creates a deep copy of the original CMSPage. Only copies persisted properties and performs initialization for them
      Parameters:
      original - template to copy all persistent properties from.
    • CMSPageTemplate

      public CMSPageTemplate(CMSPage original)
  • Method Details

    • initialiseCMSComponents

      public void initialiseCMSComponents(CMSTemplateManager templateManager)
    • hashCode

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

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

      public int compareTo(CMSPageTemplate o)
      Specified by:
      compareTo in interface Comparable<CMSPageTemplate>
    • addSidebarElement

      public void addSidebarElement(CMSSidebarElement element)
      addSidebarElement.
      Parameters:
      element - sidebar widget element to append to the list.
    • getId

      public Long getId()
      Getter for the field id.
      Returns:
      the database primary key of this page template
    • setId

      public void setId(Long id)
      Setter for the field id.
      Parameters:
      id - the database primary key to set
    • getDateCreated

      public LocalDateTime getDateCreated()
      Getter for the field dateCreated.
      Returns:
      the date and time when this page template was created
    • setDateCreated

      public void setDateCreated(LocalDateTime dateCreated)
      Setter for the field dateCreated.
      Parameters:
      dateCreated - the date and time when this page template was created
    • getDateUpdated

      public LocalDateTime getDateUpdated()
    • setDateUpdated

      public void setDateUpdated(LocalDateTime dateUpdated)
      Setter for the field dateUpdated.
      Parameters:
      dateUpdated - the date and time when this page template was last updated
    • isPublished

      public boolean isPublished()
      isPublished.
      Returns:
      true if the publication status is PUBLISHED, false otherwise
    • setPublished

      public void setPublished(boolean published)
      Setter for the field published.
      Parameters:
      published - true sets the publication status to PUBLISHED, false sets it to PRIVATE
    • isUseDefaultSidebar

      public boolean isUseDefaultSidebar()
      isUseDefaultSidebar.
      Returns:
      true if this template uses the default sidebar instead of a custom one, false otherwise
    • setUseDefaultSidebar

      public void setUseDefaultSidebar(boolean useDefaultSidebar)
      Setter for the field useDefaultSidebar.
      Parameters:
      useDefaultSidebar - true if this template should use the default sidebar instead of a custom one
    • getSidebarElements

      public List<CMSSidebarElement> getSidebarElements()
      Getter for the field sidebarElements.
      Returns:
      the list of sidebar elements configured for this template
    • setSidebarElements

      public void setSidebarElements(List<CMSSidebarElement> sidebarElements)
      Setter for the field sidebarElements.
      Parameters:
      sidebarElements - the list of sidebar widget elements to assign to this template
    • addToSidebar

      public void addToSidebar(List<WidgetDisplayElement> widgets)
    • moveUpSidebarElement

      public void moveUpSidebarElement(CMSSidebarElement element)
    • moveDownSidebarElement

      public void moveDownSidebarElement(CMSSidebarElement element)
    • removeSidebarElement

      public void removeSidebarElement(CMSSidebarElement element)
    • containsSidebarElement

      public boolean containsSidebarElement(WidgetDisplayElement widget)
    • getCategories

      public List<CMSCategory> getCategories()
      Getter for the field categories.
      Returns:
      the list of categories assigned to this template
    • setCategories

      public void setCategories(List<CMSCategory> categories)
      Setter for the field categories.
      Parameters:
      categories - list of categories to assign to this template.
    • addCategory

      public void addCategory(CMSCategory category)
      addCategory.
      Parameters:
      category - category to add if not already present.
    • removeCategory

      public void removeCategory(CMSCategory category)
      removeCategory.
      Parameters:
      category - category to remove from this template.
    • getSidebarElementString

      public String getSidebarElementString()
      Getter for the field sidebarElementString.
      Returns:
      the serialized string representation of the sidebar elements
    • setSidebarElementString

      public void setSidebarElementString(String sidebarElementString)
      Setter for the field sidebarElementString.
      Parameters:
      sidebarElementString - the serialized string representation of sidebar elements
    • isLanguageComplete

      public boolean isLanguageComplete(Locale locale)
      isLanguageComplete.
      Parameters:
      locale - locale to check translation completeness for.
      Returns:
      true if the title and all persistent components are complete for the given locale, false otherwise
    • getTitle

      public String getTitle()
      getTitle.
      Returns:
      the CMS page template title in the default language
    • getTitle

      public String getTitle(Locale locale)
      getTitle.
      Parameters:
      locale - locale to retrieve the title translation for.
      Returns:
      the CMS page template title in the given locale
    • getTitleTranslations

      public de.intranda.metadata.multilanguage.IMetadataValue getTitleTranslations()
    • getDescription

      public TranslatedText getDescription()
    • setDescription

      public void setDescription(TranslatedText description)
    • getSubTheme

      public String getSubTheme()
      Getter for the field subTheme.
      Returns:
      the sub-theme name associated with this template, or an empty string if none is set
    • setSubTheme

      public void setSubTheme(String subTheme)
      Setter for the field subTheme.
      Parameters:
      subTheme - the sub-theme name to associate with this template; null is treated as empty string
    • isHasSidebarElements

      public boolean isHasSidebarElements()
      isHasSidebarElements.
      Returns:
      true if this template uses the default sidebar or has at least one custom sidebar element, false otherwise
    • toString

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

      public String getWrapperElementClass()
      Getter for the field wrapperElementClass.
      Returns:
      the wrapperElementClass
    • setWrapperElementClass

      public void setWrapperElementClass(String wrapperElementClass)
      Setter for the field wrapperElementClass.
      Parameters:
      wrapperElementClass - the wrapperElementClass to set
    • writeSelectableCategories

      public void writeSelectableCategories()
      Retrieves all categories fresh from the DAO and write them to this depending on the state of the selectableCategories list. Saving the categories from selectableCategories directly leads to ConcurrentModificationexception when persisting page
    • getSelectableCategories

      public List<Selectable<CMSCategory>> getSelectableCategories() throws DAOException
      Getter for the field selectableCategories.
      Returns:
      the list of all allowed categories wrapped as selectable items, with selection state reflecting current template categories
      Throws:
      DAOException - if any.
    • resetSelectableCategories

      public void resetSelectableCategories()
    • getAdminBackendUrl

      public String getAdminBackendUrl()
    • getPersistentComponents

      public List<PersistentCMSComponent> getPersistentComponents()
    • getComponents

      public List<CMSComponent> getComponents()
    • getAsCMSComponent

      public CMSComponent getAsCMSComponent(PersistentCMSComponent p)
    • removeComponent

      public boolean removeComponent(PersistentCMSComponent component)
    • removeComponent

      public boolean removeComponent(CMSComponent component)
    • addComponent

      public PersistentCMSComponent addComponent(CMSComponent template)
    • isComplete

      public boolean isComplete(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unless IPolyglott.isEmpty(Locale) also returns true.
      Specified by:
      isComplete in interface IPolyglott
      Parameters:
      locale - the locale to check translation completeness for
      Returns:
      true if IPolyglott.isValid(Locale) returns true for the given locale and all fields contain a value which have a value in the default locale. For the default locale, IPolyglott.isComplete(Locale) and IPolyglott.isValid(Locale) are identical. For implementations with only one field, both methods are also always identical
    • isValid

      public boolean isValid(Locale locale)
      Description copied from interface: IPolyglott
      Only meaningful for the default language for which all required fields must be filled.
      Specified by:
      isValid in interface IPolyglott
      Parameters:
      locale - the locale to validate required fields for
      Returns:
      true if all required fields contain a value in the given locale
    • hasSearchFunctionality

      public boolean hasSearchFunctionality()
    • getSearch

      public Optional<SearchFunctionality> getSearch()
    • setComponentOrder

      public void setComponentOrder(CMSComponent component, int order)
      Sets the order attribute of the PersistentCMSComponent belonging to the given CMSComponent to the given order value. Also, sets the order value of all Components which previously had the given order to the order value of the given component
      Parameters:
      component - the CMS component whose order to set
      order - the new order value to assign
    • incrementOrder

      public void incrementOrder(CMSComponent component)
    • decrementOrder

      public void decrementOrder(CMSComponent component)
    • isFirstComponent

      public boolean isFirstComponent(CMSComponent component)
    • isLastComponent

      public boolean isLastComponent(CMSComponent component)
    • isEmpty

      public boolean isEmpty(Locale locale)
      Description copied from interface: IPolyglott
      If this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.
      Specified by:
      isEmpty in interface IPolyglott
      Parameters:
      locale - the locale to check for empty fields
      Returns:
      true if no fields are filled for the given locale
    • getSelectedLocale

      public Locale getSelectedLocale()
      Specified by:
      getSelectedLocale in interface IPolyglott
      Returns:
      the locale currently set by IPolyglott.setSelectedLocale(Locale)
    • setSelectedLocale

      public void setSelectedLocale(Locale locale)
      Description copied from interface: IPolyglott
      Sets the locale to use for display and editing.
      Specified by:
      setSelectedLocale in interface IPolyglott
      Parameters:
      locale - the locale to select
    • isLockComponents

      public boolean isLockComponents()
    • setLockComponents

      public void setLockComponents(boolean lockComponents)
    • isLegacyTemplate

      public boolean isLegacyTemplate()
    • setLegacyTemplate

      public void setLegacyTemplate(boolean legacyTemplate)
    • addComponent

      public PersistentCMSComponent addComponent(String filename, CMSTemplateManager templateManager) throws IllegalArgumentException, IllegalStateException
      Throws:
      IllegalArgumentException
      IllegalStateException
    • isContainsPagedComponents

      public boolean isContainsPagedComponents()
    • getName

      public String getName()
    • setTitleTranslations

      public void setTitleTranslations(TranslatedText title)