Package io.goobi.viewer.managedbeans
Class DynamicCollectionsBean
java.lang.Object
io.goobi.viewer.managedbeans.DynamicCollectionsBean
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckQuery(AjaxBehaviorEvent event) AJAX listener (fired on blur of the Solr query field) that computes the hit count of the current query.voidPrepares a blank dynamic collection for creation.voiddeleteCollection(DynamicCollection collection) deleteCollection.Deletes the currently edited collection and returns to the overview page.getCollectionName.Getter for the fieldcollections.Getter for the fieldcurrentCollection.getCurrentDescription(String language) getCurrentDescription.getCurrentLabel(String language) getCurrentLabel.getSearchUrl(DynamicCollection collection) Builds the search-result URL listing the records of the given collection.voidSets the value ofimageModedepending on the properties ofcurrentCollection.booleanChecks the current collection for validity.booleanWhether the current collection carries a non-blank label for every supported language.booleanisDirty()voidReloads the collection list from the database, reporting DAO errors instead of propagating them.resetCurrentCollection.saveCurrentCollection.voidsetCollectionName(String name) Loads the existing dynamic collection with the given name for editing.voidsetCurrentCollection(DynamicCollection currentCollection) Setter for the fieldcurrentCollection.voidvoidupdateCollections.voidvalidateIdentifier(FacesContext context, UIComponent comp, Object value) Validates the collection identifier entered in the edit form: it must be non-blank, matchIDENTIFIER_PATTERN(URL-safe characters only), not be the reserved placeholder, and be unique among dynamic collections.voidvalidatePI(FacesContext context, UIComponent comp, Object value) validatePI.static booleanvalidatePI(String pi) Checks whether the given PI matches a known record in the Solr index.
-
Constructor Details
-
DynamicCollectionsBean
public DynamicCollectionsBean()Creates a new DynamicCollectionsBean instance.
-
-
Method Details
-
updateCollections
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
Getter for the fieldcollections.- Returns:
- the list of all dynamic collections
-
getCurrentCollection
Getter for the fieldcurrentCollection.- Returns:
- the dynamic collection currently being edited
-
setCurrentCollection
Setter for the fieldcurrentCollection.- Parameters:
currentCollection- the dynamic collection to set as the currently selected collection
-
setCollectionName
Loads the existing dynamic collection with the given name for editing. Called by the edit pretty-URL route. New collections are created viacreateNewCollection()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
getCollectionName.- Returns:
- the name of the current collection, or the placeholder value if none/blank
-
getCurrentLabel
getCurrentLabel.- Parameters:
language- ISO language code to retrieve the label for- Returns:
- the label translation of the current collection for the given language
-
getCurrentDescription
getCurrentDescription.- Parameters:
language- ISO language code to retrieve the description for- Returns:
- the description translation of the current collection for the given language
-
saveCurrentCollection
saveCurrentCollection.- Returns:
- the pretty URL name for the collections overview after saving the current collection
- Throws:
DAOException- if any.
-
resetCurrentCollection
resetCurrentCollection.- Returns:
- the pretty URL name for the collections overview after discarding changes to the current collection
-
deleteCollection
deleteCollection.- Parameters:
collection- collection to delete from the database- Throws:
DAOException- if any.
-
deleteCurrentCollection
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, matchIDENTIFIER_PATTERN(URL-safe characters only), not be the reserved placeholder, and be unique among dynamic collections.- Parameters:
context- current JSF faces contextcomp- UI component that triggered the validationvalue- 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 contextcomp- UI component that triggered the validationvalue- PI value submitted by the user- Throws:
ValidatorException- if any.
-
validatePI
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
-
initImageMode
public void initImageMode()Sets the value ofimageModedepending on the properties ofcurrentCollection. -
isDirty
public boolean isDirty()- Returns:
- true if the current collection has unsaved edits compared to the persisted state
-
checkQuery
AJAX listener (fired on blur of the Solr query field) that computes the hit count of the current query. Only runs when the field'ssolrQueryValidatorhas already accepted the syntax, so a syntax error is reported by the validator, not here.- Parameters:
event- the AJAX behavior event
-
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
Builds the search-result URL listing the records of the given collection. The collection is passed as the activeDC_DYNAMICfacet, 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
-