Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Upgrade to dor-services 7 #294

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ gem 'whenever', '~> 0.9'

# Stanford stuff
gem 'assembly-objectfile', '~> 1.5'
gem 'dor-services', '~> 6.1', require: false
# We don't require this by default, because we need it to load after hydrus models
# or we'll get a superclass mismatch for Hydrus::Item
gem 'dor-services', '~> 7.1', require: false
gem 'dor-services-client', '~> 1.1'
gem 'rubydora', '~> 2.1'
gem 'bagit', '~> 0.4'
gem 'dor-workflow-client', '~> 3.2'
gem 'net-http-persistent', '~> 2.9' # https://github.com/sul-dlss/dor-workflow-service/issues/44
gem 'blacklight', '~> 6.19'
gem 'cancancan', '~> 1.17'

Expand Down
25 changes: 5 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -173,24 +173,22 @@ GEM
unf (>= 0.0.5, < 1.0.0)
dor-rights-auth (1.3.0)
nokogiri
dor-services (6.8.0)
dor-services (7.1.0)
active-fedora (>= 8.7.0, < 9)
activesupport (>= 4.2.10, < 6.0.0)
activesupport (~> 5.1)
confstruct (~> 0.2.7)
deprecation (~> 0)
dor-rights-auth (~> 1.0, >= 1.2.0)
dor-services-client (~> 1.5)
dor-workflow-service (~> 2.11)
dor-workflow-client (~> 3.0)
druid-tools (>= 0.4.1)
equivalent-xml (~> 0.5, >= 0.5.1)
json (>= 1.8.1)
moab-versioning (~> 4.0)
net-sftp (~> 2.1)
nokogiri (~> 1.6)
om (~> 3.0)
rdf (~> 1.1, >= 1.1.7)
rest-client (>= 1.7, < 3)
retries
retries (~> 0.0.5)
rsolr (>= 1.0.3, < 3)
ruby-cache (~> 0.3.0)
rubydora (~> 2.1)
Expand All @@ -210,14 +208,6 @@ GEM
faraday (~> 0.9, >= 0.9.2)
faraday_middleware
nokogiri (~> 1.6)
dor-workflow-service (2.12.0)
activesupport (>= 3.2.1, < 6)
confstruct (>= 0.2.7, < 2)
deprecation
faraday (~> 0.9, >= 0.9.2)
net-http-persistent (>= 2.9.4, < 4.a)
nokogiri (~> 1.6)
retries
druid-tools (1.0.0)
dry-configurable (0.8.2)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -337,11 +327,8 @@ GEM
msgpack (1.2.10)
multipart-post (2.1.1)
mysql2 (0.4.10)
net-http-persistent (2.9.4)
net-scp (2.0.0)
net-ssh (>= 2.6.5, < 6.0.0)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (5.2.0)
netrc (0.11.0)
nio4r (2.3.1)
Expand Down Expand Up @@ -577,9 +564,8 @@ DEPENDENCIES
devise (~> 4.0)
devise-remote-user (~> 1.0)
dlss-capistrano
dor-services (~> 6.1)
dor-services (~> 7.1)
dor-services-client (~> 1.1)
dor-workflow-client (~> 3.2)
dynamic_form
equivalent-xml
factory_bot_rails
Expand All @@ -589,7 +575,6 @@ DEPENDENCIES
letter_opener
listen (>= 3.0.5, < 3.2)
mysql2 (~> 0.4.5)
net-http-persistent (~> 2.9)
okcomputer
pry
rails (~> 5.2)
Expand Down
3 changes: 1 addition & 2 deletions app/models/hydrus/admin_policy_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Hydrus::AdminPolicyObject < Dor::AdminPolicyObject
include Hydrus::Validatable
include Hydrus::Processable
include Hydrus::Contentable
include Dor::Publishable
extend Hydrus::Delegatable

has_metadata(
Expand Down Expand Up @@ -88,7 +87,7 @@ def self.create(user)
args = [user, 'adminPolicy', dconf.ur_apo_druid]
response = Hydrus::GenericObject.register_dor_object(*args)
apo = Hydrus::AdminPolicyObject.find(response[:pid])
workflow_client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow, version: apo.current_version)
Dor::Config.workflow.client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow, version: apo.current_version)

