diff --git a/app/controllers/concerns/curation_concerns/curation_concern_controller.rb b/app/controllers/concerns/curation_concerns/curation_concern_controller.rb
index ca8cc73d0..4c4d074b6 100644
--- a/app/controllers/concerns/curation_concerns/curation_concern_controller.rb
+++ b/app/controllers/concerns/curation_concerns/curation_concern_controller.rb
@@ -17,7 +17,7 @@ module CurationConcerns::CurationConcernController
module ClassMethods
def curation_concern_type=(curation_concern_type)
- load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager]
+ load_and_authorize_resource class: curation_concern_type, instance_name: :curation_concern, except: [:show, :file_manager, :inspect_work]
self._curation_concern_type = curation_concern_type
end
@@ -103,6 +103,10 @@ def file_manager
presenter
end
+ def inspect_work
+ presenter
+ end
+
attr_writer :actor
protected
diff --git a/app/presenters/curation_concerns/inspect_work_presenter.rb b/app/presenters/curation_concerns/inspect_work_presenter.rb
new file mode 100644
index 000000000..c7be378aa
--- /dev/null
+++ b/app/presenters/curation_concerns/inspect_work_presenter.rb
@@ -0,0 +1,52 @@
+module CurationConcerns
+ class InspectWorkPresenter
+ def initialize(solr_document, current_ability)
+ @solr_document = solr_document
+ @current_ability = current_ability
+ end
+ attr_reader :solr_document, :current_ability
+
+ def workflow
+ if sipity_entity
+ {
+ entity_id: sipity_entity.id,
+ proxy_for: sipity_entity.proxy_for_global_id,
+ workflow_id: sipity_entity.workflow_id,
+ workflow_name: sipity_entity.workflow_name,
+ state_id: sipity_entity.workflow_state_id,
+ state_name: sipity_entity.workflow_state_name,
+ roles: sipity_role # TO-DO How to get related roles and actors for the sipity_entity
+ }
+ end
+ end
+
+ def solr
+ work.to_solr if work
+ end
+
+ def storage
+ work.inspect if work
+ end
+
+ private
+
+ def sipity_entity
+ @sipity_entity ||= PowerConverter.convert(solr_document, to: :sipity_entity)
+ rescue PowerConverter::ConversionError
+ nil
+ end
+
+ def sipity_role
+ # TO-DO How to use PowerConverter to get info on roles for a sipity_entity
+ 'Not impmlemented'
+ end
+
+ def sipity_actor
+ # TO-DO How to use PowerConverter to get info on actors for a sipity_role
+ end
+
+ def work
+ @work ||= sipity_entity.proxy_for if sipity_entity
+ end
+ end
+end
diff --git a/app/presenters/curation_concerns/work_show_presenter.rb b/app/presenters/curation_concerns/work_show_presenter.rb
index 3d6cd7530..3b1238d3e 100644
--- a/app/presenters/curation_concerns/work_show_presenter.rb
+++ b/app/presenters/curation_concerns/work_show_presenter.rb
@@ -50,6 +50,10 @@ def workflow
@workflow ||= WorkflowPresenter.new(solr_document, current_ability)
end
+ def inspect_work
+ @inspect_workflow ||= InspectWorkPresenter.new(solr_document, current_ability)
+ end
+
# @return FileSetPresenter presenter for the representative FileSets
def representative_presenter
return nil if representative_id.blank?
diff --git a/app/views/curation_concerns/base/inspect_work.html.erb b/app/views/curation_concerns/base/inspect_work.html.erb
new file mode 100644
index 000000000..a3c514338
--- /dev/null
+++ b/app/views/curation_concerns/base/inspect_work.html.erb
@@ -0,0 +1,29 @@
+
<%= t("inspect_work.link_text") %>
+
+ -
+ Back to <%= link_to @presenter.to_s, [main_app, @presenter] %>
+
+
+
+Workflow
+
+ <% workflow = @presenter.inspect_work.workflow %>
+ - Object Name
+ - <%= @presenter.to_s %>
+ - Processing Entity ID
+ - <%= workflow[:entity_id] %> (Proxy for <%= workflow[:proxy_for] %>)
+ - Workflow Name
+ - <%= workflow[:workflow_name] %> (ID=<%= workflow[:workflow_id] %>)
+ - Workflow State
+ - <%= workflow[:state_name] %> (ID=<%= workflow[:state_id] %>)
+ - Roles
+ - <%= workflow[:roles] %>
+
+Storage
+
+ - Work persistence
+ - <%= @presenter.inspect_work.storage %>
+
+ - Result of to_solr
+ - <%= @presenter.inspect_work.solr %>
+
\ No newline at end of file
diff --git a/config/locales/curation_concerns.en.yml b/config/locales/curation_concerns.en.yml
index 630fb8f56..4e3de53b6 100644
--- a/config/locales/curation_concerns.en.yml
+++ b/config/locales/curation_concerns.en.yml
@@ -240,6 +240,8 @@ en:
submit:
sipity_workflow_responsibility:
create: "Add"
+ inspect_work:
+ link_text: 'Inspect Work'
simple_form:
required:
html: 'required'
diff --git a/lib/curation_concerns/rails/routes.rb b/lib/curation_concerns/rails/routes.rb
index 425f38a0a..8c3edede4 100644
--- a/lib/curation_concerns/rails/routes.rb
+++ b/lib/curation_concerns/rails/routes.rb
@@ -16,6 +16,7 @@ def curation_concerns_basic_routes(&block)
namespaced_resources curation_concern_name, only: [] do
member do
get :file_manager
+ get :inspect_work
end
end
end
diff --git a/spec/controllers/curation_concerns/generic_works_controller_spec.rb b/spec/controllers/curation_concerns/generic_works_controller_spec.rb
index f33ee8251..60cd01e0d 100644
--- a/spec/controllers/curation_concerns/generic_works_controller_spec.rb
+++ b/spec/controllers/curation_concerns/generic_works_controller_spec.rb
@@ -293,4 +293,13 @@
expect(assigns(:presenter)).not_to be_blank
end
end
+
+ describe '#inspect_work' do
+ let(:work) { create(:private_generic_work, user: user) }
+ it "is successful" do
+ get :inspect_work, params: { id: work.id }
+ expect(response).to be_success
+ expect(assigns(:presenter)).not_to be_blank
+ end
+ end
end
diff --git a/spec/presenters/curation_concerns/work_show_presenter_spec.rb b/spec/presenters/curation_concerns/work_show_presenter_spec.rb
index 7f3a8bd4e..99810f8e6 100644
--- a/spec/presenters/curation_concerns/work_show_presenter_spec.rb
+++ b/spec/presenters/curation_concerns/work_show_presenter_spec.rb
@@ -188,6 +188,15 @@
end
end
+ context "with inspect_work" do
+ let(:user) { create(:user) }
+ let(:ability) { Ability.new(user) }
+ describe "#inspect_work" do
+ subject { presenter.inspect_work }
+ it { is_expected.to be_kind_of CurationConcerns::InspectWorkPresenter }
+ end
+ end
+
describe "graph export methods" do
let(:graph) do
RDF::Graph.new.tap do |g|
diff --git a/spec/routing/route_spec.rb b/spec/routing/route_spec.rb
index fda0d2221..55d578601 100644
--- a/spec/routing/route_spec.rb
+++ b/spec/routing/route_spec.rb
@@ -39,6 +39,10 @@
it 'routes to file_manager' do
expect(get: 'concern/generic_works/6/file_manager').to route_to(controller: 'curation_concerns/generic_works', action: 'file_manager', id: '6')
end
+
+ it 'routes to inspect_work' do
+ expect(get: 'concern/generic_works/6/inspect_work').to route_to(controller: 'curation_concerns/generic_works', action: 'inspect_work', id: '6')
+ end
end
describe 'Permissions' do