Class CmsCollectionsBean

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

@Named @SessionScoped public class CmsCollectionsBean extends Object implements Serializable
Bean handling CMS settings for collections.
Author:
Florian Alpers
See Also:
  • Constructor Details

    • CmsCollectionsBean

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

    • isDisplayTranslationWidget

      public boolean isDisplayTranslationWidget()
      Returns:
      true if the if translations for the values of solrField are not or only partially translated; false if they are fully translated
    • isDisplayTranslationWidgetEdit

      public boolean isDisplayTranslationWidgetEdit()
      Returns:
      true if the if translations for the values of solrField and solrFieldValue are not or only partially translated; false if they are fully translated
    • isDisplaySolrFieldSelectionWidget

      public boolean isDisplaySolrFieldSelectionWidget()
      Returns:
      true if there is more than one source option (configured collection fields plus the dynamic collections entry); false otherwise
    • getMessageEntryForFieldValue

      public MessageEntry getMessageEntryForFieldValue()
      Returns the MessageEntry representing existing translations for the current value of solrFieldValue. Use for the info widget in the collection administration.
      Returns:
      MessageEntry containing the translations for solrFieldValue; empty MessageEntry if none found
    • isDisplayImportDescriptionsWidget

      public boolean isDisplayImportDescriptionsWidget()
      Returns:
      true keys with description suffix found; false otherwise
    • importDescriptionsAction

      public String importDescriptionsAction(String solrField) throws DAOException
      Parameters:
      solrField - Solr field whose collection descriptions to import
      Returns:
      empty string
      Throws:
      DAOException
    • getCurrentCollection

      public CMSCollection getCurrentCollection()
      Getter for the field currentCollection.
      Returns:
      the currently selected CMS collection being edited
    • setCurrentCollection

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

      public String getSolrField()
      Getter for the field solrField.
      Returns:
      the Solr field name used to group and display collections
    • setSolrField

      public void setSolrField(String solrField)
      Setter for the field solrField.
      Parameters:
      solrField - the Solr field name used to group and display collections
    • isDynamicCollectionsSource

      public boolean isDynamicCollectionsSource()
      Whether the collection source dropdown is set to the database-defined dynamic collections instead of a Solr field.
      Returns:
      true if the SolrConstants.DC_DYNAMIC pseudo field is selected as the collection source; false otherwise
    • selectDynamicCollectionsSource

      public void selectDynamicCollectionsSource()
      Selects the database-defined dynamic collections as the collection source, so that the collection listing shows them without the user having to switch the source in the sidebar.
    • getSourceSelectItems

      public List<SelectItem> getSourceSelectItems()
      Options for the collection source dropdown: all configured collection Solr fields plus the dynamic collections pseudo field. The dynamic entry only appears once at least one dynamic collection exists (or while it is the selected source, so the selection stays valid after the last collection is deleted).
      Returns:
      the source options for the sidebar widget
    • isDynamicSourceObsolete

      public boolean isDynamicSourceObsolete()
      Whether the dynamic collections source is selected although no dynamic collections exist any more, e.g. after deleting the last one.
      Returns:
      true if the selected source is no longer available; false otherwise
    • getDefaultCollectionField

      public String getDefaultCollectionField()
      Collection source to fall back to when the selected source is no longer available.
      Returns:
      the first configured collection field; SolrConstants.DC if none are configured
    • getSolrFieldValue

      public String getSolrFieldValue()
      Getter for the field solrFieldValue.
      Returns:
      the value of the Solr field identifying the current collection
    • setSolrFieldValue

      public void setSolrFieldValue(String solrFieldValue)
      Setter for the field solrFieldValue.
      Parameters:
      solrFieldValue - the value of the Solr field identifying the current collection
    • getCollectionName

      public String getCollectionName()
    • setCollectionName

      public void setCollectionName(String collectionName) throws DAOException
      Loads existing or creates a new CMSCollection for the current solrfield and the given collectionName.
      Parameters:
      collectionName - Collection field value
      Throws:
      DAOException
    • getEditCollectionName

      public String getEditCollectionName()
    • setEditCollectionName

      public void setEditCollectionName(String editCollectionName)
    • getCollectionEditView

      public String getCollectionEditView()
      DynaView method for the collection edit pretty-URL: dynamic collections and Solr field collections share the same URL but are edited on different views.
      Returns:
      the view id matching the type of the collection addressed by editCollectionName
    • openCollectionForEditing

      public void openCollectionForEditing() throws DAOException
      Loads the collection addressed by editCollectionName for editing, delegating to DynamicCollectionsBean if a dynamic collection with that name exists. The name is taken from the field instead of an action parameter because the pretty-URL action runs in the DynaView-dispatched request, where path parameters can no longer be resolved from the URL.
      Throws:
      DAOException
    • getAllCollectionFields

      public List<String> getAllCollectionFields()
      getAllCollectionFields.
      Returns:
      a list of all configured collection Solr field names
    • getCollections

      public List<CMSCollection> getCollections()
      Getter for the field collections.
      Returns:
      the list of all CMS collections for the currently selected Solr field
    • updateCollections

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

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

      public String editCollection(CMSCollection collection)
      editCollection.
      Parameters:
      collection - collection to set as current and prepare for editing
      Returns:
      the pretty URL name for the collection edit view
    • getCurrentLabel

      public CMSCollectionTranslation 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 CMSCollectionTranslation 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() throws DAOException
      resetCurrentCollection.
      Returns:
      the pretty URL name for the collections overview after discarding changes to the current collection
      Throws:
      DAOException - if any.
    • isCurrentCollectionValid

      public boolean isCurrentCollectionValid()
      Checks the current collection for validity. Currently only checks if a possibly entered PI exists in the solr
      Returns:
      true if the current collection is valid (i.e. any configured representative work PI exists in Solr), 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 if the given pi matches a known PI in the solr index. If the pi is empty, true is returned to allow not setting any pi
      Parameters:
      pi - persistent identifier to look up in the Solr index
      Returns:
      false if no current collection is set, the pi does not match any known work
      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.
    • getCurrentTab

      public CMSCollectionTreeTab getCurrentTab()
    • setCurrentTab

      public void setCurrentTab(CMSCollectionTreeTab currentTab)
    • loadCollection

      public void loadCollection(String field) throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, IndexUnreachableException
      Initializes the collection tree for the given index field name.
      Parameters:
      field - Solr field name to load the collection for
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      IndexUnreachableException
    • initSolrField

      public void initSolrField() throws de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException, IndexUnreachableException
      Initializes the collection tree for the current solrField, but only if not yet loaded.
      Throws:
      de.unigoettingen.sub.commons.contentlib.exceptions.IllegalRequestException
      IndexUnreachableException
    • isDirty

      public boolean isDirty()
    • getSearchUrl

      public String getSearchUrl(CMSCollection collection)