Skip to content

Commit

Permalink
Save and display asset PIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
fcd1 committed Nov 21, 2024
1 parent 34c0600 commit c76f950
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/sword_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def deposit
@deposit.title =
@endpoint.deposit_title.truncate_words(20).truncate(200, omission: '')
@deposit.item_in_hyacinth = @endpoint.adapter_item_identifier
@deposit.asset_pids = @endpoint.asset_pids
@deposit.save
# @depositor.deposits << @deposit
# @collection.deposits << @deposit
Expand Down
1 change: 1 addition & 0 deletions app/models/deposit.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Deposit < ApplicationRecord
# belongs_to :depositor
# belongs_to :collectio
serialize :asset_pids, type: Array
serialize :deposit_errors, type: Array
serialize :deposit_files, type: Array
end
5 changes: 5 additions & 0 deletions app/views/deposits/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
target: '_blank') %>
</p>

<p>
<strong>Asset PIDs:</strong>
<%= @deposit.asset_pids %>
</p>

<p>
<strong>Depositor User ID:</strong>
<%= @deposit.depositor_user_id %>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20241121213246_add_asset_pids_to_deposits.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddAssetPidsToDeposits < ActiveRecord::Migration[7.2]
def change
add_column :deposits, :asset_pids, :text
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_10_30_175752) do
ActiveRecord::Schema[7.2].define(version: 2024_11_21_213246) do
create_table "collections", force: :cascade do |t|
t.string "name", null: false
t.string "atom_title", null: false
Expand Down Expand Up @@ -58,6 +58,7 @@
t.datetime "updated_at", precision: nil, null: false
t.string "depositor_user_id"
t.string "collection_slug"
t.text "asset_pids"
t.index ["collection_id"], name: "index_deposits_on_collection_id"
t.index ["collection_slug"], name: "index_deposits_on_collection_slug"
t.index ["depositor_id"], name: "index_deposits_on_depositor_id"
Expand Down
5 changes: 4 additions & 1 deletion lib/sword/adapters/hyacinth_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module Sword
module Adapters
class HyacinthAdapter

attr_reader :digital_object_data,
attr_reader :asset_pids,
:digital_object_data,
:dynamic_field_data,
:hyacinth_server_response,
:item_pid
Expand Down Expand Up @@ -37,6 +38,7 @@ class HyacinthAdapter
:use_and_reproduction_uri

def initialize
@asset_pids = []
@corporate_names = []
@dynamic_field_data = {}
@notes = []
Expand Down Expand Up @@ -133,6 +135,7 @@ def ingest_asset(parent_pid,
Rails.logger.warn("ingest_asset: Completed ingest request to Hyacinth") if HYACINTH_CONFIG[:log_ingest]
end
# puts @hyacinth_response.inspect
@asset_pids << pid_last_ingest
@hyacinth_server_response
end

Expand Down
2 changes: 2 additions & 0 deletions lib/sword/endpoints/mets_to_hyacinth_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class MetsToHyacinthEndpoint < Endpoint
# Some of these can be removed if no need for external access,
# though in that case specs may need to be updated to access
# instance var directly instead of through attr_reader
attr_reader :asset_pids
attr_reader :content_dir
attr_reader :mets_xml_file
attr_reader :mets_parser
Expand Down Expand Up @@ -66,6 +67,7 @@ def ingest_into_hyacinth
@adapter_item_identifier = ingest_item_into_hyacinth
ingest_documents_into_hyacinth
ingest_mets_xml_file_into_hyacinth
@asset_pids = @hyacinth_adapter.asset_pids
else
Rails.logger.warn "Bypassing ingest into Hyacinth, set bogus PID"
# bogus item identifier. Instead, could use string 'NotApplicable'
Expand Down

0 comments on commit c76f950

Please sign in to comment.