active-fedora 11.0.0.rc1 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +2 -7
- data/.rubocop_todo.yml +40 -9
- data/.solr_wrapper +6 -0
- data/README.md +1 -3
- data/active-fedora.gemspec +5 -9
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/contained_finder.rb +2 -2
- data/lib/active_fedora/associations/has_many_association.rb +1 -1
- data/lib/active_fedora/associations/has_subresource_association.rb +2 -2
- data/lib/active_fedora/attribute_assignment.rb +0 -1
- data/lib/active_fedora/attributes.rb +1 -1
- data/lib/active_fedora/base.rb +3 -7
- data/lib/active_fedora/change_set.rb +6 -2
- data/lib/active_fedora/containers/container.rb +1 -1
- data/lib/active_fedora/core.rb +22 -25
- data/lib/active_fedora/fedora_attributes.rb +1 -1
- data/lib/active_fedora/file.rb +1 -1
- data/lib/active_fedora/indexing_service.rb +0 -4
- data/lib/active_fedora/orders/ordered_list.rb +2 -2
- data/lib/active_fedora/querying.rb +1 -1
- data/lib/active_fedora/railtie.rb +2 -2
- data/lib/active_fedora/rake_support.rb +1 -1
- data/lib/active_fedora/rdf.rb +0 -1
- data/lib/active_fedora/relation/delegation.rb +4 -0
- data/lib/active_fedora/solr_hit.rb +0 -4
- data/lib/active_fedora/solr_query_builder.rb +16 -12
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora.rb +0 -10
- data/lib/generators/active_fedora/config/solr/templates/solr/config/solrconfig.xml +11 -0
- data/lib/generators/active_fedora/config/solr/templates/solr_wrapper_test.yml +1 -1
- data/spec/config_helper.rb +1 -1
- data/spec/integration/associations_spec.rb +17 -18
- data/spec/integration/attached_files_spec.rb +18 -8
- data/spec/integration/attributes_spec.rb +12 -16
- data/spec/integration/autosave_association_spec.rb +6 -6
- data/spec/integration/base_spec.rb +3 -3
- data/spec/integration/collection_association_spec.rb +2 -5
- data/spec/integration/date_time_properties_spec.rb +1 -2
- data/spec/integration/direct_container_spec.rb +8 -8
- data/spec/integration/directly_contains_one_association_spec.rb +11 -13
- data/spec/integration/eradicate_spec.rb +1 -1
- data/spec/integration/fedora_solr_sync_spec.rb +2 -2
- data/spec/integration/file_fixity_spec.rb +6 -8
- data/spec/integration/file_spec.rb +32 -34
- data/spec/integration/generators/solr_generator_spec.rb +7 -10
- data/spec/integration/has_many_associations_spec.rb +6 -8
- data/spec/integration/indexing_spec.rb +1 -1
- data/spec/integration/indirect_container_spec.rb +8 -9
- data/spec/integration/json_serialization_spec.rb +4 -4
- data/spec/integration/query_result_builder_spec.rb +9 -21
- data/spec/integration/rdf_nested_attributes_spec.rb +6 -6
- data/spec/integration/relation_delegation_spec.rb +8 -10
- data/spec/integration/relation_spec.rb +13 -16
- data/spec/integration/solr_hit_spec.rb +4 -4
- data/spec/integration/versionable_spec.rb +73 -327
- data/spec/spec_helper.rb +52 -10
- data/spec/unit/active_fedora_spec.rb +1 -1
- data/spec/unit/aggregation/list_source_spec.rb +37 -37
- data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
- data/spec/unit/association_hash_spec.rb +17 -31
- data/spec/unit/attached_files_spec.rb +35 -32
- data/spec/unit/attributes_spec.rb +25 -25
- data/spec/unit/base_active_model_spec.rb +8 -8
- data/spec/unit/base_cma_spec.rb +1 -1
- data/spec/unit/base_extra_spec.rb +7 -22
- data/spec/unit/base_spec.rb +14 -20
- data/spec/unit/callback_spec.rb +2 -2
- data/spec/unit/change_set_spec.rb +5 -5
- data/spec/unit/checksum_spec.rb +2 -2
- data/spec/unit/code_configurator_spec.rb +1 -1
- data/spec/unit/core_spec.rb +62 -26
- data/spec/unit/default_model_mapper_spec.rb +6 -6
- data/spec/unit/fedora_spec.rb +2 -2
- data/spec/unit/file_configurator_spec.rb +96 -96
- data/spec/unit/file_path_builder_spec.rb +1 -1
- data/spec/unit/file_spec.rb +61 -61
- data/spec/unit/files_hash_spec.rb +9 -9
- data/spec/unit/finder_methods_spec.rb +3 -3
- data/spec/unit/has_and_belongs_to_many_association_spec.rb +13 -14
- data/spec/unit/has_many_association_spec.rb +28 -13
- data/spec/unit/indexers/global_indexer_spec.rb +6 -6
- data/spec/unit/indexing_service_spec.rb +5 -5
- data/spec/unit/indexing_spec.rb +6 -6
- data/spec/unit/inheritance_spec.rb +11 -7
- data/spec/unit/loadable_from_json_spec.rb +4 -4
- data/spec/unit/logger_spec.rb +1 -1
- data/spec/unit/model_classifier_spec.rb +5 -5
- data/spec/unit/ordered_spec.rb +142 -142
- data/spec/unit/orders/list_node_spec.rb +21 -21
- data/spec/unit/orders/ordered_list_spec.rb +96 -96
- data/spec/unit/orders/reflection_spec.rb +4 -4
- data/spec/unit/pathing_spec.rb +4 -4
- data/spec/unit/persistence_spec.rb +28 -28
- data/spec/unit/property_spec.rb +2 -2
- data/spec/unit/query_spec.rb +10 -10
- data/spec/unit/rdf/indexing_service_spec.rb +26 -26
- data/spec/unit/readonly_spec.rb +5 -4
- data/spec/unit/reflection_spec.rb +3 -3
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
- data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
- data/spec/unit/serializers_spec.rb +3 -4
- data/spec/unit/solr_config_options_spec.rb +13 -16
- data/spec/unit/solr_hit_spec.rb +9 -9
- data/spec/unit/solr_service_spec.rb +4 -10
- data/spec/unit/sparql_insert_spec.rb +2 -2
- data/spec/unit/validations_spec.rb +9 -9
- data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
- data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
- metadata +17 -118
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
- data/lib/active_fedora/datastreams.rb +0 -6
- data/lib/active_fedora/nom_datastream.rb +0 -73
- data/lib/active_fedora/om_datastream.rb +0 -118
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
- data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
- data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
- data/lib/active_fedora/rdf/rdf_datastream.rb +0 -173
- data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
- data/solr/config/_rest_managed.json +0 -3
- data/solr/config/admin-extra.html +0 -31
- data/solr/config/elevate.xml +0 -36
- data/solr/config/mapping-ISOLatin1Accent.txt +0 -246
- data/solr/config/protwords.txt +0 -21
- data/solr/config/schema.xml +0 -372
- data/solr/config/scripts.conf +0 -24
- data/solr/config/solrconfig.xml +0 -311
- data/solr/config/spellings.txt +0 -2
- data/solr/config/stopwords.txt +0 -58
- data/solr/config/stopwords_en.txt +0 -58
- data/solr/config/synonyms.txt +0 -31
- data/solr/config/xslt/example.xsl +0 -132
- data/solr/config/xslt/example_atom.xsl +0 -67
- data/solr/config/xslt/example_rss.xsl +0 -66
- data/solr/config/xslt/luke.xsl +0 -337
- data/spec/fixtures/damsObjectModel.xml +0 -38
- data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
- data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
- data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
- data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
- data/spec/integration/complex_rdf_datastream_spec.rb +0 -227
- data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -180
- data/spec/integration/ntriples_datastream_spec.rb +0 -215
- data/spec/integration/om_datastream_spec.rb +0 -78
- data/spec/samples/hydra-mods_article_datastream.rb +0 -515
- data/spec/samples/models/mods_article.rb +0 -9
- data/spec/samples/oral_history_sample.xml +0 -38
- data/spec/samples/oral_history_xml.xml +0 -35
- data/spec/samples/samples.rb +0 -2
- data/spec/unit/nom_datastream_spec.rb +0 -60
- data/spec/unit/ntriples_datastream_spec.rb +0 -167
- data/spec/unit/om_datastream_spec.rb +0 -294
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
- data/spec/unit/rdf_datastream_spec.rb +0 -84
- data/spec/unit/rdf_resource_datastream_spec.rb +0 -208
- data/spec/unit/rdfxml_datastream_spec.rb +0 -106
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a3e4470dd33d72dc20a0794fd42e8a08d96363f
|
|
4
|
+
data.tar.gz: 9e7b438a6b8a23515de79c50b3f44dc2df2a6d3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f86db04efd279c3412c1e57fa8449f7fbef3ac6cb83143314b573edaf559dfca3bc0bab762ada09c87c0f86759aea537f812bd194c3361f8adbea78385abbfe3
|
|
7
|
+
data.tar.gz: fd864a26944cc8e5ca33b313a1a2544dcfa965e46005a16c6a4833755f85e82ab349e36470347c02eef601b979213c3877c2691153a41c81429595337dc68ead
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require: rubocop-rspec
|
|
2
|
+
|
|
1
3
|
inherit_from:
|
|
2
4
|
- .rubocop_todo.yml
|
|
3
5
|
|
|
@@ -45,7 +47,6 @@ Metrics/CyclomaticComplexity:
|
|
|
45
47
|
- 'lib/active_fedora/associations/builder/directly_contains_one.rb'
|
|
46
48
|
- 'lib/active_fedora/file_configurator.rb'
|
|
47
49
|
- 'lib/active_fedora/file.rb'
|
|
48
|
-
- 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
|
|
49
50
|
- 'lib/active_fedora/attribute_methods.rb'
|
|
50
51
|
- 'lib/active_fedora/scoping/named.rb'
|
|
51
52
|
- 'lib/active_fedora/inheritance.rb'
|
|
@@ -56,7 +57,6 @@ Metrics/PerceivedComplexity:
|
|
|
56
57
|
- 'lib/active_fedora/relation/finder_methods.rb'
|
|
57
58
|
- 'lib/active_fedora/nested_attributes.rb'
|
|
58
59
|
- 'lib/active_fedora/file_configurator.rb'
|
|
59
|
-
- 'lib/active_fedora/datastreams/nokogiri_datastreams.rb'
|
|
60
60
|
- 'lib/active_fedora/autosave_association.rb'
|
|
61
61
|
- 'lib/active_fedora/associations/has_many_association.rb'
|
|
62
62
|
- 'lib/active_fedora/associations/has_and_belongs_to_many_association.rb'
|
|
@@ -79,10 +79,7 @@ Metrics/ModuleLength:
|
|
|
79
79
|
|
|
80
80
|
Metrics/ClassLength:
|
|
81
81
|
Exclude:
|
|
82
|
-
- 'spec/samples/hydra-mods_article_datastream.rb'
|
|
83
|
-
- 'lib/active_fedora/rdf/rdf_datastream.rb'
|
|
84
82
|
- 'lib/active_fedora/rdf/fcrepo.rb'
|
|
85
|
-
- 'lib/active_fedora/qualified_dublin_core_datastream.rb'
|
|
86
83
|
- 'lib/active_fedora/file_configurator.rb'
|
|
87
84
|
- 'lib/active_fedora/file.rb'
|
|
88
85
|
- 'lib/active_fedora/associations/association.rb'
|
|
@@ -121,7 +118,6 @@ Style/PredicateName:
|
|
|
121
118
|
- 'lib/active_fedora/versionable.rb'
|
|
122
119
|
- 'lib/active_fedora/reflection.rb'
|
|
123
120
|
- 'lib/active_fedora/pathing.rb'
|
|
124
|
-
- 'lib/active_fedora/om_datastream.rb'
|
|
125
121
|
- 'lib/active_fedora/nested_attributes.rb'
|
|
126
122
|
- 'lib/active_fedora/clean_connection.rb'
|
|
127
123
|
- 'lib/active_fedora/attributes.rb'
|
|
@@ -219,7 +215,6 @@ Style/SignalException:
|
|
|
219
215
|
Style/FileName:
|
|
220
216
|
Exclude:
|
|
221
217
|
- 'lib/active-fedora.rb'
|
|
222
|
-
- 'spec/samples/hydra-mods_article_datastream.rb'
|
|
223
218
|
|
|
224
219
|
Style/ZeroLengthPredicate:
|
|
225
220
|
Exclude:
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,24 +1,55 @@
|
|
|
1
1
|
require: rubocop-rspec
|
|
2
|
+
|
|
2
3
|
# This configuration was generated by
|
|
3
4
|
# `rubocop --auto-gen-config`
|
|
4
|
-
# on 2016-
|
|
5
|
+
# on 2016-08-25 16:34:38 -0700 using RuboCop version 0.42.0.
|
|
5
6
|
# The point is for the user to remove these configuration records
|
|
6
7
|
# one by one as the offenses are removed from the code base.
|
|
7
8
|
# Note that changes in the inspected code, or installation of new
|
|
8
9
|
# versions of RuboCop, may require this file to be generated again.
|
|
9
10
|
|
|
10
|
-
# Offense count:
|
|
11
|
+
# Offense count: 116
|
|
11
12
|
# Configuration parameters: Max.
|
|
12
13
|
RSpec/ExampleLength:
|
|
13
14
|
Enabled: false
|
|
14
15
|
|
|
15
|
-
# Offense count:
|
|
16
|
-
|
|
17
|
-
RSpec/VerifiedDoubles:
|
|
16
|
+
# Offense count: 40
|
|
17
|
+
RSpec/LeadingSubject:
|
|
18
18
|
Enabled: false
|
|
19
19
|
|
|
20
|
-
# Offense count:
|
|
21
|
-
|
|
20
|
+
# Offense count: 15
|
|
21
|
+
RSpec/LetSetup:
|
|
22
|
+
Exclude:
|
|
23
|
+
- 'spec/integration/collection_association_spec.rb'
|
|
24
|
+
- 'spec/integration/delete_all_spec.rb'
|
|
25
|
+
- 'spec/integration/has_many_associations_spec.rb'
|
|
26
|
+
- 'spec/integration/nested_attribute_spec.rb'
|
|
27
|
+
- 'spec/integration/persistence_spec.rb'
|
|
28
|
+
- 'spec/unit/has_and_belongs_to_many_association_spec.rb'
|
|
29
|
+
|
|
30
|
+
# Offense count: 1
|
|
31
|
+
RSpec/MessageChain:
|
|
22
32
|
Exclude:
|
|
23
|
-
- '
|
|
24
|
-
|
|
33
|
+
- 'spec/unit/file_spec.rb'
|
|
34
|
+
|
|
35
|
+
# Offense count: 218
|
|
36
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
|
37
|
+
# SupportedStyles: allow, expect
|
|
38
|
+
RSpec/MessageExpectation:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
# Offense count: 238
|
|
42
|
+
RSpec/MultipleExpectations:
|
|
43
|
+
Max: 8
|
|
44
|
+
|
|
45
|
+
# Offense count: 394
|
|
46
|
+
# Configuration parameters: MaxNesting.
|
|
47
|
+
RSpec/NestedGroups:
|
|
48
|
+
Enabled: false
|
|
49
|
+
|
|
50
|
+
# Offense count: 94
|
|
51
|
+
RSpec/SubjectStub:
|
|
52
|
+
Enabled: false
|
|
53
|
+
|
|
54
|
+
RSpec/VerifiedDoubles:
|
|
55
|
+
Enabled: false
|
data/.solr_wrapper
ADDED
data/README.md
CHANGED
|
@@ -75,11 +75,9 @@ rake active_fedora:ci
|
|
|
75
75
|
If you want to run the tests manually, follow these instructions:
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
|
-
solr_wrapper
|
|
78
|
+
solr_wrapper
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
You can switch `hydra-test` to `hydra-dev` if you want to create a collection for development.
|
|
82
|
-
|
|
83
81
|
To start FCRepo, open another shell and run:
|
|
84
82
|
|
|
85
83
|
```bash
|
data/active-fedora.gemspec
CHANGED
|
@@ -14,31 +14,27 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
s.license = "APACHE2"
|
|
15
15
|
s.required_ruby_version = '~> 2.0'
|
|
16
16
|
|
|
17
|
-
s.add_dependency 'rsolr', '~> 1.
|
|
17
|
+
s.add_dependency 'rsolr', '~> 1.1', '>= 1.1.2'
|
|
18
18
|
s.add_dependency 'solrizer', '~> 3.4'
|
|
19
|
-
s.add_dependency 'om', '~> 3.1'
|
|
20
|
-
s.add_dependency 'nom-xml', '>= 0.5.1'
|
|
21
19
|
s.add_dependency "activesupport", '>= 4.2.4', '< 6'
|
|
22
20
|
s.add_dependency "activemodel", '>= 4.2', '< 6'
|
|
23
|
-
s.add_dependency "active-triples", '~> 0.
|
|
24
|
-
s.add_dependency "rdf-rdfxml"
|
|
25
|
-
s.add_dependency "linkeddata"
|
|
21
|
+
s.add_dependency "active-triples", '~> 0.11.0'
|
|
26
22
|
s.add_dependency "deprecation"
|
|
27
|
-
s.add_dependency "ldp", '~> 0.
|
|
23
|
+
s.add_dependency "ldp", '~> 0.6.0'
|
|
28
24
|
|
|
29
25
|
s.add_development_dependency "rails"
|
|
30
26
|
s.add_development_dependency "rdoc"
|
|
31
27
|
s.add_development_dependency "yard"
|
|
32
28
|
# Pin rake to 10.0 due to https://github.com/lsegal/yard/issues/947
|
|
33
29
|
s.add_development_dependency "rake", '~> 10.0'
|
|
34
|
-
s.add_development_dependency "solr_wrapper", "~> 0.
|
|
30
|
+
s.add_development_dependency "solr_wrapper", "~> 0.15"
|
|
35
31
|
s.add_development_dependency 'fcrepo_wrapper', '~> 0.2'
|
|
36
32
|
s.add_development_dependency "rspec", "~> 3.0"
|
|
37
33
|
s.add_development_dependency "rspec-its"
|
|
38
34
|
s.add_development_dependency "equivalent-xml"
|
|
39
35
|
s.add_development_dependency "simplecov", '~> 0.8'
|
|
40
36
|
s.add_development_dependency "rubocop", '~> 0.42.0'
|
|
41
|
-
s.add_development_dependency "rubocop-rspec", '~> 1.
|
|
37
|
+
s.add_development_dependency "rubocop-rspec", '~> 1.6'
|
|
42
38
|
|
|
43
39
|
s.files = `git ls-files`.split("\n")
|
|
44
40
|
s.test_files = `git ls-files -- {spec}/*`.split("\n")
|
|
@@ -291,7 +291,7 @@ module ActiveFedora
|
|
|
291
291
|
def construct_query
|
|
292
292
|
@solr_query ||= begin
|
|
293
293
|
clauses = { find_reflection => @owner.id }
|
|
294
|
-
clauses[:has_model] = @reflection.
|
|
294
|
+
clauses[:has_model] = @reflection.klass.to_rdf_representation if @reflection.klass != ActiveFedora::Base
|
|
295
295
|
ActiveFedora::SolrQueryBuilder.construct_query_for_rel(clauses)
|
|
296
296
|
end
|
|
297
297
|
end
|
|
@@ -29,7 +29,7 @@ module ActiveFedora::Associations
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
31
|
def matching_ids(record)
|
|
32
|
-
IDComposite.new(proxy_ids(record) & contained_ids, repository.translate_uri_to_id)
|
|
32
|
+
IDComposite.new(proxy_ids(record) & contained_ids.to_a, repository.translate_uri_to_id)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def proxy_ids(record)
|
|
@@ -40,7 +40,7 @@ module ActiveFedora::Associations
|
|
|
40
40
|
# a slow fedora call
|
|
41
41
|
def relation_subjects(record)
|
|
42
42
|
query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(
|
|
43
|
-
[[:has_model, proxy_class.
|
|
43
|
+
[[:has_model, proxy_class.to_rdf_representation], [:proxyFor, record.id]]
|
|
44
44
|
)
|
|
45
45
|
ActiveFedora::SolrService.query(query, fl: 'id').map(&:rdf_uri)
|
|
46
46
|
end
|
|
@@ -83,7 +83,7 @@ module ActiveFedora
|
|
|
83
83
|
protected
|
|
84
84
|
|
|
85
85
|
def find_polymorphic_inverse(record)
|
|
86
|
-
record.reflections.values.find { |r| !r.has_many? && r.
|
|
86
|
+
record.reflections.values.find { |r| !r.has_many? && r.predicate == reflection.predicate }
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# Deletes the records according to the <tt>:dependent</tt> option.
|
|
@@ -25,12 +25,12 @@ module ActiveFedora
|
|
|
25
25
|
|
|
26
26
|
def find_or_initialize_target(&block)
|
|
27
27
|
if reflection.klass < ActiveFedora::File
|
|
28
|
-
reflection.build_association(target_uri, &block)
|
|
28
|
+
reflection.build_association(id: target_uri, &block)
|
|
29
29
|
else
|
|
30
30
|
reflection.klass.find(target_uri)
|
|
31
31
|
end
|
|
32
32
|
rescue ActiveFedora::ObjectNotFoundError
|
|
33
|
-
reflection.build_association(target_uri, &block)
|
|
33
|
+
reflection.build_association(id: target_uri, &block)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def replace(record)
|
|
@@ -144,7 +144,7 @@ module ActiveFedora
|
|
|
144
144
|
|
|
145
145
|
# @param [Symbol] field the field to find or create
|
|
146
146
|
# @param [Class] klass the class to use to delegate the attribute (e.g.
|
|
147
|
-
# ActiveTripleAttribute
|
|
147
|
+
# ActiveTripleAttribute)
|
|
148
148
|
# @param [Hash] args
|
|
149
149
|
# @option args [String] :delegate_target the path to the delegate
|
|
150
150
|
# @option args [Class] :klass the class to create
|
data/lib/active_fedora/base.rb
CHANGED
|
@@ -10,16 +10,12 @@ module ActiveFedora
|
|
|
10
10
|
#
|
|
11
11
|
# =The Basics
|
|
12
12
|
# class Oralhistory < ActiveFedora::Base
|
|
13
|
-
#
|
|
14
|
-
# m.field "narrator", :string
|
|
15
|
-
# m.field "narrator", :text
|
|
16
|
-
# end
|
|
13
|
+
# property :creator, predicate: RDF::Vocab::DC.creator
|
|
17
14
|
# end
|
|
18
15
|
#
|
|
19
|
-
# The above example creates a Fedora object with a
|
|
20
|
-
# narrator and bio field.
|
|
16
|
+
# The above example creates a Fedora object with a property named "creator"
|
|
21
17
|
#
|
|
22
|
-
# Attached files defined with +
|
|
18
|
+
# Attached files defined with +has_subresource+ and iis accessed via the +attached_files+ member hash.
|
|
23
19
|
#
|
|
24
20
|
class Base
|
|
25
21
|
extend ActiveModel::Naming
|
|
@@ -23,8 +23,12 @@ module ActiveFedora
|
|
|
23
23
|
result[predicate] = graph.query(subject: object.rdf_subject, predicate: predicate)
|
|
24
24
|
elsif object.class.properties.keys.include?(key)
|
|
25
25
|
predicate = graph.reflections.reflect_on_property(key).predicate
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
results = graph.query(subject: object.rdf_subject, predicate: predicate)
|
|
27
|
+
new_graph = child_graphs(results.map(&:object))
|
|
28
|
+
results.each do |res|
|
|
29
|
+
new_graph << res
|
|
30
|
+
end
|
|
31
|
+
result[predicate] = new_graph
|
|
28
32
|
elsif key == 'type'.freeze
|
|
29
33
|
# working around https://github.com/ActiveTriples/ActiveTriples/issues/122
|
|
30
34
|
predicate = ::RDF.type
|
data/lib/active_fedora/core.rb
CHANGED
|
@@ -22,14 +22,14 @@ module ActiveFedora
|
|
|
22
22
|
# Also, if +attrs+ does not contain +:id+ but does contain +:namespace+ it will pass the
|
|
23
23
|
# +:namespace+ value to Fedora::Repository.nextid to generate the next id available within
|
|
24
24
|
# the given namespace.
|
|
25
|
-
def initialize(
|
|
25
|
+
def initialize(attributes = nil, &_block)
|
|
26
26
|
init_internals
|
|
27
|
-
|
|
28
|
-
@ldp_source = build_ldp_resource(
|
|
27
|
+
id = attributes && (attributes.delete(:id) || attributes.delete('id'))
|
|
28
|
+
@ldp_source = build_ldp_resource(id)
|
|
29
29
|
raise IllegalOperation, "Attempting to recreate existing ldp_source: `#{ldp_source.subject}'" unless ldp_source.new?
|
|
30
|
+
assign_attributes(attributes) if attributes
|
|
30
31
|
assert_content_model
|
|
31
32
|
load_attached_files
|
|
32
|
-
assign_attributes(attributes) if attributes
|
|
33
33
|
|
|
34
34
|
yield self if block_given?
|
|
35
35
|
_run_initialize_callbacks
|
|
@@ -96,13 +96,14 @@ module ActiveFedora
|
|
|
96
96
|
|
|
97
97
|
protected
|
|
98
98
|
|
|
99
|
-
# This
|
|
100
|
-
# It's normally called once in the lifecycle, by #create#
|
|
99
|
+
# This method is normally called once in the lifecycle, by #create#
|
|
101
100
|
def assert_content_model
|
|
102
|
-
self.has_model = self.class.
|
|
101
|
+
self.has_model = self.class.to_rdf_representation
|
|
103
102
|
end
|
|
104
103
|
|
|
105
104
|
module ClassMethods
|
|
105
|
+
extend Deprecation
|
|
106
|
+
|
|
106
107
|
def generated_association_methods
|
|
107
108
|
@generated_association_methods ||= begin
|
|
108
109
|
mod = const_set(:GeneratedAssociationMethods, Module.new)
|
|
@@ -111,13 +112,23 @@ module ActiveFedora
|
|
|
111
112
|
end
|
|
112
113
|
end
|
|
113
114
|
|
|
114
|
-
# Returns a suitable
|
|
115
|
-
#
|
|
116
|
-
#
|
|
117
|
-
def
|
|
115
|
+
# Returns a suitable string representation for :has_model
|
|
116
|
+
# Override this method if you want to change how this class
|
|
117
|
+
# is represented in RDF.
|
|
118
|
+
def to_rdf_representation
|
|
118
119
|
name
|
|
119
120
|
end
|
|
120
121
|
|
|
122
|
+
# Returns a suitable string representation for :has_model
|
|
123
|
+
# @deprecated use to_rdf_representation instead
|
|
124
|
+
def to_class_uri(attrs = nil)
|
|
125
|
+
if attrs
|
|
126
|
+
Deprecation.warn ActiveFedora::Core, "to_class_uri no longer acceps an argument"
|
|
127
|
+
end
|
|
128
|
+
to_rdf_representation
|
|
129
|
+
end
|
|
130
|
+
deprecation_deprecate to_class_uri: "use 'to_rdf_representation()' instead"
|
|
131
|
+
|
|
121
132
|
private
|
|
122
133
|
|
|
123
134
|
def relation
|
|
@@ -144,19 +155,5 @@ module ActiveFedora
|
|
|
144
155
|
raise ActiveFedora::ObjectNotFoundError, "Can't reload an object that hasn't been saved"
|
|
145
156
|
end
|
|
146
157
|
end
|
|
147
|
-
|
|
148
|
-
def initialize_attributes(attributes_or_id)
|
|
149
|
-
case attributes_or_id
|
|
150
|
-
when String
|
|
151
|
-
attributes = { id: attributes_or_id }.with_indifferent_access
|
|
152
|
-
when Hash
|
|
153
|
-
attributes = attributes_or_id.with_indifferent_access
|
|
154
|
-
when NilClass
|
|
155
|
-
attributes = {}.with_indifferent_access
|
|
156
|
-
else
|
|
157
|
-
raise ArgumentError, "#{attributes_or_id.class} is not acceptable"
|
|
158
|
-
end
|
|
159
|
-
attributes
|
|
160
|
-
end
|
|
161
158
|
end
|
|
162
159
|
end
|
|
@@ -43,7 +43,7 @@ module ActiveFedora
|
|
|
43
43
|
# Appending the graph at the end is necessary because adding it as the
|
|
44
44
|
# parent leaves behind triples not related to the ldp_source's rdf
|
|
45
45
|
# subject.
|
|
46
|
-
@resource ||= self.class.resource_class.new(@ldp_source.graph.rdf_subject, data: @ldp_source.graph.
|
|
46
|
+
@resource ||= self.class.resource_class.new(@ldp_source.graph.rdf_subject, data: @ldp_source.graph.graph.data)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
# You can set the URI to use for the rdf_label on ClassMethods.rdf_label, then on
|
data/lib/active_fedora/file.rb
CHANGED
|
@@ -30,7 +30,7 @@ module ActiveFedora
|
|
|
30
30
|
# @yield [self] Yields self
|
|
31
31
|
# @yieldparam [File] self the newly created file
|
|
32
32
|
def initialize(identifier = nil, &_block)
|
|
33
|
-
identifier =
|
|
33
|
+
identifier = identifier.delete(:id) if identifier.is_a? Hash
|
|
34
34
|
run_callbacks(:initialize) do
|
|
35
35
|
case identifier
|
|
36
36
|
when nil, ::RDF::URI
|
|
@@ -15,10 +15,6 @@ module ActiveFedora
|
|
|
15
15
|
@object = obj
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def self.profile_solr_name
|
|
19
|
-
@profile_solr_name ||= ActiveFedora.index_field_mapper.solr_name("object_profile", :displayable)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
18
|
def self.create_time_solr_name
|
|
23
19
|
@create_time_solr_name ||= ActiveFedora.index_field_mapper.solr_name('system_create', :stored_sortable, type: :date)
|
|
24
20
|
end
|
|
@@ -13,8 +13,8 @@ module ActiveFedora
|
|
|
13
13
|
# @param [::RDF::URI] head_subject URI of head node in list.
|
|
14
14
|
# @param [::RDF::URI] tail_subject URI of tail node in list.
|
|
15
15
|
def initialize(graph, head_subject, tail_subject)
|
|
16
|
-
@graph = if graph.respond_to?(:graph
|
|
17
|
-
graph.
|
|
16
|
+
@graph = if graph.respond_to?(:graph)
|
|
17
|
+
graph.graph.data
|
|
18
18
|
else
|
|
19
19
|
graph
|
|
20
20
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
2
|
module Querying
|
|
3
3
|
delegate :find, :first, :exists?, :where, :limit, :offset, :order, :delete_all,
|
|
4
|
-
:destroy_all, :count, :last, :
|
|
4
|
+
:destroy_all, :count, :last, :search_with_conditions, :search_in_batches, :search_by_id, :find_each, to: :all
|
|
5
5
|
|
|
6
6
|
def self.extended(base)
|
|
7
7
|
base.class_attribute :solr_query_handler
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module ActiveFedora
|
|
2
2
|
class Railtie < Rails::Railtie
|
|
3
|
-
config.app_middleware.insert_after
|
|
4
|
-
|
|
3
|
+
config.app_middleware.insert_after ::ActionDispatch::Callbacks,
|
|
4
|
+
ActiveFedora::LdpCache
|
|
5
5
|
|
|
6
6
|
initializer 'active_fedora.autoload', before: :set_autoload_paths do |app|
|
|
7
7
|
app.config.autoload_paths << 'app/models/datastreams'
|
|
@@ -21,7 +21,7 @@ def with_server(environment)
|
|
|
21
21
|
unless Dir.exist?(solr_config_path)
|
|
22
22
|
$stderr.puts "Solr configuration not found at #{solr_config_path}. Using ActiveFedora defaults"
|
|
23
23
|
# Otherwise use the configs delivered with ActiveFedora.
|
|
24
|
-
solr_config_path = File.join(File.expand_path("../..", File.dirname(__FILE__)),
|
|
24
|
+
solr_config_path = File.join(File.expand_path("../..", File.dirname(__FILE__)), 'lib', 'generators', 'active_fedora', 'config', 'solr', 'templates', 'solr', 'config')
|
|
25
25
|
end
|
|
26
26
|
solr.with_collection(name: "hydra-#{environment}", dir: solr_config_path) do
|
|
27
27
|
FcrepoWrapper.wrap(load_config(:fcrepo, environment, fcrepo_defaults)) do |fcrepo|
|
data/lib/active_fedora/rdf.rb
CHANGED
|
@@ -11,28 +11,29 @@ module ActiveFedora
|
|
|
11
11
|
"{!terms f=#{ActiveFedora.id_field}}#{ids.join(',')}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# Create a query with a clause for each key, value
|
|
14
|
+
# Create a raw query with a clause for each key, value
|
|
15
15
|
# @param [Hash, Array<Array<String>>] field_pairs key is the predicate, value is the target_uri
|
|
16
16
|
# @param [String] join_with ('AND') the value we're joining the clauses with
|
|
17
17
|
# @example
|
|
18
|
-
# construct_query_for_rel [[:has_model, "
|
|
19
|
-
# # => _query_:"{!
|
|
18
|
+
# construct_query_for_rel [[:has_model, "ComplexCollection"], [:has_model, "ActiveFedora_Base"]], 'OR'
|
|
19
|
+
# # => _query_:"{!raw f=has_model_ssim}ComplexCollection" OR _query_:"{!raw f=has_model_ssim}ActiveFedora_Base"
|
|
20
20
|
#
|
|
21
21
|
# construct_query_for_rel [[Book._reflect_on_association(:library), "foo/bar/baz"]]
|
|
22
22
|
def construct_query_for_rel(field_pairs, join_with = default_join_with)
|
|
23
23
|
field_pairs = field_pairs.to_a if field_pairs.is_a? Hash
|
|
24
|
-
construct_query(property_values_to_solr(field_pairs), join_with)
|
|
24
|
+
construct_query(property_values_to_solr(field_pairs), join_with, 'raw'.freeze)
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# Construct a solr query from a list of pairs (e.g. [field name, values])
|
|
28
28
|
# @param [Array<Array>] field_pairs a list of pairs of property name and values
|
|
29
29
|
# @param [String] join_with ('AND') the value we're joining the clauses with
|
|
30
|
+
# @param [String] type ('field') The type of query to run. Either 'raw' or 'field'
|
|
30
31
|
# @return [String] a solr query
|
|
31
32
|
# @example
|
|
32
33
|
# construct_query([['library_id_ssim', '123'], ['owner_ssim', 'Fred']])
|
|
33
34
|
# # => "_query_:\"{!field f=library_id_ssim}123\" AND _query_:\"{!field f=owner_ssim}Fred\""
|
|
34
|
-
def construct_query(field_pairs, join_with = default_join_with)
|
|
35
|
-
clauses = pairs_to_clauses(field_pairs)
|
|
35
|
+
def construct_query(field_pairs, join_with = default_join_with, type = 'field'.freeze)
|
|
36
|
+
clauses = pairs_to_clauses(field_pairs, type)
|
|
36
37
|
return "" if clauses.count.zero?
|
|
37
38
|
return clauses.first if clauses.count == 1
|
|
38
39
|
"(#{clauses.join(join_with)})"
|
|
@@ -45,22 +46,24 @@ module ActiveFedora
|
|
|
45
46
|
private
|
|
46
47
|
|
|
47
48
|
# @param [Array<Array>] pairs a list of (key, value) pairs. The value itself may
|
|
49
|
+
# @param [String] type The type of query to run. Either 'raw' or 'field'
|
|
48
50
|
# @return [Array] a list of solr clauses
|
|
49
|
-
def pairs_to_clauses(pairs)
|
|
51
|
+
def pairs_to_clauses(pairs, type)
|
|
50
52
|
pairs.flat_map do |field, value|
|
|
51
|
-
condition_to_clauses(field, value)
|
|
53
|
+
condition_to_clauses(field, value, type)
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
# @param [String] field
|
|
56
58
|
# @param [String, Array<String>] values
|
|
59
|
+
# @param [String] type The type of query to run. Either 'raw' or 'field'
|
|
57
60
|
# @return [Array<String>]
|
|
58
|
-
def condition_to_clauses(field, values)
|
|
61
|
+
def condition_to_clauses(field, values, type)
|
|
59
62
|
values = Array(values)
|
|
60
63
|
values << nil if values.empty?
|
|
61
64
|
values.map do |value|
|
|
62
65
|
if value.present?
|
|
63
|
-
|
|
66
|
+
query_clause(type, field, value)
|
|
64
67
|
else
|
|
65
68
|
# Check that the field is not present. In SQL: "WHERE field IS NULL"
|
|
66
69
|
"-#{field}:[* TO *]"
|
|
@@ -93,10 +96,11 @@ module ActiveFedora
|
|
|
93
96
|
end
|
|
94
97
|
|
|
95
98
|
# Create a raw query clause suitable for sending to solr as an fq element
|
|
99
|
+
# @param [String] type The type of query to run. Either 'raw' or 'field'
|
|
96
100
|
# @param [String] key
|
|
97
101
|
# @param [String] value
|
|
98
|
-
def
|
|
99
|
-
"_query_:\"{
|
|
102
|
+
def query_clause(type, key, value)
|
|
103
|
+
"_query_:\"{!#{type} f=#{key}}#{value.gsub('"', '\"')}\""
|
|
100
104
|
end
|
|
101
105
|
end
|
|
102
106
|
end
|
data/lib/active_fedora.rb
CHANGED
|
@@ -59,7 +59,6 @@ module ActiveFedora #:nodoc:
|
|
|
59
59
|
autoload :DirectContainer
|
|
60
60
|
autoload :IndirectContainer
|
|
61
61
|
end
|
|
62
|
-
autoload :Datastreams
|
|
63
62
|
autoload :DelegatedAttribute
|
|
64
63
|
autoload_under 'attributes' do
|
|
65
64
|
autoload :ActiveTripleAttribute
|
|
@@ -89,23 +88,14 @@ module ActiveFedora #:nodoc:
|
|
|
89
88
|
autoload :LoadableFromJson
|
|
90
89
|
autoload :ModelClassifier
|
|
91
90
|
autoload :NestedAttributes
|
|
92
|
-
autoload :NomDatastream
|
|
93
91
|
autoload :NullRelation
|
|
94
|
-
autoload :OmDatastream
|
|
95
92
|
autoload :Orders
|
|
96
93
|
autoload :Pathing
|
|
97
94
|
autoload :Persistence
|
|
98
95
|
autoload :Property
|
|
99
|
-
autoload :QualifiedDublinCoreDatastream
|
|
100
96
|
autoload :Querying
|
|
101
97
|
autoload :QueryResultBuilder
|
|
102
98
|
autoload :RDF
|
|
103
|
-
autoload_under 'rdf' do
|
|
104
|
-
autoload :RDFDatastream
|
|
105
|
-
autoload :RDFXMLDatastream
|
|
106
|
-
autoload :NtriplesRDFDatastream
|
|
107
|
-
autoload :FedoraRdfResource
|
|
108
|
-
end
|
|
109
99
|
autoload :Reflection
|
|
110
100
|
autoload :Relation
|
|
111
101
|
|
|
@@ -187,6 +187,17 @@
|
|
|
187
187
|
</lst>
|
|
188
188
|
</requestHandler>
|
|
189
189
|
|
|
190
|
+
<searchComponent name="termsComponent" class="solr.TermsComponent" />
|
|
191
|
+
|
|
192
|
+
<requestHandler name="/terms" class="solr.SearchHandler">
|
|
193
|
+
<lst name="defaults">
|
|
194
|
+
<bool name="terms">true</bool>
|
|
195
|
+
</lst>
|
|
196
|
+
<arr name="components">
|
|
197
|
+
<str>termsComponent</str>
|
|
198
|
+
</arr>
|
|
199
|
+
</requestHandler>
|
|
200
|
+
|
|
190
201
|
<!-- Spell Check
|
|
191
202
|
|
|
192
203
|
The spell check component can return a list of alternative spelling
|