Skip to content

Commit

Permalink
Add support for Allinson Flex metadata
Browse files Browse the repository at this point in the history
Implemented a sql query to pull labels and names from
`AllinsonFlex::ProfileProperty` so all defined m3 metadata can be
displayed.
  • Loading branch information
kirkkwang committed Mar 9, 2023
1 parent d142466 commit 23d16a9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion lib/iiif_print.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def iiif_print_config?
# @see Hyrax::IiifManifestPresenter#manifest_metadata
def self.manifest_metadata_for(work:,
version: config.default_iiif_manifest_version,
fields: default_fields_for(work),
fields: defined?(AllinsonFlex) ? allinson_flex_fields_for(work) : default_fields_for(work),
current_ability:,
base_url:)
Metadata.build_metadata_for(work: work,
Expand All @@ -133,4 +133,29 @@ def self.default_fields_for(_work, fields: config.metadata_fields)
)
end
end

def self.allinson_flex_fields_for(_work, fields: allinson_flex_fields)
fields.map do |field|
Field.new(
name: field.name,
label: field.label,
# TODO: transform Allinson Flex `indexing` properties to determine
# render as value (ex. facetable => render_as: faceted)
options: nil
)
end
end

def self.allinson_flex_fields
AllinsonFlex::ProfileProperty
.find_by_sql(
"SELECT DISTINCT allinson_flex_profile_texts.value AS label, " \
"allinson_flex_profile_properties.name AS name " \
"FROM allinson_flex_profile_properties " \
"JOIN allinson_flex_profile_texts " \
"ON allinson_flex_profile_properties.id = " \
"allinson_flex_profile_texts.profile_property_id " \
"WHERE allinson_flex_profile_texts.name = 'display_label'"
)
end
end
2 changes: 1 addition & 1 deletion lib/iiif_print/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def build_metadata

def build_metadata_for_v2
fields.map do |field|
label = Hyrax::Renderers::AttributeRenderer.new(field.name, nil).label
label = Hyrax::Renderers::AttributeRenderer.new(field.label, nil).label
if field.name == :collection && member_of_collection?
viewable_collections = Hyrax::CollectionMemberService.run(work, @current_ability)
next if viewable_collections.empty?
Expand Down

0 comments on commit 23d16a9

Please sign in to comment.