hydra-pcdm 0.8.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/lib/hydra/pcdm.rb +1 -0
- data/lib/hydra/pcdm/collection_indexer.rb +1 -4
- data/lib/hydra/pcdm/config.rb +5 -0
- data/lib/hydra/pcdm/models/concerns/object_behavior.rb +12 -0
- data/lib/hydra/pcdm/object_indexer.rb +2 -5
- data/lib/hydra/pcdm/pcdm_indexer.rb +12 -0
- data/lib/hydra/pcdm/version.rb +1 -1
- data/lib/hydra/pcdm/vocab/pcdm_terms.rb +30 -6
- data/spec/hydra/pcdm/models/object_spec.rb +24 -0
- data/spec/hydra/pcdm/object_indexer_spec.rb +4 -0
- data/spec/hydra/pcdm/pcdm_indexer_spec.rb +19 -0
- data/spec/spec_helper.rb +71 -6
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 006a56a41489a68705b5f0ba39cb71adaebcd93a
|
4
|
+
data.tar.gz: 9bf9ac83b49048e144b2a595ad0a38ae16507936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45a1c0c840a1262986f00485d2eed19e0032c84dffabf0fa5ce51f7dcadd1e2dc0db5e02c748a4192c3e8fb541f1ca56d236726ddc2e0c02630421423d8a1b8d
|
7
|
+
data.tar.gz: 02969cb30e666ea14ced04268404702aea51fbee3f346957677d142e6bb907a685b1fcfac745c9017f7613cac55988171d7316b6ac88b7269fd5341babfa9b5b
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/lib/hydra/pcdm.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
1
|
module Hydra::PCDM
|
2
|
-
class CollectionIndexer <
|
2
|
+
class CollectionIndexer < PCDMIndexer
|
3
3
|
def generate_solr_document
|
4
4
|
super.tap do |solr_doc|
|
5
|
-
solr_doc[Config.indexing_member_ids_key] ||= []
|
6
|
-
solr_doc[Config.indexing_member_ids_key] += object.member_ids
|
7
|
-
solr_doc[Config.indexing_member_ids_key].uniq!
|
8
5
|
solr_doc[Config.indexing_collection_ids_key] = object.ordered_collection_ids
|
9
6
|
end
|
10
7
|
end
|
data/lib/hydra/pcdm/config.rb
CHANGED
@@ -7,6 +7,11 @@ module Hydra
|
|
7
7
|
INDEXING_MEMBER_IDS_KEY
|
8
8
|
end
|
9
9
|
|
10
|
+
INDEXING_MEMBER_OF_COLLECTION_IDS_KEY = 'member_of_collection_ids_ssim'.freeze
|
11
|
+
def self.indexing_member_of_collection_ids_key
|
12
|
+
INDEXING_MEMBER_OF_COLLECTION_IDS_KEY
|
13
|
+
end
|
14
|
+
|
10
15
|
INDEXING_COLLECTION_IDS_KEY = 'collection_ids_ssim'.freeze
|
11
16
|
def self.indexing_collection_ids_key
|
12
17
|
INDEXING_COLLECTION_IDS_KEY
|
@@ -17,6 +17,14 @@ module Hydra::PCDM
|
|
17
17
|
|
18
18
|
directly_contains :files, has_member_relation: Vocab::PCDMTerms.hasFile,
|
19
19
|
class_name: 'Hydra::PCDM::File'
|
20
|
+
|
21
|
+
indirectly_contains :member_of_collections,
|
22
|
+
has_member_relation: Vocab::PCDMTerms.memberOf,
|
23
|
+
inserted_content_relation: RDF::Vocab::ORE.proxyFor,
|
24
|
+
class_name: 'ActiveFedora::Base',
|
25
|
+
through: 'ActiveFedora::Aggregation::Proxy',
|
26
|
+
foreign_key: :target,
|
27
|
+
type_validator: Validators::PCDMCollectionValidator
|
20
28
|
end
|
21
29
|
|
22
30
|
module ClassMethods
|
@@ -43,6 +51,10 @@ module Hydra::PCDM
|
|
43
51
|
member_of.select(&:pcdm_object?).to_a
|
44
52
|
end
|
45
53
|
|
54
|
+
def member_of_collection_ids
|
55
|
+
member_of_collections.map(&:id)
|
56
|
+
end
|
57
|
+
|
46
58
|
# Returns directly contained files that have the requested RDF Type
|
47
59
|
# @param [RDF::URI] uri for the desired Type
|
48
60
|
# @example
|
@@ -1,11 +1,8 @@
|
|
1
1
|
module Hydra::PCDM
|
2
|
-
class ObjectIndexer <
|
2
|
+
class ObjectIndexer < PCDMIndexer
|
3
3
|
def generate_solr_document
|
4
4
|
super.tap do |solr_doc|
|
5
|
-
solr_doc[Config.
|
6
|
-
solr_doc[Config.indexing_member_ids_key] += object.member_ids
|
7
|
-
solr_doc[Config.indexing_member_ids_key].uniq!
|
8
|
-
solr_doc[Config.indexing_object_ids_key] = object.ordered_object_ids
|
5
|
+
solr_doc[Config.indexing_member_of_collection_ids_key] = object.member_of_collection_ids
|
9
6
|
end
|
10
7
|
end
|
11
8
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Hydra::PCDM
|
2
|
+
class PCDMIndexer < ActiveFedora::IndexingService
|
3
|
+
def generate_solr_document
|
4
|
+
super.tap do |solr_doc|
|
5
|
+
solr_doc[Config.indexing_member_ids_key] ||= []
|
6
|
+
solr_doc[Config.indexing_member_ids_key] += object.member_ids
|
7
|
+
solr_doc[Config.indexing_member_ids_key].uniq!
|
8
|
+
solr_doc[Config.indexing_object_ids_key] = object.ordered_object_ids
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/hydra/pcdm/version.rb
CHANGED
@@ -49,13 +49,21 @@ module Hydra::PCDM
|
|
49
49
|
type: 'rdfs:Class'.freeze
|
50
50
|
|
51
51
|
# Property definitions
|
52
|
+
property :fileOf,
|
53
|
+
comment: %(Links from a File to its containing Object.).freeze,
|
54
|
+
domain: 'http://pcdm.org/models#File'.freeze,
|
55
|
+
label: 'is file of'.freeze,
|
56
|
+
range: 'http://pcdm.org/models#Object'.freeze,
|
57
|
+
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
58
|
+
subPropertyOf: 'http://www.openarchives.org/ore/terms/isAggregatedBy'.freeze,
|
59
|
+
type: 'rdf:Property'.freeze
|
52
60
|
property :hasFile,
|
53
61
|
comment: %(Links to a File contained by this Object.).freeze,
|
54
62
|
domain: 'http://pcdm.org/models#Object'.freeze,
|
55
63
|
label: 'has file'.freeze,
|
56
64
|
range: 'http://pcdm.org/models#File'.freeze,
|
57
65
|
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
58
|
-
subPropertyOf: 'http://www.
|
66
|
+
subPropertyOf: 'http://www.openarchives.org/ore/terms/aggregates'.freeze,
|
59
67
|
type: 'rdf:Property'.freeze
|
60
68
|
property :hasMember,
|
61
69
|
comment: %(Links to a related Object. Typically used to link to component parts, such as a book linking to a page.).freeze,
|
@@ -65,13 +73,29 @@ module Hydra::PCDM
|
|
65
73
|
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
66
74
|
subPropertyOf: 'http://www.openarchives.org/ore/terms/aggregates'.freeze,
|
67
75
|
type: 'rdf:Property'.freeze
|
68
|
-
property :
|
69
|
-
comment: %(Links to a
|
76
|
+
property :hasRelatedObject,
|
77
|
+
comment: %(Links to a related Object that is not a component part, such as an object representing a donor agreement or policies that govern the resource.).freeze,
|
78
|
+
domain: 'http://www.openarchives.org/ore/terms/Aggregation'.freeze,
|
79
|
+
label: 'has related object'.freeze,
|
80
|
+
range: 'http://pcdm.org/models#Object'.freeze,
|
81
|
+
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
82
|
+
subPropertyOf: 'http://www.openarchives.org/ore/terms/aggregates'.freeze,
|
83
|
+
type: 'rdf:Property'.freeze
|
84
|
+
property :memberOf,
|
85
|
+
comment: %(Links from an Object or Collection to a containing Object or Collection.).freeze,
|
86
|
+
domain: 'http://www.openarchives.org/ore/terms/Aggregation'.freeze,
|
87
|
+
label: 'is member of'.freeze,
|
88
|
+
range: 'http://www.openarchives.org/ore/terms/Aggregation'.freeze,
|
89
|
+
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
90
|
+
subPropertyOf: 'http://www.openarchives.org/ore/terms/isAggregatedBy'.freeze,
|
91
|
+
type: 'rdf:Property'.freeze
|
92
|
+
property :relatedObjectOf,
|
93
|
+
comment: %(Links from an Object to a Object or Collection that it is related to.).freeze,
|
70
94
|
domain: 'http://pcdm.org/models#Object'.freeze,
|
71
|
-
label: '
|
72
|
-
range: 'http://
|
95
|
+
label: 'is related object of'.freeze,
|
96
|
+
range: 'http://www.openarchives.org/ore/terms/Aggregation'.freeze,
|
73
97
|
'rdfs:isDefinedBy' => %(http://pcdm.org/models#).freeze,
|
74
|
-
subPropertyOf: 'http://www.
|
98
|
+
subPropertyOf: 'http://www.openarchives.org/ore/terms/isAggregatedBy'.freeze,
|
75
99
|
type: 'rdf:Property'.freeze
|
76
100
|
|
77
101
|
# Extra definitions
|
@@ -516,4 +516,28 @@ describe Hydra::PCDM::Object do
|
|
516
516
|
it { is_expected.to eq IndexingStuff::AltIndexer }
|
517
517
|
end
|
518
518
|
end
|
519
|
+
|
520
|
+
describe 'membership in collections' do
|
521
|
+
let(:collection1) { Hydra::PCDM::Collection.create }
|
522
|
+
let(:collection2) { Hydra::PCDM::Collection.create }
|
523
|
+
|
524
|
+
subject do
|
525
|
+
object = described_class.new
|
526
|
+
object.member_of_collections = [collection1, collection2]
|
527
|
+
object.save
|
528
|
+
object
|
529
|
+
end
|
530
|
+
|
531
|
+
describe '#member_of_collections' do
|
532
|
+
it 'contains collections the object is a member of' do
|
533
|
+
expect(subject.member_of_collections).to match_array [collection1, collection2]
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
describe '#member_of_collection_ids' do
|
538
|
+
it 'contains the ids of collections the object is a member of' do
|
539
|
+
expect(subject.member_of_collection_ids).to match_array [collection1.id, collection2.id]
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
519
543
|
end
|
@@ -4,10 +4,13 @@ describe Hydra::PCDM::ObjectIndexer do
|
|
4
4
|
let(:object) { Hydra::PCDM::Object.new }
|
5
5
|
let(:child_object1) { Hydra::PCDM::Object.new(id: '123') }
|
6
6
|
let(:child_object2) { Hydra::PCDM::Object.new(id: '456') }
|
7
|
+
let(:collection1) { Hydra::PCDM::Collection.new(id: 'abc') }
|
8
|
+
let(:collection2) { Hydra::PCDM::Collection.new(id: 'def') }
|
7
9
|
let(:indexer) { described_class.new(object) }
|
8
10
|
|
9
11
|
before do
|
10
12
|
allow(object).to receive(:ordered_object_ids).and_return([child_object1.id, child_object2.id])
|
13
|
+
allow(object).to receive(:member_of_collection_ids).and_return([collection1.id, collection2.id])
|
11
14
|
end
|
12
15
|
|
13
16
|
describe '#generate_solr_document' do
|
@@ -15,6 +18,7 @@ describe Hydra::PCDM::ObjectIndexer do
|
|
15
18
|
|
16
19
|
it 'has fields' do
|
17
20
|
expect(subject[Hydra::PCDM::Config.indexing_object_ids_key]).to eq %w(123 456)
|
21
|
+
expect(subject[Hydra::PCDM::Config.indexing_member_of_collection_ids_key]).to eq %w(abc def)
|
18
22
|
end
|
19
23
|
end
|
20
24
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hydra::PCDM::PCDMIndexer do
|
4
|
+
let(:collection) { Hydra::PCDM::Collection.new }
|
5
|
+
let(:member_ids) { %w(123 456 789) }
|
6
|
+
let(:indexer) { described_class.new(collection) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow(collection).to receive(:member_ids).and_return(member_ids)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#generate_solr_document' do
|
13
|
+
subject { indexer.generate_solr_document }
|
14
|
+
|
15
|
+
it 'has fields' do
|
16
|
+
expect(subject[Hydra::PCDM::Config.indexing_member_ids_key]).to eq %w(123 456 789)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -28,16 +28,81 @@ Dir['./spec/support/**/*.rb'].each { |f| require f }
|
|
28
28
|
# HttpLogger.log_headers = true
|
29
29
|
|
30
30
|
RSpec.configure do |config|
|
31
|
-
config.color = true
|
32
|
-
config.tty = true
|
33
|
-
|
34
31
|
# Uncomment the following line to get errors and backtrace for deprecation warnings
|
35
32
|
# config.raise_errors_for_deprecations!
|
36
33
|
|
37
|
-
# Use the specified formatter
|
38
|
-
config.formatter = :progress
|
39
|
-
|
40
34
|
config.before :suite do
|
41
35
|
ActiveFedora::Cleaner.clean! if ActiveFedora::Base.count > 0
|
42
36
|
end
|
37
|
+
# rspec-expectations config goes here. You can use an alternate
|
38
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
39
|
+
# assertions if you prefer.
|
40
|
+
config.expect_with :rspec do |expectations|
|
41
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
42
|
+
# and `failure_message` of custom matchers include text for helper methods
|
43
|
+
# defined using `chain`, e.g.:
|
44
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
45
|
+
# # => "be bigger than 2 and smaller than 4"
|
46
|
+
# ...rather than:
|
47
|
+
# # => "be bigger than 2"
|
48
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
49
|
+
end
|
50
|
+
|
51
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
52
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
53
|
+
config.mock_with :rspec do |mocks|
|
54
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
55
|
+
# a real object. This is generally recommended, and will default to
|
56
|
+
# `true` in RSpec 4.
|
57
|
+
mocks.verify_partial_doubles = true
|
58
|
+
end
|
59
|
+
|
60
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
61
|
+
# have no way to turn it off -- the option exists only for backwards
|
62
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
63
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
64
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
65
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
66
|
+
|
67
|
+
# The settings below are suggested to provide a good initial experience
|
68
|
+
# with RSpec, but feel free to customize to your heart's content.
|
69
|
+
|
70
|
+
# This allows you to limit a spec run to individual examples or groups
|
71
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
72
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
73
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
74
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
75
|
+
config.filter_run_when_matching :focus
|
76
|
+
|
77
|
+
# Allows RSpec to persist some state between runs in order to support
|
78
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
79
|
+
# you configure your source control system to ignore this file.
|
80
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
81
|
+
|
82
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
83
|
+
# file, and it's useful to allow more verbose output when running an
|
84
|
+
# individual spec file.
|
85
|
+
if config.files_to_run.one?
|
86
|
+
# Use the documentation formatter for detailed output,
|
87
|
+
# unless a formatter has already been configured
|
88
|
+
# (e.g. via a command-line flag).
|
89
|
+
config.default_formatter = 'doc'
|
90
|
+
end
|
91
|
+
|
92
|
+
# Print the 10 slowest examples and example groups at the
|
93
|
+
# end of the spec run, to help surface which specs are running
|
94
|
+
# particularly slow.
|
95
|
+
config.profile_examples = 10
|
96
|
+
|
97
|
+
# Run specs in random order to surface order dependencies. If you find an
|
98
|
+
# order dependency and want to debug it, you can fix the order by providing
|
99
|
+
# the seed, which is printed after each run.
|
100
|
+
# --seed 1234
|
101
|
+
config.order = :random
|
102
|
+
|
103
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
104
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
105
|
+
# test failures related to randomization by passing the same `--seed` value
|
106
|
+
# as the one that triggered the failure.
|
107
|
+
Kernel.srand config.seed
|
43
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-pcdm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E. Lynette Rayle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active-fedora
|
@@ -137,6 +137,7 @@ extra_rdoc_files: []
|
|
137
137
|
files:
|
138
138
|
- ".coveralls.yml"
|
139
139
|
- ".gitignore"
|
140
|
+
- ".rspec"
|
140
141
|
- ".rubocop.yml"
|
141
142
|
- ".travis.yml"
|
142
143
|
- CONTRIBUTING.md
|
@@ -157,6 +158,7 @@ files:
|
|
157
158
|
- lib/hydra/pcdm/models/file.rb
|
158
159
|
- lib/hydra/pcdm/models/object.rb
|
159
160
|
- lib/hydra/pcdm/object_indexer.rb
|
161
|
+
- lib/hydra/pcdm/pcdm_indexer.rb
|
160
162
|
- lib/hydra/pcdm/services/file/add_type.rb
|
161
163
|
- lib/hydra/pcdm/services/file/get_mime_type.rb
|
162
164
|
- lib/hydra/pcdm/validators.rb
|
@@ -190,6 +192,7 @@ files:
|
|
190
192
|
- spec/hydra/pcdm/models/file_spec.rb
|
191
193
|
- spec/hydra/pcdm/models/object_spec.rb
|
192
194
|
- spec/hydra/pcdm/object_indexer_spec.rb
|
195
|
+
- spec/hydra/pcdm/pcdm_indexer_spec.rb
|
193
196
|
- spec/hydra/pcdm/services/file/get_mime_type_spec.rb
|
194
197
|
- spec/hydra/pcdm_spec.rb
|
195
198
|
- spec/spec_helper.rb
|
@@ -225,6 +228,7 @@ test_files:
|
|
225
228
|
- spec/hydra/pcdm/models/file_spec.rb
|
226
229
|
- spec/hydra/pcdm/models/object_spec.rb
|
227
230
|
- spec/hydra/pcdm/object_indexer_spec.rb
|
231
|
+
- spec/hydra/pcdm/pcdm_indexer_spec.rb
|
228
232
|
- spec/hydra/pcdm/services/file/get_mime_type_spec.rb
|
229
233
|
- spec/hydra/pcdm_spec.rb
|
230
234
|
- spec/spec_helper.rb
|