active-fedora 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +26 -0
- data/README.rdoc +2 -2
- data/lib/active_fedora.rb +14 -1
- data/lib/active_fedora/base.rb +58 -11
- data/lib/active_fedora/metadata_datastream.rb +4 -0
- data/lib/active_fedora/solr_service.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
1.0.5 2009-07-17
|
2
|
+
|
3
|
+
Minor update.
|
4
|
+
|
5
|
+
* Bug #387: Base.deserialize should mark all datastreams as not new
|
6
|
+
* ToDo #389: Base.update_attributes and Base.update_indexed_attributes should accept :datastream limiter
|
7
|
+
* Feature #388: Base.update_attributes and Base.update_indexed_attributes should support deleting fields
|
8
|
+
|
9
|
+
1.0.4 2009-07-10
|
10
|
+
|
11
|
+
!! Not Backwards Compatible with Fedora < 3.2.* !!
|
12
|
+
|
13
|
+
* 1 major enhancement:
|
14
|
+
* ruby-fedora is now compatible with Fedora 3.2.1
|
15
|
+
|
16
|
+
Changelog:
|
17
|
+
* ToDo #272: Datastream.new should accept a :prefix option for auto-incrementing DSIDs
|
18
|
+
* ToDo #275: Update RubyFedora to work with Fedora 3.2 REST API
|
19
|
+
* ToDo #308: ActiveFedora::FedoraObject.datatsreams should load label as well as pid and dsId
|
20
|
+
* ToDo #318: Intelligent FileDatastream and FileAsset Management
|
21
|
+
* Bug #312: Base.delete should delete the solr record as well as the Fedora Object
|
22
|
+
* Feature #46: Improve OSX Fedora/Solr Disk Image
|
23
|
+
* Feature #284: solr document id should by a config option instead of hard coded as "id"
|
24
|
+
* Feature #307: ActiveFedora::Base should provide a label setter.
|
25
|
+
* Feature #314: Relationship finder should provide a "response_format" option, default to format of "objects"
|
26
|
+
* Feature #327: Option to turn off solr updates (assume that something else will update Solr for you)
|
data/README.rdoc
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
* Further documentation is available at <http://projects.mediashelf.us/show/active-fedora>
|
5
5
|
* Community Discussions & Mailing List are located at <http://groups.google.com/group/active-fedora>
|
6
6
|
|
7
|
-
=
|
7
|
+
= active-fedora gem
|
8
8
|
|
9
9
|
* FIX (url)
|
10
10
|
|
@@ -26,7 +26,7 @@ FIX (describe your package)
|
|
26
26
|
|
27
27
|
== INSTALL:
|
28
28
|
|
29
|
-
|
29
|
+
sudo gem install active-fedora
|
30
30
|
|
31
31
|
== LICENSE:
|
32
32
|
|
data/lib/active_fedora.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
gem 'ruby-fedora'
|
3
3
|
gem 'solr-ruby'
|
4
4
|
module ActiveFedora #:nodoc:
|
5
|
-
VERSION='1.0.
|
5
|
+
VERSION='1.0.5'
|
6
6
|
end
|
7
7
|
|
8
8
|
SOLR_DOCUMENT_ID = "id" unless defined?(SOLR_DOCUMENT_ID)
|
@@ -22,3 +22,16 @@ require 'active_fedora/rels_ext_datastream.rb'
|
|
22
22
|
require 'active_fedora/semantic_node.rb'
|
23
23
|
require 'active_fedora/solr_service.rb'
|
24
24
|
|
25
|
+
|
26
|
+
if ![].respond_to?(:count)
|
27
|
+
class Array
|
28
|
+
puts "active_fedora is Adding count method to Array"
|
29
|
+
def count(&action)
|
30
|
+
count = 0
|
31
|
+
self.each { |v| count = count + 1}
|
32
|
+
# self.each { |v| count = count + 1 if action.call(v) }
|
33
|
+
return count
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/lib/active_fedora/base.rb
CHANGED
@@ -40,7 +40,12 @@ module ActiveFedora
|
|
40
40
|
def new_object?
|
41
41
|
@new_object
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
|
+
def new_object=(bool)
|
45
|
+
@new_object = bool
|
46
|
+
inner_object.new_object = bool
|
47
|
+
end
|
48
|
+
|
44
49
|
# Constructor. If +attrs+ does not comtain +:pid+, we assume we're making a new one,
|
45
50
|
# and call off to the Fedora Rest API for the next available Fedora pid, and mark as new object.
|
46
51
|
#
|
@@ -51,7 +56,7 @@ module ActiveFedora
|
|
51
56
|
attrs = attrs.merge!({:pid=>Fedora::Repository.instance.nextid})
|
52
57
|
@new_object=true
|
53
58
|
else
|
54
|
-
@new_object=false
|
59
|
+
@new_object=false
|
55
60
|
end
|
56
61
|
@inner_object = Fedora::FedoraObject.new(attrs)
|
57
62
|
@datastreams = {}
|
@@ -186,7 +191,7 @@ module ActiveFedora
|
|
186
191
|
# Example: if there are already datastreams with IDs DS1 and DS2, this method will return DS3. If you specify FOO as the prefix, it will return FOO1.
|
187
192
|
def generate_dsid(prefix="DS")
|
188
193
|
keys = datastreams.keys
|
189
|
-
next_index = keys.select {|v| v =~ /(#{prefix}\d*$)/}.
|
194
|
+
next_index = keys.select {|v| v =~ /(#{prefix}\d*$)/}.length + 1
|
190
195
|
new_dsid = prefix.to_s + next_index.to_s
|
191
196
|
# while keys.include?(new_dsid)
|
192
197
|
# next_index += 1
|
@@ -289,6 +294,10 @@ module ActiveFedora
|
|
289
294
|
def owner_id
|
290
295
|
@inner_object.owner_id
|
291
296
|
end
|
297
|
+
|
298
|
+
def owner_id=(owner_id)
|
299
|
+
@inner_object.owner_id=(owner_id)
|
300
|
+
end
|
292
301
|
|
293
302
|
#return the create_date of the inner object (unless it's a new object)
|
294
303
|
def create_date
|
@@ -317,8 +326,10 @@ module ActiveFedora
|
|
317
326
|
|
318
327
|
def self.deserialize(doc) #:nodoc:
|
319
328
|
pid = doc.elements['/foxml:digitalObject'].attributes['PID']
|
329
|
+
|
320
330
|
proto = self.new(:pid=>pid)
|
321
331
|
proto.datastreams.each do |name,ds|
|
332
|
+
ds.new_object = false
|
322
333
|
doc.elements.each("//foxml:datastream[@ID='#{name}']") do |el|
|
323
334
|
proto.datastreams[name]=ds.class.from_xml(ds, el)
|
324
335
|
end
|
@@ -369,12 +380,33 @@ module ActiveFedora
|
|
369
380
|
|
370
381
|
# An ActiveRecord-ism to udpate metadata values.
|
371
382
|
#
|
372
|
-
#
|
373
|
-
#
|
374
|
-
#
|
375
|
-
|
383
|
+
# Example Usage:
|
384
|
+
#
|
385
|
+
# m.update_attributes(:fubar=>'baz')
|
386
|
+
#
|
387
|
+
# This will attempt to set the values for any fields named fubar in any of
|
388
|
+
# the object's datastreams. This means DS1.fubar_values and DS2.fubar_values
|
389
|
+
# are _both_ overwritten.
|
390
|
+
#
|
391
|
+
# If you want to specify which datastream(s) to update,
|
392
|
+
# use the :datastreams argument like so:
|
393
|
+
# m.update_attributes({:fubar=>'baz'}, :datastreams=>"my_ds")
|
394
|
+
# or
|
395
|
+
# m.update_attributes({:fubar=>'baz'}, :datastreams=>["my_ds", "my_other_ds"])
|
396
|
+
def update_attributes(params={}, opts={})
|
376
397
|
params.each do |k,v|
|
377
|
-
|
398
|
+
if v == :delete || v == "" || v == nil
|
399
|
+
v = []
|
400
|
+
end
|
401
|
+
if opts[:datastreams]
|
402
|
+
ds_array = []
|
403
|
+
opts[:datastreams].each do |dsname|
|
404
|
+
ds_array << datastreams[dsname]
|
405
|
+
end
|
406
|
+
else
|
407
|
+
ds_array = datastreams.values
|
408
|
+
end
|
409
|
+
ds_array.each do |d|
|
378
410
|
if d.fields[k.to_sym]
|
379
411
|
d.send("#{k}_values=", v)
|
380
412
|
end
|
@@ -391,11 +423,25 @@ module ActiveFedora
|
|
391
423
|
# An index of -1 will insert a new value. any existing value at the relevant index
|
392
424
|
# will be overwritten.
|
393
425
|
#
|
394
|
-
# As in update_attributes, this overwrites _all_ available fields.
|
426
|
+
# As in update_attributes, this overwrites _all_ available fields by default.
|
395
427
|
#
|
396
|
-
|
428
|
+
# If you want to specify which datastream(s) to update,
|
429
|
+
# use the :datastreams argument like so:
|
430
|
+
# m.update_attributes({"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}, :datastreams=>"my_ds")
|
431
|
+
# or
|
432
|
+
# m.update_attributes({"fubar"=>{"-1"=>"mork", "0"=>"york", "1"=>"mangle"}}, :datastreams=>["my_ds", "my_other_ds"])
|
433
|
+
#
|
434
|
+
def update_indexed_attributes(params={}, opts={})
|
435
|
+
if opts[:datastreams]
|
436
|
+
ds_array = []
|
437
|
+
opts[:datastreams].each do |dsname|
|
438
|
+
ds_array << datastreams[dsname]
|
439
|
+
end
|
440
|
+
else
|
441
|
+
ds_array = datastreams.values
|
442
|
+
end
|
397
443
|
params.each do |key,value|
|
398
|
-
|
444
|
+
ds_array.each do |dstream|
|
399
445
|
if dstream.fields[key.to_sym]
|
400
446
|
aname="#{key}_values"
|
401
447
|
curval = dstream.send("#{aname}")
|
@@ -409,6 +455,7 @@ module ActiveFedora
|
|
409
455
|
end
|
410
456
|
end
|
411
457
|
cpv.each { |y,z| curval<<z}#just append everything left
|
458
|
+
curval.delete_if {|x| x == :delete || x == "" || x == nil}
|
412
459
|
dstream.send("#{aname}=", curval) #write it back to the ds
|
413
460
|
end
|
414
461
|
end
|
@@ -81,6 +81,10 @@ module ActiveFedora
|
|
81
81
|
#At some point, these modifiers will be ported up to work for any +ActiveFedora::MetadataDatastream+.
|
82
82
|
#
|
83
83
|
#There is quite a good example of this class in use in spec/examples/oral_history.rb
|
84
|
+
#
|
85
|
+
#!! Careful: If you declare two fields that correspond to the same xml node without any qualifiers to differentiate them,
|
86
|
+
#you will end up replicating the values in the underlying datastream, resulting in mysterious dubling, quadrupling, etc.
|
87
|
+
#whenever you edit the field's values.
|
84
88
|
def field(name, tupe, opts={})
|
85
89
|
@fields[name.to_s.to_sym]={:type=>tupe, :values=>[]}.merge(opts)
|
86
90
|
eval <<-EOS
|
@@ -35,7 +35,7 @@ module ActiveFedora
|
|
35
35
|
query = ""
|
36
36
|
pid_array.each_index do |i|
|
37
37
|
query << "#{SOLR_DOCUMENT_ID}:#{escape_uri_for_query(pid_array[i])}"
|
38
|
-
query << " OR " if i != pid_array.
|
38
|
+
query << " OR " if i != pid_array.length-1
|
39
39
|
end
|
40
40
|
query = "id:NEVER_USE_THIS_ID" if query.empty? || query == "id:"
|
41
41
|
return query
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MediaShelf Inc.
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-20 00:00:00 -03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.0.
|
23
|
+
version: 1.0.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: solr-ruby
|