diff --git a/lib/qa/authorities/discogs/discogs_translation.rb b/lib/qa/authorities/discogs/discogs_translation.rb index 0b128cda..fa548bfe 100644 --- a/lib/qa/authorities/discogs/discogs_translation.rb +++ b/lib/qa/authorities/discogs/discogs_translation.rb @@ -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 @@ -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"]) diff --git a/lib/qa/authorities/discogs/generic_authority.rb b/lib/qa/authorities/discogs/generic_authority.rb index 3ecb4130..a634a3ab 100644 --- a/lib/qa/authorities/discogs/generic_authority.rb +++ b/lib/qa/authorities/discogs/generic_authority.rb @@ -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 diff --git a/spec/fixtures/discogs-find-response-json.json b/spec/fixtures/discogs-find-response-json.json index e92c037a..f51823f7 100644 --- a/spec/fixtures/discogs-find-response-json.json +++ b/spec/fixtures/discogs-find-response-json.json @@ -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"}]} \ No newline at end of file +{"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"} \ No newline at end of file