active-fedora 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +30 -0
- data/.gitmodules +3 -0
- data/.rvmrc +33 -0
- data/CONSOLE_GETTING_STARTED.textile +337 -0
- data/Gemfile +6 -1
- data/Gemfile.lock +39 -23
- data/NOKOGIRI_DATASTREAMS.textile +107 -0
- data/README.textile +41 -17
- data/Rakefile +5 -30
- data/active-fedora.gemspec +34 -496
- data/lib/active_fedora.rb +6 -1
- data/lib/active_fedora/base.rb +7 -5
- data/lib/active_fedora/datastream.rb +9 -8
- data/lib/active_fedora/metadata_datastream.rb +10 -3
- data/lib/active_fedora/model.rb +8 -4
- data/lib/active_fedora/nokogiri_datastream.rb +30 -24
- data/lib/active_fedora/qualified_dublin_core_datastream.rb +3 -2
- data/lib/active_fedora/rels_ext_datastream.rb +14 -5
- data/lib/active_fedora/samples.rb +3 -0
- data/lib/active_fedora/samples/hydra-mods_article_datastream.rb +517 -0
- data/lib/active_fedora/samples/hydra-rights_metadata_datastream.rb +206 -0
- data/lib/active_fedora/samples/marpa-dc_datastream.rb +97 -0
- data/lib/active_fedora/samples/special_thing.rb +45 -0
- data/lib/active_fedora/semantic_node.rb +16 -13
- data/lib/active_fedora/version.rb +3 -0
- data/lib/fedora/base.rb +5 -5
- data/lib/fedora/datastream.rb +1 -1
- data/lib/fedora/fedora_object.rb +1 -1
- data/lib/fedora/repository.rb +4 -0
- data/lib/tasks/active_fedora.rake +126 -0
- data/lib/tasks/active_fedora_dev.rake +127 -0
- data/solr/conf/schema.xml +278 -0
- data/solr/conf/solrconfig.xml +840 -0
- data/spec/integration/full_featured_model_spec.rb +2 -2
- data/spec/integration/mods_article_integration_spec.rb +2 -2
- data/spec/integration/nokogiri_datastream_spec.rb +2 -2
- data/spec/rcov.opts +2 -0
- data/spec/samples/models/hydrangea_article.rb +12 -0
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/nokogiri_datastream_spec.rb +10 -7
- metadata +189 -886
- data/NG_XML_DATASTREAM.textile +0 -25
- data/USING_OM_DATASTREAMS.textile +0 -60
- data/VERSION +0 -1
- data/lib/hydra.rb +0 -2
- data/lib/hydra/sample_mods_datastream.rb +0 -63
- data/tasks/hoe.rake +0 -0
- data/tasks/rspec.rake +0 -29
data/.gitignore
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
##SVN
|
17
|
+
.svn
|
18
|
+
.svn/*
|
19
|
+
|
20
|
+
## PROJECT::GENERAL
|
21
|
+
coverage
|
22
|
+
rdoc
|
23
|
+
pkg
|
24
|
+
/.bundle
|
25
|
+
#/.rvmrc
|
26
|
+
.yardoc
|
27
|
+
doc
|
28
|
+
|
29
|
+
## PROJECT::SPECIFIC
|
30
|
+
hydra-jetty
|
data/.gitmodules
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
ruby_string="ree-1.8.7"
|
7
|
+
gemset_name="active_fedora"
|
8
|
+
|
9
|
+
# Install rubies when used instead of only displaying a warning and exiting
|
10
|
+
rvm_install_on_use_flag=1
|
11
|
+
|
12
|
+
# Specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
13
|
+
environment_id="${ruby_string}@${gemset_name}"
|
14
|
+
|
15
|
+
# First, attempt to load the desired environment directly from the environment
|
16
|
+
# file. This is very fast and efficient compared to running through the entire
|
17
|
+
# CLI and selector. If you want feedback on which environment was used then
|
18
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
19
|
+
#
|
20
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
21
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] ; then
|
22
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
23
|
+
else
|
24
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
25
|
+
rvm --create "$environment_id"
|
26
|
+
fi
|
27
|
+
|
28
|
+
# Ensure that Bundler is installed, install it if it is not.
|
29
|
+
if ! (command -v bundle > /dev/null) ; then
|
30
|
+
printf "The rubygem 'bundler' is not installed, installing it now.\n"
|
31
|
+
gem install bundler
|
32
|
+
fi
|
33
|
+
|
@@ -0,0 +1,337 @@
|
|
1
|
+
h2. Dependencies
|
2
|
+
|
3
|
+
You will need Ruby 1.8.7+ to go through this tutorial. If you don't have Ruby 1.8.7 installed, "RVM":https://rvm.beginrescueend.com/ is the best way to install it.
|
4
|
+
|
5
|
+
h2. Get a Copy of the Code
|
6
|
+
|
7
|
+
All of the stuff you're learning here can be done in any application where you have the active-fedora gem installed and where you have called "require 'active-fedora'". For this tutorial, you're cloning a full copy of the active-fedora code so you have access to the sample files that are stored there.
|
8
|
+
|
9
|
+
First, clone the git repository and cd into the root
|
10
|
+
|
11
|
+
<pre>
|
12
|
+
git clone git@github.com:mediashelf/active_fedora.git
|
13
|
+
cd active_fedora
|
14
|
+
</pre>
|
15
|
+
|
16
|
+
If you don't have bundler installed yet, install it
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
gem install bundler
|
20
|
+
</pre>
|
21
|
+
|
22
|
+
Now let bundler handle installing active-fedora's dependencies
|
23
|
+
|
24
|
+
<pre>
|
25
|
+
bundle install
|
26
|
+
</pre>
|
27
|
+
|
28
|
+
h2. Run Solr & Fedora
|
29
|
+
|
30
|
+
h3. Get a copy of hydra-jetty and start it (easiest)
|
31
|
+
|
32
|
+
"hydra-jetty":http://github.com/projecthydra/hydra-jetty is a copy of a Jetty server with Fedora and Solr installed and ready to use with ActiveFedora. Grab a copy and start it up.
|
33
|
+
|
34
|
+
<pre>
|
35
|
+
git clone git://github.com/projecthydra/hydra-jetty.git
|
36
|
+
cd hydra-jetty
|
37
|
+
java -jar start.jar
|
38
|
+
</pre>
|
39
|
+
|
40
|
+
This will start Jetty and spit a bunch of info out onto the console. Leave that terminal window open and open a new one to play around with ActiveFedora.
|
41
|
+
|
42
|
+
You can also set up your own copies of Fedora and Solr to run against. For info on that, see "Setting up Fedora and Solr for use with ActiveFedora":http://projects.mediashelf.us/projects/active-fedora/wiki/Setting_up_Fedora_and_Solr_for_use_with_ActiveFedora
|
43
|
+
|
44
|
+
h2. Open up the Console
|
45
|
+
|
46
|
+
<pre>
|
47
|
+
script/console
|
48
|
+
</pre>
|
49
|
+
|
50
|
+
<pre>
|
51
|
+
require "rubygems"
|
52
|
+
require "active-fedora"
|
53
|
+
require "active_fedora/samples" # these are the sample models and datastreams that come with ActiveFedora
|
54
|
+
</pre>
|
55
|
+
|
56
|
+
h2. Initialize ActiveFedora
|
57
|
+
|
58
|
+
In order to function, ActiveFedora needs to know where Fedora and Solr are running. It gets this information from a YAML file.
|
59
|
+
|
60
|
+
<pre>
|
61
|
+
ActiveFedora.init
|
62
|
+
I, [...] INFO -- : Using the default fedora.yml that comes with active-fedora.
|
63
|
+
If you want to override this, pass the path to fedora.yml as an argument to ActiveFedora.init or set RAILS_ROOT and put fedora.yml into #{RAILS_ROOT}/config.
|
64
|
+
I, [...] INFO -- : FEDORA: loading ActiveFedora config from /opt/local/lib/ruby/gems/1.8/gems/active-fedora-1.1.3/config/fedora.yml
|
65
|
+
I, [...] INFO -- : FEDORA: initializing ActiveFedora::SolrService with solr_config: {:url=>"http://127.0.0.1:8983/solr/development"}
|
66
|
+
I, [...8] INFO -- : FEDORA: initialized Solr with ActiveFedora.solr_config: #<ActiveFedora::SolrService:0x1021245f0 @conn=#<Solr::Connection:... >>>
|
67
|
+
I, [...] INFO -- : FEDORA: initializing Fedora with fedora_config: {:url=>"http://fedoraAdmin:fedoraAdmin@127.0.0.1:8983/fedora"}
|
68
|
+
I, [...] INFO -- : FEDORA: initialized Fedora as: #<Fedora::Repository:0x102123b78 ....>
|
69
|
+
=> true
|
70
|
+
</pre>
|
71
|
+
|
72
|
+
As you can see, ActiveFedora.init defaults to using the fedora.yml included in the gem, which points to a local instance of jetty running on port 8983 with fedora and solr installed.
|
73
|
+
|
74
|
+
If you want to use a different fedora.yml (pointing ActiveFedora to differed Fedora & Solr URLs), put your info into a new fedora.yml and pass that path to ActiveFedora.init
|
75
|
+
|
76
|
+
<pre>ActiveFedora.init("path/to/fedora.yml")</pre>
|
77
|
+
|
78
|
+
You can see a sample fedora.yml in the ActiveFedora code on GitHub: "http://github.com/mediashelf/active_fedora/blob/master/config/fedora.yml":http://github.com/mediashelf/active_fedora/blob/master/config/fedora.yml
|
79
|
+
|
80
|
+
If you are running a rails app, ActiveFedora.init will automatically look for configs in config/fedora.yml
|
81
|
+
|
82
|
+
Also, within a rails app, you should create a file in config/initializers (ie. fedora_config.rb) that calls ActiveFedora.init
|
83
|
+
|
84
|
+
h2. Load a fixture object to play with
|
85
|
+
|
86
|
+
The ActiveFedora code includes foxml files for Fedora objects that you can load into a Fedora repository and play around with. Here we will load the one called hydrangea_fixture_mods_article1.foxml.xml
|
87
|
+
|
88
|
+
<pre>
|
89
|
+
filename = File.join(File.dirname(__FILE__),"spec","fixtures", "hydrangea_fixture_mods_article1.foxml.xml")
|
90
|
+
file = File.new(filename, "r")
|
91
|
+
result = foxml = Fedora::Repository.instance.ingest(file.read)
|
92
|
+
</pre>
|
93
|
+
|
94
|
+
If you get an error that starts with the lines below, this means that you already have a copy of that object in fedora.
|
95
|
+
|
96
|
+
<pre>
|
97
|
+
Fedora::ServerError: Failed with 500 Error from Fedora: javax.ws.rs.WebApplicationException: org.fcrepo.server.errors.ObjectExistsException: The PID 'hydrangea:fixture_mods_article1' already exists in the registry; the object can't be re-created.
|
98
|
+
</pre>
|
99
|
+
|
100
|
+
The easiest way to delete an object from Fedora is to use the following line. Note that this will raise an error if the object didn't exist in the first place.
|
101
|
+
|
102
|
+
<pre>
|
103
|
+
ActiveFedora::Base.load_instance("hydrangea:fixture_mods_article1").delete
|
104
|
+
</pre>
|
105
|
+
|
106
|
+
|
107
|
+
To see a more complete implementation of importing and deleting Fedora objects, see the code in the fedora rake tasks "https://github.com/mediashelf/active_fedora/blob/master/lib/tasks/fedora.rake":https://github.com/mediashelf/active_fedora/blob/master/lib/tasks/fedora.rake
|
108
|
+
|
109
|
+
|
110
|
+
*When you're done playing around with importing and deleting, make sure that you leave a copy of hydrangea:fixture_mods_article1 in fedora so we can play with it.*
|
111
|
+
|
112
|
+
|
113
|
+
h4. Define a Model
|
114
|
+
|
115
|
+
Look at the SpecialThing model defined in lib/active_fedora/samples/special_thing.rb to see how you declare an ActiveFedora model
|
116
|
+
|
117
|
+
|
118
|
+
Create an instance of the SpecialThing class
|
119
|
+
|
120
|
+
<pre>
|
121
|
+
newthing = SpecialThing.new
|
122
|
+
</pre>
|
123
|
+
|
124
|
+
Get the pid of your new object
|
125
|
+
|
126
|
+
<pre>
|
127
|
+
newthing.pid
|
128
|
+
=> "changeme:30"
|
129
|
+
</pre>
|
130
|
+
|
131
|
+
This pid was retrieved from Fedora's getNextPid method. Your object will not show up in Fedora until you save it using newthing.save, but let's hold off on saving it for now.
|
132
|
+
|
133
|
+
h3. RELATIONSHIPS
|
134
|
+
|
135
|
+
ActiveFedora provides convenience methods for creating and editing RELS-EXT relationships. It also auto-generates methods for using Solr to search based on these relationships.
|
136
|
+
|
137
|
+
List the object's relationships.
|
138
|
+
|
139
|
+
<pre>
|
140
|
+
newthing.relationships
|
141
|
+
=> {:self=>{}}
|
142
|
+
</pre>
|
143
|
+
|
144
|
+
Call the "inspirations" method that was created by the has_relationship line in your class definition.
|
145
|
+
|
146
|
+
<pre>
|
147
|
+
newthing.inspirations
|
148
|
+
=> []
|
149
|
+
</pre>
|
150
|
+
|
151
|
+
Now create another Fedora object and make it assert that it's a part of the SpecialThing object, then save it to Fedora.
|
152
|
+
|
153
|
+
<pre>
|
154
|
+
inspirational = ActiveFedora::Base.new
|
155
|
+
inspirational.add_relationship(:has_derivation, newthing)
|
156
|
+
=> true
|
157
|
+
inspirational.relationships
|
158
|
+
=> {:self=>{:has_derivation=>["info:fedora/changeme:30"]}}
|
159
|
+
inspirational.save
|
160
|
+
=> ...
|
161
|
+
inspirational.pid
|
162
|
+
=> "changeme:164" # this is the pid you want to put in the following URLs as a replacement for {PID}
|
163
|
+
</pre>
|
164
|
+
|
165
|
+
You can now see that object in Fedora by going to http://localhost:8983/fedora/objects/{PID} and you can see the relationship asserted in http://localhost: 8983/fedora/objects/{PID}/datastreams/RELS-EXT/content
|
166
|
+
|
167
|
+
Now look and see that the object you created shows up associated with newthing
|
168
|
+
|
169
|
+
<pre>
|
170
|
+
newthing.inspirations
|
171
|
+
=> ...
|
172
|
+
newthing.inspirations.each {|pt| puts pt.pid }
|
173
|
+
=> ...
|
174
|
+
newthing.inspirations(:response_format=>:id_array)
|
175
|
+
=> ...
|
176
|
+
</pre>
|
177
|
+
|
178
|
+
Note that you didn't have to save newthing in order for this relationship to show up in solr because it is an inbound relationship. Only the object that makes the assertion needs to be saved in order for the search to work. In this case, the inspirational object asserts :has_derivation rather than the derivative asserting :is_derivation_of, so only the inspirational object had to be saved.
|
179
|
+
|
180
|
+
h3. DATASTREAMS & METADATA
|
181
|
+
|
182
|
+
h4. Blobs (a.k.a. File Datastreams, a.k.a Managed Content Datastreams)
|
183
|
+
|
184
|
+
<pre>
|
185
|
+
file = File.new('spec/fixtures/minivan.jpg')
|
186
|
+
=> #<File:spec/fixtures/minivan.jpg>
|
187
|
+
file_ds = ActiveFedora::Datastream.new(:dsID => "minivan", :dsLabel => 'hello', :controlGroup => 'M', :blob => file)
|
188
|
+
=> ...
|
189
|
+
newthing.add_datastream(file_ds)
|
190
|
+
=> "minivan"
|
191
|
+
newthing.save
|
192
|
+
=> true
|
193
|
+
</pre>
|
194
|
+
|
195
|
+
Now user your browser to find the file datastreams in Fedora ...
|
196
|
+
|
197
|
+
|
198
|
+
h4. On auto-generating datatsream ids
|
199
|
+
|
200
|
+
If you don't specify a dsid, ActiveFedora will generate one for you.
|
201
|
+
|
202
|
+
<pre>
|
203
|
+
file_ds2 = ActiveFedora::Datastream.new(:dsLabel => 'Minivan Plays', :altIDs => 'default', :controlGroup => 'M', :blob => file)
|
204
|
+
newthing.add_datastream(file_ds2)
|
205
|
+
=> "DS1"
|
206
|
+
newthing.datastreams.keys
|
207
|
+
=> ["DS1", "descMetadata", "minivan", "RELS-EXT", "rightsMetadata", "DC", "extraMetadataForFun"]
|
208
|
+
newthing.datastreams_in_memory["DS1"] == file_ds2
|
209
|
+
=> true
|
210
|
+
</pre>
|
211
|
+
|
212
|
+
You can choose a different prefix for the dsid by passing a :prefix value to add_datastream (be careful to ensure that the resulting dsid is a valid XMLString, or fedora will reject it!)
|
213
|
+
|
214
|
+
<pre>
|
215
|
+
file_ds3 = ActiveFedora::Datastream.new(:dsLabel => 'Minivan Plays', :altIDs => 'default', :controlGroup => 'M', :blob => file)
|
216
|
+
newthing.add_datastream(file_ds3, :prefix=>"Foo")
|
217
|
+
=> "Foo1"
|
218
|
+
newthing.datastreams.keys
|
219
|
+
newthing.save
|
220
|
+
</pre>
|
221
|
+
|
222
|
+
h2. Retrieving Existing Objects
|
223
|
+
|
224
|
+
You can use the load_instance class method on any kind of ActiveFedora::Base class to load objects from Fedora.
|
225
|
+
|
226
|
+
<pre>
|
227
|
+
newthing.pid
|
228
|
+
=> "changeme:30"
|
229
|
+
copy_as_base = ActiveFedora::Base.load_instance("changeme:30")
|
230
|
+
copy_as_base.pid
|
231
|
+
=> "changeme:30"
|
232
|
+
copy_as_base.relationships
|
233
|
+
=> {:self=>{:has_model=>["info:fedora/afmodel:SpecialThing"]}}
|
234
|
+
copy_as_base.datastreams.keys
|
235
|
+
=> ["DS1", "descMetadata", "Foo1", "minivan", "RELS-EXT", "rightsMetadata", "DC", "extraMetadataForFun"]
|
236
|
+
</pre>
|
237
|
+
|
238
|
+
As you can see, ActiveFedora::Base will load the object, its datastreams, its generic Fedora Object information, and even its RELS-EXT relationships. It will _not_, however, know how to deserialize any model-specific metadata datastreams. In other words, ActiveFedora::Base treats all datastreams as generic Fedora datastreams.
|
239
|
+
|
240
|
+
<pre>
|
241
|
+
copy_as_base.datastreams["extraMetadataForFun"].class
|
242
|
+
=> ActiveFedora::Datastream
|
243
|
+
</pre>
|
244
|
+
|
245
|
+
If you want the model-specific metadata to be deserialized, you must call load_instance on the appropriate model class. This will load all of the same info as ActiveFedora::Base, but it will also attempt to deserialize the xml from any metadata datastreams that were declared by the has_metadata method in the model.
|
246
|
+
|
247
|
+
<pre>
|
248
|
+
copy_as_specialthing = SpecialThing.load_instance(newthing.pid)
|
249
|
+
copy_as_specialthing.datastreams["descMetadata"].class
|
250
|
+
=> Hydra::ModsArticleDatastream
|
251
|
+
copy_as_specialthing.datastreams["extraMetadataForFun"].class
|
252
|
+
=> ActiveFedora::Marpa::DcDatastream
|
253
|
+
</pre>
|
254
|
+
|
255
|
+
h2. Finding Objects
|
256
|
+
|
257
|
+
All descendants of ActiveFedora::Base provide a find method that will search for objects of the given class. The method is somewhat incomplete at the moment, but is functional. We are actively working on making it better.
|
258
|
+
|
259
|
+
h3. Finding Instances of the Class
|
260
|
+
|
261
|
+
Imitating ActiveRecord, you can search for instances of the given class by calling find(:all) on that class. In current versions of the gem, this method searches solr using the active_fedora_model_field. In future versions it will not hit solr at all, instead relying on Fedora's Resource Index and searching for anything that asserts "conformsTo" or "hasModel" relationships pointing at the given model.
|
262
|
+
|
263
|
+
<pre>
|
264
|
+
ActiveFedora::Base.find(:all)
|
265
|
+
SpecialThing.find(:all)
|
266
|
+
</pre>
|
267
|
+
|
268
|
+
Note that the results from these two searches do not overlap. Base.find will only return objects that have been saved with active_fedora_model_field set to "info:fedora/afmodel:Base". If you open an object as an instance of a different model and save it as that model, it will overwrite the active_fedora_model_field. This is, of course, no good. That's why the method will be rewritten in "Version 1.1":/versions/show/7. In the meantime, you could search directly against Solr with queries like this:
|
269
|
+
|
270
|
+
<pre>
|
271
|
+
solr_result = ActiveFedora::SolrService.instance.conn.query('has_model_s:info\:fedora/afmodel\:SpecialThing')
|
272
|
+
</pre>
|
273
|
+
|
274
|
+
This query will return a Solr::Result containing all of the objects that have conformsTo relationships pointing at info:fedora/afmodel:SpecialThing in their RELS-EXT. This relationship gets added to the RELS-EXT whenever you save an object as a given ActiveFedora model and it does not get erased if you later save it as a different model.
|
275
|
+
|
276
|
+
h3. Finding (Loading) a specific Object
|
277
|
+
|
278
|
+
You can use this instead of .load_instance. In practice, we tend to use load_instance though -- it's more direct.
|
279
|
+
|
280
|
+
<pre>
|
281
|
+
Base.find("changeme:30")
|
282
|
+
SpecialThing.find("changeme:30")
|
283
|
+
</pre>
|
284
|
+
|
285
|
+
|
286
|
+
h3. Looking a bit deeper at what Models do
|
287
|
+
|
288
|
+
ActiveFedora Models don't actually do much. They mainly keep a list of datastream ids and associate them with classes that help you use the content from those datastreams.
|
289
|
+
|
290
|
+
When you're ready to learn more about how to define ActiveFedora models and OM-based datastreams, open up the files in lib/active_fedora/samples. Those will give you more background. Here, we're seeing what happens when you use those Models and datastreams.
|
291
|
+
|
292
|
+
For now, load an instance of the SpecialThing model and take a look at its datastreams.
|
293
|
+
|
294
|
+
<pre>
|
295
|
+
st = SpecialThing.load_instance("hydrangea:fixture_mods_article1")
|
296
|
+
st.datastreams
|
297
|
+
... woah. that's a lot of stuff. how about just the datastream ids
|
298
|
+
st.datastreams.keys
|
299
|
+
=> ["descMetadata", "RELS-EXT", "rightsMetadata", "DC", "extraMetadataForFun", "properties"]
|
300
|
+
</pre>
|
301
|
+
|
302
|
+
We see the three datastreams that are declared by the SpecialThing Model, but where did the other datastreams come from?
|
303
|
+
|
304
|
+
The RELS-EXT is where Fedora objects store their relationships, so SpecialThing uses that datastream when it uses the methods created by has_relationship.
|
305
|
+
|
306
|
+
The other two datastreams, DC and properties, were already there in the object we imported. Our model doesn't define anything about those datastreams, so they are loaded as mere ActiveFedora::Datastreams. When a datastream is loaded in this way, you can still see it and access/update its content as a blob, but your model doesn't know anything special about its contents. This behavior is what allows us to have multiple interfaces for the same content. One model might care only about the descMetadata and the properties while another model only cares about the descMetadata and rightsMetadata. The two models only need to be consistent with each other when they are both operating on the same datastream.
|
307
|
+
|
308
|
+
Let's see what classes the datastreams have been bound to
|
309
|
+
|
310
|
+
<pre>
|
311
|
+
st.datastreams.keys.each do |dsid|
|
312
|
+
puts "#{dsid}:"
|
313
|
+
puts " #{st.datastreams[dsid].class}"
|
314
|
+
end
|
315
|
+
</pre>
|
316
|
+
|
317
|
+
This will output
|
318
|
+
|
319
|
+
<pre>
|
320
|
+
descMetadata:
|
321
|
+
Hydra::ModsArticleDatastream
|
322
|
+
RELS-EXT:
|
323
|
+
ActiveFedora::RelsExtDatastream
|
324
|
+
rightsMetadata:
|
325
|
+
Hydra::RightsMetadataDatastream
|
326
|
+
DC:
|
327
|
+
ActiveFedora::Datastream
|
328
|
+
extraMetadataForFun:
|
329
|
+
Marpa::DcDatastream
|
330
|
+
properties:
|
331
|
+
ActiveFedora::Datastream
|
332
|
+
</pre>
|
333
|
+
|
334
|
+
Notice that properties and DC have been loaded as ActiveFedora::Datastream, RELS-EXT has been loaded as ActiveFedora::RelsExtDatastream, and the other three have been loaded as the classes specified in the Model.
|
335
|
+
|
336
|
+
Now read about "OM-based NokogiriDatastreams":https://github.com/mediashelf/active_fedora/blob/master/NOKOGIRI_DATASTREAMS.textile to see what the datastream definitions have done for you.
|
337
|
+
|
data/Gemfile
CHANGED
@@ -5,8 +5,13 @@ group :development, :test do
|
|
5
5
|
gem "rspec", "<2.0.0"
|
6
6
|
gem "mocha", ">= 0.9.8"
|
7
7
|
gem "ruby-debug"
|
8
|
+
gem "jettywrapper"
|
9
|
+
gem "rcov"
|
10
|
+
gem "yard"
|
11
|
+
gem "RedCloth"
|
12
|
+
gem "solrizer-fedora"
|
8
13
|
end
|
9
14
|
|
10
15
|
# Bundler will rely on active-fedora.gemspec (which is generated by Jeweler section of Rakefile) for runtime dependency information.
|
11
16
|
|
12
|
-
gemspec
|
17
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,76 +1,92 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active-fedora (2.0
|
4
|
+
active-fedora (2.2.0)
|
5
|
+
RedCloth
|
6
|
+
active-fedora
|
5
7
|
activeresource
|
6
8
|
equivalent-xml
|
9
|
+
facets
|
7
10
|
mediashelf-loggable
|
8
11
|
mime-types (>= 1.16)
|
9
12
|
multipart-post
|
10
13
|
nokogiri
|
11
14
|
om (>= 1.0)
|
15
|
+
rcov
|
12
16
|
solr-ruby (>= 0.0.6)
|
13
17
|
solrizer (> 1.0.0)
|
14
18
|
xml-simple (>= 1.0.12)
|
19
|
+
yard
|
15
20
|
|
16
21
|
GEM
|
17
22
|
remote: http://rubygems.org/
|
18
23
|
specs:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
activemodel (= 3.0.5)
|
25
|
-
activesupport (= 3.0.5)
|
26
|
-
activesupport (3.0.5)
|
27
|
-
builder (2.1.2)
|
24
|
+
RedCloth (4.2.7)
|
25
|
+
activeresource (2.3.11)
|
26
|
+
activesupport (= 2.3.11)
|
27
|
+
activesupport (2.3.11)
|
28
|
+
builder (3.0.0)
|
28
29
|
columnize (0.3.2)
|
29
|
-
|
30
|
-
|
30
|
+
daemons (1.1.3)
|
31
|
+
equivalent-xml (0.2.6)
|
32
|
+
nokogiri (>= 1.4.3)
|
31
33
|
facets (2.9.1)
|
32
34
|
git (1.2.5)
|
33
|
-
|
34
|
-
jeweler (1.
|
35
|
+
jettywrapper (0.0.3)
|
36
|
+
jeweler (1.6.0)
|
35
37
|
bundler (~> 1.0.0)
|
36
38
|
git (>= 1.2.5)
|
37
39
|
rake
|
38
40
|
linecache (0.43)
|
39
|
-
mediashelf-loggable (0.4.
|
41
|
+
mediashelf-loggable (0.4.2)
|
40
42
|
mime-types (1.16)
|
41
43
|
mocha (0.9.12)
|
42
44
|
multipart-post (1.1.0)
|
43
45
|
nokogiri (1.4.4)
|
44
|
-
om (1.
|
45
|
-
facets
|
46
|
-
facets
|
47
|
-
nokogiri
|
46
|
+
om (1.2.4)
|
48
47
|
nokogiri (>= 1.4.2)
|
48
|
+
om
|
49
49
|
rake (0.8.7)
|
50
|
-
|
50
|
+
rcov (0.9.9)
|
51
|
+
rsolr (1.0.0)
|
52
|
+
builder (>= 2.1.2)
|
53
|
+
rspec (1.3.2)
|
51
54
|
ruby-debug (0.10.4)
|
52
55
|
columnize (>= 0.1)
|
53
56
|
ruby-debug-base (~> 0.10.4.0)
|
54
57
|
ruby-debug-base (0.10.4)
|
55
58
|
linecache (>= 0.3)
|
56
59
|
solr-ruby (0.0.8)
|
57
|
-
solrizer (1.0.
|
60
|
+
solrizer (1.0.4)
|
61
|
+
daemons
|
58
62
|
mediashelf-loggable
|
59
63
|
mediashelf-loggable
|
60
64
|
nokogiri
|
61
65
|
nokogiri
|
62
66
|
nokogiri
|
63
|
-
om
|
64
67
|
om (>= 1.0.0)
|
68
|
+
om
|
69
|
+
stomp
|
65
70
|
xml-simple
|
66
|
-
|
71
|
+
solrizer-fedora (1.0.2)
|
72
|
+
active-fedora (>= 2.0.0)
|
73
|
+
rsolr
|
74
|
+
solrizer (>= 1.0.0)
|
75
|
+
stomp (1.1.8)
|
76
|
+
xml-simple (1.0.15)
|
77
|
+
yard (0.6.8)
|
67
78
|
|
68
79
|
PLATFORMS
|
69
80
|
ruby
|
70
81
|
|
71
82
|
DEPENDENCIES
|
83
|
+
RedCloth
|
72
84
|
active-fedora!
|
85
|
+
jettywrapper
|
73
86
|
jeweler
|
74
87
|
mocha (>= 0.9.8)
|
88
|
+
rcov
|
75
89
|
rspec (< 2.0.0)
|
76
90
|
ruby-debug
|
91
|
+
solrizer-fedora
|
92
|
+
yard
|