qa 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/qa/linked_data_terms_controller.rb +17 -39
  3. data/app/controllers/qa/terms_controller.rb +26 -2
  4. data/app/services/qa/linked_data/authority_url_service.rb +35 -21
  5. data/app/services/qa/linked_data/graph_service.rb +2 -4
  6. data/app/services/qa/linked_data/request_header_service.rb +97 -0
  7. data/lib/qa/authorities/discogs/discogs_instance_builder.rb +17 -19
  8. data/lib/qa/authorities/discogs/discogs_translation.rb +26 -22
  9. data/lib/qa/authorities/discogs/discogs_utils.rb +32 -20
  10. data/lib/qa/authorities/discogs/discogs_works_builder.rb +26 -47
  11. data/lib/qa/authorities/discogs/generic_authority.rb +64 -33
  12. data/lib/qa/authorities/getty/tgn.rb +1 -1
  13. data/lib/qa/authorities/linked_data/find_term.rb +60 -18
  14. data/lib/qa/authorities/linked_data/search_query.rb +43 -15
  15. data/lib/qa/authorities/loc/generic_authority.rb +2 -2
  16. data/lib/qa/version.rb +1 -1
  17. data/spec/controllers/linked_data_terms_controller_spec.rb +36 -0
  18. data/spec/controllers/terms_controller_spec.rb +26 -2
  19. data/spec/fixtures/discogs-find-response-json.json +1 -1
  20. data/spec/lib/authorities/discogs/generic_authority_spec.rb +103 -9
  21. data/spec/lib/authorities/getty/tgn_spec.rb +2 -2
  22. data/spec/lib/authorities/linked_data/find_term_spec.rb +11 -11
  23. data/spec/lib/authorities/linked_data/search_query_spec.rb +9 -9
  24. data/spec/lib/authorities/loc_spec.rb +9 -9
  25. data/spec/services/linked_data/authority_url_service_spec.rb +14 -8
  26. data/spec/services/linked_data/graph_service_spec.rb +2 -1
  27. data/spec/services/linked_data/request_header_service_spec.rb +124 -0
  28. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eb0e94ad762c71e5dd0bf2a7b99e03ee71b348e8
4
- data.tar.gz: c8d21f4c0379b3035439e39a6b085faa314bf602
2
+ SHA256:
3
+ metadata.gz: 7e4ee1da3b72cee5194380a24b44e96793395d110cbe2234da55541da3f962c9
4
+ data.tar.gz: 27dffc56d77c9e583000c99823a31fe8c90f3591ea3de04935c4e476bda9d289
5
5
  SHA512:
6
- metadata.gz: c1b33787d92489239f1530cc05b4ea3e912e7ae913ed0197a0fb1e58e13e3bf75a701e3ec5d93a15c49288a3cca0f06647ec11380bb48d3eefb0917d3f594390
7
- data.tar.gz: 2a6613d06be5b77c2709bc95d0dfe3d78814c3271e3399578726fe1e9bb2ecd533ae9533cf92e30c02345ff09624c705a8f3895f08986f104dd2baf0124e56b1
6
+ metadata.gz: ad1a1bc75bcde5877679a355e7afec3f992e869686f3c3c706d5e1ffee6ecdcc66c4be4a8572c9ca1c27b6b177b12b211debc8a579268037aff006872d3e9b5a
7
+ data.tar.gz: 789919e7a524d155d69ae2ca0203900cc0509f613d94d3b2b14ed697e2c80134b9d13dd56fb013c9db052069296955f4b948b43ff95ae10f93e4dd2ccbd643d6
@@ -7,9 +7,15 @@ class Qa::LinkedDataTermsController < ::ApplicationController
7
7
  before_action :check_show_subauthority, :check_id_param, only: :show
8
8
  before_action :check_uri_param, only: :fetch
9
9
  before_action :validate_auth_reload_token, only: :reload
10
+ before_action :create_request_header_service, only: [:search, :show, :fetch]
10
11
 
11
12
  delegate :cors_allow_origin_header, to: Qa::ApplicationController
12
13
 
14
+ class_attribute :request_header_service_class
15
+ self.request_header_service_class = Qa::LinkedData::RequestHeaderService
16
+
17
+ attr_reader :request_header_service
18
+
13
19
  # Provide a warning if there is a request for all terms.
14
20
  def index
15
21
  logger.warn 'Linked data authorities do not support retrieving all terms.'
