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_year_statements(response, type) ⇒ 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
-
#get_year_rdf(type, year) ⇒ Array
Rdf statements.
-
#rdf_type_predicate ⇒ Object
frequently used predicates and objects.
- #rdfs_label_predicate ⇒ Object
Instance Method Details
#bf_agent_predicate ⇒ Object
39 40 41 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 39 def bf_agent_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/agent") end |
#bf_agent_type_object ⇒ Object
43 44 45 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 43 def bf_agent_type_object RDF::URI("http://id.loc.gov/ontologies/bibframe/Agent") end |
#bf_main_title_predicate ⇒ Object
35 36 37 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 35 def bf_main_title_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/mainTitle") end |
#bf_role_predicate ⇒ Object
47 48 49 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 47 def bf_role_predicate RDF::URI("http://id.loc.gov/ontologies/bibframe/role") end |
#bf_role_type_object ⇒ Object
51 52 53 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 51 def bf_role_type_object RDF::URI("http://id.loc.gov/ontologies/bibframe/Role") end |
#build_year_statements(response, type) ⇒ Array
both the work and the instance require a statement for the release year
67 68 69 70 71 72 73 74 75 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 67 def build_year_statements(response, type) year_stmts = [] if type == "Work" && response["year"].present? year_stmts = get_year_rdf(type + "1", response["year"]) elsif response["released"].present? year_stmts = get_year_rdf(type + "1", response["released"]) end 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
22 23 24 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 22 def contruct_stmt_literal_object(subject, predicate, object) RDF::Statement(RDF::URI.new(subject), 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 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 13 def contruct_stmt_uri_object(subject, predicate, object) RDF::Statement(RDF::URI.new(subject), RDF::URI(predicate), RDF::URI.new(object)) end |
#discogs_formats ⇒ Object
59 60 61 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 59 def discogs_formats DISCOGS_FORMATS_MAPPING end |
#discogs_genres ⇒ Object
55 56 57 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 55 def discogs_genres DISCOGS_GENRE_MAPPING end |
#get_year_rdf(type, year) ⇒ Array
Returns rdf statements.
80 81 82 83 84 85 86 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 80 def get_year_rdf(type, year) year_stmts = [] year_stmts << contruct_stmt_uri_object(type, "http://id.loc.gov/ontologies/bibframe/provisionActivity", "#{type}ProvisionActivityDate") year_stmts << contruct_stmt_uri_object("#{type}ProvisionActivityDate", rdf_type_predicate, "http://id.loc.gov/ontologies/bibframe/ProvisionActivity") # Full RDF statement syntax as this one requires a datatype year_stmts << RDF::Statement(RDF::URI.new("#{type}ProvisionActivityDate"), RDF::URI("http://id.loc.gov/ontologies/bibframe/date"), RDF::Literal.new(year.to_s, datatype: RDF::XSD.date)) end |
#rdf_type_predicate ⇒ Object
frequently used predicates and objects
27 28 29 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 27 def rdf_type_predicate RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type") end |
#rdfs_label_predicate ⇒ Object
31 32 33 |
# File 'lib/qa/authorities/discogs/discogs_utils.rb', line 31 def rdfs_label_predicate RDF::URI("http://www.w3.org/2000/01/rdf-schema#label") end |