Class: Qa::Authorities::LinkedData::TermConfig
- Inherits:
-
Object
- Object
- Qa::Authorities::LinkedData::TermConfig
- Defined in:
- lib/qa/authorities/linked_data/config/term_config.rb
Instance Attribute Summary collapse
-
#prefixes ⇒ Object
readonly
Returns the value of attribute prefixes.
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(config, prefixes = {}, full_config = nil) ⇒ TermConfig
constructor
A new instance of TermConfig.
-
#supports_language_parameter? ⇒ Boolean
True if supports language parameter; otherwise, false.
-
#supports_subauthorities? ⇒ Boolean
True if supports language parameter; otherwise, false.
-
#supports_term? ⇒ True|False
Does this authority configuration have term defined?.
-
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?.
-
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?.
-
#term_language ⇒ Symbol
(also: #language)
Return the preferred language for literal value selection for term fetch.
-
#term_qa_replacement_patterns ⇒ Hash
(also: #qa_replacement_patterns)
Return parameters that are required for QA api.
-
#term_results ⇒ Hash
Return results ldpaths or predicates.
-
#term_results_altlabel_ldpath ⇒ String
Return results altlabel_ldpath.
-
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate.
-
#term_results_broader_ldpath ⇒ String
Return results broader_ldpath.
-
#term_results_broader_predicate ⇒ String
Return results broader_predicate.
-
#term_results_id_ldpath ⇒ String
Return results id_ldpath.
-
#term_results_id_predicate(suppress_deprecation_warning: false) ⇒ String
Return results id_predicate NOTE: Customizations using this method should be updated to use ‘term_results_id_predicates` which returns [Array<String>] of id predicates.
-
#term_results_id_predicates ⇒ Array<String>
Return results id_predicates.
-
#term_results_label_ldpath ⇒ String
Return results label_ldpath.
-
#term_results_label_predicate(suppress_deprecation_warning: false) ⇒ String
Return results label_predicate.
-
#term_results_narrower_ldpath ⇒ String
Return results narrower_ldpath.
-
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate.
-
#term_results_sameas_ldpath ⇒ String
Return results sameas_ldpath.
-
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate.
-
#term_subauthorities ⇒ Hash
(also: #subauthorities)
Return the list of subauthorities for term fetch.
-
#term_subauthorities? ⇒ True|False
(also: #subauthorities?)
Are there subauthorities configured for term fetch?.
-
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?.
-
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch.
-
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
Constructor Details
#initialize(config, prefixes = {}, full_config = nil) ⇒ TermConfig
Returns a new instance of TermConfig.
16 17 18 19 20 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 16 def initialize(config, prefixes = {}, full_config = nil) @term_config = config @prefixes = prefixes @full_config = full_config end |
Instance Attribute Details
#prefixes ⇒ Object (readonly)
Returns the value of attribute prefixes.
8 9 10 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 8 def prefixes @prefixes end |
Instance Method Details
#info ⇒ Object
231 232 233 234 235 236 237 238 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 231 def info return [] unless supports_term? auth_name = .downcase.to_s language = Qa::LinkedData::LanguageService.preferred_language(authority_language: language).map(&:to_s) details = (auth_name, language) .keys { |subauth_name| details << (auth_name, subauth_name.downcase.to_s, language) } details end |
#supports_language_parameter? ⇒ Boolean
Returns true if supports language parameter; otherwise, false.
199 200 201 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 199 def supports_language_parameter? qa_replacement_patterns.key? :lang end |
#supports_subauthorities? ⇒ Boolean
Returns true if supports language parameter; otherwise, false.
194 195 196 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 194 def qa_replacement_patterns.key?(:subauth) && end |
#supports_term? ⇒ True|False
Does this authority configuration have term defined?
24 25 26 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 24 def supports_term? term_config.present? end |
#term_id_expects_id? ⇒ True|False
Is the term_id substitution expected to be an ID?
43 44 45 46 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 43 def term_id_expects_id? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "ID" end |
#term_id_expects_uri? ⇒ True|False
Is the term_id substitution expected to be a URI?
36 37 38 39 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 36 def term_id_expects_uri? return false if term_config.nil? || !(term_config.key? :term_id) term_config[:term_id] == "URI" end |
#term_language ⇒ Symbol Also known as: language
Return the preferred language for literal value selection for term fetch. Only applies if the authority provides language encoded literals. This is the default used for this authority if the user does not pass in a language. Only applies if the authority provides language encoded literals.
52 53 54 55 56 57 58 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 52 def term_language return @term_language unless @term_language.nil? lang = Config.config_value(term_config, :language) return nil if lang.nil? lang = [lang] if lang.is_a? String @term_language = lang.collect(&:to_sym) end |
#term_qa_replacement_patterns ⇒ Hash Also known as: qa_replacement_patterns
Return parameters that are required for QA api
188 189 190 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 188 def term_qa_replacement_patterns term_config.fetch(:qa_replacement_patterns, {}) end |
#term_results ⇒ Hash
Return results ldpaths or predicates
63 64 65 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 63 def term_results Config.config_value(term_config, :results) end |
#term_results_altlabel_ldpath ⇒ String
Return results altlabel_ldpath
120 121 122 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 120 def term_results_altlabel_ldpath Config.config_value(term_results, :altlabel_ldpath) end |
#term_results_altlabel_predicate ⇒ String
Return results altlabel_predicate
126 127 128 129 130 131 132 133 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 126 def term_results_altlabel_predicate Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_altlabel_predicate` is deprecated; use `term_results_altlabel_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `altlabel_ldpath`" ) Config.predicate_uri(term_results, :altlabel_predicate) end |
#term_results_broader_ldpath ⇒ String
Return results broader_ldpath
137 138 139 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 137 def term_results_broader_ldpath Config.config_value(term_results, :broader_ldpath) end |
#term_results_broader_predicate ⇒ String
Return results broader_predicate
143 144 145 146 147 148 149 150 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 143 def term_results_broader_predicate Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_broader_predicate` is deprecated; use `term_results_broader_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `broader_ldpath`" ) Config.predicate_uri(term_results, :broader_predicate) end |
#term_results_id_ldpath ⇒ String
Return results id_ldpath
69 70 71 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 69 def term_results_id_ldpath Config.config_value(term_results, :id_ldpath) end |
#term_results_id_predicate(suppress_deprecation_warning: false) ⇒ String
Return results id_predicate NOTE: Customizations using this method should be updated to use ‘term_results_id_predicates` which returns [Array<String>] of
id predicates. This method remains for backward compatibility only but may cause issues if used in places expecting an Array
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 87 def term_results_id_predicate(suppress_deprecation_warning: false) unless suppress_deprecation_warning Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_id_predicate` is deprecated; use `term_results_id_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `id_ldpath`" ) end id_predicates = term_results_id_predicates id_predicates.first end |
#term_results_id_predicates ⇒ Array<String>
Return results id_predicates
75 76 77 78 79 80 81 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 75 def term_results_id_predicates @pred_ids ||= begin pred = Config.predicate_uri(term_results, :id_predicate) pred ? [pred] : id_predicates_from_ldpath end end |
#term_results_label_ldpath ⇒ String
Return results label_ldpath
101 102 103 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 101 def term_results_label_ldpath Config.config_value(term_results, :label_ldpath) end |
#term_results_label_predicate(suppress_deprecation_warning: false) ⇒ String
Return results label_predicate
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 107 def term_results_label_predicate(suppress_deprecation_warning: false) unless suppress_deprecation_warning Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_label_predicate` is deprecated; use `term_results_label_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `label_ldpath`" ) end Config.predicate_uri(term_results, :label_predicate) end |
#term_results_narrower_ldpath ⇒ String
Return results narrower_ldpath
154 155 156 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 154 def term_results_narrower_ldpath Config.config_value(term_results, :narrower_ldpath) end |
#term_results_narrower_predicate ⇒ String
Return results narrower_predicate
160 161 162 163 164 165 166 167 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 160 def term_results_narrower_predicate Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_narrower_predicate` is deprecated; use `term_results_narrower_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `narrower_ldpath`" ) Config.predicate_uri(term_results, :narrower_predicate) end |
#term_results_sameas_ldpath ⇒ String
Return results sameas_ldpath
171 172 173 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 171 def term_results_sameas_ldpath Config.config_value(term_results, :sameas_ldpath) end |
#term_results_sameas_predicate ⇒ String
Return results sameas_predicate
177 178 179 180 181 182 183 184 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 177 def term_results_sameas_predicate Qa.deprecation_warning( in_msg: 'Qa::Authorities::LinkedData::TermConfig', msg: "`term_results_sameas_predicate` is deprecated; use `term_results_sameas_ldpath` by updating linked data " \ "term config results in authority #{} to specify as `sameas_ldpath`" ) Config.predicate_uri(term_results, :sameas_predicate) end |
#term_subauthorities ⇒ Hash Also known as:
Return the list of subauthorities for term fetch
225 226 227 228 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 225 def @term_subauthorities ||= {} if term_config.nil? || !(term_config.key? :subauthorities) @term_subauthorities ||= term_config[:subauthorities] end |
#term_subauthorities? ⇒ True|False Also known as:
Are there subauthorities configured for term fetch?
205 206 207 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 205 def .positive? end |
#term_subauthority?(subauth_name) ⇒ True|False
Is a specific subauthority configured for term fetch?
212 213 214 215 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 212 def (subauth_name) subauth_name = subauth_name.to_sym if subauth_name.is_a? String .key? subauth_name end |
#term_subauthority_count ⇒ Integer
Return the number of subauthorities defined for term fetch
219 220 221 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 219 def .size end |
#url_config ⇒ Qa::IriTemplate::UrlConfig
Return term url template defined in the configuration for this authority.
30 31 32 |
# File 'lib/qa/authorities/linked_data/config/term_config.rb', line 30 def url_config @url_config ||= Qa::IriTemplate::UrlConfig.new(term_config[:url]) if supports_term? end |