@@ -35,8 +41,8 @@ class Qa::LinkedDataTermsController < ::ApplicationController
35
41
  # Return a list of terms based on a query
36
42
  # get "/search/linked_data/:vocab(/:subauthority)"
37
43
  # @see Qa::Authorities::LinkedData::SearchQuery#search
38
- def search # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
39
- terms = @authority.search(query, subauth: subauthority, language: language, replacements: replacement_params, context: context?, performance_data: performance_data?)
44
+ def search # rubocop:disable Metrics/MethodLength
45
+ terms = @authority.search(query, request_header: request_header_service.search_header)
40
46
  cors_allow_origin_header(response)
41
47
  render json: terms
42
48
  rescue Qa::ServiceUnavailable
@@ -59,10 +65,9 @@ class Qa::LinkedDataTermsController < ::ApplicationController
59
65
  # get "/show/linked_data/:vocab/:subauthority/:id
60
66
  # @see Qa::Authorities::LinkedData::FindTerm#find
61
67
  def show # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
62
- term = @authority.find(id, subauth: subauthority, language: language, replacements: replacement_params, jsonld: jsonld?, performance_data: performance_data?)
68
+ term = @authority.find(id, request_header: request_header_service.fetch_header)
63
69
  cors_allow_origin_header(response)
64
- content_type = jsonld? ? 'application/ld+json' : 'application/json'
65
- render json: term, content_type: content_type
70
+ render json: term, content_type: request_header_service.content_type_for_format
66
71
  rescue Qa::TermNotFound
67
72
  msg = "Term Not Found - Fetch term #{id} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
68
73
  logger.warn msg
@@ -90,10 +95,9 @@ class Qa::LinkedDataTermsController < ::ApplicationController
90
95
  # get "/fetch/linked_data/:vocab"
91
96
  # @see Qa::Authorities::LinkedData::FindTerm#find
92
97
  def fetch # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
93
- term = @authority.find(uri, subauth: subauthority, language: language, replacements: replacement_params, jsonld: jsonld?, performance_data: performance_data?)
98
+ term = @authority.find(uri, request_header: request_header_service.fetch_header)
94
99
  cors_allow_origin_header(response)
95
- content_type = jsonld? ? 'application/ld+json' : 'application/json'
96
- render json: term, content_type: content_type
100
+ render json: term, content_type: request_header_service.content_type_for_format
97
101
  rescue Qa::TermNotFound
98
102
  msg = "Term Not Found - Fetch term #{uri} unsuccessful for#{subauth_warn_msg} authority #{vocab_param}"
99
103
  logger.warn msg
@@ -149,6 +153,10 @@ class Qa::LinkedDataTermsController < ::ApplicationController
149
153
  end
150
154
  end
151
155
 
156
+ def create_request_header_service
157
+ @request_header_service = request_header_service_class.new(request, params)
158
+ end
159
+
152
160
  def init_authority
153
161
  @authority = Qa::Authorities::LinkedData::GenericAuthority.new(vocab_param)
154
162
  rescue Qa::InvalidLinkedDataAuthority => e
@@ -192,47 +200,17 @@ class Qa::LinkedDataTermsController < ::ApplicationController
192
200
  params[:id]
193
201
  end
194
202
 
195
- def language
196
- request_language = request.env['HTTP_ACCEPT_LANGUAGE']
197
- request_language = request_language.scan(/^[a-z]{2}/).first if request_language.present?
198
- params[:lang] || request_language
199
- end
200
-
201
203
  def subauthority
202
204
  params[:subauthority]
203
205
  end
204
206
 
205
- def replacement_params
206
- params.reject { |k, _v| ['q', 'vocab', 'controller', 'action', 'subauthority', 'lang', 'id'].include?(k) }
207
- end
208
-
209
207
  def subauth_warn_msg
210
208
  subauthority.blank? ? "" : " sub-authority #{subauthority} in"
211
209
  end
212
210
 
213
- def format
214
- return 'json' unless params.key?(:format)
215
- return 'json' if params[:format].blank?
216
- params[:format]
217
- end
218
-
219
- def jsonld?
220
- format.casecmp('jsonld').zero?
221
- end
222
-
223
- def context?
224
- context = params.fetch(:context, 'false')
225
- context.casecmp('true').zero?
226
- end
227
-
228
211
  def details?
229
212
  details = params.fetch(:details, 'false')
