Class DynamicCollectionsBean

java.lang.Object
io.goobi.viewer.managedbeans.DynamicCollectionsBean
All Implemented Interfaces:
Serializable

@Named @SessionScoped public class DynamicCollectionsBean extends Object implements Serializable
Bean handling administration of database-defined dynamic collections. Each dynamic collection carries a unique name, a multilingual description, an arbitrary Solr query defining its contents, and a representative image. Modeled on CmsCollectionsBean but managing a flat list.
See Also:
  • Constructor Details

    • DynamicCollectionsBean

      public DynamicCollectionsBean()
      Creates a new DynamicCollectionsBean instance.
  • Method Details

    • updateCollections

      public void updateCollections() throws DAOException
      updateCollections.
      Throws:
      DAOException - if any.
    • reloadCollections

      public void reloadCollections()
      Reloads the collection list from the database, reporting DAO errors instead of propagating them.

      Invoked when the collections overview page is opened, because this bean is session scoped: collection labels are written directly to the database by the translations editor, and other editors may change collections concurrently.

    • getCollections

      public List<DynamicCollection> getCollections()
      Getter for the field collections.
      Returns:
      the list of all dynamic collections
    • getCurrentCollection

      public DynamicCollection getCurrentCollection()
      Getter for the field currentCollection.
      Returns:
      the dynamic collection currently being edited
    • setCurrentCollection

      public void setCurrentCollection(DynamicCollection currentCollection)
      Setter for the field currentCollection.
      Parameters:
      currentCollection - the dynamic collection to set as the currently selected collection
    • setCollectionName

      public void setCollectionName(String name) throws DAOException
      Loads the existing dynamic collection with the given name for editing. Called by the edit pretty-URL route. New collections are created via createNewCollection() instead, so this never treats any name as a "create new" sentinel.
      Parameters:
      name - unique name of the collection to load
      Throws:
      DAOException - if any.
    • createNewCollection

      public void createNewCollection()
      Prepares a blank dynamic collection for creation. Called by the "new collection" pretty-URL route.
    • getCollectionName

      public String getCollectionName()
      getCollectionName.
      Returns:
      the name of the current collection, or the placeholder value if none/blank
    • getCurrentLabel

      public DynamicCollectionTranslation getCurrentLabel(String language)
      getCurrentLabel.
      Parameters:
      language - ISO language code to retrieve the label for
      Returns:
      the label translation of the current collection for the given language
    • getCurrentDescription

      public DynamicCollectionTranslation getCurrentDescription(String language)
      getCurrentDescription.
      Parameters:
      language - ISO language code to retrieve the description for
      Returns:
      the description translation of the current collection for the given language
    • saveCurrentCollection

      public String saveCurrentCollection() throws DAOException
      saveCurrentCollection.
      Returns:
      the pretty URL name for the collections overview after saving the current collection
      Throws:
      DAOException - if any.
    • resetCurrentCollection

      public String resetCurrentCollection()
      resetCurrentCollection.
      Returns:
      the pretty URL name for the collections overview after discarding changes to the current collection
    • deleteCollection

      public void deleteCollection(DynamicCollection collection) throws DAOException
      deleteCollection.
      Parameters:
      collection - collection to delete from the database
      Throws:
      DAOException - if any.
    • deleteCurrentCollection

      public String deleteCurrentCollection() throws DAOException
      Deletes the currently edited collection and returns to the overview page. Used by the delete button on the edit page.
      Returns:
      pretty URL outcome of the dynamic collections overview
      Throws:
      DAOException - if any.
    • validateIdentifier

      public void validateIdentifier(FacesContext context, UIComponent comp, Object value) throws ValidatorException
      Validates the collection identifier entered in the edit form: it must be non-blank, match IDENTIFIER_PATTERN (URL-safe characters only), not be the reserved placeholder, and be unique among dynamic collections.
      Parameters:
      context - current JSF faces context
      comp - UI component that triggered the validation
      value - identifier value submitted by the user
      Throws:
      ValidatorException - if the identifier is invalid
    • isCurrentCollectionValid

      public boolean isCurrentCollectionValid()
      Checks the current collection for validity. Currently only checks whether a possibly entered PI exists in Solr.
      Returns:
      true if the current collection is valid, false otherwise
    • validatePI

      public void validatePI(FacesContext context, UIComponent comp, Object value) throws ValidatorException
      validatePI.
      Parameters:
      context - current JSF faces context
      comp - UI component that triggered the validation
      value - PI value submitted by the user
      Throws:
      ValidatorException - if any.
    • validatePI

      public static boolean validatePI(String pi) throws IndexUnreachableException, PresentationException
      Checks whether the given PI matches a known record in the Solr index. An empty PI is treated as valid (no representative record set).
      Parameters:
      pi - persistent identifier to look up in the Solr index
      Returns:
      true if the PI is blank or matches a known record; false otherwise
      Throws:
      IndexUnreachableException - if any.
      PresentationException - if any.
    • getImageMode

    • setImageMode

      public void setImageMode(CmsCollectionsBean.CMSCollectionImageMode imageMode)
    • initImageMode

      public void initImageMode()
      Sets the value of imageMode depending on the properties of currentCollection.
    • isDirty

      public boolean isDirty()
      Returns:
      true if the current collection has unsaved edits compared to the persisted state
    • checkQuery

      public void checkQuery(AjaxBehaviorEvent event)
      AJAX listener (fired on blur of the Solr query field) that computes the hit count of the current query. Only runs when the field's solrQueryValidator has already accepted the syntax, so a syntax error is reported by the validator, not here.
      Parameters:
      event - the AJAX behavior event
    • getQueryHitCount

      public Long getQueryHitCount()
      Returns:
      the hit count computed on page load or by the last checkQuery(AjaxBehaviorEvent) call, or null if not evaluated / query empty
    • isCurrentLabelsComplete

      public boolean isCurrentLabelsComplete()
      Whether the current collection carries a non-blank label for every supported language. Used by the translation hint in the edit page sidebar.
      Returns:
      true if all label translations are filled (or no collection is loaded); false otherwise
    • getSearchUrl

      public String getSearchUrl(DynamicCollection collection)
      Builds the search-result URL listing the records of the given collection. The collection is passed as the active DC_DYNAMIC facet, so the search shows it as the selected collection, matching the links of the collection listings in the frontend.
      Parameters:
      collection - collection to build the search URL for
      Returns:
      an absolute search page URL listing the collection's records