Module: Qa::Authorities::Discogs::DiscogsUtils
- Included in:
- DiscogsInstanceBuilder, DiscogsTranslation, DiscogsWorksBuilder
- Defined in:
- lib/qa/authorities/discogs/discogs_utils.rb
Constant Summary collapse
- DISCOGS_GENRE_MAPPING =
YAML.load_file(Rails.root.join("config", "discogs-genres.yml"))
- DISCOGS_FORMATS_MAPPING =
YAML.load_file(Rails.root.join("config", "discogs-formats.yml"))
Instance Method Summary collapse
- #bf_agent_predicate ⇒ Object
- #bf_agent_type_object ⇒ Object
- #bf_main_title_predicate ⇒ Object
- #bf_role_predicate ⇒ Object
- #bf_role_type_object ⇒ Object
-
#build_playing_speed_stmts(label, count) ⇒ Array
Rdf statements.
-
#build_role_stmts(subject_node, role_node, label) ⇒ Array
Rdf statements.
-
#build_year_statements(response) ⇒ Array
both the work and the instance require a statement for the release year.
-
#contruct_stmt_literal_object(subject, predicate, object) ⇒ Class
Constructs an RDF statement where the subject and predicate are URIs and the object is a literal.
-
#contruct_stmt_uri_object(subject, predicate, object) ⇒ Class
Constructs an RDF statement where the subject, predicate and object are all URIs.
- #discogs_formats ⇒ Object
- #discogs_genres ⇒ Object
-
#rdf_type_predicate ⇒ Object
frequently used predicates and objects.
- #rdfs_label_predicate ⇒ Object
Instance Method Details
#bf_agent_predicate ⇒ Object
42 43 44 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 42 def bf_agent_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/agent") end |
#bf_agent_type_object ⇒ Object
46 47 48 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 46 def bf_agent_type_object "http://id.loc.gov/ontologies/bibframe/Agent" end |
#bf_main_title_predicate ⇒ Object
38 39 40 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 38 def bf_main_title_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/mainTitle") end |
#bf_role_predicate ⇒ Object
50 51 52 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 50 def bf_role_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/role") end |
#bf_role_type_object ⇒ Object
54 55 56 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 54 def bf_role_type_object "http://id.loc.gov/ontologies/bibframe/Role" end |
#build_playing_speed_stmts(label, count) ⇒ Array
Returns rdf statements.
92 93 94 95 96 97 98 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 92 def (label, count) stmts = [] stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/soundCharacteristic", "speed#{count}") stmts << contruct_stmt_uri_object("speed#{count}", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/PlayingSpeed") stmts << contruct_stmt_literal_object("speed#{count}", rdfs_label_predicate, label) stmts # w/out this line, building the graph throws an undefined method `graph_name=' error end |
#build_role_stmts(subject_node, role_node, label) ⇒ Array
Returns rdf statements.
81 82 83 84 85 86 87 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 81 def build_role_stmts(subject_node, role_node, label) stmts = [] stmts << contruct_stmt_uri_object(subject_node, bf_role_predicate, role_node) stmts << contruct_stmt_uri_object(role_node, rdf_type_predicate, bf_role_type_object) stmts << contruct_stmt_literal_object(role_node, rdfs_label_predicate, label) stmts # w/out this line, building the graph throws an undefined method `graph_name=' error end |
#build_year_statements(response) ⇒ Array
both the work and the instance require a statement for the release year
69 70 71 72 73 74 75 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 69 def build_year_statements(response) year_stmts = [] year_stmts << contruct_stmt_uri_object(instance_uri, "http://id.loc.gov/ontologies/bibframe/provisionActivity", "daten1") year_stmts << contruct_stmt_uri_object("daten1", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/Publication") year_stmts << contruct_stmt_literal_object("daten1", RDF::URI("http://id.loc.gov/ontologies/bibframe/date"), response["released"].to_s) year_stmts # w/out this line, building the graph throws an undefined method `graph_name=' error end |
#contruct_stmt_literal_object(subject, predicate, object) ⇒ Class
Constructs an RDF statement where the subject and predicate are URIs and the object is a literal
24 25 26 27 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 24 def contruct_stmt_literal_object(subject, predicate, object) s = subject.include?("http") ? RDF::URI.new(subject) : subject.to_sym RDF::Statement(s, RDF::URI(predicate), RDF::Literal.new(object)) end |
#contruct_stmt_uri_object(subject, predicate, object) ⇒ Class
Constructs an RDF statement where the subject, predicate and object are all URIs
13 14 15 16 17 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 13 def contruct_stmt_uri_object(subject, predicate, object) s = subject.include?("http") ? RDF::URI.new(subject) : subject.to_sym o = object.to_s.include?("http") ? RDF::URI.new(object) : object.to_sym RDF::Statement(s, RDF::URI(predicate), o) end |
#discogs_formats ⇒ Object
62 63 64 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 62 def discogs_formats DISCOGS_FORMATS_MAPPING end |
#discogs_genres ⇒ Object
58 59 60 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 58 def discogs_genres DISCOGS_GENRE_MAPPING end |
#rdf_type_predicate ⇒ Object
frequently used predicates and objects
30 31 32 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 30 def rdf_type_predicate RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") end |
#rdfs_label_predicate ⇒ Object
34 35 36 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 34 def rdfs_label_predicate RDF::URI("http://www.w3.org/2000/01/rdf-schema#label") end |