230
- details.casecmp('true').zero?
231
- end
232
-
233
- def performance_data?
234
- performance_data = params.fetch(:performance_data, 'false')
235
- performance_data.casecmp('true').zero?
213
+ details.casecmp?('true')
236
214
  end
237
215
 
238
216
  def validate_auth_reload_token
@@ -30,8 +30,7 @@ class Qa::TermsController < ::ApplicationController
30
30
  def show
31
31
  term = @authority.method(:find).arity == 2 ? @authority.find(params[:id], self) : @authority.find(params[:id])
32
32
  cors_allow_origin_header(response)
33
- content_type = params["format"] == "jsonld" ? 'application/ld+json' : 'application/json'
34
- render json: term, content_type: content_type
33
+ render json: term, content_type: content_type_for_format
35
34
  end
36
35
 
37
36
  def check_vocab_param
@@ -81,4 +80,29 @@ class Qa::TermsController < ::ApplicationController
81
80
  def url_search
82
81
  params[:q].gsub("*", "%2A")
83
82
  end
83
+
84
+ def format
85
+ return 'json' unless params.key?(:format)
86
+ return 'json' if params[:format].blank?
87
+ params[:format]
88
+ end
89
+
90
+ def jsonld?
91
+ format.casecmp?('jsonld')
92
+ end
93
+
94
+ def n3?
95
+ format.casecmp?('n3')
96
+ end
97
+
98
+ def ntriples?
99
+ format.casecmp?('ntriples')
100
+ end
101
+
102
+ def content_type_for_format
103
+ return 'application/ld+json' if jsonld?
104
+ return 'text/n3' if n3?
105
+ return 'application/n-triples' if ntriples?
106
+ 'application/json'
107
+ end
84
108
  end
@@ -7,14 +7,17 @@ module Qa
7
7
  # @param action_config [Qa::Authorities::LinkedData::SearchConfig | Qa::Authorities::LinkedData::TermConfig] action configuration for the authority
8
8
  # @param action [Symbol] action with valid values :search or :term
9
9
  # @param action_request [String] the request the user is making of the authority (e.g. query text or term id/uri)
10
- # @param substitutions [Hash] variable-value pairs to substitute into the URL template (optional)
11
- # @param subauthority [String] name of a subauthority (optional)
12
- # @param language [Array<Symbol>] languages for filtering returned literals (optional)
10
+ # @param request_header [Hash] optional attributes that can be appended to the generated URL
11
+ # @option replacements [Hash] variable-value pairs to substitute into the URL template
12
+ # @option subauthority [String] name of a subauthority
13
+ # @option language [Array<Symbol>] languages for filtering returned literals
13
14
  # @return a valid URL that submits the action request to the external authority
14
- def build_url(action_config:, action:, action_request:, substitutions: {}, subauthority: nil, language: nil) # rubocop:disable Metrics/ParameterLists
15
+ # @note All parameters after request_header are deprecated and will be removed in the next major release.
16
+ def build_url(action_config:, action:, action_request:, request_header: {}, substitutions: {}, subauthority: nil, language: nil) # rubocop:disable Metrics/ParameterLists
17
+ request_header = build_request_header(substitutions, subauthority, language) if request_header.empty?
15
18
  action_validation(action)
16
19
  url_config = action_config.url_config
17
- selected_substitutions = url_config.extract_substitutions(combined_substitutions(action_config, action, action_request, substitutions, subauthority, language))
20
+ selected_substitutions = url_config.extract_substitutions(combined_substitutions(action_config, action, action_request, request_header))
18
21
  Qa::IriTemplateService.build_url(url_config: url_config, substitutions: selected_substitutions)
19
22
  end
20
23
 
@@ -25,10 +28,12 @@ module Qa
25
28
  raise Qa::UnsupportedAction, "#{action} Not Supported - Action must be one of the supported actions (e.g. :term, :search)"
26
29
  end
27
30
 
28
- def combined_substitutions(action_config, action, action_request, substitutions, subauthority, language) # rubocop:disable Metrics/ParameterLists
31
+ def combined_substitutions(action_config, action, action_request, request_header)
32
+ substitutions = request_header.fetch(:replacements, {})
29
33
  substitutions[action_request_variable(action_config, action)] = action_request