apo.remove_relationship :has_model, 'info:fedora/afmodel:Dor_AdminPolicyObject'
apo.assert_content_model
Expand Down
2 changes: 1 addition & 1 deletion app/models/hydrus/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def self.create(user)

coll = Hydrus::Collection.find(response[:pid])
# Create workflow
workflow_client.create_workflow_by_name(coll.pid, Dor::Config.hydrus.app_workflow, version: coll.current_version)
Dor::Config.workflow.client.create_workflow_by_name(response[:pid], Dor::Config.hydrus.app_workflow, version: coll.current_version)

coll.remove_relationship :has_model, 'info:fedora/afmodel:Dor_Collection'
coll.assert_content_model
Expand Down
18 changes: 18 additions & 0 deletions app/models/hydrus/desc_metadata_ds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ def self.xml_template
end.doc
end

# Required by the indexer. This is something that Dor::DescMetadataDS has
# intended for read-access, "as SearchWorks would see it", mostly for to_solr()
# @param [Nokogiri::XML::Document] content Nokogiri descMetadata document (overriding internal data)
# @param [boolean] ns_aware namespace awareness toggle for from_nk_node()
def stanford_mods(content = nil, ns_aware = true)
@stanford_mods ||= begin
m = Stanford::Mods::Record.new
desc = content.nil? ? ng_xml : content
m.from_nk_node(desc.root, ns_aware)
m
end
end

# This is something the Dor::DescMetadataDS has and the indexer expects of this class
def full_title
stanford_mods.sw_title_display
end

# This provides the prefix for the solr fields generated by ActiveFedora.
# Since we don't want a prefix, we override this to return an empty string.
def prefix
Expand Down
8 changes: 1 addition & 7 deletions app/models/hydrus/processable.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# A mixin for workflow stuff.

module Hydrus::Processable
extend ActiveSupport::Concern
REPO = 'dor'

def workflow_client
@workflow_client ||= self.class.workflow_client
Dor::Config.workflow.client
end

module ClassMethods
def workflow_client
Dor::Workflow::Client.new(url: Settings.workflow.url)
end
end
# Takes the name of a step in the Hydrus workflow.
# Calls the workflow service to mark that step as completed.
def complete_workflow_step(step)
Expand Down
14 changes: 14 additions & 0 deletions app/models/hydrus/rights_metadata_ds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,18 @@ def self.xml_template
}
end.doc
end

# Copied in from Dor::Services because this is an interface that the rights metadata is supposed to implement
def rights
xml = ng_xml
if xml.search('//rightsMetadata/access[@type=\'read\']/machine/group').length == 1
'Stanford'
elsif xml.search('//rightsMetadata/access[@type=\'read\']/machine/world').length == 1
'World'
elsif xml.search('//rightsMetadata/access[@type=\'discover\']/machine/none').length == 1
'Dark'
else
'None'
end
end
end
2 changes: 1 addition & 1 deletion app/models/hydrus/workflow_ds_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_workflow_step(step)
end

# Takes the name of a hydrusAssemblyWF step.
# Returns the staus of the corresponding process node.
# Returns the status of the corresponding process node.
def get_workflow_status(step)
node = get_workflow_step(step)
node && node['status']
Expand Down
2 changes: 1 addition & 1 deletion app/services/item_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def build_item(item_type)
end

def workflow_client
@workflow_client ||= Dor::Workflow::Client.new(url: Settings.workflow.url)
Dor::Config.workflow.client
end

# Add the Item to the Collection.
Expand Down
1 change: 0 additions & 1 deletion config/initializers/dor_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
end

solr.url Settings.solr.url
sdr.url Settings.sdr.url

hydrus do
initial_apo_title 'Intial Hydrus APO title'
Expand Down
6 changes: 2 additions & 4 deletions config/initializers/rights_overrides.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Dor
module Publishable
class Abstract
# need to override if we want to use the Hydra access permissions code
included do
has_metadata name: 'rightsMetadata', type: Hydra::Datastream::RightsMetadata, label: 'Rights Metadata'
end
has_metadata name: 'rightsMetadata', type: Hydra::Datastream::RightsMetadata, label: 'Rights Metadata'
end
end
5 changes: 1 addition & 4 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ stacks:

