diff --git a/lib/qa/authorities/linked_data/config/search_config.rb b/lib/qa/authorities/linked_data/config/search_config.rb index 62c802a1..a3129639 100644 --- a/lib/qa/authorities/linked_data/config/search_config.rb +++ b/lib/qa/authorities/linked_data/config/search_config.rb @@ -105,7 +105,7 @@ def results_altlabel_predicate # Does this authority configuration support sorting of search results? # @return [True|False] true if sorting of search results is supported; otherwise, false def supports_sort? - return true unless results_sort_ldpath.present? || !results_sort_predicate.present? + return true if results_sort_ldpath.present? || results_sort_predicate.present? false end diff --git a/spec/fixtures/authorities/linked_data/lod_full_config.json b/spec/fixtures/authorities/linked_data/lod_full_config.json index 3ea881d0..b6e6ea9a 100644 --- a/spec/fixtures/authorities/linked_data/lod_full_config.json +++ b/spec/fixtures/authorities/linked_data/lod_full_config.json @@ -2,8 +2,7 @@ "QA_CONFIG_VERSION": "2.2", "service_uri": "http://ld4l.org/ld4l_services/cache", "prefixes": { - "schema": "http://www.w3.org/2000/01/rdf-schema#", - "skos": "http://www.w3.org/2004/02/skos/core#" + "dcterms": "http://purl.org/dc/terms/" }, "term": { "url": { @@ -56,12 +55,12 @@ "term_id": "ID", "language": [ "es" ], "results": { - "id_predicate": "http://purl.org/dc/terms/identifier", - "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel", - "altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel", - "broader_predicate": "http://www.w3.org/2004/02/skos/core#broader", - "narrower_predicate": "http://www.w3.org/2004/02/skos/core#narrower", - "sameas_predicate": "http://www.w3.org/2004/02/skos/core#exactMatch" + "id_ldpath": "dcterms:identifier", + "label_ldpath": "skos:prefLabel", + "altlabel_ldpath": "skos:altLabel", + "broader_ldpath": "skos:broader", + "narrower_ldpath": "skos:narrower", + "sameas_ldpath": "skos:exactMatch" }, "subauthorities": { "term_sub1_key": "term_sub1_name", @@ -122,10 +121,10 @@ "language": [ "en", "fr", "de" ], "total_count_ldpath": "vivo:count", "results": { - "id_predicate": "http://purl.org/dc/terms/identifier", - "label_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel", - "altlabel_predicate": "http://www.w3.org/2004/02/skos/core#altLabel", - "sort_predicate": "http://www.w3.org/2004/02/skos/core#prefLabel" + "id_ldpath": "dcterms:identifier", + "label_ldpath": "skos:prefLabel", + "altlabel_ldpath": "skos:altLabel", + "sort_ldpath": "skos:prefLabel" }, "context": { "groups": { @@ -150,7 +149,7 @@ "group_id": "dates", "property_label_i18n": "qa.linked_data.authority.locnames_ld4l_cache.birth_date", "property_label_default": "Birth", - "ldpath": "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label", + "ldpath": "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label", "selectable": false, "drillable": false }, diff --git a/spec/lib/authorities/linked_data/config_spec.rb b/spec/lib/authorities/linked_data/config_spec.rb index 1edd2a53..ff879d9f 100644 --- a/spec/lib/authorities/linked_data/config_spec.rb +++ b/spec/lib/authorities/linked_data/config_spec.rb @@ -28,8 +28,7 @@ QA_CONFIG_VERSION: "2.2", service_uri: "http://ld4l.org/ld4l_services/cache", prefixes: { - schema: "http://www.w3.org/2000/01/rdf-schema#", - skos: "http://www.w3.org/2004/02/skos/core#" + dcterms: "http://purl.org/dc/terms/" }, term: { url: { @@ -82,12 +81,12 @@ term_id: 'ID', language: ['es'], results: { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader', - narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower', - sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + broader_ldpath: 'skos:broader', + narrower_ldpath: 'skos:narrower', + sameas_ldpath: 'skos:exactMatch' }, subauthorities: { term_sub1_key: 'term_sub1_name', @@ -148,10 +147,10 @@ language: ['en', 'fr', 'de'], total_count_ldpath: "vivo:count", results: { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + sort_ldpath: 'skos:prefLabel' }, context: { groups: { @@ -176,7 +175,7 @@ group_id: "dates", property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date", property_label_default: "Birth", - ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label", + ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label", selectable: false, drillable: false }, @@ -405,8 +404,7 @@ describe '#prefixes' do let(:expected_results) do { - schema: "http://www.w3.org/2000/01/rdf-schema#", - skos: "http://www.w3.org/2004/02/skos/core#" + dcterms: "http://purl.org/dc/terms/" } end diff --git a/spec/lib/authorities/linked_data/search_config_spec.rb b/spec/lib/authorities/linked_data/search_config_spec.rb index 827f9760..e147ce8f 100644 --- a/spec/lib/authorities/linked_data/search_config_spec.rb +++ b/spec/lib/authorities/linked_data/search_config_spec.rb @@ -11,12 +11,12 @@ let(:term_only_config) { Qa::Authorities::LinkedData::Config.new(:LOD_TERM_ONLY_CONFIG).search } let(:encoding_config) { Qa::Authorities::LinkedData::Config.new(:LOD_ENCODING_CONFIG).search } - let(:ldpath_results_config) do + let(:predicate_results_config) do { - id_ldpath: 'schema:identifier ::xsd:string', - label_ldpath: 'skos:prefLabel ::xsd:string', - altlabel_ldpath: 'skos:altLabel ::xsd:string', - sort_ldpath: 'skos:prefLabel ::xsd:string' + id_predicate: 'http://purl.org/dc/terms/identifier', + label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', + altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', + sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel' } end @@ -75,10 +75,10 @@ language: ['en', 'fr', 'de'], total_count_ldpath: "vivo:count", results: { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + sort_ldpath: 'skos:prefLabel' }, context: { groups: { @@ -103,7 +103,7 @@ group_id: "dates", property_label_i18n: "qa.linked_data.authority.locnames_ld4l_cache.birth_date", property_label_default: "Birth", - ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/schema:label", + ldpath: "madsrdf:identifiesRWO/madsrdf:birthDate/rdfs:label", selectable: false, drillable: false }, @@ -178,22 +178,23 @@ describe '#results' do let(:results_config) do { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - sort_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + sort_ldpath: 'skos:prefLabel' } end it 'returns nil if only term configuration is defined' do expect(term_only_config.results).to eq nil end - it 'returns hash of predicates' do + it 'returns hash of ldpaths' do expect(full_config.results).to eq results_config end end describe '#results_id_predicate' do + before { allow(full_config).to receive(:results).and_return(predicate_results_config) } it 'returns nil if only term configuration is defined' do expect(term_only_config.results_id_predicate).to eq nil end @@ -208,14 +209,15 @@ end context 'when id specified as ldpath' do - before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.results_id_ldpath).to eq 'schema:identifier ::xsd:string' + expect(full_config.results_id_ldpath).to eq 'dcterms:identifier' end end end describe '#results_label_predicate' do + before { allow(full_config).to receive(:results).and_return(predicate_results_config) } it 'returns nil if only term configuration is defined' do expect(term_only_config.results_label_predicate).to eq nil end @@ -230,14 +232,15 @@ end context 'when label specified as ldpath' do - before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.results_label_ldpath).to eq 'skos:prefLabel ::xsd:string' + expect(full_config.results_label_ldpath).to eq 'skos:prefLabel' end end end describe '#results_altlabel_predicate' do + before { allow(full_config).to receive(:results).and_return(predicate_results_config) } it 'returns nil if only term configuration is defined' do expect(term_only_config.results_altlabel_predicate).to eq nil end @@ -258,9 +261,9 @@ end context 'when altlabel specified as ldpath' do - before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.results_altlabel_ldpath).to eq 'skos:altLabel ::xsd:string' + expect(full_config.results_altlabel_ldpath).to eq 'skos:altLabel' end end end @@ -269,15 +272,16 @@ it 'returns false if only term configuration is defined' do expect(term_only_config.supports_sort?).to eq false end - it 'returns false if sort predicate is NOT defined' do + it 'returns false if sort ldpath is NOT defined' do expect(min_config.supports_sort?).to eq false end - it 'returns true if sort predicate IS defined' do + it 'returns true if sort ldpath IS defined' do expect(full_config.supports_sort?).to eq true end end describe '#results_sort_predicate' do + before { allow(full_config).to receive(:results).and_return(predicate_results_config) } it 'returns nil if only term configuration is defined' do expect(term_only_config.results_sort_predicate).to eq nil end @@ -298,9 +302,9 @@ end context 'when sort specified as ldpath' do - before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.results_sort_ldpath).to eq 'skos:prefLabel ::xsd:string' + expect(full_config.results_sort_ldpath).to eq 'skos:prefLabel' end end end diff --git a/spec/lib/authorities/linked_data/term_config_spec.rb b/spec/lib/authorities/linked_data/term_config_spec.rb index ce0248c7..cf06ea9d 100644 --- a/spec/lib/authorities/linked_data/term_config_spec.rb +++ b/spec/lib/authorities/linked_data/term_config_spec.rb @@ -8,14 +8,14 @@ let(:encoding_config) { Qa::Authorities::LinkedData::Config.new(:LOD_ENCODING_CONFIG).term } let(:loc_config) { Qa::Authorities::LinkedData::Config.new(:LOC).term } - let(:ldpath_results_config) do + let(:predicate_results_config) do { - id_ldpath: 'schema:identifier ::xsd:string', - label_ldpath: 'skos:prefLabel ::xsd:string', - altlabel_ldpath: 'skos:altLabel ::xsd:string', - broader_ldpath: 'skos:broader ::xsd:string', - narrower_ldpath: 'skos:narrower ::xsd:string', - sameas_ldpath: 'skos:exactMatch ::xsd:string' + id_predicate: 'http://purl.org/dc/terms/identifier', + label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', + altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', + broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader', + narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower', + sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch' } end @@ -72,12 +72,12 @@ term_id: 'ID', language: ['es'], results: { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader', - narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower', - sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + broader_ldpath: 'skos:broader', + narrower_ldpath: 'skos:narrower', + sameas_ldpath: 'skos:exactMatch' }, subauthorities: { term_sub1_key: 'term_sub1_name', @@ -191,23 +191,24 @@ describe '#term_results' do let(:results_config) do { - id_predicate: 'http://purl.org/dc/terms/identifier', - label_predicate: 'http://www.w3.org/2004/02/skos/core#prefLabel', - altlabel_predicate: 'http://www.w3.org/2004/02/skos/core#altLabel', - broader_predicate: 'http://www.w3.org/2004/02/skos/core#broader', - narrower_predicate: 'http://www.w3.org/2004/02/skos/core#narrower', - sameas_predicate: 'http://www.w3.org/2004/02/skos/core#exactMatch' + id_ldpath: 'dcterms:identifier', + label_ldpath: 'skos:prefLabel', + altlabel_ldpath: 'skos:altLabel', + broader_ldpath: 'skos:broader', + narrower_ldpath: 'skos:narrower', + sameas_ldpath: 'skos:exactMatch' } end it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results).to eq nil end - it 'returns hash of predicates or ldpaths' do + it 'returns hash of ldpaths' do expect(full_config.term_results).to eq results_config end end describe '#term_results_id_predicates' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_id_predicates).to eq [] end @@ -235,14 +236,14 @@ end context 'when id specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_id_ldpath).to eq 'schema:identifier ::xsd:string' + expect(full_config.term_results_id_ldpath).to eq 'dcterms:identifier' end end end describe '#term_results_label_predicate' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_label_predicate).to eq nil end @@ -257,14 +258,15 @@ end context 'when label specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_label_ldpath).to eq 'skos:prefLabel ::xsd:string' + expect(full_config.term_results_label_ldpath).to eq 'skos:prefLabel' end end end describe '#term_results_altlabel_predicate' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_altlabel_predicate).to eq nil end @@ -285,14 +287,15 @@ end context 'when altlabel specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_altlabel_ldpath).to eq 'skos:altLabel ::xsd:string' + expect(full_config.term_results_altlabel_ldpath).to eq 'skos:altLabel' end end end describe '#term_results_broader_predicate' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_broader_predicate).to eq nil end @@ -313,14 +316,15 @@ end context 'when broader specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_broader_ldpath).to eq 'skos:broader ::xsd:string' + expect(full_config.term_results_broader_ldpath).to eq 'skos:broader' end end end describe '#term_results_narrower_predicate' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_narrower_predicate).to eq nil end @@ -341,14 +345,15 @@ end context 'when narrower specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_narrower_ldpath).to eq 'skos:narrower ::xsd:string' + expect(full_config.term_results_narrower_ldpath).to eq 'skos:narrower' end end end describe '#term_results_sameas_predicate' do + before { allow(full_config).to receive(:term_results).and_return(predicate_results_config) } it 'returns nil if only search configuration is defined' do expect(search_only_config.term_results_sameas_predicate).to eq nil end @@ -369,9 +374,9 @@ end context 'when sameas specified as ldpath' do - before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } + # before { allow(full_config).to receive(:term_results).and_return(ldpath_results_config) } it 'returns the ldpath' do - expect(full_config.term_results_sameas_ldpath).to eq 'skos:exactMatch ::xsd:string' + expect(full_config.term_results_sameas_ldpath).to eq 'skos:exactMatch' end end end