diff --git a/.dassie/config/metadata/m3_profile.yaml b/.dassie/config/metadata/m3_profile.yaml new file mode 100644 index 0000000000..e8d1dcb582 --- /dev/null +++ b/.dassie/config/metadata/m3_profile.yaml @@ -0,0 +1,162 @@ +--- +m3_version: 1.0.beta2 +profile: + date_modified: '2024-06-01' + responsibility: https://samvera.org + responsibility_statement: Hyrax Initial Profile + type: + version: 1 +classes: + GenericWorkResource: + display_label: Generic Work + Monograph: + display_label: Monograph + AdminSet: + diplay_label: AdminSet + AdminSetResource: + diplay_label: AdministrativeSet + Collection: + display_label: Collection + CollectionResource: + display_label: PcdmCollection + Hyrax::FileSet: + display_label: FileSet +contexts: + flexible_context: + display_label: Flexible Metadata Example +mappings: + blacklight: + name: Additional Blacklight Solr Mappings + metatags: + name: Metatags + mods_oai_pmh: + name: MODS OAI PMH + qualified_dc_pmh: + name: Qualified DC OAI PMH + simple_dc_pmh: + name: Simple DC OAI PMH +properties: + title: + available_on: + class: + - AdminSetResource + - AdminSet + - Hyrax::FileSet + - CollectionResource + - GenericWorkResource + - Monograph + cardinality: + minimum: 0 + multi_value: true + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + definition: + default: Enter a standardized title for display. If only one + title is needed, transcribe the title from the source + itself. + display_label: + default: Title + index_documentation: displayable, searchable + indexing: + - 'title_sim' + - 'title_tesim' + form: + required: true + primary: true + multi_value: true + mappings: + metatags: twitter:title, og:title + mods_oai_pmh: mods:titleInfo/mods:title + qualified_dc_pmh: dcterms:title + simple_dc_pmh: dc:title + property_uri: http://purl.org/dc/terms/title + range: http://www.w3.org/2001/XMLSchema#string + requirement: required + sample_values: + - Pencil drawn portrait study of woman + date_modified: + available_on: + class: + - AdminSetResource + - AdminSet + - Hyrax::FileSet + - CollectionResource + - GenericWorkResource + - Monograph + cardinality: + minimum: 0 + maximum: 1 + multi_value: false + display_label: + default: Date Modified + property_uri: http://purl.org/dc/terms/modified + range: http://www.w3.org/2001/XMLSchema#dateTime + sample_values: + - "2024-06-06 21:06:51 +0000" + date_uploaded: + available_on: + class: + - AdminSetResource + - AdminSet + - Hyrax::FileSet + - CollectionResource + - GenericWorkResource + - Monograph + cardinality: + minimum: 0 + maximum: 1 + multi_value: false + display_label: + default: Date Uploaded + property_uri: http://purl.org/dc/terms/dateSubmitted + range: http://www.w3.org/2001/XMLSchema#dateTime + sample_values: + - "2024-06-06 21:06:51 +0000" + depositor: + available_on: + class: + - AdminSetResource + - AdminSet + - Hyrax::FileSet + - CollectionResource + - GenericWorkResource + - Monograph + cardinality: + minimum: 0 + maximum: 1 + multi_value: false + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Depositor + index_documentation: searchable + indexing: + - 'depositor_tesim' + property_uri: http://id.loc.gov/vocabulary/relators/dpt + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - Julie Allinson + creator: + available_on: + class: + - Hyrax::FileSet + cardinality: + minimum: 1 + multi_value: true + controlled_values: + format: http://www.w3.org/2001/XMLSchema#string + sources: + - 'null' + display_label: + default: Creator + index_documentation: searchable + indexing: + - 'creator_tesim' + property_uri: http://purl.org/dc/elements/1.1/creator + range: http://www.w3.org/2001/XMLSchema#string + sample_values: + - Julie Allinson diff --git a/.dassie/db/migrate/20240606205215_create_hyrax_flexible_schemas.rb b/.dassie/db/migrate/20240606205215_create_hyrax_flexible_schemas.rb index 0bc7567dec..bdbac2bc49 100644 --- a/.dassie/db/migrate/20240606205215_create_hyrax_flexible_schemas.rb +++ b/.dassie/db/migrate/20240606205215_create_hyrax_flexible_schemas.rb @@ -1,7 +1,6 @@ class CreateHyraxFlexibleSchemas < ActiveRecord::Migration[6.1] def change create_table :hyrax_flexible_schemas do |t| - t.string :version, index: { unique: true } t.text :profile t.timestamps diff --git a/.dassie/db/schema.rb b/.dassie/db/schema.rb index d58a685ed5..639068a227 100644 --- a/.dassie/db/schema.rb +++ b/.dassie/db/schema.rb @@ -173,7 +173,6 @@ end create_table "hyrax_flexible_schemas", force: :cascade do |t| - t.string "version" t.text "profile" t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false diff --git a/app/models/concerns/hyrax/flexibility.rb b/app/models/concerns/hyrax/flexibility.rb index b20c03ac79..3dfa2675ee 100644 --- a/app/models/concerns/hyrax/flexibility.rb +++ b/app/models/concerns/hyrax/flexibility.rb @@ -59,7 +59,7 @@ def new(attributes = default_attributes, safe = false, &block) # rubocop:disable ## Read the schema from the database and load the correct schemas for the instance in to the class def load(attributes, safe = false) - attributes[:schema_version] ||= Hyrax::FlexibleSchema.order('created_at DESC').pick(:version) + attributes[:schema_version] ||= Hyrax::FlexibleSchema.order('id DESC').pick(:id) struct = allocate schema_version = attributes[:schema_version] struct.singleton_class.attributes(Hyrax::Schema(self, schema_version:).attributes) diff --git a/app/models/hyrax/flexible_schema.rb b/app/models/hyrax/flexible_schema.rb index b68d1ee688..5d4bb99ef2 100644 --- a/app/models/hyrax/flexible_schema.rb +++ b/app/models/hyrax/flexible_schema.rb @@ -1,6 +1,10 @@ class Hyrax::FlexibleSchema < ApplicationRecord serialize :profile, coder: YAML + def title + "#{profile['profile']['responsibility_statement']} - version #{id}" + end + def attributes_for(class_name) class_names[class_name] end @@ -22,8 +26,8 @@ def class_names end def values_map(values) - values['type'] = lookup_type(value['range']) - values['predicate'] = value['property_uri'] + values['type'] = lookup_type(values['range']) + values['predicate'] = values['property_uri'] values['index_keys'] = values['indexing'] values['multiple'] = values['multi_value'] values diff --git a/app/services/hyrax/m3_schema_loader.rb b/app/services/hyrax/m3_schema_loader.rb index 25554b81f5..4fd7a7a2b8 100644 --- a/app/services/hyrax/m3_schema_loader.rb +++ b/app/services/hyrax/m3_schema_loader.rb @@ -14,9 +14,11 @@ class M3SchemaLoader < Hyrax::SchemaLoader # @param [#to_s] schema_name # @return [Enumerable] a map from attribute names to # types def attributes_for(schema:, version: 1) - definitions(schema).each_with_object({}) do |definition, hash| + definitions(schema, version).each_with_object({}) do |definition, hash| hash[definition.name] = definition.type.meta(definition.config) end end @@ -24,7 +26,7 @@ def attributes_for(schema:, version: 1) # # @return [Hash{Symbol => Hash{Symbol => Object}}] def form_definitions_for(schema:, version: 1) - definitions(schema).each_with_object({}) do |definition, hash| + definitions(schema, version).each_with_object({}) do |definition, hash| next if definition.form_options.empty? hash[definition.name] = definition.form_options @@ -36,7 +38,7 @@ def form_definitions_for(schema:, version: 1) # # @return [{Symbol => Symbol}] a map from index keys to attribute names def index_rules_for(schema:, version: 1) - definitions(schema).each_with_object({}) do |definition, hash| + definitions(schema, version).each_with_object({}) do |definition, hash| definition.index_keys.each do |key| hash[key] = definition.name end diff --git a/app/services/hyrax/simple_schema_loader.rb b/app/services/hyrax/simple_schema_loader.rb index eba090961c..69a015f0e4 100644 --- a/app/services/hyrax/simple_schema_loader.rb +++ b/app/services/hyrax/simple_schema_loader.rb @@ -14,14 +14,12 @@ def permissive_schema_for_valkrie_adapter end end - class UndefinedSchemaError < ArgumentError; end - private ## # @param [#to_s] schema_name # @return [Enumerable def change create_table :hyrax_flexible_schemas do |t| - t.string :version, index: { unique: true } t.text :profile t.timestamps