solr:
url: 'https://solr.example.com/solr/collection'

sdr:
url: 'https://sdr.example.com/solr/collection'


suri:
url: 'http://localhost:3002'
user: ~
Expand Down
2 changes: 1 addition & 1 deletion spec/features/collection_create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:archivist1) { create :archivist1 }
let(:archivist99) { create :archivist99 }

before(:each) do
before do
@alert = 'div.alert'
@notice_save = 'Your changes have been saved'
@notice_open = 'Collection opened'
Expand Down
40 changes: 21 additions & 19 deletions spec/features/models/item_spec.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'spec_helper'

describe(Hydrus::Item, type: :feature, integration: true) do
describe('Content metadata generation') do
it 'should be able to generate content metadata, returning blank CM when no files exist and setting content metadata stream to a blank template' do
RSpec.describe Hydrus::Item, type: :feature, integration: true do
describe 'Content metadata generation' do
it 'generates content metadata, returning blank CM when no files exist and setting content metadata stream to a blank template' do
xml = '<contentMetadata objectId="__DO_NOT_USE__" type="file"/>'
hi = Hydrus::Item.new pid: '__DO_NOT_USE__'
hi.update_content_metadata
expect(hi.datastreams['contentMetadata'].content).to be_equivalent_to(xml)
end

it 'should be able to generate content metadata, returning and setting correct cm when files exist' do
it 'generates content metadata, returning and setting correct cm when files exist' do
item = Hydrus::Item.find('druid:oo000oo0001')
expect(item.files.size).to eq(4)
expect(item.datastreams['contentMetadata'].content).to be_equivalent_to '<contentMetadata></contentMetadata>'
Expand Down Expand Up @@ -55,7 +55,7 @@
Dor::Config.configure.suri.mint_ids = @prev_mint_ids
end

it 'should accept the terms for an item, updating the appropriate hydrusProperties metadata in item and collection' do
it 'accepts the terms for an item, updating the appropriate hydrusProperties metadata in item and collection' do
expect(item.requires_terms_acceptance(user_key, collection)).to eq(true)
expect(item.accepted_terms_of_deposit).to eq('false')
expect(collection.users_accepted_terms_of_deposit.keys.include?(user_key)).to eq(false)
Expand All @@ -70,31 +70,33 @@

describe 'do_publish()' do
let(:user) { create :archivist1 }

let(:mock_wf_client) { instance_double(Dor::Workflow::Client) }

before(:each) do
let(:wfs) do
instance_double(Dor::Workflow::Client,
all_workflows_xml: '',
milestones: [],
update_workflow_status: nil,
create_workflow_by_name: nil)
end
before do
@prev_mint_ids = config_mint_ids()
allow(Dor::Workflow::Client).to receive(:new).and_return(mock_wf_client)
allow(mock_wf_client).to receive(:create_workflow_by_name)
allow(mock_wf_client).to receive(:update_workflow_status)
allow(Dor::Config.workflow).to receive(:client).and_return(wfs)
end

after(:each) do
after do
config_mint_ids(@prev_mint_ids)
end

it 'should modify workflows as expected' do
it 'modifies workflows' do
druid = 'druid:oo000oo0003'
hi = ItemService.create(druid, user)
allow(hi).to receive(:should_start_assembly_wf).and_return(true)
allow(hi).to receive(:is_assemblable).and_return(true)
hi.do_publish()
expect(mock_wf_client).to have_received(:update_workflow_status).with('dor', hi.pid,
'hydrusAssemblyWF', 'approve', 'completed')
expect(mock_wf_client).to have_received(:update_workflow_status).with('dor', hi.pid,
'hydrusAssemblyWF', 'start-assembly', 'completed')
expect(mock_wf_client).to have_received(:create_workflow_by_name).with(hi.pid, 'assemblyWF', version: '1')
expect(wfs).to have_received(:update_workflow_status).with('dor', hi.pid,
'hydrusAssemblyWF', 'approve', 'completed')
expect(wfs).to have_received(:update_workflow_status).with('dor', hi.pid,
'hydrusAssemblyWF', 'start-assembly', 'completed')
expect(wfs).to have_received(:create_workflow_by_name).with(hi.pid, 'assemblyWF', version: '1')
end
end

Expand Down