Skip to content

Commit

Permalink
persist banners, logos and thumbnails for collection migration (#2331)
Browse files Browse the repository at this point in the history
* thumbnails for collections
  • Loading branch information
orangewolf authored Sep 19, 2024
1 parent dd59dbf commit 43a2d1e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GIT

GIT
remote: https://github.com/samvera/hyrax.git
revision: e1160bbbb1b917640515f8db1f3ad3dcdc376c47
revision: e4886f1e70a1ee9962c604a76a523ef4b32ccd46
branch: main
specs:
hyrax (5.0.1)
Expand Down
12 changes: 11 additions & 1 deletion app/jobs/migrate_resources_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def perform(models: [])
fm = form_for(model:).constantize.new(resource: res)
# save the form
result = Hyrax::Transactions::Container[collection_model_event_mapping[model]]
.call(fm)
.with_step_args(**collection_model_steps_mapping[model]).call(fm)
result.value!
end
end
Expand All @@ -34,4 +34,14 @@ def collection_model_event_mapping
'Collection' => 'change_set.update_collection'
}
end

def collection_model_steps_mapping
{
'AdminSet' => {},
'Collection' => {
'collection_resource.save_collection_banner' => { banner_unchanged_indicator: true },
'collection_resource.save_collection_logo' => { logo_unchanged_indicator: true }
}
}
end
end
1 change: 1 addition & 0 deletions app/models/collection_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class CollectionResource < Hyrax::PcdmCollection
include Hyrax::Schema(:basic_metadata)
include Hyrax::Schema(:bulkrax_metadata)
include Hyrax::Schema(:collection_resource)
include Hyrax::Schema(:with_thumbnail)
include Hyrax::ArResource

Hyrax::ValkyrieLazyMigration.migrating(self, from: ::Collection)
Expand Down
12 changes: 12 additions & 0 deletions config/metadata/with_thumbnail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
attributes:
thumbnail_id:
type: string
predicate: http://www.ebu.ch/metadata/ontologies/ebucore/ebucore#hasRelatedImage
multiple: false
form:
display: false
primary: false
required: false
multiple: false
index_keys:
- "thumbnail_id_ssim"
14 changes: 14 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,20 @@
t.datetime "updated_at"
end

create_table "work_authorizations", force: :cascade do |t|
t.string "work_title"
t.bigint "user_id"
t.datetime "expires_at"
t.string "work_pid", null: false
t.string "scope"
t.string "error"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["expires_at"], name: "index_work_authorizations_on_expires_at"
t.index ["user_id"], name: "index_work_authorizations_on_user_id"
t.index ["work_pid"], name: "index_work_authorizations_on_work_pid"
end

create_table "work_view_stats", id: :serial, force: :cascade do |t|
t.datetime "date"
t.integer "work_views"
Expand Down

0 comments on commit 43a2d1e

Please sign in to comment.