30
- substitutions[action_subauth_variable(action_config)] = action_subauth_variable_value(action_config, subauthority) if supports_subauthorities?(action_config) && subauthority.present?
31
- substitutions[action_language_variable(action_config)] = language_value(language) if supports_language_parameter?(action_config) && language.present?
34
+ substitutions[action_subauth_variable(action_config)] = action_subauth_variable_value(action_config, request_header)
35
+ substitutions[action_language_variable(action_config)] = language_value(action_config, request_header)
36
+ substitutions.reject { |_k, v| v.nil? }
32
37
  substitutions
33
38
  end
34
39
 
@@ -37,29 +42,38 @@ module Qa
37
42
  action_config.qa_replacement_patterns[key]
38
43
  end
39
44
 
40
- def supports_subauthorities?(action_config)
41
- action_config.supports_subauthorities?
42
- end
43
-
44
45
  def action_subauth_variable(action_config)
45
46
  action_config.qa_replacement_patterns[:subauth]
46
47
  end
47
48
 
48
- def action_subauth_variable_value(action_config, subauthority)
49
- action_config.subauthorities[subauthority.to_sym]
50
- end
51
-
52
- def supports_language_parameter?(action_config)
53
- action_config.supports_language_parameter?
49
+ def action_subauth_variable_value(action_config, request_header)
50
+ subauth = request_header.fetch(:subauthority, nil)
51
+ return nil unless subauth && action_config.supports_subauthorities?
52
+ action_config.subauthorities[subauth.to_sym]
54
53
  end
55
54
 
56
55
  def action_language_variable(action_config)
57
56
  action_config.qa_replacement_patterns[:lang]
58
57
  end
59
58
 
60
- def language_value(language)
61
- return nil if language.blank?
62
- language.first
59
+ def language_value(action_config, request_header)
60
+ return nil unless action_config.supports_language_parameter?
61
+ request_header.fetch(:language, []).first
62
+ end
63
+
64
+ # This is providing support for calling build_url with individual parameters instead of the request_header.
65
+ # This is deprecated and will be removed in the next major release.
66
+ def build_request_header(substitutions, subauthority, language) # rubocop:disable Metrics/CyclomaticComplexity
67
+ return {} if substitutions.blank? && subauthority.blank? && language.blank?
68
+ Qa.deprecation_warning(
69
+ in_msg: 'Qa::LinkedData::AuthorityUrlService',
70
+ msg: "individual attributes for options (e.g. substitutions, subauthority, language) are deprecated; use request_header instead"
71
+ )
72
+ request_header = {}
73
+ request_header[:replacements] = substitutions unless substititions.blank?
74
+ request_header[:subauthority] = subauthority unless subauthority.blank?
75
+ request_header[:language] = language unless language.blank?
76
+ request_header
63
77
  end
64
78
  end
65
79
  end
@@ -106,12 +106,10 @@ module Qa
106
106
  end
107
107
  end
108
108
 
109
+ # process ioerror_code from RDF::Graph.load whether the code is in parentheses (i.e. "... (404)"), or not (i.e. "... 404")
109
110
  def ioerror_code(e)
110
111
  msg = e.message
111
- return 'format' if msg.start_with? "Unknown RDF format"
112
- a = msg.size - 4
113
- z = msg.size - 2
114
- msg[a..z]
112
+ msg[/(\(?)(\d\d\d)(\)?)$/, 2]
115
113
  end
116
114
  end
117
115
  end
