Class AbstractBuilder
java.lang.Object
io.goobi.viewer.model.iiif.presentation.v2.builder.AbstractBuilder
- Direct Known Subclasses:
CollectionBuilder,LayerBuilder,ManifestBuilder,SequenceBuilder,StructureBuilder
Abstract base class for IIIF Presentation API v2 resource builders, providing shared URI construction and metadata helpers.
- Author:
- Florian Alpers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Configurationprotected static final String[]ConstantREQUIRED_SOLR_FIELDS.protected final AbstractApiUrlManagerConstantUGC_SOLR_FIELDS. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractBuilder(AbstractApiUrlManager apiUrlManager) Creates a new AbstractBuilder instance.protectedAbstractBuilder(AbstractApiUrlManager apiUrlManager, Configuration config) Creates a new AbstractBuilder instance. -
Method Summary
Modifier and TypeMethodDescriptionabsolutize(String uri) absolutize(URI uri) voidaddCrowdourcingAnnotations(List<de.intranda.api.iiif.presentation.v2.Canvas2> canvases, Map<Integer, List<de.intranda.api.annotation.oa.OpenAnnotation>> crowdsourcingAnnotations, Map<de.intranda.api.iiif.presentation.enums.AnnotationType, List<de.intranda.api.iiif.presentation.v2.AnnotationList>> annotationMap) Adds the annotations from the crowdsourcingAnnotations map to the respective canvases in the canvases list as well as to the given annotationMap.protected voidaddEventMetadataToWorkElement(List<StructElement> eles, List<org.apache.solr.common.SolrDocument> events) Adds all metadata from the given events to the first work document contained in eles.addLanguageFields(List<String> displayFields, List<Locale> locales) voidaddMetadata(de.intranda.api.iiif.presentation.v2.AbstractPresentationModelElement2 manifest, StructElement ele) addMetadata.addRendering(LinkingProperty.LinkingTarget target, de.intranda.metadata.multilanguage.IMetadataValue label) addSeeAlso(LinkingProperty.LinkingTarget target, de.intranda.metadata.multilanguage.IMetadataValue label) protected booleanReturn true if the field is contained in displayFields, accounting for wildcard characters.getAnnotationListURI(String pi, int pageNo, de.intranda.api.iiif.presentation.enums.AnnotationType type, boolean openAnnotation) getAnnotationListURI.getAnnotationListURI(String pi, de.intranda.api.iiif.presentation.enums.AnnotationType type) getAnnotationListURI.getAnnotationURI.getAnnotationURI(String pi, int order, de.intranda.api.iiif.presentation.enums.AnnotationType type, int annoNum) getAnnotationURI.protected List<de.intranda.metadata.multilanguage.IMetadataValue> Gets the attribution text configured in webapi.iiif.attribution and returns all translations if any are found, or the configured string itself otherwise.Get URL to auto complete service fromApiUrls.getAutoSuggestURI(String pi, String query, List<String> motivation) getAutoSuggestURI.getCanvasURI(String pi, int pageNo) getCanvasURI.getCollectionURI(String collectionField, String baseCollectionName) getCollectionURI.getCommentAnnotationURI(long id) getCommentAnnotationURI.protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getDescription.getDocument(String pi) getDocument.Queries all DocStructs which have the given PI as PI_TOPSTRUCT or anchor (or are the anchor themselves).getEventFields.getImageAnnotationURI(String pi, int order) getImageAnnotationURI.protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getLabel(StructElement ele) getDescription.protected de.intranda.metadata.multilanguage.IMetadataValueOptional<de.intranda.metadata.multilanguage.IMetadataValue> getLabelIfExists(org.apache.solr.common.SolrDocument solrDocument) Simple method to create a label for aSolrDocumentfromSolrConstants.LABEL,SolrConstants.TITLEorSolrConstants.DOCSTRCT.getLayerURI(String pi, de.intranda.api.iiif.presentation.enums.AnnotationType type) getLayerURI.getLidoResolverUrl.protected LocalegetLocale.getManifestURI(String pi) getManifestURI.getManifestURI(String pi, BuildMode mode) getManifestURI.getMetsResolverUrl.getPageManifestURI(String pi, int pageNo) getManifestURI for page.Get the page order (1-based) from a canvas URI.getPIFromCanvasURI(URI uri) Get the persistent identifier from a canvas URI.getRangeURI(String pi, String logId) getRangeURI.Get URL to search service fromApiUrls.getSearchURI(String pi, String query, List<String> motivation) getSearchURI.getSequenceURI(String pi, String label) getSequenceURI.getSolrFieldList.getViewUrl(PhysicalElement ele, PageType pageType) getViewUrl.
-
Field Details
-
REQUIRED_SOLR_FIELDS
ConstantREQUIRED_SOLR_FIELDS. -
urls
ConstantUGC_SOLR_FIELDS. -
config
-
-
Constructor Details
-
AbstractBuilder
Creates a new AbstractBuilder instance.- Parameters:
apiUrlManager- API URL manager for building IIIF resource URIs
-
AbstractBuilder
Creates a new AbstractBuilder instance.- Parameters:
apiUrlManager- API URL manager for building IIIF resource URIsconfig- viewer configuration instance
-
-
Method Details
-
getLabel
- Parameters:
value- message key or literal string to translate- Returns:
IMetadataValue
-
absolutize
- Parameters:
uri- the URI to make absolute; returned unchanged if already absolute- Returns:
URI
-
absolutize
-
getLocale
getLocale.- Parameters:
language- BCP 47 language tag string- Returns:
- the Locale for the given language tag, defaulting to English if not resolvable
-
getMetsResolverUrl
getMetsResolverUrl.- Parameters:
ele- structure element whose PI is used to build the URL- Returns:
- METS resolver link for the DFG Viewer
-
getLidoResolverUrl
getLidoResolverUrl.- Parameters:
ele- structure element whose PI is used to build the URL- Returns:
- LIDO resolver link for the DFG Viewer
-
getViewUrl
getViewUrl.- Parameters:
ele- physical page element whose PURL part is appended to the URLpageType- page type determining the viewer URL prefix- Returns:
- viewer url for the given page in the given
PageType
-
getLabelIfExists
public Optional<de.intranda.metadata.multilanguage.IMetadataValue> getLabelIfExists(org.apache.solr.common.SolrDocument solrDocument) Simple method to create a label for aSolrDocumentfromSolrConstants.LABEL,SolrConstants.TITLEorSolrConstants.DOCSTRCT.- Parameters:
solrDocument- Solr document to extract label information from- Returns:
- an Optional containing the label derived from LABEL, TITLE, or DOCSTRCT fields, or empty if none are present
-
addMetadata
public void addMetadata(de.intranda.api.iiif.presentation.v2.AbstractPresentationModelElement2 manifest, StructElement ele) addMetadata.- Parameters:
manifest- IIIF presentation element to attach metadata toele- structure element providing the metadata values
-
addCrowdourcingAnnotations
public void addCrowdourcingAnnotations(List<de.intranda.api.iiif.presentation.v2.Canvas2> canvases, Map<Integer, List<de.intranda.api.annotation.oa.OpenAnnotation>> crowdsourcingAnnotations, Map<de.intranda.api.iiif.presentation.enums.AnnotationType, List<de.intranda.api.iiif.presentation.v2.AnnotationList>> annotationMap) Adds the annotations from the crowdsourcingAnnotations map to the respective canvases in the canvases list as well as to the given annotationMap.- Parameters:
canvases- The list of canvases which should receive the annotations as otherContentcrowdsourcingAnnotations- A map of annotations by page numberannotationMap- A global annotation map for a whole manifest; may be null if not needed
-
contained
Return true if the field is contained in displayFields, accounting for wildcard characters.- Parameters:
field- Solr field name to look updisplayFields- list of configured display field names (may contain wildcards)- Returns:
- true if displayFields contains field; false otherwise
-
addLanguageFields
- Parameters:
displayFields- list of base Solr field names to expandlocales- locales for which language-specific field variants should be added- Returns:
- List
(immutable!)
-
getDocumentWithChildren
public List<StructElement> getDocumentWithChildren(String pi) throws PresentationException, IndexUnreachableException Queries all DocStructs which have the given PI as PI_TOPSTRUCT or anchor (or are the anchor themselves). Works are sorted by aStructElementComparatorIf no hits are found, an empty list is returned.- Parameters:
pi- persistent identifier of the top-level record- Returns:
- A list of all docstructs with the given pi or children thereof. An empty list if no hits are found
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
addEventMetadataToWorkElement
protected void addEventMetadataToWorkElement(List<StructElement> eles, List<org.apache.solr.common.SolrDocument> events) Adds all metadata from the given events to the first work document contained in eles. All metadata will be attached twice, once in the form "/[fieldName]" and once in the form "[eventType]/[fieldName]"- Parameters:
eles- The list of StructElements from which to select the first work document. All metadata are attached to this documentevents- The list of event SolrDocuments from which to take the metadata
-
getEventFields
getEventFields.- Returns:
- a map of event type names to their associated Solr field names, as configured for IIIF
-
getDocument
getDocument.- Parameters:
pi- persistent identifier of the record to load- Returns:
- the StructElement for the given PI, or null if the document was not found
- Throws:
PresentationException- if any.IndexUnreachableException- if any.
-
getSolrFieldList
getSolrFieldList.- Returns:
- a list of Solr field names required for IIIF presentation data retrieval
-
getAttributions
Gets the attribution text configured in webapi.iiif.attribution and returns all translations if any are found, or the configured string itself otherwise.- Returns:
- the configured attribution
-
getDescription
protected Optional<de.intranda.metadata.multilanguage.IMetadataValue> getDescription(StructElement ele) getDescription.- Parameters:
ele- structure element to extract description fields from- Returns:
- an Optional containing the description metadata value, or empty if no configured field has a value
-
getLabel
getDescription.- Parameters:
ele- structure element to extract label fields from- Returns:
- an Optional containing the label metadata value, or empty if no configured field has a value
-
getCollectionURI
getCollectionURI.- Parameters:
collectionField- Solr field used to group the collectionbaseCollectionName- top-level collection name, or blank for root collection- Returns:
- the URI identifying the IIIF collection resource
-
getManifestURI
getManifestURI.- Parameters:
pi- persistent identifier of the record- Returns:
- the manifest URI for the given record, using an external URL if configured
-
getExternalManifestURI
-
getPageManifestURI
getManifestURI for page.- Parameters:
pi- Persistent identifier of a recordpageNo- 1-based page order within the record- Returns:
- the manifest URI for the specified page of the given record
-
getManifestURI
getManifestURI.- Parameters:
pi- persistent identifier of the recordmode- build mode appended as a query parameter- Returns:
- the manifest URI for the given record with the build mode as a query parameter
-
getRangeURI
getRangeURI.- Parameters:
pi- persistent identifier of the recordlogId- logical structure element ID for the range- Returns:
- the range URI for the given record and logical structure element
-
getSequenceURI
getSequenceURI.- Parameters:
pi- persistent identifier of the recordlabel- sequence label; defaults to "basic" if blank- Returns:
- the sequence URI for the given record and label
-
getCanvasURI
getCanvasURI.- Parameters:
pi- persistent identifier of the recordpageNo- 1-based physical page order number- Returns:
- the canvas URI for the given page of the record
-
getPageOrderFromCanvasURI
Get the page order (1-based) from a canvas URI. That is the number in the last path parameter after '/canvas/' If the URI doesn't match a canvas URI, null is returned- Parameters:
uri- canvas URI to extract the page order from- Returns:
- the 1-based page order number extracted from the canvas URI, or null if the URI does not match
-
getPIFromCanvasURI
Get the persistent identifier from a canvas URI. This is the URI path param between '/iiif/manifests/' and '/canvas/'- Parameters:
uri- canvas URI to extract the persistent identifier from- Returns:
- The pi, or null if the URI doesn't match a iiif canvas URI
-
getAnnotationListURI
public URI getAnnotationListURI(String pi, int pageNo, de.intranda.api.iiif.presentation.enums.AnnotationType type, boolean openAnnotation) getAnnotationListURI.- Parameters:
pi- persistent identifier of the recordpageNo- 1-based physical page order numbertype- annotation type determining the URL pathopenAnnotation- if true, appends a format=oa query parameter for Open Annotation format- Returns:
- the annotation list URI for the given record page and annotation type
-
getAnnotationListURI
public URI getAnnotationListURI(String pi, de.intranda.api.iiif.presentation.enums.AnnotationType type) getAnnotationListURI.- Parameters:
pi- persistent identifier of the recordtype- annotation type appended as a query parameter- Returns:
- the annotation list URI for the given record and annotation type
-
getCommentAnnotationURI
getCommentAnnotationURI.- Parameters:
id- database ID of the comment annotation- Returns:
- the URI identifying the comment annotation with the given ID
-
getLayerURI
getLayerURI.- Parameters:
pi- persistent identifier of the recordtype- annotation type identifying the layer- Returns:
- the layer URI for the given record and annotation type
-
getImageAnnotationURI
getImageAnnotationURI.- Parameters:
pi- persistent identifier of the recordorder- 1-based physical page order number- Returns:
- the image annotation URI for the given page of the record
-
getAnnotationURI
public URI getAnnotationURI(String pi, int order, de.intranda.api.iiif.presentation.enums.AnnotationType type, int annoNum) throws URISyntaxException getAnnotationURI.- Parameters:
pi- persistent identifier of the recordorder- 1-based physical page order numbertype- annotation type used as a path segmentannoNum- 1-based annotation index within the page- Returns:
- the URI identifying the specific annotation on the given page
- Throws:
URISyntaxException- if any.
-
getAnnotationURI
getAnnotationURI.- Parameters:
id- annotation ID used as a path parameter- Returns:
- the URI identifying the annotation with the given ID
-
getSearchServiceURI
Get URL to search service fromApiUrls.- Parameters:
pi- The persistent identifier of the work to search- Returns:
- the service URI
-
getAutoCompleteServiceURI
Get URL to auto complete service fromApiUrls.- Parameters:
pi- The persistent identifier of the work to search for autocomplete- Returns:
- the service URI
-
getSearchURI
getSearchURI.- Parameters:
pi- persistent identifier of the record to search withinquery- search term appended as the q parametermotivation- list of motivation strings to filter results- Returns:
- the search URI for the given record with the query and motivation parameters
-
getAutoSuggestURI
getAutoSuggestURI.- Parameters:
pi- persistent identifier of the record to autocomplete withinquery- partial search term for autocomplete suggestionsmotivation- list of motivation strings to filter suggestions- Returns:
- the autocomplete URI for the given record with the query and motivation parameters
-
addSeeAlso
public AbstractBuilder addSeeAlso(LinkingProperty.LinkingTarget target, de.intranda.metadata.multilanguage.IMetadataValue label) -
addRendering
public AbstractBuilder addRendering(LinkingProperty.LinkingTarget target, de.intranda.metadata.multilanguage.IMetadataValue label) -
getSeeAlsos
-
getRenderings
-