Skip to content

Commit

Permalink
Merge pull request #276 from samvera/resource_url
Browse files Browse the repository at this point in the history
Discogs URI change
  • Loading branch information
elrayle authored Oct 17, 2019
2 parents 6c89900 + 91fa5bd commit 80d678f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions lib/qa/authorities/discogs/discogs_translation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,16 @@ def compile_rdf_statements(response, subauthority)
# all we need is a work and not an instance. If there's no subauthority, we can determine
# if the discogs record is a master because it will have a main_release field.
if master_only(response, subauthority)
self.work_uri = response["uri"]
self.work_uri = response["uri"].present? ? response["uri"] : response["resource_url"]
complete_rdf_stmts.concat(build_master_statements(response))
else
# If the subauthority is not "master," we need to define an instance as well as a
# If the subauthority is "release," we need to define an instance as well as a
# work. If the discogs record has a master_id, fetch that and use the results to
# build the statements for the work.
master_resp = response["master_id"].present? ? json("https://api.discogs.com/masters/#{response['master_id']}") : response
self.work_uri = master_resp["uri"] if master_resp["uri"].present? && master_resp["uri"].include?("master")
complete_rdf_stmts.concat(build_master_statements(master_resp))
# Now do the statements for the instance.
self.instance_uri = response["uri"] if response["uri"].present?
# Now do the statements for the release/instance.
self.instance_uri = response["uri"].present? ? response["uri"] : response["resource_url"]
complete_rdf_stmts.concat(build_instance_statements(response))
end
end
Expand Down Expand Up @@ -93,7 +92,7 @@ def get_primary_work_definition(response)
# @return [Array] rdf statements
def get_primary_instance_definition(response)
stmts = []
stmts << contruct_stmt_uri_object(work_uri, "http://id.loc.gov/ontologies/bibframe/hasInstance", instance_uri)
stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/instanceOf", work_uri)
stmts << contruct_stmt_uri_object(instance_uri, rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Instance")
stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/title", "titlen2")
stmts << contruct_stmt_literal_object("titlen2", bf_main_title_predicate, response["title"])
Expand Down
4 changes: 2 additions & 2 deletions lib/qa/authorities/discogs/generic_authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class Discogs::GenericAuthority < Base
def initialize(subauthority)
@subauthority = subauthority
self.primary_artists = []
self.work_uri = "http://generic.uri/workn1"
self.instance_uri = "http://generic.uri/instn1"
self.work_uri = "workn1"
self.instance_uri = "instn1"
end

# @param [String] the query
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/discogs-find-response-json.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"status":"Accepted","series":[],"labels":[{"name":"Blue Note"}],"year":1962,"artists":[{"name":"Dexter Gordon"}],"id":3380671,"genres":["Jazz"],"title":"A Swingin' Affair","styles":["Hard Bop"],"formats":[{"qty":"1","descriptions":["LP","Album","Mono"],"name":"Vinyl"}]}
{"status":"Accepted","series":[],"labels":[{"name":"Blue Note"}],"year":1962,"artists":[{"name":"Dexter Gordon"}],"id":3380671,"genres":["Jazz"],"title":"A Swingin' Affair","styles":["Hard Bop"],"formats":[{"qty":"1","descriptions":["LP","Album","Mono"],"name":"Vinyl"}],"uri":"https://www.discogs.com/Dexter-Gordon-A-Swingin-Affair/release/3380671","resource_url":"https://api.discogs.com/releases/3380671"}

0 comments on commit 80d678f

Please sign in to comment.