active-fedora 9.7.0 → 9.8.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 +10 -9
- data/History.txt +18 -0
- data/README.md +12 -13
- data/Rakefile +1 -1
- data/active-fedora.gemspec +2 -1
- data/config/fedora.yml +2 -2
- data/config/solr.yml +5 -5
- data/lib/active_fedora/association_hash.rb +2 -2
- data/lib/active_fedora/associations/builder/collection_association.rb +1 -1
- data/lib/active_fedora/associations/builder/has_many.rb +1 -1
- data/lib/active_fedora/associations/collection_association.rb +1 -1
- data/lib/active_fedora/associations/collection_proxy.rb +4 -4
- data/lib/active_fedora/associations/directly_contains_one_association.rb +3 -7
- data/lib/active_fedora/associations/has_many_association.rb +22 -29
- data/lib/active_fedora/associations/indirectly_contains_association.rb +1 -1
- data/lib/active_fedora/autosave_association.rb +1 -1
- data/lib/active_fedora/base.rb +1 -1
- data/lib/active_fedora/callbacks.rb +1 -1
- data/lib/active_fedora/change_set.rb +1 -2
- data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +6 -6
- data/lib/active_fedora/file.rb +5 -4
- data/lib/active_fedora/file_configurator.rb +6 -11
- data/lib/active_fedora/fixity_service.rb +1 -1
- data/lib/active_fedora/indexing/map.rb +2 -1
- data/lib/active_fedora/indexing_service.rb +3 -3
- data/lib/active_fedora/ldp_cache.rb +1 -1
- data/lib/active_fedora/model.rb +9 -10
- data/lib/active_fedora/nested_attributes.rb +1 -1
- data/lib/active_fedora/nom_datastream.rb +5 -5
- data/lib/active_fedora/om_datastream.rb +2 -2
- data/lib/active_fedora/persistence.rb +2 -2
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +1 -1
- data/lib/active_fedora/rdf/fcrepo.rb +6 -0
- data/lib/active_fedora/rdf/field_map.rb +4 -2
- data/lib/active_fedora/rdf/persistence.rb +2 -2
- data/lib/active_fedora/rdf/rdf_datastream.rb +1 -1
- data/lib/active_fedora/reflection.rb +3 -3
- data/lib/active_fedora/relation.rb +2 -2
- data/lib/active_fedora/solr_query_builder.rb +93 -91
- data/lib/active_fedora/solr_service.rb +2 -2
- data/lib/active_fedora/version.rb +1 -1
- data/lib/active_fedora/versionable.rb +14 -12
- data/lib/active_fedora/versions_graph.rb +1 -1
- data/lib/active_fedora.rb +2 -2
- data/lib/generators/active_fedora/config/fedora/templates/fedora.yml +2 -2
- data/lib/generators/active_fedora/config/solr/solr_generator.rb +0 -1
- data/lib/generators/active_fedora/config/solr/templates/solr.yml +2 -2
- data/lib/tasks/active_fedora_dev.rake +13 -8
- data/solr/config/_rest_managed.json +3 -0
- data/solr/config/admin-extra.html +31 -0
- data/solr/config/elevate.xml +36 -0
- data/solr/config/mapping-ISOLatin1Accent.txt +246 -0
- data/solr/config/protwords.txt +21 -0
- data/solr/config/schema.xml +372 -0
- data/solr/config/scripts.conf +24 -0
- data/solr/config/solrconfig.xml +419 -0
- data/solr/config/spellings.txt +2 -0
- data/solr/config/stopwords.txt +58 -0
- data/solr/config/stopwords_en.txt +58 -0
- data/solr/config/synonyms.txt +31 -0
- data/solr/config/xslt/example.xsl +132 -0
- data/solr/config/xslt/example_atom.xsl +67 -0
- data/solr/config/xslt/example_rss.xsl +66 -0
- data/solr/config/xslt/luke.xsl +337 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +8 -8
- data/spec/integration/full_featured_model_spec.rb +1 -1
- data/spec/integration/ntriples_datastream_spec.rb +12 -1
- data/spec/integration/rdf_nested_attributes_spec.rb +51 -20
- data/spec/integration/scoped_query_spec.rb +2 -2
- data/spec/integration/versionable_spec.rb +1 -3
- data/spec/unit/active_fedora_spec.rb +0 -3
- data/spec/unit/base_spec.rb +1 -1
- data/spec/unit/forbidden_attributes_protection_spec.rb +1 -1
- data/spec/unit/ntriples_datastream_spec.rb +21 -11
- data/spec/unit/persistence_spec.rb +1 -1
- data/spec/unit/predicates_spec.rb +1 -1
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -1
- data/spec/unit/solr_config_options_spec.rb +3 -3
- data/spec/unit/sparql_insert_spec.rb +1 -1
- metadata +38 -11
- data/config/solr_mappings_af_0.1.yml +0 -9
- data/config/solr_mappings_bl_2.4.yml +0 -17
- data/lib/generators/active_fedora/config/solr/templates/jetty.yml +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb7bb622089037ec0a49870417c31aedf0b2b3c1
|
|
4
|
+
data.tar.gz: 077acf9671652587082be135de13ca1afa05b709
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8cee9e01316cd57089335922d058f7bb537f3845c5da764601be842331707ac1ef175ecd20e6bc8e7cb759b432ec752b0fe9bcda08877b10dea2a72f97a2fc76
|
|
7
|
+
data.tar.gz: 23964a8f464c39dd2d0c53f5f6418337c76235489d2924895af34d979c214e551999b430d0072d28d6243e7c06114f170eecb8a6e9124664715e82b342f4c1f2
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require: rubocop-rspec
|
|
2
2
|
|
|
3
3
|
AllCops:
|
|
4
|
-
|
|
4
|
+
TargetRubyVersion: 2.2
|
|
5
5
|
DisplayCopNames: true
|
|
6
6
|
Include:
|
|
7
7
|
- '**/Rakefile'
|
|
@@ -9,10 +9,6 @@ AllCops:
|
|
|
9
9
|
- 'script/**/*'
|
|
10
10
|
- 'vendor/**/*'
|
|
11
11
|
|
|
12
|
-
Lint/RescueException:
|
|
13
|
-
Exclude:
|
|
14
|
-
- 'lib/active_fedora/ldp_cache.rb'
|
|
15
|
-
|
|
16
12
|
Lint/HandleExceptions:
|
|
17
13
|
Exclude:
|
|
18
14
|
- 'spec/unit/**/*'
|
|
@@ -184,9 +180,6 @@ Style/ClassAndModuleChildren:
|
|
|
184
180
|
Style/Documentation:
|
|
185
181
|
Enabled: false
|
|
186
182
|
|
|
187
|
-
Style/HashSyntax:
|
|
188
|
-
Exclude:
|
|
189
|
-
|
|
190
183
|
Style/GlobalVars:
|
|
191
184
|
Exclude:
|
|
192
185
|
- 'spec/**/*'
|
|
@@ -210,6 +203,15 @@ Style/FileName:
|
|
|
210
203
|
- 'lib/active-fedora.rb'
|
|
211
204
|
- 'spec/samples/hydra-mods_article_datastream.rb'
|
|
212
205
|
|
|
206
|
+
Style/ZeroLengthPredicate:
|
|
207
|
+
Enabled: false # https://github.com/bbatsov/rubocop/issues/2782
|
|
208
|
+
|
|
209
|
+
Performance/RedundantMerge:
|
|
210
|
+
Enabled: false # https://github.com/bbatsov/rubocop/issues/2781
|
|
211
|
+
|
|
212
|
+
Rails:
|
|
213
|
+
Enabled: true
|
|
214
|
+
|
|
213
215
|
Rails/Output:
|
|
214
216
|
Exclude:
|
|
215
217
|
- 'lib/generators/**/*'
|
|
@@ -242,4 +244,3 @@ RSpec/DescribeClass:
|
|
|
242
244
|
RSpec/DescribedClass:
|
|
243
245
|
Exclude:
|
|
244
246
|
- 'spec/unit/finder_methods_spec.rb'
|
|
245
|
-
|
data/History.txt
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
v9.8.0
|
|
2
|
+
2016-02-04: Remove unused files [Justin Coyne]
|
|
3
|
+
|
|
4
|
+
2016-02-03: Test on Solr 5 [Justin Coyne]
|
|
5
|
+
|
|
6
|
+
2016-02-04: Fix rubocop [Justin Coyne]
|
|
7
|
+
|
|
8
|
+
2016-01-29: Pass hash of options to index.as [Adam Wead]
|
|
9
|
+
|
|
10
|
+
v9.7.1
|
|
11
|
+
2016-01-22 : The jcr/mix versionable predicate is no longer used [Adam Wead]
|
|
12
|
+
|
|
13
|
+
2016-01-22 : Add detail to SolrQueryBuilder.construct_query_for_pids deprecation warning [David Chandek-Stark]
|
|
14
|
+
|
|
15
|
+
2016-01-21 : Updating to the latest Rubocop [Michael J. Giarlo]
|
|
16
|
+
|
|
17
|
+
2015-12-04 : Adds :PID property to ActiveFedora::RDF::Fcrepo::Model vocab [David Chandek-Stark]
|
|
18
|
+
|
|
1
19
|
v9.7.0
|
|
2
20
|
2015-11-25 : Allowing access to the gone? method from outside the object [Carolyn Cole]
|
|
3
21
|
|
data/README.md
CHANGED
|
@@ -63,12 +63,8 @@ You can test ActiveFedora using the same process as our continuous
|
|
|
63
63
|
integration server. To do that, unzip a copy of hydra-jetty first. This includes copies of Fedora and Solr which are
|
|
64
64
|
used during the testing process.
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Once hydra-jetty is unzipped, the ci rake task will spin up jetty,
|
|
71
|
-
import the fixtures, and run the tests for you.
|
|
66
|
+
The `ci` rake task will download solr and fedora, start them,
|
|
67
|
+
and run the tests for you.
|
|
72
68
|
|
|
73
69
|
```bash
|
|
74
70
|
rake active_fedora:ci
|
|
@@ -76,18 +72,21 @@ rake active_fedora:ci
|
|
|
76
72
|
|
|
77
73
|
### Testing Manually
|
|
78
74
|
|
|
79
|
-
If you want to run the tests manually, follow these instructions
|
|
75
|
+
If you want to run the tests manually, follow these instructions:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
solr_wrapper -d solr/config/ --collection_name hydra-test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
You can switch `hydra-test` to `hydra-dev` if you want to create a collection for development.
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
working copy of
|
|
83
|
-
[hydra-jetty](https://github.com/projecthydra/hydra-jetty), cd into its
|
|
84
|
-
root and run:
|
|
83
|
+
To start FCRepo, open another shell and run:
|
|
85
84
|
|
|
86
85
|
```bash
|
|
87
|
-
|
|
86
|
+
fedora_wrapper -p 8984
|
|
88
87
|
```
|
|
89
88
|
|
|
90
|
-
Now you’re ready to run the tests. In the directory where
|
|
89
|
+
Now you’re ready to run the tests. In the directory where active\_fedora
|
|
91
90
|
is installed, run:
|
|
92
91
|
|
|
93
92
|
```bash
|
data/Rakefile
CHANGED
|
@@ -9,7 +9,7 @@ load "lib/tasks/active_fedora_dev.rake"
|
|
|
9
9
|
CLEAN.include %w(**/.DS_Store tmp *.log *.orig *.tmp **/*~)
|
|
10
10
|
|
|
11
11
|
desc 'setup jetty and run tests'
|
|
12
|
-
task ci: ['
|
|
12
|
+
task ci: ['active_fedora:ci']
|
|
13
13
|
desc 'run tests'
|
|
14
14
|
task spec: ['active_fedora:rubocop', 'active_fedora:rspec']
|
|
15
15
|
task rcov: ['active_fedora:rcov']
|
data/active-fedora.gemspec
CHANGED
|
@@ -27,7 +27,8 @@ Gem::Specification.new do |s|
|
|
|
27
27
|
s.add_development_dependency "rdoc"
|
|
28
28
|
s.add_development_dependency "yard"
|
|
29
29
|
s.add_development_dependency "rake"
|
|
30
|
-
s.add_development_dependency "
|
|
30
|
+
s.add_development_dependency "solr_wrapper", "~> 0.4"
|
|
31
|
+
s.add_development_dependency 'fcrepo_wrapper', '~> 0.1'
|
|
31
32
|
s.add_development_dependency "rspec", "~> 3.0"
|
|
32
33
|
s.add_development_dependency "rspec-its"
|
|
33
34
|
s.add_development_dependency "equivalent-xml"
|
data/config/fedora.yml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
development:
|
|
2
2
|
user: fedoraAdmin
|
|
3
3
|
password: fedoraAdmin
|
|
4
|
-
url: http://127.0.0.1:
|
|
4
|
+
url: http://127.0.0.1:8984/rest
|
|
5
5
|
base_path: /dev
|
|
6
6
|
test:
|
|
7
7
|
user: fedoraAdmin
|
|
8
8
|
password: fedoraAdmin
|
|
9
|
-
url: http://localhost:
|
|
9
|
+
url: http://localhost:8984/rest
|
|
10
10
|
base_path: /test
|
|
11
11
|
production:
|
|
12
12
|
user: fedoraAdmin
|
data/config/solr.yml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
development:
|
|
2
2
|
default:
|
|
3
|
-
url: http://localhost:8983/solr/
|
|
3
|
+
url: http://localhost:8983/solr/hydra-dev
|
|
4
4
|
full_text:
|
|
5
5
|
url: http://localhost:8983/solr/development
|
|
6
|
-
test:
|
|
6
|
+
test:
|
|
7
7
|
default:
|
|
8
|
-
url: http://localhost:8983/solr/test
|
|
8
|
+
url: http://localhost:8983/solr/hydra-test
|
|
9
9
|
full_text:
|
|
10
10
|
url: http://localhost:8983/solr/test
|
|
11
11
|
production:
|
|
12
12
|
default:
|
|
13
|
-
url: http://localhost:8080/solr/production
|
|
13
|
+
url: http://localhost:8080/solr/production
|
|
14
14
|
full_text:
|
|
15
|
-
url: http://localhost:8080/solr/production
|
|
15
|
+
url: http://localhost:8080/solr/production
|
|
@@ -44,8 +44,8 @@ module ActiveFedora
|
|
|
44
44
|
def key?(key)
|
|
45
45
|
keys.include?(key) || keys.map(&:to_s).include?(key)
|
|
46
46
|
end
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
alias include? key?
|
|
48
|
+
alias has_key? key?
|
|
49
49
|
|
|
50
50
|
def values
|
|
51
51
|
keys.map { |k| self[k] }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require 'active_fedora/associations'
|
|
2
2
|
module ActiveFedora::Associations::Builder
|
|
3
3
|
class CollectionAssociation < Association #:nodoc:
|
|
4
|
-
CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove]
|
|
4
|
+
CALLBACKS = [:before_add, :after_add, :before_remove, :after_remove].freeze
|
|
5
5
|
|
|
6
6
|
self.valid_options += [
|
|
7
7
|
:before_add, :after_add, :before_remove, :after_remove
|
|
@@ -52,7 +52,7 @@ module ActiveFedora::Associations::Builder
|
|
|
52
52
|
send(name).delete_all
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
|
-
|
|
55
|
+
alias define_nullify_dependency_method define_delete_all_dependency_method
|
|
56
56
|
|
|
57
57
|
def define_restrict_dependency_method
|
|
58
58
|
name = self.name
|
|
@@ -835,7 +835,7 @@ module ActiveFedora
|
|
|
835
835
|
@association.include?(record)
|
|
836
836
|
end
|
|
837
837
|
|
|
838
|
-
|
|
838
|
+
alias new build
|
|
839
839
|
|
|
840
840
|
def proxy_association
|
|
841
841
|
@association
|
|
@@ -845,17 +845,17 @@ module ActiveFedora
|
|
|
845
845
|
def scope
|
|
846
846
|
@association.scope
|
|
847
847
|
end
|
|
848
|
-
|
|
848
|
+
alias spawn scope
|
|
849
849
|
|
|
850
850
|
def to_ary
|
|
851
851
|
load_target.dup
|
|
852
852
|
end
|
|
853
|
-
|
|
853
|
+
alias to_a to_ary
|
|
854
854
|
|
|
855
855
|
def <<(*records)
|
|
856
856
|
proxy_association.concat(records) && self
|
|
857
857
|
end
|
|
858
|
-
|
|
858
|
+
alias push <<
|
|
859
859
|
|
|
860
860
|
def clear
|
|
861
861
|
delete_all
|
|
@@ -98,13 +98,9 @@ module ActiveFedora
|
|
|
98
98
|
# Returns the RDF node that contains metadata like RDF.type assertions for the record
|
|
99
99
|
# Sometimes this is the record, other times it's record.metadata_node
|
|
100
100
|
def metadata_node_for_record(record)
|
|
101
|
-
if record.respond_to?(:type) && record.respond_to?(:set_value)
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return record.metadata_node
|
|
105
|
-
else
|
|
106
|
-
raise ArgumentError, "record must either have a metadata node or must respond to .type"
|
|
107
|
-
end
|
|
101
|
+
return record if record.respond_to?(:type) && record.respond_to?(:set_value)
|
|
102
|
+
return record.metadata_node if record.respond_to?(:metadata_node)
|
|
103
|
+
raise ArgumentError, "record must either have a metadata node or must respond to .type"
|
|
108
104
|
end
|
|
109
105
|
end
|
|
110
106
|
end
|
|
@@ -69,40 +69,33 @@ module ActiveFedora
|
|
|
69
69
|
|
|
70
70
|
# Deletes the records according to the <tt>:dependent</tt> option.
|
|
71
71
|
def delete_records(records, method)
|
|
72
|
-
if method == :destroy
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
# keys = records.map { |r| r[reflection.association_primary_key] }
|
|
77
|
-
# scope = scoped.where(reflection.association_primary_key => keys)
|
|
72
|
+
return records.each(&:destroy) if method == :destroy
|
|
73
|
+
# Find all the records that point to this and nullify them
|
|
74
|
+
# keys = records.map { |r| r[reflection.association_primary_key] }
|
|
75
|
+
# scope = scoped.where(reflection.association_primary_key => keys)
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
raise "Not Implemented"
|
|
81
|
-
# update_counter(-scope.delete_all)
|
|
82
|
-
else
|
|
77
|
+
raise "Not Implemented" if method == :delete_all # update_counter(-scope.delete_all)
|
|
83
78
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
# Check to see if the object still exists (may be already deleted).
|
|
98
|
-
# In Rails, they do this with an update_all to avoid callbacks and validations, we may need the same.
|
|
99
|
-
record.save! if record.class.exists?(record.id)
|
|
100
|
-
end
|
|
79
|
+
if reflection.inverse_of # Can't get an inverse when class_name: 'ActiveFedora::Base' is supplied
|
|
80
|
+
inverse = reflection.inverse_of
|
|
81
|
+
records.each do |record|
|
|
82
|
+
next unless record.persisted?
|
|
83
|
+
if inverse.collection?
|
|
84
|
+
# Remove from a has_and_belongs_to_many
|
|
85
|
+
record.association(inverse.name).delete(@owner)
|
|
86
|
+
elsif inverse.klass == ActiveFedora::Base
|
|
87
|
+
record[inverse.foreign_key] = nil
|
|
88
|
+
else
|
|
89
|
+
# Remove from a belongs_to
|
|
90
|
+
record[reflection.foreign_key] = nil
|
|
101
91
|
end
|
|
102
|
-
|
|
103
|
-
#
|
|
92
|
+
# Check to see if the object still exists (may be already deleted).
|
|
93
|
+
# In Rails, they do this with an update_all to avoid callbacks and validations, we may need the same.
|
|
94
|
+
record.save! if record.class.exists?(record.id)
|
|
104
95
|
end
|
|
105
96
|
end
|
|
97
|
+
|
|
98
|
+
# update_counter(-scope.update_all(reflection.foreign_key => nil))
|
|
106
99
|
end
|
|
107
100
|
end
|
|
108
101
|
end
|
|
@@ -75,7 +75,7 @@ module ActiveFedora
|
|
|
75
75
|
module AutosaveAssociation
|
|
76
76
|
extend ActiveSupport::Concern
|
|
77
77
|
|
|
78
|
-
ASSOCIATION_TYPES = %w( HasMany BelongsTo HasAndBelongsToMany DirectlyContains IndirectlyContains)
|
|
78
|
+
ASSOCIATION_TYPES = %w( HasMany BelongsTo HasAndBelongsToMany DirectlyContains IndirectlyContains).freeze
|
|
79
79
|
|
|
80
80
|
module AssociationBuilderExtension #:nodoc:
|
|
81
81
|
def self.included(base)
|
data/lib/active_fedora/base.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
|
|
1
|
+
SOLR_DOCUMENT_ID = "id".freeze unless defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
|
|
2
2
|
ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
|
|
3
3
|
require 'active_support/descendants_tracker'
|
|
4
4
|
require 'active_fedora/errors'
|
|
@@ -216,7 +216,7 @@ module ActiveFedora
|
|
|
216
216
|
:before_save, :around_save, :after_save, :before_create, :around_create,
|
|
217
217
|
:after_create, :before_update, :around_update, :after_update,
|
|
218
218
|
:before_destroy, :around_destroy, :after_destroy
|
|
219
|
-
]
|
|
219
|
+
].freeze
|
|
220
220
|
|
|
221
221
|
included do
|
|
222
222
|
extend ActiveModel::Callbacks
|
|
@@ -59,8 +59,7 @@ module ActiveFedora
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def internal?
|
|
62
|
-
value.object.to_s.start_with?("http://www.jcp.org") ||
|
|
63
|
-
value.object.to_s.start_with?("http://fedora.info") ||
|
|
62
|
+
value.object.to_s.start_with?("http://www.jcp.org", "http://fedora.info") ||
|
|
64
63
|
value.predicate.to_s.start_with?("http://fedora.info")
|
|
65
64
|
end
|
|
66
65
|
end
|
|
@@ -15,12 +15,12 @@ module ActiveFedora
|
|
|
15
15
|
|
|
16
16
|
def ng_xml
|
|
17
17
|
@ng_xml ||= begin
|
|
18
|
-
if new_record?
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
xml = if new_record?
|
|
19
|
+
## Load up the template
|
|
20
|
+
self.class.xml_template
|
|
21
|
+
else
|
|
22
|
+
Nokogiri::XML::Document.parse(remote_content)
|
|
23
|
+
end
|
|
24
24
|
self.class.decorate_ng_xml xml
|
|
25
25
|
end
|
|
26
26
|
end
|
data/lib/active_fedora/file.rb
CHANGED
|
@@ -188,6 +188,11 @@ module ActiveFedora
|
|
|
188
188
|
false
|
|
189
189
|
end
|
|
190
190
|
|
|
191
|
+
def self.relation
|
|
192
|
+
FileRelation.new(self)
|
|
193
|
+
end
|
|
194
|
+
private_class_method :relation
|
|
195
|
+
|
|
191
196
|
protected
|
|
192
197
|
|
|
193
198
|
# The string to prefix all solr fields with. Override this method if you want
|
|
@@ -198,10 +203,6 @@ module ActiveFedora
|
|
|
198
203
|
|
|
199
204
|
private
|
|
200
205
|
|
|
201
|
-
def self.relation
|
|
202
|
-
FileRelation.new(self)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
206
|
# Rack::Test::UploadedFile is often set via content=, however it's not an IO, though it wraps an io object.
|
|
206
207
|
def behaves_like_io?(obj)
|
|
207
208
|
[IO, Tempfile, StringIO].any? { |klass| obj.is_a? klass } || (defined?(Rack) && obj.is_a?(Rack::Test::UploadedFile))
|
|
@@ -149,14 +149,12 @@ module ActiveFedora
|
|
|
149
149
|
# Given the solr_config that's been loaded for this environment,
|
|
150
150
|
# determine which solr url to use
|
|
151
151
|
def solr_url(solr_config)
|
|
152
|
+
return solr_config[:url] if solr_config.key?(:url)
|
|
153
|
+
return solr_config['url'] if solr_config.key?('url')
|
|
152
154
|
if @index_full_text == true && solr_config.key?(:fulltext) && solr_config[:fulltext].key?('url')
|
|
153
|
-
|
|
155
|
+
solr_config[:fulltext]['url']
|
|
154
156
|
elsif solr_config.key?(:default) && solr_config[:default].key?('url')
|
|
155
|
-
|
|
156
|
-
elsif solr_config.key?('url')
|
|
157
|
-
return solr_config['url']
|
|
158
|
-
elsif solr_config.key?(:url)
|
|
159
|
-
return solr_config[:url]
|
|
157
|
+
solr_config[:default]['url']
|
|
160
158
|
else
|
|
161
159
|
raise URI::InvalidURIError
|
|
162
160
|
end
|
|
@@ -208,11 +206,8 @@ module ActiveFedora
|
|
|
208
206
|
# Checks the existing fedora_config.path to see if there is a solr.yml there
|
|
209
207
|
def check_fedora_path_for_solr
|
|
210
208
|
path = ::File.dirname(self.path) + "/solr.yml"
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
else
|
|
214
|
-
return nil
|
|
215
|
-
end
|
|
209
|
+
return unless ::File.file? path
|
|
210
|
+
path
|
|
216
211
|
end
|
|
217
212
|
|
|
218
213
|
def predicate_config
|
|
@@ -16,7 +16,7 @@ module ActiveFedora::Indexing
|
|
|
16
16
|
|
|
17
17
|
# this enables a cleaner API for solr integration
|
|
18
18
|
class IndexObject
|
|
19
|
-
attr_accessor :data_type, :behaviors
|
|
19
|
+
attr_accessor :data_type, :behaviors, :term
|
|
20
20
|
attr_reader :key
|
|
21
21
|
|
|
22
22
|
def initialize(name, &_block)
|
|
@@ -27,6 +27,7 @@ module ActiveFedora::Indexing
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def as(*args)
|
|
30
|
+
@term = args.last.is_a?(Hash) ? args.pop : {}
|
|
30
31
|
@behaviors = args
|
|
31
32
|
end
|
|
32
33
|
|
|
@@ -39,9 +39,9 @@ module ActiveFedora
|
|
|
39
39
|
Solrizer.set_field(solr_doc, 'system_create', c_time, :stored_sortable)
|
|
40
40
|
Solrizer.set_field(solr_doc, 'system_modified', m_time, :stored_sortable)
|
|
41
41
|
Solrizer.set_field(solr_doc, 'active_fedora_model', object.class.inspect, :stored_sortable)
|
|
42
|
-
solr_doc
|
|
43
|
-
solr_doc
|
|
44
|
-
solr_doc
|
|
42
|
+
solr_doc[QueryResultBuilder::HAS_MODEL_SOLR_FIELD] = object.has_model
|
|
43
|
+
solr_doc[SOLR_DOCUMENT_ID.to_sym] = object.id
|
|
44
|
+
solr_doc[self.class.profile_solr_name] = profile_service.new(object).export
|
|
45
45
|
object.declared_attached_files.each do |name, file|
|
|
46
46
|
solr_doc.merge! file.to_solr(solr_doc, name: name.to_s)
|
|
47
47
|
end
|
data/lib/active_fedora/model.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID)
|
|
1
|
+
SOLR_DOCUMENT_ID = "id".freeze unless defined?(SOLR_DOCUMENT_ID)
|
|
2
2
|
|
|
3
3
|
module ActiveFedora
|
|
4
4
|
# = ActiveFedora
|
|
@@ -17,14 +17,13 @@ module ActiveFedora
|
|
|
17
17
|
ActiveFedora.class_from_string(model_value)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
end
|
|
20
|
+
def self.class_exists?(class_name)
|
|
21
|
+
return false if class_name.empty?
|
|
22
|
+
klass = class_name.constantize
|
|
23
|
+
return klass.is_a?(Class)
|
|
24
|
+
rescue NameError
|
|
25
|
+
return false
|
|
26
|
+
end
|
|
27
|
+
private_class_method :class_exists?
|
|
29
28
|
end
|
|
30
29
|
end
|
|
@@ -113,7 +113,7 @@ module ActiveFedora
|
|
|
113
113
|
|
|
114
114
|
# Attribute hash keys that should not be assigned as normal attributes.
|
|
115
115
|
# These hash keys are nested attributes implementation details.
|
|
116
|
-
UNASSIGNABLE_KEYS = %w( id _destroy )
|
|
116
|
+
UNASSIGNABLE_KEYS = %w( id _destroy ).freeze
|
|
117
117
|
|
|
118
118
|
def assign_nested_attributes_for_collection_association(association_name, attributes_collection)
|
|
119
119
|
options = nested_attributes_options[association_name]
|
|
@@ -34,11 +34,11 @@ module ActiveFedora
|
|
|
34
34
|
term.values.each do |v|
|
|
35
35
|
Array(term.options[:index]).each do |index_as|
|
|
36
36
|
solr_doc[index_as] ||= []
|
|
37
|
-
if v.is_a? Nokogiri::XML::Node
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
solr_doc[index_as] << if v.is_a? Nokogiri::XML::Node
|
|
38
|
+
v.text
|
|
39
|
+
else
|
|
40
|
+
v
|
|
41
|
+
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
end
|
|
@@ -13,8 +13,8 @@ module ActiveFedora
|
|
|
13
13
|
include OM::XML::TerminologyBasedSolrizer # this adds support for calling .to_solr
|
|
14
14
|
include Datastreams::NokogiriDatastreams
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
alias om_term_values term_values unless method_defined?(:om_term_values)
|
|
17
|
+
alias om_update_values update_values unless method_defined?(:om_update_values)
|
|
18
18
|
|
|
19
19
|
def default_mime_type
|
|
20
20
|
'text/xml'
|
|
@@ -37,7 +37,7 @@ module ActiveFedora
|
|
|
37
37
|
save
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
alias update_attributes update
|
|
41
41
|
|
|
42
42
|
# Deletes an object from Fedora and deletes the indexed record from Solr.
|
|
43
43
|
# Delete does not run any callbacks, so consider using _destroy_ instead.
|
|
@@ -186,7 +186,7 @@ module ActiveFedora
|
|
|
186
186
|
end
|
|
187
187
|
|
|
188
188
|
def base_path_for_resource
|
|
189
|
-
init_root_path if
|
|
189
|
+
init_root_path if has_uri_prefix?
|
|
190
190
|
root_resource_path
|
|
191
191
|
end
|
|
192
192
|
|
|
@@ -157,6 +157,12 @@ module ActiveFedora::RDF
|
|
|
157
157
|
comment: %(indicates the owner of an object).freeze,
|
|
158
158
|
label: "ownerId".freeze,
|
|
159
159
|
type: "rdf:Property".freeze
|
|
160
|
+
property :PID,
|
|
161
|
+
comment: %(the Fedora 3 PID for an object).freeze,
|
|
162
|
+
label: "PID".freeze,
|
|
163
|
+
domain: "info:fedora/fedora-system:def/model#FedoraObject".freeze,
|
|
164
|
+
range: "xsd:string".freeze,
|
|
165
|
+
type: "rdf:Property".freeze
|
|
160
166
|
property :state,
|
|
161
167
|
comment: %(indicates the state of the object or datastream).freeze,
|
|
162
168
|
label: "state".freeze,
|