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

[HOLD] Allow rights metadata indexing to function again #466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/indexers/rights_metadata_datastream_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

class RightsMetadataDatastreamIndexer
attr_reader :resource

def initialize(resource:)
@resource = resource
end
Expand Down
18 changes: 16 additions & 2 deletions app/models/hydrus/rights_metadata_ds.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# frozen_string_literal: true

require 'dor/rights_auth'

class Hydrus::RightsMetadataDS < ActiveFedora::OmDatastream
include Hydrus::GenericDS
include Hydrus::Accessible
Expand Down Expand Up @@ -48,10 +52,20 @@ class Hydrus::RightsMetadataDS < ActiveFedora::OmDatastream
xml.machine(type: gcode) { xml.text(code) }
end

# just a wrapper to invalidate @dra_object
def content=(xml)
@dra_object = nil
super
end

def dra_object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem is not that we are missing this object, but that the indexer should not be referencing this object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't disagree. Was shooting to put up a quick fix and move on to other fires.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne OK, I'll have a look.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jcoyne if I remove all the dra stuff in the rights metadata datastream indexer, it's not going to be doing very much, which has me wondering why we have all this code in Hydrus now. I'm not eager to do a deep dive on this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added so that we could upgrade to the latest version of dor-services which does not have its own indexing. This indexing code was for Dor::RightsMetadataDS not for Hydrus::RightsMetadataDS

@dra_object ||= Dor::RightsAuth.parse(ng_xml, true)
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
''.freeze
''
end

# Takes a license-group code, a license code, and the corresponding license text.
Expand All @@ -72,7 +86,7 @@ def remove_license
# Dor::Editable module and moved into a datastream which Hydrus does not use.
# Stub out these methods to get the test suite running
[:default_rights, :use_license].each do |missing_method_name|
define_method(missing_method_name) {}
define_method(missing_method_name) { [] }
end

def self.xml_template
Expand Down
1 change: 1 addition & 0 deletions app/services/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class Indexer
Dor::Agreement => ITEM_INDEXER, # Agreement uses same indexer as Dor::Item
Dor::AdminPolicyObject => ADMIN_POLICY_INDEXER,
Dor::Collection => COLLECTION_INDEXER,
Hydrus::Collection => COLLECTION_INDEXER,
Hydrus::Item => ITEM_INDEXER,
Hydrus::AdminPolicyObject => ADMIN_POLICY_INDEXER,
Dor::Item => ITEM_INDEXER,
Expand Down
4 changes: 2 additions & 2 deletions spec/indexers/rights_metadata_datastream_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
XML
end

let(:obj) { Dor::Item.new(pid: 'druid:rt923jk342') }
let(:obj) { Hydrus::Item.new(pid: 'druid:rt923jk342') }
let(:rights_md_ds) { obj.rightsMetadata }

let(:indexer) do
Expand All @@ -47,7 +47,7 @@
expect(doc).to include(
'copyright_ssim' => ['Copyright © World Trade Organization'],
'use_statement_ssim' => ['Official WTO documents are free for public use.'],
'use_license_machine_ssi' => 'by-nc-nd',
'use_license_machine_ssi' => nil,
'rights_descriptions_ssim' => ['world']
)
end
Expand Down