diff --git a/app/models/zizia/pre_ingest_work.rb b/app/models/zizia/pre_ingest_work.rb
index 7d7685d..f417dc1 100644
--- a/app/models/zizia/pre_ingest_work.rb
+++ b/app/models/zizia/pre_ingest_work.rb
@@ -2,5 +2,15 @@
module Zizia
class PreIngestWork < ::ApplicationRecord
has_many :pre_ingest_files
+
+ # Returns the title based on the deduplication_key if the work has been indexed to solr
+ # @return [String] the work's title
+ def title
+ return 'This work does not have a deduplication key.' if deduplication_key.nil?
+ solr_title = ActiveFedora::SolrService.get("deduplication_key_tesim:#{deduplication_key}")
+ .dig('response', 'docs', 0, 'title_tesim', 0)
+ return solr_title unless solr_title.nil?
+ 'This work\'s metadata has not been indexed yet.'
+ end
end
end
diff --git a/app/views/zizia/csv_import_details/_pre_ingest_files_table.html.erb b/app/views/zizia/csv_import_details/_pre_ingest_files_table.html.erb
new file mode 100644
index 0000000..f3def5a
--- /dev/null
+++ b/app/views/zizia/csv_import_details/_pre_ingest_files_table.html.erb
@@ -0,0 +1,20 @@
+
+
+ Filename |
+ Size |
+ Row Number |
+
+ <% pre_ingest_work.pre_ingest_files.each do |pre_ingest_file| %>
+
+
+ <%= pre_ingest_file.basename %>
+ |
+
+ <%= number_to_human_size(pre_ingest_file.size) %>
+ |
+
+ <%= pre_ingest_file.row_number %>
+ |
+
+ <% end %>
+
diff --git a/app/views/zizia/csv_import_details/show.html.erb b/app/views/zizia/csv_import_details/show.html.erb
index b4d0dcd..42d150f 100644
--- a/app/views/zizia/csv_import_details/show.html.erb
+++ b/app/views/zizia/csv_import_details/show.html.erb
@@ -7,26 +7,32 @@
Total Size: <%= number_to_human_size(@csv_import_detail.total_size) %>
- Files
-
+ Works & Files
+
+
- Filename |
- Size |
- Row Number |
+ Deduplication Key |
+ Title |
+ Files |
+ Date |
-
- <% @csv_import_detail.pre_ingest_files.each do |pre_ingest_file| %>
-
-
- <%= pre_ingest_file.basename %>
- |
-
- <%= number_to_human_size(pre_ingest_file.size) %>
- |
-
- <%= pre_ingest_file.row_number %>
- |
-
+ <% @csv_import_detail.pre_ingest_works.each do |pre_ingest_work| %>
+ <% if pre_ingest_work.pre_ingest_files.length > 0 %>
+
+
+ <%= pre_ingest_work.deduplication_key%>
+ |
+
+ <%= pre_ingest_work.title %>
+ |
+
+ <%= render 'pre_ingest_files_table', pre_ingest_work: pre_ingest_work %>
+ |
+
+ <%= pre_ingest_work.created_at.strftime("%B %-d, %Y %H:%M") %>
+ |
+
+ <% end %>
<% end %>
diff --git a/spec/dummy/app/models/work.rb b/spec/dummy/app/models/work.rb
index a7c3877..267e164 100644
--- a/spec/dummy/app/models/work.rb
+++ b/spec/dummy/app/models/work.rb
@@ -8,6 +8,10 @@ class Work < ActiveFedora::Base
# self.valid_child_concerns = []
validates :title, presence: { message: 'Your work must have a title.' }
+
+ property :deduplication_key, predicate: 'http://metadata.example.com/vocab/predicates#deduplicationKey', multiple: false do |index|
+ index.as :stored_searchable
+ end
# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
diff --git a/spec/dummy/spec/system/csv_import_details_page_spec.rb b/spec/dummy/spec/system/csv_import_details_page_spec.rb
index 3f1a13d..fe80c9a 100644
--- a/spec/dummy/spec/system/csv_import_details_page_spec.rb
+++ b/spec/dummy/spec/system/csv_import_details_page_spec.rb
@@ -33,6 +33,7 @@
expect(page).to have_content('undetermined')
click_on '1'
expect(page).to have_content('Total Size')
+ expect(page).to have_content('Deduplication Key')
end
it 'has links to sort' do
diff --git a/spec/models/zizia/pre_ingest_work_spec.rb b/spec/models/zizia/pre_ingest_work_spec.rb
index e05cb7c..18d0f31 100644
--- a/spec/models/zizia/pre_ingest_work_spec.rb
+++ b/spec/models/zizia/pre_ingest_work_spec.rb
@@ -2,8 +2,23 @@
require 'rails_helper'
RSpec.describe Zizia::PreIngestWork do
- let(:pre_ingest_work) { FactoryBot.create(:pre_ingest_work, deduplication_key: "42") }
+ let(:pre_ingest_work) { FactoryBot.create(:pre_ingest_work, deduplication_key: '42') }
+ let(:pre_ingest_work_indexed) { FactoryBot.create(:pre_ingest_work, deduplication_key: '43') }
+ let(:work) { Work.new(title: ['A Nice Title'], deduplication_key: '43') }
+
+ before do
+ work.save
+ end
+
it 'has a deduplication_key' do
- expect(pre_ingest_work.deduplication_key).to eq "42"
+ expect(pre_ingest_work.deduplication_key).to eq '42'
+ end
+
+ it 'can return that metadata has not been indexed yet' do
+ expect(pre_ingest_work.title).to eq('This work\'s metadata has not been indexed yet.')
+ end
+
+ it 'can return a title for a work based on the deduplication key' do
+ expect(pre_ingest_work_indexed.title).to eq('A Nice Title')
end
end