@@ -0,0 +1,97 @@
1
+ # Service to construct a request header that includes optional attributes for search and fetch requests.
2
+ module Qa
3
+ module LinkedData
4
+ class RequestHeaderService
5
+ attr_reader :request, :params
6
+
7
+ # @param request [HttpRequest] request from controller
8
+ # @param params [Hash] attribute-value pairs holding the request parameters
9
+ # @option subauthority [String] the subauthority to query
10
+ # @option lang [Symbol] language used to select literals when multi-language is supported (e.g. :en, :fr, etc.)
11
+ # @option performance_data [Boolean] true if include_performance_data should be returned with the results; otherwise, false (default: false)
12
+ # @option context [Boolean] true if context should be returned with the results; otherwise, false (default: false) (search only)
13
+ # @option format [String] return data in this format (fetch only)
14
+ # @note params may have additional attribute-value pairs that are passed through via replacements (only configured replacements are used)
15
+ def initialize(request, params)
16
+ @request = request
17
+ @params = params
18
+ end
19
+
20
+ # Construct request parameters to pass to search_query (linked data module).
21
+ # @returns [Hash] parsed out attribute-value pairs that are required for the search query
22
+ # @see Qa::Authorities::LinkedData::SearchQuery
23
+ def search_header
24
+ header = {}
25
+ header[:subauthority] = params.fetch(:subauthority, nil)
26
+ header[:user_language] = user_language
27
+ header[:performance_data] = performance_data?
28
+ header[:context] = context?
29
+ header[:replacements] = replacements
30
+ header
31
+ end
32
+
33
+ # Construct request parameters to pass to fetching a term (linked data module).
34
+ # @returns [Hash] parsed out attribute-value pairs that are required for the term fetch.
35
+ # @see Qa::Authorities::LinkedData::FindTerm
36
+ def fetch_header
37
+ header = {}
38
+ header[:subauthority] = params.fetch(:subauthority, nil)
39
+ header[:user_language] = user_language
40
+ header[:performance_data] = performance_data?
41
+ header[:format] = format
42
+ header[:replacements] = replacements
43
+ header
44
+ end
45
+
46
+ # @returns [String] the response header content type based on requested format
47
+ def content_type_for_format
48
+ case format
49
+ when 'jsonld'
50
+ 'application/ld+json'
51
+ when 'n3'
52
+ 'text/n3'
53
+ when 'ntriples'
54
+ 'application/n-triples'
55
+ else
56
+ 'application/json'
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ # filter literals in results to this language
63
+ def user_language
64
+ request_language = request.env['HTTP_ACCEPT_LANGUAGE']
65
+ request_language = request_language.scan(/^[a-z]{2}/).first if request_language.present?
66
+ lang = params[:lang] || request_language
67
+ lang.present? ? Array(lang) : nil
68
+ end
69
+
70
+ # include extended context in the results if true (applies to search only)
71
+ def context?
72
+ context = params.fetch(:context, 'false')
73
+ context.casecmp?('true')
74
+ end
75
+
76
+ # include performance data in the results if true
77
+ def performance_data?
78
+ performance_data = params.fetch(:performance_data, 'false')
79
+ performance_data.casecmp?('true')
80
+ end
81
+
82
+ # any params not specifically handled are passed through via replacements
83
+ def replacements
84
+ params.reject do |k, _v|
85
+ ['q', 'vocab', 'controller', 'action', 'subauthority', 'lang', 'id',
86
+ 'context', 'performance_data', 'response_header', 'format'].include?(k)
87
+ end
88
+ end
89
+
90
+ # results are returned in the format (applies to fetch only)
91
+ def format
92
+ f = params.fetch(:format, 'json').downcase
93
+ ['jsonld', 'n3', 'ntriples'].include?(f) ? f : 'json'
94
+ end
95
+ end
96
+ end
97
+ end
@@ -44,11 +44,12 @@ module Qa::Authorities
44
44
  count = 1
45
45
  return stmts unless response["identifiers"].present?
46
46
  response["identifiers"].each do |activity|
47
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/identifiedBy", "Identifier#{count}")
48
- stmts << contruct_stmt_uri_object("Identifier#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Identifier")
49
- stmts << contruct_stmt_literal_object("Identifier#{count}", rdfs_label_predicate, activity["value"])
47
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/identifiedBy", "iidn#{count}")
48
+ stmts << contruct_stmt_uri_object("iidn#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Identifier")
49
+ stmts << contruct_stmt_literal_object("iidn#{count}", rdfs_label_predicate, activity["value"])
50
50
  count += 1
51
51
  end
52
+ stmts.concat(build_year_statements(response)) if response["released"].present?
52
53
  stmts # w/out this line, building the graph throws an undefined method `graph_name=' error
53
54
  end
54
55
 
@@ -64,7 +65,7 @@ module Qa::Authorities
64
65
  if df.present?
65
66
  stmts += build_format_characteristics(df, count)
66
67
  else
67
- stmts << contruct_stmt_literal_object("Instance1", "http://id.loc.gov/ontologies/bibframe/editionStatement", desc)
68
+ stmts << contruct_stmt_literal_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/editionStatement", desc)
68
69
  end
69
70
  end
70
71
  stmts
@@ -77,15 +78,13 @@ module Qa::Authorities
77
78
  stmts = []
78
79
  case df["type"]
79
80
  when "playbackChannel"
