active-fedora 6.8.0 → 7.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +15 -5
- data/CONTRIBUTING.md +2 -0
- data/Gemfile +0 -2
- data/History.txt +2 -32
- data/README.md +143 -0
- data/Rakefile +5 -7
- data/active-fedora.gemspec +9 -9
- data/gemfiles/rails3.gemfile +11 -0
- data/gemfiles/rails4.gemfile +10 -0
- data/lib/active_fedora.rb +31 -4
- data/lib/active_fedora/association_relation.rb +18 -0
- data/lib/active_fedora/associations.rb +38 -171
- data/lib/active_fedora/associations/association.rb +163 -0
- data/lib/active_fedora/associations/association_scope.rb +39 -0
- data/lib/active_fedora/associations/belongs_to_association.rb +47 -25
- data/lib/active_fedora/associations/builder/association.rb +55 -0
- data/lib/active_fedora/associations/builder/belongs_to.rb +100 -0
- data/lib/active_fedora/associations/builder/collection_association.rb +56 -0
- data/lib/active_fedora/associations/builder/has_and_belongs_to_many.rb +30 -0
- data/lib/active_fedora/associations/builder/has_many.rb +63 -0
- data/lib/active_fedora/associations/builder/singular_association.rb +32 -0
- data/lib/active_fedora/associations/{association_collection.rb → collection_association.rb} +203 -53
- data/lib/active_fedora/associations/collection_proxy.rb +862 -0
- data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +35 -25
- data/lib/active_fedora/associations/has_many_association.rb +36 -11
- data/lib/active_fedora/associations/singular_association.rb +62 -0
- data/lib/active_fedora/attributes.rb +43 -139
- data/lib/active_fedora/autosave_association.rb +317 -0
- data/lib/active_fedora/base.rb +10 -327
- data/lib/active_fedora/callbacks.rb +1 -3
- data/lib/active_fedora/content_model.rb +16 -0
- data/lib/active_fedora/core.rb +151 -0
- data/lib/active_fedora/datastream_attribute.rb +76 -0
- data/lib/active_fedora/datastream_hash.rb +8 -13
- data/lib/active_fedora/datastreams.rb +39 -26
- data/lib/active_fedora/digital_object.rb +2 -2
- data/lib/active_fedora/fedora_attributes.rb +45 -0
- data/lib/active_fedora/fixture_loader.rb +1 -1
- data/lib/active_fedora/indexing.rb +6 -1
- data/lib/active_fedora/model.rb +0 -17
- data/lib/active_fedora/nested_attributes.rb +2 -2
- data/lib/active_fedora/null_relation.rb +7 -0
- data/lib/active_fedora/om_datastream.rb +3 -4
- data/lib/active_fedora/persistence.rb +41 -29
- data/lib/active_fedora/querying.rb +2 -163
- data/lib/active_fedora/rdf.rb +1 -0
- data/lib/active_fedora/rdf/indexing.rb +67 -0
- data/lib/active_fedora/rdf_datastream.rb +2 -50
- data/lib/active_fedora/rdf_node.rb +12 -7
- data/lib/active_fedora/rdf_node/term_proxy.rb +30 -21
- data/lib/active_fedora/rdfxml_rdf_datastream.rb +1 -1
- data/lib/active_fedora/reflection.rb +163 -20
- data/lib/active_fedora/relation.rb +33 -130
- data/lib/active_fedora/relation/calculations.rb +19 -0
- data/lib/active_fedora/relation/delegation.rb +22 -0
- data/lib/active_fedora/relation/finder_methods.rb +247 -0
- data/lib/active_fedora/relation/merger.rb +22 -0
- data/lib/active_fedora/relation/query_methods.rb +58 -0
- data/lib/active_fedora/relation/spawn_methods.rb +46 -0
- data/lib/active_fedora/relationship_graph.rb +0 -2
- data/lib/active_fedora/rels_ext_datastream.rb +1 -4
- data/lib/active_fedora/rubydora_connection.rb +1 -1
- data/lib/active_fedora/scoping.rb +20 -0
- data/lib/active_fedora/scoping/default.rb +38 -0
- data/lib/active_fedora/scoping/named.rb +32 -0
- data/lib/active_fedora/semantic_node.rb +54 -106
- data/lib/active_fedora/serialization.rb +19 -0
- data/lib/active_fedora/sharding.rb +58 -0
- data/lib/active_fedora/solr_digital_object.rb +15 -5
- data/lib/active_fedora/solr_instance_loader.rb +1 -1
- data/lib/active_fedora/solr_service.rb +1 -1
- data/lib/active_fedora/unsaved_digital_object.rb +6 -4
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +3 -0
- data/lib/tasks/active_fedora_dev.rake +6 -5
- data/spec/config_helper.rb +14 -14
- data/spec/integration/associations_spec.rb +168 -455
- data/spec/integration/attributes_spec.rb +12 -11
- data/spec/integration/auditable_spec.rb +11 -11
- data/spec/integration/autosave_association_spec.rb +25 -0
- data/spec/integration/base_spec.rb +163 -163
- data/spec/integration/belongs_to_association_spec.rb +166 -0
- data/spec/integration/bug_spec.rb +7 -7
- data/spec/integration/collection_association_spec.rb +58 -0
- data/spec/integration/complex_rdf_datastream_spec.rb +88 -88
- data/spec/integration/datastream_collections_spec.rb +69 -69
- data/spec/integration/datastream_spec.rb +43 -43
- data/spec/integration/datastreams_spec.rb +63 -63
- data/spec/integration/delete_all_spec.rb +46 -39
- data/spec/integration/fedora_solr_sync_spec.rb +5 -5
- data/spec/integration/field_to_solr_name_spec.rb +34 -0
- data/spec/integration/full_featured_model_spec.rb +100 -101
- data/spec/integration/has_and_belongs_to_many_associations_spec.rb +341 -0
- data/spec/integration/has_many_associations_spec.rb +172 -24
- data/spec/integration/json_serialization_spec.rb +31 -0
- data/spec/integration/load_from_solr_spec.rb +48 -0
- data/spec/integration/model_spec.rb +35 -40
- data/spec/integration/nested_attribute_spec.rb +42 -43
- data/spec/integration/ntriples_datastream_spec.rb +131 -113
- data/spec/integration/om_datastream_spec.rb +67 -67
- data/spec/integration/persistence_spec.rb +7 -7
- data/spec/integration/rdf_nested_attributes_spec.rb +56 -56
- data/spec/integration/relation_delegation_spec.rb +26 -25
- data/spec/integration/relation_spec.rb +42 -0
- data/spec/integration/rels_ext_datastream_spec.rb +20 -20
- data/spec/integration/scoped_query_spec.rb +61 -51
- data/spec/integration/solr_instance_loader_spec.rb +5 -5
- data/spec/integration/solr_service_spec.rb +46 -46
- data/spec/samples/hydra-mods_article_datastream.rb +334 -334
- data/spec/samples/hydra-rights_metadata_datastream.rb +57 -57
- data/spec/samples/marpa-dc_datastream.rb +17 -17
- data/spec/samples/models/audio_record.rb +16 -16
- data/spec/samples/models/image.rb +2 -2
- data/spec/samples/models/mods_article.rb +5 -5
- data/spec/samples/models/oral_history.rb +18 -18
- data/spec/samples/models/seminar.rb +24 -24
- data/spec/samples/models/seminar_audio_file.rb +17 -17
- data/spec/samples/oral_history_sample_model.rb +21 -21
- data/spec/samples/special_thing.rb +14 -14
- data/spec/spec_helper.rb +11 -7
- data/spec/support/an_active_model.rb +2 -8
- data/spec/support/freeze_mocks.rb +12 -0
- data/spec/support/mock_fedora.rb +17 -16
- data/spec/unit/active_fedora_spec.rb +58 -60
- data/spec/unit/attributes_spec.rb +314 -0
- data/spec/unit/base_active_model_spec.rb +28 -27
- data/spec/unit/base_cma_spec.rb +5 -5
- data/spec/unit/base_datastream_management_spec.rb +27 -27
- data/spec/unit/base_extra_spec.rb +76 -48
- data/spec/unit/base_spec.rb +277 -348
- data/spec/unit/callback_spec.rb +18 -19
- data/spec/unit/code_configurator_spec.rb +17 -17
- data/spec/unit/config_spec.rb +8 -16
- data/spec/unit/content_model_spec.rb +79 -60
- data/spec/unit/datastream_collections_spec.rb +229 -229
- data/spec/unit/datastream_spec.rb +51 -63
- data/spec/unit/datastreams_spec.rb +87 -87
- data/spec/unit/file_configurator_spec.rb +217 -217
- data/spec/unit/has_and_belongs_to_many_collection_spec.rb +44 -25
- data/spec/unit/has_many_collection_spec.rb +26 -8
- data/spec/unit/inheritance_spec.rb +13 -12
- data/spec/unit/model_spec.rb +39 -45
- data/spec/unit/nom_datastream_spec.rb +15 -15
- data/spec/unit/ntriples_datastream_spec.rb +123 -118
- data/spec/unit/om_datastream_spec.rb +227 -233
- data/spec/unit/persistence_spec.rb +34 -15
- data/spec/unit/predicates_spec.rb +73 -73
- data/spec/unit/property_spec.rb +17 -9
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +33 -33
- data/spec/unit/query_spec.rb +222 -198
- data/spec/unit/rdf_datastream_spec.rb +21 -28
- data/spec/unit/rdf_list_nested_attributes_spec.rb +34 -34
- data/spec/unit/rdf_list_spec.rb +65 -64
- data/spec/unit/rdf_node_spec.rb +7 -7
- data/spec/unit/rdf_xml_writer_spec.rb +10 -10
- data/spec/unit/rdfxml_rdf_datastream_spec.rb +27 -27
- data/spec/unit/relationship_graph_spec.rb +51 -51
- data/spec/unit/rels_ext_datastream_spec.rb +68 -74
- data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +15 -15
- data/spec/unit/rspec_matchers/match_fedora_datastream_matcher_spec.rb +12 -12
- data/spec/unit/rubydora_connection_spec.rb +5 -5
- data/spec/unit/semantic_node_spec.rb +48 -107
- data/spec/unit/serializers_spec.rb +4 -4
- data/spec/unit/service_definitions_spec.rb +26 -26
- data/spec/unit/simple_datastream_spec.rb +17 -17
- data/spec/unit/solr_config_options_spec.rb +29 -28
- data/spec/unit/solr_digital_object_spec.rb +17 -25
- data/spec/unit/solr_service_spec.rb +95 -82
- data/spec/unit/unsaved_digital_object_spec.rb +24 -23
- data/spec/unit/validations_spec.rb +21 -21
- metadata +110 -159
- data/.rspec +0 -1
- data/.rubocop.yml +0 -1
- data/.rubocop_todo.yml +0 -938
- data/CONSOLE_GETTING_STARTED.textile +0 -1
- data/NOKOGIRI_DATASTREAMS.textile +0 -1
- data/README.textile +0 -116
- data/lib/active_fedora/associations/association_proxy.rb +0 -178
- data/lib/active_fedora/delegating.rb +0 -72
- data/lib/active_fedora/nokogiri_datastream.rb +0 -11
- data/spec/integration/delegating_spec.rb +0 -59
- data/spec/rails3_test_app/.gitignore +0 -4
- data/spec/rails3_test_app/.rspec +0 -1
- data/spec/rails3_test_app/Gemfile +0 -40
- data/spec/rails3_test_app/Rakefile +0 -7
- data/spec/rails3_test_app/app/controllers/application_controller.rb +0 -3
- data/spec/rails3_test_app/app/helpers/application_helper.rb +0 -2
- data/spec/rails3_test_app/app/views/layouts/application.html.erb +0 -14
- data/spec/rails3_test_app/config.ru +0 -4
- data/spec/rails3_test_app/config/application.rb +0 -42
- data/spec/rails3_test_app/config/boot.rb +0 -6
- data/spec/rails3_test_app/config/database.yml +0 -22
- data/spec/rails3_test_app/config/environment.rb +0 -5
- data/spec/rails3_test_app/config/environments/development.rb +0 -25
- data/spec/rails3_test_app/config/environments/production.rb +0 -49
- data/spec/rails3_test_app/config/environments/test.rb +0 -35
- data/spec/rails3_test_app/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/rails3_test_app/config/initializers/inflections.rb +0 -10
- data/spec/rails3_test_app/config/initializers/mime_types.rb +0 -5
- data/spec/rails3_test_app/config/initializers/secret_token.rb +0 -7
- data/spec/rails3_test_app/config/initializers/session_store.rb +0 -8
- data/spec/rails3_test_app/config/locales/en.yml +0 -5
- data/spec/rails3_test_app/config/routes.rb +0 -58
- data/spec/rails3_test_app/db/seeds.rb +0 -7
- data/spec/rails3_test_app/run_tests +0 -3
- data/spec/rails3_test_app/script/rails +0 -6
- data/spec/rails3_test_app/spec/spec_helper.rb +0 -27
- data/spec/rails3_test_app/spec/unit/rails_3_init.rb +0 -15
- data/spec/unit/association_proxy_spec.rb +0 -12
- data/spec/unit/base_delegate_spec.rb +0 -197
- data/spec/unit/base_delegate_to_spec.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c74522099ed634b608f204bad305da5f8d75cab4
|
4
|
+
data.tar.gz: 2e8c34f85de2b43228be92b308bae48dc09743be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e860a7bcd89e37df76919459ed159f618de89d3e86a34b8ec47fd05f3471a3be2a252b1639e41f4e8d8e1f799f833e8cb4b4d65351ef866bc461691e362bb619
|
7
|
+
data.tar.gz: bf290c42f829451d2858e06c25a283bcbbf5d30b4ea942322ea3d0d984740eb38318d6e5262d5c36da38211386b04bc57bd9b41264c54c0dbd718d81780ff3eb
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,13 +1,23 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
2
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.
|
3
|
+
- 2.1.0
|
4
|
+
- 2.0.0
|
5
|
+
- 1.9.3
|
6
|
+
|
7
|
+
matrix:
|
8
|
+
allow_failures:
|
9
|
+
- rvm: 2.1.0
|
10
|
+
|
11
|
+
|
12
|
+
gemfile:
|
13
|
+
- gemfiles/rails3.gemfile
|
14
|
+
- gemfiles/rails4.gemfile
|
6
15
|
|
7
16
|
notifications:
|
8
17
|
irc: "irc.freenode.org#projecthydra"
|
9
18
|
|
10
19
|
before_install:
|
11
20
|
- gem install bundler
|
12
|
-
|
13
|
-
|
21
|
+
env:
|
22
|
+
global:
|
23
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
data/CONTRIBUTING.md
CHANGED
@@ -78,6 +78,8 @@ You should also add yourself to the `CONTRIBUTORS.md` file in the root of the pr
|
|
78
78
|
|
79
79
|
### Submitting Changes
|
80
80
|
|
81
|
+
[Detailed Walkthrough of One Pull Request per Commit](http://ndlib.github.io/practices/one-commit-per-pull-request/)
|
82
|
+
|
81
83
|
* Read the article ["Using Pull Requests"](https://help.github.com/articles/using-pull-requests) on GitHub.
|
82
84
|
* Make sure your branch is up to date with its parent branch (i.e. master)
|
83
85
|
* `git checkout master`
|
data/Gemfile
CHANGED
data/History.txt
CHANGED
@@ -1,36 +1,6 @@
|
|
1
|
-
|
2
|
-
Backported changes from master for proper deserialization of ActiveFedora::DatastreamHash (Fixed #439) [Michael B. Klein]
|
1
|
+
v7.0.0 Unreleased
|
3
2
|
|
4
|
-
|
5
|
-
Backported changes from master for rubydora 1.7.1+ compatibility (Fixes #354). Upgraded rubydora to ~> 1.7.4. [David Chandek-Stark]
|
6
|
-
|
7
|
-
v6.7.6
|
8
|
-
Patch ActiveFedora::SolrDigitalObject for Rubydora 1.7.0 compatibility. [David Chandek-Stark]
|
9
|
-
|
10
|
-
v6.7.5
|
11
|
-
Support for rubydora 1.7.0 [Justin Coyne]
|
12
|
-
|
13
|
-
v6.7.4
|
14
|
-
Restrict rdf to ~> 1.1.1.1 because rdf 1.1.2 breaks ActiveFedora [Justin Coyne]
|
15
|
-
|
16
|
-
v6.7.3
|
17
|
-
Force overwrite the blacklight configuration [Justin Coyne]
|
18
|
-
|
19
|
-
v6.7.2
|
20
|
-
ConfigGenerator should use a unique method name, not `generate` so that it doesn't cause an infinite loop [Justin Coyne]
|
21
|
-
|
22
|
-
v6.7.1
|
23
|
-
Force RDF data to be UTF-8 The RDF reader chokes on certain character combinations if the raw data is not encoded UTF-8. See https://github.com/ruby-rdf/rdf/issues/142 Fedora does not store character encoding, so by default they come back as ASCII-8BIT. [Justin Coyne]
|
24
|
-
Renaming invoke -> generate [Jeremy Friesen]
|
25
|
-
|
26
|
-
v6.7.0
|
27
|
-
Remove loading of rake tasks because they are already loaded in the railtie [Chris Colvard]
|
28
|
-
Added has_attributes to replace delegate_to [Justin Coyne]
|
29
|
-
|
30
|
-
v6.6.1
|
31
|
-
Don't try to track changes on delegates that are not attributes [Justin Coyne]
|
32
|
-
Alter test so that it's compatible with the solr document produced by om 3.0.4 [Justin Coyne]
|
33
|
-
Fix test for Fedora 3.7 [Justin Coyne]
|
3
|
+
Removed update_indexed_attributes, update_datastream_attributes, get_values_from_datastream
|
34
4
|
|
35
5
|
v6.6.0
|
36
6
|
Add _destroy method for building nested forms [Justin Coyne]
|
data/README.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
Description
|
2
|
+
-----------
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/projecthydra/active_fedora.png?branch=master)](https://travis-ci.org/projecthydra/active\_fedora)
|
5
|
+
[![Version](https://badge.fury.io/rb/active-fedora.png)](http://badge.fury.io/rb/active-fedora)
|
6
|
+
[![Dependencies](https://gemnasium.com/projecthydra/active_fedora.png)](https://gemnasium.com/projecthydra/active\_fedora)
|
7
|
+
|
8
|
+
RubyFedora and ActiveFedora provide a set of Ruby gems for creating and
|
9
|
+
managing objects in the Fedora Repository Architecture
|
10
|
+
([http://fedora-commons.org](http://fedora-commons.org)). ActiveFedora
|
11
|
+
is loosely based on “ActiveRecord” in Rails. The 3.x series of
|
12
|
+
ActiveFedora depends on Rails 3, specifically activemodel and
|
13
|
+
activesupport.
|
14
|
+
|
15
|
+
Getting Help
|
16
|
+
------------
|
17
|
+
|
18
|
+
- Community Discussions & Mailing List are located at
|
19
|
+
[http://groups.google.com/group/hydra-tech](http://groups.google.com/group/hydra-tech)
|
20
|
+
- Developers hang out on IRC in \#projecthydra on freenet.
|
21
|
+
|
22
|
+
Installation
|
23
|
+
------------
|
24
|
+
|
25
|
+
The gem is hosted on gemcutter.
|
26
|
+
|
27
|
+
gem install active-fedora
|
28
|
+
|
29
|
+
Getting Started
|
30
|
+
---------------
|
31
|
+
|
32
|
+
The [ActiveFedora Console
|
33
|
+
Tour](https://github.com/projecthydra/active_fedora/wiki/Getting-Started:-Console-Tour)
|
34
|
+
gives you a brief tour through ActiveFedora’s features on the command
|
35
|
+
line.
|
36
|
+
|
37
|
+
Generators
|
38
|
+
----------
|
39
|
+
|
40
|
+
You can generate a model inheriting from ActiveFedora::Base.
|
41
|
+
|
42
|
+
rails generate active_fedora:model Book
|
43
|
+
|
44
|
+
Testing (this Gem)
|
45
|
+
------------------
|
46
|
+
|
47
|
+
In order to run the RSpec tests, you need to have a copy of the
|
48
|
+
ActiveFedora source code, and then run bundle install in the source
|
49
|
+
directory. Testing requires hydra-jetty, which contains version for
|
50
|
+
Fedora and Solr. Setting up and maintaining hydra-jetty for the purposes
|
51
|
+
of testing this gem is all accomplished via
|
52
|
+
|
53
|
+
git clone https://github.com/projecthydra/active_fedora.git
|
54
|
+
cd /wherever/active_fedora/is
|
55
|
+
bundle install
|
56
|
+
|
57
|
+
### Using the continuous integration server
|
58
|
+
|
59
|
+
You can test ActiveFedora using the same process as our continuous
|
60
|
+
integration server. To do that, unzip a copy\
|
61
|
+
of hydra-jetty first. This includes copies of Fedora and Solr which are
|
62
|
+
used during the testing process.
|
63
|
+
|
64
|
+
rake jetty:unzip
|
65
|
+
|
66
|
+
Once hydra-jetty is unzipped, the ci rake task will spin up jetty,
|
67
|
+
import the fixtures, and run the tests for you.
|
68
|
+
|
69
|
+
rake active_fedora:ci
|
70
|
+
|
71
|
+
### Testing Manually
|
72
|
+
|
73
|
+
If you want to run the tests manually, follow these instructions.
|
74
|
+
|
75
|
+
You need to have a copy of hydra-jetty running. To do this, download a
|
76
|
+
working copy of
|
77
|
+
[hydra-jetty](https://github.com/projecthydra/hydra-jetty), cd into its
|
78
|
+
root and run
|
79
|
+
|
80
|
+
java -jar start.jar
|
81
|
+
|
82
|
+
Now you’re ready to run the tests. In the directory where active\_fedora
|
83
|
+
is installed, run
|
84
|
+
|
85
|
+
rake spec
|
86
|
+
|
87
|
+
Predicate Mappings
|
88
|
+
------------------
|
89
|
+
|
90
|
+
ActiveFedora versions 2.2.1 and higher provides specialized control over
|
91
|
+
the predicate mappings used by SemanticNode. In order to provide your
|
92
|
+
own mappings, \
|
93
|
+
you must supply a predicate\_mappings.yml in the same format as the
|
94
|
+
config/predicate\_mappings.yml file shipped with the ActiveFedora gem.
|
95
|
+
Place the file in the same directory\
|
96
|
+
as your fedora.yml file and use the current method of initializing
|
97
|
+
ActiveFedora:
|
98
|
+
|
99
|
+
ActiveFedora.init("/path/to/my/config/fedora.yml")
|
100
|
+
|
101
|
+
If no predicate\_mappings.yml file is found, ActiveFedora will use the
|
102
|
+
default mappings.
|
103
|
+
|
104
|
+
Acknowledgements
|
105
|
+
----------------
|
106
|
+
|
107
|
+
Creator: Matt Zumwalt ([MediaShelf](http://yourmediashelf.com))
|
108
|
+
|
109
|
+
Developers: \
|
110
|
+
Justin Coyne, McClain Looney & Eddie Shin
|
111
|
+
([MediaShelf](http://yourmediashelf.com)), Rick Johnson (Notre Dame)
|
112
|
+
|
113
|
+
LICENSE:
|
114
|
+
--------
|
115
|
+
|
116
|
+
Copyright © 2009-2012 Matt Zumwalt & MediaShelf, LLC
|
117
|
+
|
118
|
+
This program is free software: you can redistribute it and/or modify\
|
119
|
+
it under the terms of the GNU Lesser General Public License (LGPL) as \
|
120
|
+
published by the Free Software Foundation, either version 3 of the
|
121
|
+
License, \
|
122
|
+
or (at your option) any later version.
|
123
|
+
|
124
|
+
This program is distributed in the hope that it will be useful,\
|
125
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of\
|
126
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\
|
127
|
+
GNU General Public License for more details.
|
128
|
+
|
129
|
+
You should have received a copy of the GNU Lesser General Public
|
130
|
+
License\
|
131
|
+
along with this program. If not, see <http://www.gnu.org/licenses/> or \
|
132
|
+
see <http://www.gnu.org/licenses/lgpl.html>.
|
133
|
+
|
134
|
+
The above copyright notice and this permission notice shall be\
|
135
|
+
included in all copies or substantial portions of the Software.
|
136
|
+
|
137
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,\
|
138
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\
|
139
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\
|
140
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\
|
141
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\
|
142
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\
|
143
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,21 +1,19 @@
|
|
1
1
|
require 'rake/clean'
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler'
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "bundler/setup"
|
5
|
+
require "active-fedora"
|
6
6
|
|
7
7
|
Bundler::GemHelper.install_tasks
|
8
8
|
|
9
|
-
# peg to an expected-to-match version of jetty, if not specified
|
10
|
-
ZIP_URL ||= ENV['ZIP_URL'] || 'https://github.com/projecthydra/hydra-jetty/archive/v7.2.0.zip'
|
11
|
-
|
12
9
|
# load rake tasks defined in lib/tasks that are not loaded in lib/active_fedora.rb
|
13
|
-
load
|
10
|
+
load "lib/tasks/active_fedora_dev.rake"
|
14
11
|
|
15
12
|
CLEAN.include %w[**/.DS_Store tmp *.log *.orig *.tmp **/*~]
|
16
13
|
|
17
|
-
task :ci
|
14
|
+
task :ci => ['jetty:clean', 'active_fedora:ci']
|
18
15
|
task :spec => ['active_fedora:rspec']
|
19
16
|
task :rcov => ['active_fedora:rcov']
|
20
17
|
|
18
|
+
|
21
19
|
task :default => [:ci]
|
data/active-fedora.gemspec
CHANGED
@@ -15,31 +15,31 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.required_ruby_version = '>= 1.9.3'
|
16
16
|
|
17
17
|
s.add_dependency('rsolr')
|
18
|
-
s.add_dependency('om', '~> 3.0')
|
18
|
+
s.add_dependency('om', '~> 3.0.0')
|
19
19
|
s.add_dependency('nom-xml', '>=0.5.1')
|
20
|
-
s.add_dependency("activesupport", '>= 3')
|
20
|
+
s.add_dependency("activesupport", '>= 3.0.0')
|
21
21
|
s.add_dependency("mediashelf-loggable")
|
22
|
-
s.add_dependency("rubydora", '~>1.
|
23
|
-
s.add_dependency("rdf"
|
24
|
-
s.add_dependency("rdf-rdfxml", '~>1.1')
|
22
|
+
s.add_dependency("rubydora", '~>1.7.0.pre1')
|
23
|
+
s.add_dependency("rdf")
|
24
|
+
s.add_dependency("rdf-rdfxml", '~>1.1.0')
|
25
25
|
s.add_dependency("deprecation")
|
26
26
|
s.add_development_dependency("rdoc")
|
27
27
|
s.add_development_dependency("yard")
|
28
|
-
s.add_development_dependency("RedCloth") # for RDoc formatting
|
29
28
|
s.add_development_dependency("rake")
|
30
29
|
s.add_development_dependency("jettywrapper", ">=1.4.0")
|
31
|
-
s.add_development_dependency("rspec", "
|
30
|
+
s.add_development_dependency("rspec", ">= 2.9.0")
|
32
31
|
s.add_development_dependency("equivalent-xml")
|
33
32
|
s.add_development_dependency("rest-client")
|
34
33
|
s.add_development_dependency("webmock")
|
35
|
-
|
34
|
+
|
36
35
|
s.files = `git ls-files`.split("\n")
|
37
36
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
38
37
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
39
38
|
s.extra_rdoc_files = [
|
40
39
|
"LICENSE",
|
41
|
-
"README.
|
40
|
+
"README.md"
|
42
41
|
]
|
43
42
|
s.require_paths = ["lib"]
|
44
43
|
|
45
44
|
end
|
45
|
+
|
data/lib/active_fedora.rb
CHANGED
@@ -22,28 +22,33 @@ module ActiveFedora #:nodoc:
|
|
22
22
|
class AssociationTypeMismatch < RuntimeError; end # :nodoc:
|
23
23
|
class UnregisteredPredicateError < RuntimeError; end # :nodoc:
|
24
24
|
class RecordNotSaved < RuntimeError; end # :nodoc:
|
25
|
+
class IllegalOperation < RuntimeError; end # :nodoc:
|
25
26
|
|
26
27
|
|
27
28
|
eager_autoload do
|
29
|
+
autoload :AssociationRelation
|
28
30
|
autoload :Associations
|
29
31
|
autoload :Attributes
|
30
32
|
autoload :Auditable
|
33
|
+
autoload :AutosaveAssociation
|
31
34
|
autoload :Base
|
32
35
|
autoload :ContentModel
|
33
36
|
autoload :Callbacks
|
34
37
|
autoload :Config
|
38
|
+
autoload :Core
|
35
39
|
autoload :Datastream
|
40
|
+
autoload :DatastreamAttribute
|
36
41
|
autoload :DatastreamHash
|
37
42
|
autoload :Datastreams
|
38
|
-
autoload :Delegating
|
39
43
|
autoload :DigitalObject
|
44
|
+
autoload :FedoraAttributes
|
40
45
|
autoload :FileConfigurator
|
41
46
|
autoload :Indexing
|
42
47
|
autoload :Model
|
43
48
|
autoload :NestedAttributes
|
44
|
-
autoload :NokogiriDatastream
|
45
49
|
autoload :NomDatastream
|
46
50
|
autoload :NtriplesRDFDatastream
|
51
|
+
autoload :NullRelation
|
47
52
|
autoload :OmDatastream
|
48
53
|
autoload :Property
|
49
54
|
autoload :Persistence
|
@@ -57,10 +62,22 @@ module ActiveFedora #:nodoc:
|
|
57
62
|
autoload :RdfxmlRDFDatastream
|
58
63
|
autoload :Reflection
|
59
64
|
autoload :Relation
|
65
|
+
|
66
|
+
autoload_under 'relation' do
|
67
|
+
autoload :Calculations
|
68
|
+
autoload :Delegation
|
69
|
+
autoload :SpawnMethods
|
70
|
+
autoload :QueryMethods
|
71
|
+
autoload :FinderMethods
|
72
|
+
end
|
73
|
+
|
60
74
|
autoload :RelationshipGraph
|
61
75
|
autoload :RelsExtDatastream
|
62
|
-
autoload :
|
76
|
+
autoload :Scoping
|
63
77
|
autoload :SemanticNode
|
78
|
+
autoload :ServiceDefinitions
|
79
|
+
autoload :Serialization
|
80
|
+
autoload :Sharding
|
64
81
|
autoload :SimpleDatastream
|
65
82
|
autoload :SolrDigitalObject
|
66
83
|
autoload :SolrService
|
@@ -72,7 +89,17 @@ module ActiveFedora #:nodoc:
|
|
72
89
|
autoload :Validations
|
73
90
|
autoload :SolrInstanceLoader
|
74
91
|
end
|
75
|
-
|
92
|
+
|
93
|
+
module Scoping
|
94
|
+
extend ActiveSupport::Autoload
|
95
|
+
|
96
|
+
eager_autoload do
|
97
|
+
autoload :Default
|
98
|
+
autoload :Named
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
76
103
|
|
77
104
|
include Loggable
|
78
105
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveFedora
|
2
|
+
class AssociationRelation < Relation
|
3
|
+
def initialize(klass, association)
|
4
|
+
super(klass)
|
5
|
+
@association = association
|
6
|
+
end
|
7
|
+
|
8
|
+
def proxy_association
|
9
|
+
@association
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def exec_queries
|
15
|
+
super.each { |r| @association.set_inverse_instance r }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -5,13 +5,26 @@ module ActiveFedora
|
|
5
5
|
module Associations
|
6
6
|
extend ActiveSupport::Concern
|
7
7
|
|
8
|
-
autoload :
|
9
|
-
autoload :
|
8
|
+
autoload :Association, 'active_fedora/associations/association'
|
9
|
+
autoload :AssociationScope, 'active_fedora/associations/association_scope'
|
10
|
+
autoload :SingularAssociation, 'active_fedora/associations/singular_association'
|
11
|
+
autoload :CollectionAssociation, 'active_fedora/associations/collection_association'
|
12
|
+
autoload :CollectionProxy, 'active_fedora/associations/collection_proxy'
|
13
|
+
|
14
|
+
autoload :HasManyAssociation, 'active_fedora/associations/has_many_association'
|
15
|
+
autoload :BelongsToAssociation, 'active_fedora/associations/belongs_to_association'
|
10
16
|
autoload :HasAndBelongsToManyAssociation, 'active_fedora/associations/has_and_belongs_to_many_association'
|
11
17
|
|
18
|
+
module Builder
|
19
|
+
autoload :Association, 'active_fedora/associations/builder/association'
|
20
|
+
autoload :SingularAssociation, 'active_fedora/associations/builder/singular_association'
|
21
|
+
autoload :CollectionAssociation, 'active_fedora/associations/builder/collection_association'
|
22
|
+
|
23
|
+
autoload :BelongsTo, 'active_fedora/associations/builder/belongs_to'
|
24
|
+
autoload :HasMany, 'active_fedora/associations/builder/has_many'
|
25
|
+
autoload :HasAndBelongsToMany, 'active_fedora/associations/builder/has_and_belongs_to_many'
|
26
|
+
end
|
12
27
|
|
13
|
-
autoload :AssociationCollection, 'active_fedora/associations/association_collection'
|
14
|
-
autoload :AssociationProxy, 'active_fedora/associations/association_proxy'
|
15
28
|
|
16
29
|
# Clears out the association cache.
|
17
30
|
def clear_association_cache #:nodoc:
|
@@ -20,6 +33,21 @@ module ActiveFedora
|
|
20
33
|
|
21
34
|
# :nodoc:
|
22
35
|
attr_reader :association_cache
|
36
|
+
|
37
|
+
|
38
|
+
# Returns the association instance for the given name, instantiating it if it doesn't already exist
|
39
|
+
def association(name) #:nodoc:
|
40
|
+
association = association_instance_get(name)
|
41
|
+
|
42
|
+
if association.nil?
|
43
|
+
reflection = self.class.reflect_on_association(name)
|
44
|
+
association = reflection.association_class.new(self, reflection)
|
45
|
+
association_instance_set(name, association)
|
46
|
+
end
|
47
|
+
|
48
|
+
association
|
49
|
+
end
|
50
|
+
|
23
51
|
|
24
52
|
private
|
25
53
|
|
@@ -35,10 +63,8 @@ module ActiveFedora
|
|
35
63
|
|
36
64
|
module ClassMethods
|
37
65
|
|
38
|
-
def has_many(
|
39
|
-
|
40
|
-
add_association_callbacks(reflection.name, reflection.options)
|
41
|
-
collection_accessor_methods(reflection, HasManyAssociation)
|
66
|
+
def has_many(name, options={})
|
67
|
+
Builder::HasMany.build(self, name, options)
|
42
68
|
end
|
43
69
|
|
44
70
|
|
@@ -75,14 +101,9 @@ module ActiveFedora
|
|
75
101
|
# Option examples:
|
76
102
|
# belongs_to :firm, :property => :client_of
|
77
103
|
# belongs_to :author, :class_name => "Person", :property => :author_of
|
78
|
-
def belongs_to(
|
104
|
+
def belongs_to(name, options = {})
|
79
105
|
raise "You must specify a property name for #{name}" if !options[:property]
|
80
|
-
|
81
|
-
|
82
|
-
association_accessor_methods(reflection, BelongsToAssociation)
|
83
|
-
association_constructor_method(:build, reflection, BelongsToAssociation)
|
84
|
-
association_constructor_method(:create, reflection, BelongsToAssociation)
|
85
|
-
#configure_dependency_for_belongs_to(reflection)
|
106
|
+
Builder::BelongsTo.build(self, name, options)
|
86
107
|
end
|
87
108
|
|
88
109
|
|
@@ -148,163 +169,9 @@ module ActiveFedora
|
|
148
169
|
# has_and_belongs_to_many :projects, :property=>:works_on
|
149
170
|
# has_and_belongs_to_many :nations, :class_name => "Country", :property=>:is_citizen_of
|
150
171
|
# has_and_belongs_to_many :topics, :property=>:has_topic, :inverse_of=>:is_topic_of
|
151
|
-
def has_and_belongs_to_many(
|
152
|
-
|
153
|
-
collection_accessor_methods(reflection, HasAndBelongsToManyAssociation)
|
154
|
-
#configure_after_destroy_method_for_has_and_belongs_to_many(reflection)
|
155
|
-
add_association_callbacks(reflection.name, options)
|
172
|
+
def has_and_belongs_to_many(name, options = {})
|
173
|
+
Builder::HasAndBelongsToMany.build(self, name, options)
|
156
174
|
end
|
157
|
-
|
158
|
-
|
159
|
-
private
|
160
|
-
|
161
|
-
def create_has_many_reflection(association_id, options)
|
162
|
-
create_reflection(:has_many, association_id, options, self)
|
163
|
-
#collection_accessor_methods(reflection, HasManyAssociation)
|
164
|
-
end
|
165
|
-
|
166
|
-
def create_belongs_to_reflection(association_id, options)
|
167
|
-
create_reflection(:belongs_to, association_id, options, self)
|
168
|
-
end
|
169
|
-
|
170
|
-
def create_has_and_belongs_to_many_reflection(association_id, options)
|
171
|
-
create_reflection(:has_and_belongs_to_many, association_id, options, self)
|
172
|
-
end
|
173
|
-
|
174
|
-
def add_association_callbacks(association_name, options)
|
175
|
-
callbacks = %w(before_add after_add before_remove after_remove)
|
176
|
-
callbacks.each do |callback_name|
|
177
|
-
full_callback_name = "#{callback_name}_for_#{association_name}"
|
178
|
-
defined_callbacks = options[callback_name.to_sym]
|
179
|
-
class_attribute full_callback_name.to_sym
|
180
|
-
if options.has_key?(callback_name.to_sym)
|
181
|
-
self.send((full_callback_name +'=').to_sym, [defined_callbacks].flatten)
|
182
|
-
else
|
183
|
-
self.send((full_callback_name +'=').to_sym, [])
|
184
|
-
end
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
def association_accessor_methods(reflection, association_proxy_class)
|
189
|
-
redefine_method(reflection.name) do |*params|
|
190
|
-
force_reload = params.first unless params.empty?
|
191
|
-
association = association_instance_get(reflection.name)
|
192
|
-
|
193
|
-
if association.nil? || force_reload
|
194
|
-
association = association_proxy_class.new(self, reflection)
|
195
|
-
retval = force_reload ? reflection.klass.uncached { association.reload } : association.reload
|
196
|
-
if retval.nil? and association_proxy_class == BelongsToAssociation
|
197
|
-
association_instance_set(reflection.name, nil)
|
198
|
-
return nil
|
199
|
-
end
|
200
|
-
association_instance_set(reflection.name, association)
|
201
|
-
end
|
202
|
-
|
203
|
-
association.target.nil? ? nil : association
|
204
|
-
end
|
205
|
-
|
206
|
-
redefine_method("loaded_#{reflection.name}?") do
|
207
|
-
association = association_instance_get(reflection.name)
|
208
|
-
association && association.loaded?
|
209
|
-
end
|
210
|
-
|
211
|
-
redefine_method("#{reflection.name}=") do |new_value|
|
212
|
-
association = association_instance_get(reflection.name)
|
213
|
-
|
214
|
-
if association.nil? || association.target != new_value
|
215
|
-
association = association_proxy_class.new(self, reflection)
|
216
|
-
end
|
217
|
-
|
218
|
-
association.replace(new_value)
|
219
|
-
association_instance_set(reflection.name, new_value.nil? ? nil : association)
|
220
|
-
end
|
221
|
-
|
222
|
-
redefine_method("set_#{reflection.name}_target") do |target|
|
223
|
-
return if target.nil? and association_proxy_class == BelongsToAssociation
|
224
|
-
association = association_proxy_class.new(self, reflection)
|
225
|
-
association.target = target
|
226
|
-
association_instance_set(reflection.name, association)
|
227
|
-
end
|
228
|
-
|
229
|
-
redefine_method("#{reflection.name}_id=") do |new_value|
|
230
|
-
options = reflection.klass == ActiveFedora::Base ? {cast: true} : {}
|
231
|
-
obj = new_value.blank? ? nil : reflection.klass.find(new_value, options)
|
232
|
-
send("#{reflection.name}=", obj)
|
233
|
-
end
|
234
|
-
redefine_method("#{reflection.name}_id") do
|
235
|
-
obj = send("#{reflection.name}")
|
236
|
-
obj.pid if obj
|
237
|
-
end
|
238
|
-
end
|
239
|
-
|
240
|
-
|
241
|
-
def collection_reader_method(reflection, association_proxy_class)
|
242
|
-
redefine_method(reflection.name) do |*params|
|
243
|
-
|
244
|
-
if (params.first.is_a?(Hash) && params.first[:response_format] == :solr)
|
245
|
-
load_from_solr = true
|
246
|
-
force_reload = false
|
247
|
-
else
|
248
|
-
force_reload = params.first unless params.empty?
|
249
|
-
end
|
250
|
-
association = association_instance_get(reflection.name)
|
251
|
-
unless association
|
252
|
-
association = association_proxy_class.new(self, reflection)
|
253
|
-
association_instance_set(reflection.name, association)
|
254
|
-
end
|
255
|
-
|
256
|
-
association.reload if force_reload
|
257
|
-
return association.load_from_solr if load_from_solr
|
258
|
-
|
259
|
-
association
|
260
|
-
end
|
261
|
-
|
262
|
-
redefine_method("#{reflection.name.to_s.singularize}_ids") do
|
263
|
-
send(reflection.name).map { |r| r.pid }
|
264
|
-
end
|
265
|
-
|
266
|
-
end
|
267
|
-
|
268
|
-
|
269
|
-
def collection_accessor_methods(reflection, association_proxy_class, writer = true)
|
270
|
-
collection_reader_method(reflection, association_proxy_class)
|
271
|
-
|
272
|
-
if writer
|
273
|
-
redefine_method("#{reflection.name}=") do |new_value|
|
274
|
-
# Loads proxy class instance (defined in collection_reader_method) if not already loaded
|
275
|
-
association = send(reflection.name)
|
276
|
-
association.replace(new_value)
|
277
|
-
association
|
278
|
-
end
|
279
|
-
|
280
|
-
redefine_method("#{reflection.name.to_s.singularize}_ids=") do |new_value|
|
281
|
-
ids = (new_value || []).reject { |nid| nid.blank? }
|
282
|
-
#TODO, like this when find() can return multiple records
|
283
|
-
#send("#{reflection.name}=", reflection.klass.find(ids))
|
284
|
-
opts = reflection.klass == ActiveFedora::Base ? {cast: true} : nil
|
285
|
-
send("#{reflection.name}=", ids.collect { |id| reflection.klass.find(id, opts)})
|
286
|
-
end
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
def association_constructor_method(constructor, reflection, association_proxy_class)
|
291
|
-
redefine_method("#{constructor}_#{reflection.name}") do |*params|
|
292
|
-
attributees = params.first unless params.empty?
|
293
|
-
replace_existing = params[1].nil? ? true : params[1]
|
294
|
-
association = association_instance_get(reflection.name)
|
295
|
-
|
296
|
-
unless association
|
297
|
-
association = association_proxy_class.new(self, reflection)
|
298
|
-
association_instance_set(reflection.name, association)
|
299
|
-
end
|
300
|
-
|
301
|
-
# if association_proxy_class == HasOneAssociation
|
302
|
-
# association.send(constructor, attributees, replace_existing)
|
303
|
-
# else
|
304
|
-
association.send(constructor, attributees)
|
305
|
-
#end
|
306
|
-
end
|
307
|
-
end
|
308
175
|
end
|
309
176
|
end
|
310
177
|
end
|