Class: Dor::Services::Client::Object
- Inherits:
-
VersionedService
- Object
- VersionedService
- Dor::Services::Client::Object
- Extended by:
- Deprecation
- Defined in:
- lib/dor/services/client/object.rb
Overview
API calls that are about a repository object
Constant Summary collapse
- BASE_ALLOWED_FIELDS =
%i[external_identifier cocina_version label version administrative description].freeze
- DRO_ALLOWED_FIELDS =
BASE_ALLOWED_FIELDS + %i[content_type access identification structural geographic]
Constants inherited from VersionedService
VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE
Instance Attribute Summary collapse
-
#object_identifier ⇒ Object
readonly
Returns the value of attribute object_identifier.
Instance Method Summary collapse
- #accession(params = {}) ⇒ Object
- #administrative_tags ⇒ Object
-
#collections ⇒ Array<Cocina::Models::DRO>
Get a list of the collections.
- #events ⇒ Object
-
#find(validate: false) ⇒ Cocina::Models::DROWithMetadata, ...
Retrieves the Cocina model.
-
#find_lite(administrative: true, description: true, access: true, structural: true, identification: true, geographic: true) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/ParameterLists.
-
#initialize(connection:, version:, object_identifier:) ⇒ Object
constructor
A new instance of Object.
-
#members ⇒ Array<Members::Member>
Get a list of the members.
- #mutate ⇒ Object
-
#notify_goobi ⇒ boolean
Notify the external Goobi system for a new object that was registered in DOR.
-
#reindex ⇒ boolean
Reindex the object in Solr.
- #release_tags ⇒ Object
- #transfer ⇒ Object
-
#update_doi_metadata ⇒ boolean
Update the DOI metadata at DataCite.
-
#update_marc_record ⇒ boolean
Update the marc record for the given object.
-
#update_orcid_work ⇒ Boolean
Update the ORCID Work.
- #user_version ⇒ Object
- #version ⇒ Object
- #workspace ⇒ Object
Methods inherited from VersionedService
#async_result, #with_querystring
Constructor Details
#initialize(connection:, version:, object_identifier:) ⇒ Object
Returns a new instance of Object.
14 15 16 17 18 19 |
# File 'lib/dor/services/client/object.rb', line 14 def initialize(connection:, version:, object_identifier:) raise ArgumentError, "The `object_identifier` parameter must be an identifier string: #{object_identifier.inspect}" unless object_identifier.is_a?(String) super(connection: connection, version: version) @object_identifier = object_identifier end |
Instance Attribute Details
#object_identifier ⇒ Object (readonly)
Returns the value of attribute object_identifier.
11 12 13 |
# File 'lib/dor/services/client/object.rb', line 11 def object_identifier @object_identifier end |
Instance Method Details
#accession(params = {}) ⇒ Object
45 46 47 |
# File 'lib/dor/services/client/object.rb', line 45 def accession(params = {}) @accession ||= Accession.new(**parent_params.merge(params)) end |
#administrative_tags ⇒ Object
29 30 31 |
# File 'lib/dor/services/client/object.rb', line 29 def @administrative_tags ||= AdministrativeTags.new(**parent_params) end |
#collections ⇒ Array<Cocina::Models::DRO>
Get a list of the collections. (Similar to Valkyrie’s find_inverse_references_by)
95 96 97 |
# File 'lib/dor/services/client/object.rb', line 95 def collections Collections.new(**parent_params).collections end |
#events ⇒ Object
21 22 23 |
# File 'lib/dor/services/client/object.rb', line 21 def events @events ||= Events.new(**parent_params) end |
#find(validate: false) ⇒ Cocina::Models::DROWithMetadata, ...
Retrieves the Cocina model
54 55 56 57 58 59 60 61 |
# File 'lib/dor/services/client/object.rb', line 54 def find(validate: false) resp = connection.get do |req| req.url object_path end raise_exception_based_on_response!(resp) unless resp.success? build_cocina_from_response(resp, validate: validate) end |
#find_lite(administrative: true, description: true, access: true, structural: true, identification: true, geographic: true) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/ParameterLists
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/dor/services/client/object.rb', line 70 def find_lite(administrative: true, description: true, access: true, structural: true, identification: true, geographic: true) fields = [] fields << :administrative if administrative fields << :description if description fields << :access if access fields << :structural if structural fields << :identification if identification fields << :geographic if geographic resp = connection.post '/graphql', query(fields), 'Content-Type' => 'application/json' raise_exception_based_on_response!(resp) unless resp.success? resp_json = JSON.parse(resp.body) # GraphQL returns 200 even when an error raise_graphql_exception(resp, resp_json) Cocina::Models.build_lite(resp_json['data']['cocinaObject']) end |
#members ⇒ Array<Members::Member>
Get a list of the members
102 103 104 |
# File 'lib/dor/services/client/object.rb', line 102 def members Members.new(**parent_params).members end |
#mutate ⇒ Object
112 113 114 |
# File 'lib/dor/services/client/object.rb', line 112 def mutate Mutate.new(**parent_params) end |
#notify_goobi ⇒ boolean
Notify the external Goobi system for a new object that was registered in DOR
162 163 164 165 166 167 168 169 |
# File 'lib/dor/services/client/object.rb', line 162 def notify_goobi resp = connection.post do |req| req.url "#{object_path}/notify_goobi" end return true if resp.success? raise_exception_based_on_response!(resp) end |
#reindex ⇒ boolean
Reindex the object in Solr.
175 176 177 178 179 180 181 182 |
# File 'lib/dor/services/client/object.rb', line 175 def reindex resp = connection.post do |req| req.url "#{object_path}/reindex" end return true if resp.success? raise_exception_based_on_response!(resp) end |
#release_tags ⇒ Object
33 34 35 |
# File 'lib/dor/services/client/object.rb', line 33 def @release_tags ||= ReleaseTags.new(**parent_params) end |
#transfer ⇒ Object
106 107 108 |
# File 'lib/dor/services/client/object.rb', line 106 def transfer Transfer.new(**parent_params) end |
#update_doi_metadata ⇒ boolean
Update the DOI metadata at DataCite
137 138 139 140 141 142 143 144 |
# File 'lib/dor/services/client/object.rb', line 137 def resp = connection.post do |req| req.url "#{object_path}/update_doi_metadata" end return true if resp.success? raise_exception_based_on_response!(resp) end |
#update_marc_record ⇒ boolean
Update the marc record for the given object
125 126 127 128 129 130 131 132 |
# File 'lib/dor/services/client/object.rb', line 125 def update_marc_record resp = connection.post do |req| req.url "#{object_path}/update_marc_record" end return true if resp.success? raise_exception_based_on_response!(resp) end |
#update_orcid_work ⇒ Boolean
Update the ORCID Work
149 150 151 152 153 154 155 156 |
# File 'lib/dor/services/client/object.rb', line 149 def update_orcid_work resp = connection.post do |req| req.url "#{object_path}/update_orcid_work" end return true if resp.success? raise_exception_based_on_response!(resp) end |
#user_version ⇒ Object
41 42 43 |
# File 'lib/dor/services/client/object.rb', line 41 def user_version @user_version ||= UserVersion.new(**parent_params) end |
#version ⇒ Object
37 38 39 |
# File 'lib/dor/services/client/object.rb', line 37 def version @version ||= ObjectVersion.new(**parent_params) end |