80
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/soundCharacteristic", df["uri"])
81
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/soundCharacteristic", df["uri"])
81
82
  stmts << contruct_stmt_uri_object(df["uri"], rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/PlaybackChannel")
82
83
  stmts << contruct_stmt_literal_object(df["uri"], rdfs_label_predicate, df["label"])
83
84
  when "dimension"
84
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/dimensions", df["label"])
85
+ stmts << contruct_stmt_literal_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/dimensions", df["label"])
85
86
  when "playingSpeed"
86
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/soundCharacteristic", "PlayingSpeed#{count}")
87
- stmts << contruct_stmt_uri_object("PlayingSpeed#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/PlayingSpeed")
88
- stmts << contruct_stmt_literal_object("PlayingSpeed#{count}", rdfs_label_predicate, df["label"])
87
+ stmts.concat(build_playing_speed_stmts(df["label"], count))
89
88
  end
90
89
  stmts # w/out this line, building the graph throws an undefined method `graph_name=' error
91
90
  end
@@ -98,13 +97,13 @@ module Qa::Authorities
98
97
  return stmts unless name.present?
99
98
  dc = discogs_formats[name.gsub(/\s+/, "")]
100
99
  if dc.present?
101
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/carrier", dc["uri"])
100
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/carrier", dc["uri"])
102
101
  stmts << contruct_stmt_uri_object(dc["uri"], rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Carrier")
103
102
  stmts << contruct_stmt_literal_object(dc["uri"], rdfs_label_predicate, dc["label"])
104
103
  stmts.concat(build_base_materials(name))
105
104
  else
106
105
  # if it's not a carrier, it's an edition statement
107
- stmts << contruct_stmt_literal_object("Instance1", "http://id.loc.gov/ontologies/bibframe/editionStatement", name)
106
+ stmts << contruct_stmt_literal_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/editionStatement", name)
108
107
  end
109
108
  stmts # w/out this line, building the graph throws an undefined method `graph_name=' error
110
109
  end
@@ -116,7 +115,7 @@ module Qa::Authorities
116
115
  return stmts unless name == "Vinyl" || name == "Shellac"
117
116
  id = name == "Vinyl" ? "300014502" : "300014918"
118
117
 
119
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/baseMaterial", "http://vocab.getty.edu/aat/" + id)
118
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/baseMaterial", "http://vocab.getty.edu/aat/" + id)
120
119
  stmts << contruct_stmt_uri_object("http://vocab.getty.edu/aat/" + id, rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/BaseMaterial")
121
120
  stmts << contruct_stmt_literal_object("http://vocab.getty.edu/aat/" + id, rdfs_label_predicate, name)
122
121
  stmts # w/out this line, building the graph throws an undefined method `graph_name=' error
@@ -129,13 +128,12 @@ module Qa::Authorities
129
128
  # need to distinguish among different provision activities and roles
130
129
  count = 1
131
130
  activities.each do |activity|
132
- stmts << contruct_stmt_uri_object("Instance1", "http://id.loc.gov/ontologies/bibframe/provisionActivity", "ProvisionActivity#{count}")
133
- stmts << contruct_stmt_uri_object("ProvisionActivity#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/ProvisionActivity")
134
- stmts << contruct_stmt_uri_object("ProvisionActivity#{count}", bf_agent_predicate, activity["name"])
135
- stmts << contruct_stmt_uri_object(activity["name"], rdf_type_predicate, bf_agent_type_object)
136
- stmts << contruct_stmt_uri_object(activity["name"], bf_role_predicate, "PA_Role#{count}")
137
- stmts << contruct_stmt_uri_object("PA_Role#{count}", rdf_type_predicate, bf_role_type_object)
138
- stmts << contruct_stmt_literal_object("PA_Role#{count}", rdfs_label_predicate, activity["entity_type_name"])
131
+ stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/provisionActivity", "proact#{count}")
132
+ stmts << contruct_stmt_uri_object("proact#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/ProvisionActivity")
133
+ stmts << contruct_stmt_uri_object("proact#{count}", bf_agent_predicate, "agentn3#{count}")
134
+ stmts << contruct_stmt_uri_object("agentn3#{count}", rdf_type_predicate, bf_agent_type_object)
135
+ stmts << contruct_stmt_literal_object("agentn3#{count}", rdfs_label_predicate, activity["name"])
136
+ stmts += build_role_stmts("agentn3#{count}", "role3#{count}", activity["entity_type_name"])
139
137
  count += 1
140
138
  end
141
139
  stmts # w/out this line, building the graph throws an undefined method `graph_name=' error