active-fedora 3.2.0 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/History.txt +10 -0
- data/Rakefile +3 -2
- data/active-fedora.gemspec +1 -1
- data/lib/active_fedora.rb +4 -1
- data/lib/active_fedora/base.rb +1 -3
- data/lib/active_fedora/datastream.rb +0 -28
- data/lib/active_fedora/datastreams.rb +1 -25
- data/lib/active_fedora/delegating.rb +6 -6
- data/lib/active_fedora/fixture_exporter.rb +33 -0
- data/lib/active_fedora/metadata_datastream.rb +46 -1
- data/lib/active_fedora/metadata_datastream_helper.rb +1 -40
- data/lib/active_fedora/model.rb +1 -1
- data/lib/active_fedora/rubydora_connection.rb +1 -0
- data/lib/active_fedora/version.rb +1 -1
- data/lib/tasks/active_fedora.rake +36 -61
- data/lib/tasks/active_fedora_dev.rake +17 -14
- data/script/console +1 -1
- data/spec/integration/base_find_by_fields_spec.rb +74 -64
- data/spec/integration/datastream_collections_spec.rb +0 -1
- data/spec/integration/metadata_datastream_spec.rb +66 -0
- data/spec/unit/base_spec.rb +5 -0
- data/spec/unit/datastream_spec.rb +1 -1
- data/spec/unit/metadata_datastream_spec.rb +7 -3
- data/spec/unit/qualified_dublin_core_datastream_spec.rb +1 -5
- metadata +11 -10
- data/lib/active_fedora/fedora_object.rb +0 -78
- data/lib/active_fedora/railtie.rb +0 -10
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
active-fedora (3.2.
|
4
|
+
active-fedora (3.2.2)
|
5
5
|
activeresource (>= 3.0.0)
|
6
6
|
activesupport (>= 3.0.0)
|
7
7
|
equivalent-xml
|
@@ -13,7 +13,7 @@ PATH
|
|
13
13
|
om (>= 1.4.4)
|
14
14
|
rdf
|
15
15
|
rdf-rdfxml
|
16
|
-
rubydora (~> 0.
|
16
|
+
rubydora (~> 0.4.1)
|
17
17
|
solr-ruby (>= 0.0.6)
|
18
18
|
solrizer (> 1.0.0)
|
19
19
|
xml-simple (>= 1.0.12)
|
@@ -43,7 +43,7 @@ GEM
|
|
43
43
|
diff-lcs (1.1.3)
|
44
44
|
equivalent-xml (0.2.8)
|
45
45
|
nokogiri (>= 1.4.3)
|
46
|
-
facets (2.9.
|
46
|
+
facets (2.9.3)
|
47
47
|
fastercsv (1.5.4)
|
48
48
|
ffi (1.0.11)
|
49
49
|
gyoku (0.4.4)
|
@@ -74,7 +74,7 @@ GEM
|
|
74
74
|
om (1.4.4)
|
75
75
|
mediashelf-loggable
|
76
76
|
nokogiri (>= 1.4.2)
|
77
|
-
rack (1.
|
77
|
+
rack (1.4.0)
|
78
78
|
rake (0.9.2.2)
|
79
79
|
rbx-require-relative (0.0.5)
|
80
80
|
rcov (0.9.11)
|
@@ -110,7 +110,7 @@ GEM
|
|
110
110
|
ruby-debug-base19 (>= 0.11.19)
|
111
111
|
ruby_core_source (0.1.5)
|
112
112
|
archive-tar-minitar (>= 0.5.2)
|
113
|
-
rubydora (0.
|
113
|
+
rubydora (0.4.1)
|
114
114
|
activemodel
|
115
115
|
activesupport
|
116
116
|
fastercsv
|
data/History.txt
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
3.2.2
|
2
|
+
Rubydora 0.4.1
|
3
|
+
Fixed bugs where updating datastream properties would overwrite content.
|
4
|
+
HYDRA-661: Changed namespaces and names or rake tasks according to HYDRA-661 with the exception that harvest was renamed export
|
5
|
+
|
6
|
+
3.2.1
|
7
|
+
Load rake tasks.
|
8
|
+
Rubydora 0.4.0
|
9
|
+
Added fixture exporter
|
10
|
+
|
1
11
|
3.2.0
|
2
12
|
|
3
13
|
Deprecate ContentModel.pid_from_ruby_class, use Model.to_class_uri instead
|
data/Rakefile
CHANGED
@@ -2,11 +2,12 @@ require 'rake/clean'
|
|
2
2
|
require 'rubygems'
|
3
3
|
require 'bundler'
|
4
4
|
require "bundler/setup"
|
5
|
+
require "active-fedora"
|
5
6
|
|
6
7
|
Bundler::GemHelper.install_tasks
|
7
8
|
|
8
|
-
# load rake tasks defined in lib/tasks
|
9
|
-
|
9
|
+
# load rake tasks defined in lib/tasks that are not loaded in lib/active_fedora.rb
|
10
|
+
load "lib/tasks/active_fedora_dev.rake" if defined?(Rake)
|
10
11
|
|
11
12
|
CLEAN.include %w[**/.DS_Store tmp *.log *.orig *.tmp **/*~]
|
12
13
|
|
data/active-fedora.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_dependency("mediashelf-loggable")
|
28
28
|
s.add_dependency("equivalent-xml")
|
29
29
|
s.add_dependency("facets")
|
30
|
-
s.add_dependency("rubydora", '~>0.
|
30
|
+
s.add_dependency("rubydora", '~>0.4.1')
|
31
31
|
s.add_dependency("rdf")
|
32
32
|
s.add_dependency("rdf-rdfxml")
|
33
33
|
s.add_development_dependency("yard")
|
data/lib/active_fedora.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "loggable"
|
2
|
-
require 'active_fedora/railtie' if defined? Rails
|
3
2
|
require 'active_support'
|
4
3
|
require 'active_fedora/solr_service'
|
5
4
|
require 'active_fedora/rubydora_connection'
|
@@ -40,6 +39,7 @@ module ActiveFedora #:nodoc:
|
|
40
39
|
autoload :SemanticNode
|
41
40
|
autoload :NestedAttributes
|
42
41
|
autoload :FixtureLoader
|
42
|
+
autoload :FixtureExporter
|
43
43
|
autoload :DatastreamCollections
|
44
44
|
autoload :NamedRelationships
|
45
45
|
autoload :Predicates
|
@@ -294,3 +294,6 @@ module ActiveFedora
|
|
294
294
|
|
295
295
|
end
|
296
296
|
|
297
|
+
load File.join(File.dirname(__FILE__),"tasks/active_fedora.rake") if defined?(Rake)
|
298
|
+
|
299
|
+
|
data/lib/active_fedora/base.rb
CHANGED
@@ -22,13 +22,11 @@ module ActiveFedora
|
|
22
22
|
# end
|
23
23
|
# end
|
24
24
|
#
|
25
|
-
# The above example creates a
|
25
|
+
# The above example creates a Fedora object with a metadata datastream named "properties", which is composed of a
|
26
26
|
# narrator and bio field.
|
27
27
|
#
|
28
28
|
# Datastreams defined with +has_metadata+ are accessed via the +datastreams+ member hash.
|
29
29
|
#
|
30
|
-
# =Implementation
|
31
|
-
# This class is really a facade for a basic Fedora::FedoraObject, which is stored internally.
|
32
30
|
class Base
|
33
31
|
include SemanticNode
|
34
32
|
|
@@ -75,34 +75,6 @@ module ActiveFedora
|
|
75
75
|
tmpl
|
76
76
|
end
|
77
77
|
|
78
|
-
# # Callback. Override this to insert behaviors after the save method. By default, sets self.dirty = false
|
79
|
-
# def after_save
|
80
|
-
# self.dirty = false
|
81
|
-
# end
|
82
|
-
|
83
|
-
# returns a datetime in the standard W3C DateTime Format.
|
84
|
-
# ie 2008-10-17T00:17:18.194Z
|
85
|
-
# def last_modified_in_repository
|
86
|
-
# # A hack to get around the fact that you can't call getDatastreamHistory
|
87
|
-
# # or API-M getDatasreams on Fedora 3.0 REST API
|
88
|
-
# # grabs the CREATED attribute off of the last foxml:datastreamVersion
|
89
|
-
# # within the appropriate datastream node in the objectXML
|
90
|
-
# if self.pid != nil
|
91
|
-
# object_xml = Fedora::FedoraObject.object_xml(self.pid).gsub("\n ","")
|
92
|
-
# datastream_xml = REXML::Document.new(object_xml).root.elements["foxml:datastream[@ID='#{self.dsid}']"]
|
93
|
-
#
|
94
|
-
# if datastream_xml.length > 3
|
95
|
-
# datastream_xml.elements.each do |el|
|
96
|
-
# logger.debug el.inspect
|
97
|
-
# end
|
98
|
-
# end
|
99
|
-
#
|
100
|
-
# datastream_xml.elements[datastream_xml.length - 2].attributes["CREATED"]
|
101
|
-
# else
|
102
|
-
# return nil
|
103
|
-
# end
|
104
|
-
# end
|
105
|
-
|
106
78
|
def check_concurrency # :nodoc:
|
107
79
|
return true
|
108
80
|
end
|
@@ -204,7 +204,7 @@ module ActiveFedora
|
|
204
204
|
ds.mimeType = opts[:mimeType]
|
205
205
|
ds.controlGroup = opts[:controlGroup]
|
206
206
|
ds.dsLabel = opts[:dsLabel]
|
207
|
-
ds.dsLocation = opts[:dsLocation]
|
207
|
+
ds.dsLocation = opts[:dsLocation] if opts[:dsLocation]
|
208
208
|
blob = opts[:blob]
|
209
209
|
if blob
|
210
210
|
if !ds.mimeType.present?
|
@@ -213,37 +213,13 @@ module ActiveFedora
|
|
213
213
|
end
|
214
214
|
if !ds.dsLabel.present? && blob.respond_to?(:path)
|
215
215
|
ds.dsLabel = File.basename(blob.path)
|
216
|
-
# ds.dsLabel = blob.original_filename
|
217
216
|
end
|
218
217
|
end
|
219
218
|
|
220
|
-
# blob = blob.read if blob.respond_to? :read
|
221
219
|
ds.content = blob || ""
|
222
220
|
ds
|
223
221
|
end
|
224
222
|
|
225
|
-
# def configure_defined_datastreams
|
226
|
-
# if self.class.ds_specs
|
227
|
-
# self.class.ds_specs.each do |name,ds_config|
|
228
|
-
# if self.datastreams.has_key?(name)
|
229
|
-
# #attributes = self.datastreams[name].attributes
|
230
|
-
# else
|
231
|
-
# ds = ds_config[:type].new(inner_object, name)
|
232
|
-
# ds.model = self if ds_config[:type] == RelsExtDatastream
|
233
|
-
# ds.dsLabel = ds_config[:label] if ds_config[:label].present?
|
234
|
-
# ds.controlGroup = ds_config[:control_group]
|
235
|
-
# # If you called has_metadata with a block, pass the block into the Datastream class
|
236
|
-
# if ds_config[:block].class == Proc
|
237
|
-
# ds_config[:block].call(ds)
|
238
|
-
# end
|
239
|
-
# additional_attributes_for_external_and_redirect_control_groups(ds, ds_config)
|
240
|
-
# self.add_datastream(ds)
|
241
|
-
# end
|
242
|
-
# end
|
243
|
-
# end
|
244
|
-
# end
|
245
|
-
|
246
|
-
|
247
223
|
# This method provides validation of proper options for control_group 'E' and 'R' and builds an attribute hash to be merged back into ds.attributes prior to saving
|
248
224
|
#
|
249
225
|
# @param [Object] ds The datastream
|
@@ -31,11 +31,11 @@ module ActiveFedora
|
|
31
31
|
def create_delegate_accessor(field, args)
|
32
32
|
define_method field do
|
33
33
|
ds = self.send(args[:to])
|
34
|
-
val = if ds.kind_of? ActiveFedora::
|
34
|
+
val = if ds.kind_of? ActiveFedora::MetadataDatastream
|
35
|
+
ds.send(:get_values, field)
|
36
|
+
else
|
35
37
|
terminology = args[:at] || [field]
|
36
38
|
ds.send(:term_values, *terminology)
|
37
|
-
else
|
38
|
-
ds.send(:get_values, field)
|
39
39
|
end
|
40
40
|
args[:unique] ? val.first : val
|
41
41
|
|
@@ -45,11 +45,11 @@ module ActiveFedora
|
|
45
45
|
def create_delegate_setter(field, args)
|
46
46
|
define_method "#{field}=".to_sym do |v|
|
47
47
|
ds = self.send(args[:to])
|
48
|
-
if ds.kind_of? ActiveFedora::
|
48
|
+
if ds.kind_of? ActiveFedora::MetadataDatastream
|
49
|
+
ds.send(:set_value, field, v)
|
50
|
+
else
|
49
51
|
terminology = args[:at] || [field]
|
50
52
|
ds.send(:update_indexed_attributes, {terminology => v})
|
51
|
-
else
|
52
|
-
ds.send(:set_value, field, v)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ActiveFedora
|
2
|
+
module FixtureExporter
|
3
|
+
|
4
|
+
def self.export_to_path(pid, path, extra_params={})
|
5
|
+
foxml = export(pid, extra_params)
|
6
|
+
name = "#{pid.gsub(":","_")}.foxml.xml"
|
7
|
+
filename = File.join(path, name)
|
8
|
+
file = File.new(filename,"w")
|
9
|
+
file.syswrite(foxml)
|
10
|
+
filename
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.export(pid, extra_params={})
|
14
|
+
extra_params = {:format=>:foxml, :context=>:archive}.merge!(extra_params)
|
15
|
+
if extra_params[:format].kind_of?(String)
|
16
|
+
format = extra_params[:format]
|
17
|
+
else
|
18
|
+
format = case extra_params[:format]
|
19
|
+
when :atom then "info:fedora/fedora-system:ATOM-1.1"
|
20
|
+
when :atom_zip then "info:fedora/fedora-system:ATOMZip-1.1"
|
21
|
+
when :mets then "info:fedora/fedora-system:METSFedoraExt-1.1"
|
22
|
+
when :foxml then "info:fedora/fedora-system:FOXML-1.1"
|
23
|
+
else "info:fedora/fedora-system:FOXML-1.1"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
RubydoraConnection.instance.connection.export(:pid=>pid, :format=>format, :context=>extra_params[:context].to_s)
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -6,11 +6,56 @@ module ActiveFedora
|
|
6
6
|
# <title>Foo</title>
|
7
7
|
# <author>Bar</author>
|
8
8
|
# </fields>
|
9
|
-
class MetadataDatastream <
|
9
|
+
class MetadataDatastream < NokogiriDatastream
|
10
10
|
|
11
11
|
# .to_solr (among other things) is provided by ActiveFedora::MetadataDatastreamHelper
|
12
12
|
include ActiveFedora::MetadataDatastreamHelper
|
13
13
|
|
14
|
+
# def initialize(digital_object, dsid)
|
15
|
+
# ActiveSupport::Deprecation.warn("MetadataDatastream is deprecated and will be removed in a future release. Create a NokogiriDatastream to structure your data")
|
16
|
+
# super
|
17
|
+
# end
|
18
|
+
def to_solr(solr_doc = Hash.new) # :nodoc:
|
19
|
+
fields.each do |field_key, field_info|
|
20
|
+
if field_info.has_key?(:values) && !field_info[:values].nil?
|
21
|
+
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
22
|
+
values = field_info[:values]
|
23
|
+
values = [values] unless values.respond_to? :each
|
24
|
+
values.each do |val|
|
25
|
+
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
return solr_doc
|
31
|
+
end
|
32
|
+
|
33
|
+
# ** EXPERIMENTAL **
|
34
|
+
#
|
35
|
+
# This is utilized by ActiveFedora::Base.load_instance_from_solr to set
|
36
|
+
# metadata values in this object using the Solr document passed in.
|
37
|
+
# Any keys in the solr document that map to a metadata field key within a MetadataDatastream object
|
38
|
+
# are set to the corresponding value. Any others are ignored. ActiveFedora::SolrService.solr_name
|
39
|
+
# is used to map solr key to field key name.
|
40
|
+
#
|
41
|
+
# ====Warning
|
42
|
+
# Solr must be synchronized with data in Fedora.
|
43
|
+
def from_solr(solr_doc)
|
44
|
+
fields.each do |field_key, field_info|
|
45
|
+
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
46
|
+
value = (solr_doc[field_symbol].nil? ? solr_doc[field_symbol.to_s]: solr_doc[field_symbol])
|
47
|
+
unless value.nil?
|
48
|
+
if value.is_a? Array
|
49
|
+
update_attributes({field_key=>value})
|
50
|
+
else
|
51
|
+
update_indexed_attributes({field_key=>{0=>value}})
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
14
59
|
|
15
60
|
def update_attributes(params={},opts={})
|
16
61
|
result = params.dup
|
@@ -32,48 +32,9 @@ module ActiveFedora::MetadataDatastreamHelper
|
|
32
32
|
|
33
33
|
def serialize! # :nodoc:
|
34
34
|
if dirty?
|
35
|
+
return unless xml_loaded
|
35
36
|
self.content = self.to_xml
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
|
-
def to_solr(solr_doc = Hash.new) # :nodoc:
|
40
|
-
fields.each do |field_key, field_info|
|
41
|
-
if field_info.has_key?(:values) && !field_info[:values].nil?
|
42
|
-
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
43
|
-
values = field_info[:values]
|
44
|
-
values = [values] unless values.respond_to? :each
|
45
|
-
values.each do |val|
|
46
|
-
::Solrizer::Extractor.insert_solr_field_value(solr_doc, field_symbol, val )
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
return solr_doc
|
52
|
-
end
|
53
|
-
|
54
|
-
# ** EXPERIMENTAL **
|
55
|
-
#
|
56
|
-
# This is utilized by ActiveFedora::Base.load_instance_from_solr to set
|
57
|
-
# metadata values in this object using the Solr document passed in.
|
58
|
-
# Any keys in the solr document that map to a metadata field key within a MetadataDatastream object
|
59
|
-
# are set to the corresponding value. Any others are ignored. ActiveFedora::SolrService.solr_name
|
60
|
-
# is used to map solr key to field key name.
|
61
|
-
#
|
62
|
-
# ====Warning
|
63
|
-
# Solr must be synchronized with data in Fedora.
|
64
|
-
def from_solr(solr_doc)
|
65
|
-
fields.each do |field_key, field_info|
|
66
|
-
field_symbol = ActiveFedora::SolrService.solr_name(field_key, field_info[:type])
|
67
|
-
value = (solr_doc[field_symbol].nil? ? solr_doc[field_symbol.to_s]: solr_doc[field_symbol])
|
68
|
-
unless value.nil?
|
69
|
-
if value.is_a? Array
|
70
|
-
update_attributes({field_key=>value})
|
71
|
-
else
|
72
|
-
update_indexed_attributes({field_key=>{0=>value}})
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
40
|
end
|
data/lib/active_fedora/model.rb
CHANGED
@@ -164,7 +164,7 @@ module ActiveFedora
|
|
164
164
|
# Find all ActiveFedora objects for this model that match arguments
|
165
165
|
# passed in by querying Solr. Like find_by_solr this returns a solr result.
|
166
166
|
#
|
167
|
-
# query_fields a hash of object field names and values to filter on
|
167
|
+
# query_fields a hash of object field names and values to filter on (query_fields must be the solr_field_name for non-MetadataDatastream derived datastreams)
|
168
168
|
# opts specifies options for the solr query
|
169
169
|
#
|
170
170
|
# options may include:
|
@@ -35,6 +35,7 @@ module ActiveFedora
|
|
35
35
|
return unless @connection.nil? or force
|
36
36
|
allowable_options = [:url, :user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key]
|
37
37
|
client_options = options.reject { |k,v| not allowable_options.include?(k) }
|
38
|
+
#puts "CLIENT OPTS #{client_options.inspect}"
|
38
39
|
@connection = Rubydora.connect client_options
|
39
40
|
end
|
40
41
|
|
@@ -1,21 +1,15 @@
|
|
1
1
|
require "active-fedora"
|
2
2
|
require "solrizer-fedora"
|
3
3
|
require "active_support" # This is just to load ActiveSupport::CoreExtensions::String::Inflections
|
4
|
-
namespace :
|
4
|
+
namespace :repo do
|
5
5
|
|
6
|
+
desc "Delete and re-import the object identified by pid"
|
7
|
+
task :refresh => [:delete,:load]
|
6
8
|
|
7
|
-
desc "Delete
|
8
|
-
task :refresh_fixture => [:delete,:import_fixture]
|
9
|
-
|
10
|
-
desc "Delete the object identified by pid. Example: rake fedora:delete pid=demo:12"
|
9
|
+
desc "Delete the object identified by pid. Example: rake repo:delete pid=demo:12"
|
11
10
|
task :delete => :init do
|
12
|
-
# If a destination url has been provided, attampt to export from the fedora repository there.
|
13
|
-
if ENV["destination"]
|
14
|
-
Fedora::Repository.register(ENV["destination"])
|
15
|
-
end
|
16
|
-
|
17
11
|
if ENV["pid"].nil?
|
18
|
-
puts "You must specify a valid pid. Example: rake
|
12
|
+
puts "You must specify a valid pid. Example: rake repo:delete pid=demo:12"
|
19
13
|
else
|
20
14
|
pid = ENV["pid"]
|
21
15
|
begin
|
@@ -25,22 +19,19 @@ namespace :af do
|
|
25
19
|
rescue Errno::ECONNREFUSED => e
|
26
20
|
puts "Can't connect to Fedora! Are you sure jetty is running?"
|
27
21
|
end
|
28
|
-
|
22
|
+
puts "Deleted '#{pid}' from #{ActiveFedora.fedora_config[:url]}"
|
29
23
|
end
|
30
24
|
end
|
31
25
|
|
32
|
-
desc "Delete a range of objects in a given namespace. ie 'rake
|
33
|
-
task :
|
34
|
-
# If Fedora Repository connection is not already initialized, initialize it using ActiveFedora defaults
|
35
|
-
# ActiveFedora.init unless Thread.current[:repo]
|
36
|
-
|
26
|
+
desc "Delete a range of objects in a given namespace. ie 'rake repo:delete_range namespace=demo start=22 stop=50' will delete demo:22 through demo:50"
|
27
|
+
task :delete_range => :init do |t, args|
|
37
28
|
namespace = ENV["namespace"]
|
38
29
|
start_point = ENV["start"].to_i
|
39
30
|
stop_point = ENV["stop"].to_i
|
40
|
-
unless start_point
|
31
|
+
unless start_point <= stop_point
|
41
32
|
raise StandardError "start point must be less that end point."
|
42
33
|
end
|
43
|
-
puts "Deleting #{stop_point - start_point} objects from #{namespace}:#{start_point.to_s} to #{namespace}:#{stop_point.to_s}"
|
34
|
+
puts "Deleting #{stop_point - start_point + 1} objects from #{namespace}:#{start_point.to_s} to #{namespace}:#{stop_point.to_s}"
|
44
35
|
i = start_point
|
45
36
|
while i <= stop_point do
|
46
37
|
pid = namespace + ":" + i.to_s
|
@@ -49,68 +40,52 @@ namespace :af do
|
|
49
40
|
rescue ActiveFedora::ObjectNotFoundError
|
50
41
|
# The object has already been deleted (or was never created). Do nothing.
|
51
42
|
end
|
52
|
-
puts "Deleted '#{pid}' from #{ActiveFedora
|
43
|
+
puts "Deleted '#{pid}' from #{ActiveFedora.fedora_config[:url]}"
|
53
44
|
i += 1
|
54
45
|
end
|
55
46
|
end
|
56
|
-
|
57
|
-
desc "Export the object identified by pid into spec/fixtures. Example:rake
|
58
|
-
task :
|
59
|
-
|
60
|
-
# If a source url has been provided, attampt to export from the fedora repository there.
|
61
|
-
if ENV["source"]
|
62
|
-
#FIXME
|
63
|
-
raise "Not Implemented"
|
64
|
-
#Fedora::Repository.register(ENV["source"])
|
65
|
-
end
|
66
|
-
|
47
|
+
|
48
|
+
desc "Export the object identified by pid into spec/fixtures. Example:rake repo:export pid=demo:12"
|
49
|
+
task :export => :init do
|
67
50
|
if ENV["pid"].nil?
|
68
|
-
puts "You must specify a valid pid. Example: rake
|
51
|
+
puts "You must specify a valid pid. Example: rake repo:export pid=demo:12"
|
69
52
|
else
|
70
53
|
pid = ENV["pid"]
|
71
|
-
puts "Exporting '#{pid}' from #{ActiveFedora
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
54
|
+
puts "Exporting '#{pid}' from #{ActiveFedora.fedora_config[:url]}"
|
55
|
+
if !ENV["path"].nil?
|
56
|
+
path = ENV["path"]
|
57
|
+
else
|
58
|
+
path = File.join('spec', 'fixtures')
|
59
|
+
end
|
60
|
+
filename = ActiveFedora::FixtureExporter.export_to_path(pid, path)
|
78
61
|
puts "The object has been saved as #{filename}"
|
79
62
|
end
|
80
63
|
end
|
81
64
|
|
82
|
-
desc "
|
83
|
-
task :
|
84
|
-
|
85
|
-
|
86
|
-
if ENV["destination"]
|
87
|
-
#FIXME
|
88
|
-
raise "Not Implemented"
|
89
|
-
Fedora::Repository.register(ENV["destination"])
|
90
|
-
end
|
91
|
-
|
92
|
-
if !ENV["fixture"].nil?
|
93
|
-
filename = ENV["fixture"]
|
65
|
+
desc "Load the object located at the provided path or identified by pid. Example: rake repo:load path=spec/fixtures/demo_12.foxml.xml"
|
66
|
+
task :load => :init do
|
67
|
+
if !ENV["path"].nil?
|
68
|
+
filename = ENV["path"]
|
94
69
|
elsif !ENV["pid"].nil?
|
95
70
|
pid = ENV["pid"]
|
96
71
|
filename = File.join("spec","fixtures","#{pid.gsub(":","_")}.foxml.xml")
|
97
72
|
else
|
98
|
-
puts "You must specify a path to the
|
73
|
+
puts "You must specify a path to the object or provide its pid. Example: rake repo:load path=spec/fixtures/demo_12.foxml.xml"
|
99
74
|
end
|
100
75
|
|
101
76
|
if !filename.nil?
|
102
|
-
puts "
|
77
|
+
puts "Loading '#{filename}' in #{ActiveFedora.fedora_config[:url]}"
|
103
78
|
file = File.new(filename, "r")
|
104
|
-
result =
|
105
|
-
# result = foxml = Fedora::Repository.instance.ingest(file.read)
|
79
|
+
result = ActiveFedora::RubydoraConnection.instance.connection.ingest(:file=>file.read)
|
106
80
|
if result
|
107
|
-
puts "The
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
81
|
+
puts "The object has been loaded as #{result.body}"
|
82
|
+
if pid.nil?
|
83
|
+
pid = result.body
|
84
|
+
end
|
85
|
+
solrizer = Solrizer::Fedora::Solrizer.new
|
86
|
+
solrizer.solrize(pid)
|
112
87
|
else
|
113
|
-
puts "Failed to
|
88
|
+
puts "Failed to load the object."
|
114
89
|
end
|
115
90
|
end
|
116
91
|
|
@@ -2,20 +2,6 @@ APP_ROOT = File.expand_path("#{File.dirname(__FILE__)}/../../")
|
|
2
2
|
|
3
3
|
require 'jettywrapper'
|
4
4
|
|
5
|
-
desc "Hudson build"
|
6
|
-
task :hudson do
|
7
|
-
ENV['environment'] = "test"
|
8
|
-
Rake::Task["active_fedora:doc"].invoke
|
9
|
-
Rake::Task["active_fedora:configure_jetty"].invoke
|
10
|
-
jetty_params = Jettywrapper.load_config
|
11
|
-
jetty_params[:startup_wait]= 30
|
12
|
-
error = Jettywrapper.wrap(jetty_params) do
|
13
|
-
Rake::Task["active_fedora:load_fixtures"].invoke
|
14
|
-
Rake::Task["active_fedora:rspec"].invoke
|
15
|
-
end
|
16
|
-
raise "test failures: #{error}" if error
|
17
|
-
end
|
18
|
-
|
19
5
|
namespace :active_fedora do
|
20
6
|
require 'active-fedora'
|
21
7
|
|
@@ -73,6 +59,20 @@ require 'rspec/core/rake_task'
|
|
73
59
|
cp("#{f}", 'jetty/solr/test-core/conf/', :verbose => true)
|
74
60
|
end
|
75
61
|
end
|
62
|
+
|
63
|
+
|
64
|
+
desc "Hudson build"
|
65
|
+
task :hudson do
|
66
|
+
ENV['environment'] = "test"
|
67
|
+
Rake::Task["active_fedora:doc"].invoke
|
68
|
+
Rake::Task["active_fedora:configure_jetty"].invoke
|
69
|
+
jetty_params = Jettywrapper.load_config
|
70
|
+
jetty_params[:startup_wait]= 30
|
71
|
+
error = Jettywrapper.wrap(jetty_params) do
|
72
|
+
Rake::Task["active_fedora:load_fixtures"].invoke
|
73
|
+
Rake::Task["active_fedora:rspec"].invoke
|
74
|
+
end
|
75
|
+
raise "test failures: #{error}" if error
|
76
76
|
end
|
77
77
|
|
78
78
|
# Provides an :environment task for use while working within a working copy of active-fedora
|
@@ -83,3 +83,6 @@ task :environment do
|
|
83
83
|
require "#{APP_ROOT}/spec/samples/models/hydrangea_article"
|
84
84
|
require 'active_fedora/samples'
|
85
85
|
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
data/script/console
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
4
|
ENV["RUBYLIB"] = "lib"
|
5
5
|
libs = " -r irb/completion"
|
6
|
+
libs << " -r rubygems"
|
6
7
|
libs << " -r #{File.dirname(__FILE__) + '/../spec/spec_helper'}"
|
7
|
-
#libs << " -r rubygems"
|
8
8
|
# libs << " -r #{File.dirname(__FILE__) + '/../lib/active_fedora.rb'}"
|
9
9
|
|
10
10
|
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require "active_fedora/samples"
|
2
3
|
|
3
4
|
class MockAFBaseQuerySolr < ActiveFedora::Base
|
4
5
|
has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
|
@@ -13,15 +14,45 @@ class MockAFBaseQuerySolr < ActiveFedora::Base
|
|
13
14
|
m.field "geography", :string, :xml_node => "geography"
|
14
15
|
m.field "title", :string, :xml_node => "title"
|
15
16
|
end
|
17
|
+
|
18
|
+
has_metadata :name=>'ng_metadata', :type=> Hydra::ModsArticleDatastream
|
16
19
|
end
|
17
20
|
|
18
21
|
describe ActiveFedora::Base do
|
19
22
|
|
20
|
-
before(:
|
23
|
+
before(:all) do
|
21
24
|
@test_object = ActiveFedora::Base.new
|
25
|
+
#get objects into fedora and solr
|
26
|
+
@test_object2 = MockAFBaseQuerySolr.new
|
27
|
+
attributes = {"holding_id"=>{0=>"Holding 1"},
|
28
|
+
"language"=>{0=>"Italian"},
|
29
|
+
"creator"=>{0=>"Linguist, A."},
|
30
|
+
"geography"=>{0=>"Italy"},
|
31
|
+
"title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
|
32
|
+
@test_object2.update_indexed_attributes(attributes)
|
33
|
+
@test_object2.save
|
34
|
+
|
35
|
+
@test_object3 = MockAFBaseQuerySolr.new
|
36
|
+
attributes = {"holding_id"=>{0=>"Holding 2"},
|
37
|
+
"language"=>{0=>"Spanish;Latin"},
|
38
|
+
"creator"=>{0=>"Linguist, A."},
|
39
|
+
"geography"=>{0=>"Spain"},
|
40
|
+
"title"=>{0=>"A study of the evolution of Spanish from Latin"}}
|
41
|
+
@test_object3.update_indexed_attributes(attributes)
|
42
|
+
@test_object3.save
|
43
|
+
|
44
|
+
@test_object4 = MockAFBaseQuerySolr.new
|
45
|
+
attributes = {"holding_id"=>{0=>"Holding 3"},
|
46
|
+
"language"=>{0=>"Spanish;Latin"},
|
47
|
+
"creator"=>{0=>"Linguist, A."},
|
48
|
+
"geography"=>{0=>"Spain"},
|
49
|
+
"title"=>{0=>"An obscure look into early nomadic tribes of Spain"}}
|
50
|
+
@test_object4.update_indexed_attributes(attributes)
|
51
|
+
@test_object4.save
|
52
|
+
|
22
53
|
end
|
23
54
|
|
24
|
-
after(:
|
55
|
+
after(:all) do
|
25
56
|
begin
|
26
57
|
@test_object.delete
|
27
58
|
rescue
|
@@ -38,42 +69,10 @@ describe ActiveFedora::Base do
|
|
38
69
|
@test_object4.delete
|
39
70
|
rescue
|
40
71
|
end
|
41
|
-
begin
|
42
|
-
@test_object5.delete
|
43
|
-
rescue
|
44
|
-
end
|
45
72
|
end
|
46
73
|
|
47
74
|
describe '#find_by_fields_by_solr' do
|
48
|
-
it 'should return fedora objects of the
|
49
|
-
#get objects into fedora and solr
|
50
|
-
@test_object2 = MockAFBaseQuerySolr.new
|
51
|
-
attributes = {"holding_id"=>{0=>"Holding 1"},
|
52
|
-
"language"=>{0=>"Italian"},
|
53
|
-
"creator"=>{0=>"Linguist, A."},
|
54
|
-
"geography"=>{0=>"Italy"},
|
55
|
-
"title"=>{0=>"Italian and Spanish: A Comparison of Common Phrases"}}
|
56
|
-
@test_object2.update_indexed_attributes(attributes)
|
57
|
-
@test_object2.save
|
58
|
-
|
59
|
-
@test_object3 = MockAFBaseQuerySolr.new
|
60
|
-
attributes = {"holding_id"=>{0=>"Holding 2"},
|
61
|
-
"language"=>{0=>"Spanish;Latin"},
|
62
|
-
"creator"=>{0=>"Linguist, A."},
|
63
|
-
"geography"=>{0=>"Spain"},
|
64
|
-
"title"=>{0=>"A study of the evolution of Spanish from Latin"}}
|
65
|
-
@test_object3.update_indexed_attributes(attributes)
|
66
|
-
@test_object3.save
|
67
|
-
|
68
|
-
@test_object4 = MockAFBaseQuerySolr.new
|
69
|
-
attributes = {"holding_id"=>{0=>"Holding 3"},
|
70
|
-
"language"=>{0=>"Spanish;Latin"},
|
71
|
-
"creator"=>{0=>"Linguist, A."},
|
72
|
-
"geography"=>{0=>"Spain"},
|
73
|
-
"title"=>{0=>"An obscure look into early nomadic tribes of Spain"}}
|
74
|
-
@test_object4.update_indexed_attributes(attributes)
|
75
|
-
@test_object4.save
|
76
|
-
|
75
|
+
it 'should return fedora objects of the correct class' do
|
77
76
|
#query based on just model
|
78
77
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({})
|
79
78
|
found_pids = []
|
@@ -82,7 +81,9 @@ describe ActiveFedora::Base do
|
|
82
81
|
end
|
83
82
|
|
84
83
|
found_pids.should == [@test_object2.pid,@test_object3.pid,@test_object4.pid]
|
84
|
+
end
|
85
85
|
|
86
|
+
it 'should match a query against multiple result fields' do
|
86
87
|
#query on certain fields
|
87
88
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"language"=>"Latin"})
|
88
89
|
found_pids = []
|
@@ -107,23 +108,10 @@ describe ActiveFedora::Base do
|
|
107
108
|
end
|
108
109
|
|
109
110
|
found_pids.should == [@test_object3.pid,@test_object4.pid]
|
111
|
+
end
|
110
112
|
|
113
|
+
it 'should query against many fields' do
|
111
114
|
#assume spaces removed at index time so query by 'Linguist,A.' instead of 'Linguist, A.'
|
112
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."})
|
113
|
-
found_pids = []
|
114
|
-
results.hits.each do |hit|
|
115
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
116
|
-
end
|
117
|
-
|
118
|
-
found_pids.should == [@test_object2.pid,@test_object3.pid,@test_object4.pid]
|
119
|
-
|
120
|
-
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"geography"=>"Italy"})
|
121
|
-
found_pids = []
|
122
|
-
results.hits.each do |hit|
|
123
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
124
|
-
end
|
125
|
-
|
126
|
-
found_pids.should == [@test_object2.pid]
|
127
115
|
|
128
116
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A.","title"=>"latin"})
|
129
117
|
found_pids = []
|
@@ -132,6 +120,9 @@ describe ActiveFedora::Base do
|
|
132
120
|
end
|
133
121
|
|
134
122
|
found_pids.should == [@test_object3.pid]
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should query by id' do
|
135
126
|
|
136
127
|
#query with value with embedded ':' (pid)
|
137
128
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"id"=>@test_object3.pid})
|
@@ -141,9 +132,10 @@ describe ActiveFedora::Base do
|
|
141
132
|
end
|
142
133
|
|
143
134
|
found_pids.should == [@test_object3.pid]
|
144
|
-
|
145
|
-
|
146
|
-
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
it "should sort by default by system_create_date" do
|
147
139
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A.","language"=>"Spanish"})
|
148
140
|
found_pids = []
|
149
141
|
results.hits.each do |hit|
|
@@ -151,8 +143,9 @@ describe ActiveFedora::Base do
|
|
151
143
|
end
|
152
144
|
|
153
145
|
found_pids.should == [@test_object3.pid,@test_object4.pid]
|
154
|
-
|
155
|
-
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should be able to change the sort direction" do
|
156
149
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>[{"system_create"=>"desc"}]})
|
157
150
|
found_pids = []
|
158
151
|
results.hits.each do |hit|
|
@@ -160,8 +153,9 @@ describe ActiveFedora::Base do
|
|
160
153
|
end
|
161
154
|
|
162
155
|
found_pids.should == [@test_object4.pid,@test_object3.pid,@test_object2.pid]
|
163
|
-
|
164
|
-
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should default the sort direction to ascending" do
|
165
159
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["system_create"]})
|
166
160
|
found_pids = []
|
167
161
|
results.hits.each do |hit|
|
@@ -169,8 +163,10 @@ describe ActiveFedora::Base do
|
|
169
163
|
end
|
170
164
|
|
171
165
|
found_pids.should == [@test_object2.pid,@test_object3.pid,@test_object4.pid]
|
166
|
+
end
|
172
167
|
|
173
|
-
|
168
|
+
|
169
|
+
it "should sort by multiple fields" do
|
174
170
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["geography",{"system_create"=>"desc"}]})
|
175
171
|
found_pids = []
|
176
172
|
results.hits.each do |hit|
|
@@ -178,7 +174,9 @@ describe ActiveFedora::Base do
|
|
178
174
|
end
|
179
175
|
|
180
176
|
found_pids.should == [@test_object2.pid,@test_object4.pid,@test_object3.pid]
|
177
|
+
end
|
181
178
|
|
179
|
+
it "should transform system_modified_date" do
|
182
180
|
#check appropriate logic for system_modified_date field name transformation
|
183
181
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:sort=>["geography",{"system_mod"=>"desc"}]})
|
184
182
|
found_pids = []
|
@@ -187,7 +185,9 @@ describe ActiveFedora::Base do
|
|
187
185
|
end
|
188
186
|
|
189
187
|
found_pids.should == [@test_object2.pid,@test_object4.pid,@test_object3.pid]
|
190
|
-
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should accept rows as a parameter" do
|
191
191
|
#check pass in rows values
|
192
192
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"creator"=>"Linguist,A."},{:rows=>2})
|
193
193
|
found_pids = []
|
@@ -196,16 +196,26 @@ describe ActiveFedora::Base do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
found_pids.should == [@test_object2.pid,@test_object3.pid]
|
199
|
+
end
|
199
200
|
|
201
|
+
it "should accept a solr field (geography_t) that is not an object field name(e.g. geography)" do
|
200
202
|
#check query with field mapping to solr field and with solr field that is not a field in object
|
201
203
|
#should be able to query by either active fedora model field name or solr key name
|
202
204
|
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"geography_t"=>"Italy"})
|
203
|
-
found_pids = []
|
204
|
-
results.hits.each do |hit|
|
205
|
-
found_pids.push(hit[SOLR_DOCUMENT_ID])
|
206
|
-
end
|
207
|
-
|
205
|
+
found_pids = results.hits.map{|h| h[SOLR_DOCUMENT_ID]}
|
208
206
|
found_pids.should == [@test_object2.pid]
|
209
207
|
end
|
208
|
+
|
209
|
+
describe "with Nokogiri based datastreams" do
|
210
|
+
before do
|
211
|
+
@test_object2.ng_metadata.journal_title = "foo"
|
212
|
+
@test_object2.save
|
213
|
+
end
|
214
|
+
it "should query Nokogiri based datastreams if you use the solr field names (doesn't do mapping)" do
|
215
|
+
results = MockAFBaseQuerySolr.find_by_fields_by_solr({"journal_title_t" => "foo"})
|
216
|
+
found_pids = results.hits.map{|h| h[SOLR_DOCUMENT_ID]}
|
217
|
+
found_pids.should == [@test_object2.pid]
|
218
|
+
end
|
219
|
+
end
|
210
220
|
end
|
211
221
|
end
|
@@ -15,7 +15,6 @@ describe ActiveFedora::DatastreamCollections do
|
|
15
15
|
describe '#add_named_datastream' do
|
16
16
|
it 'should add a datastream with the given name to the object in fedora' do
|
17
17
|
@test_object2 = MockAFBaseDatastream.new
|
18
|
-
# @test_object2.new_object = true
|
19
18
|
f = File.open(File.join( File.dirname(__FILE__), "../fixtures/minivan.jpg"), 'rb')
|
20
19
|
f2 = File.open(File.join( File.dirname(__FILE__), "../fixtures/dino.jpg" ), 'rb')
|
21
20
|
f2.stubs(:original_filename).returns("dino.jpg")
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ActiveFedora::MetadataDatastream do
|
4
|
+
|
5
|
+
describe "changing the controlGroup of a datastream" do
|
6
|
+
before :all do
|
7
|
+
class Foo < ActiveFedora::Base
|
8
|
+
has_metadata :name => "stuff", :type => ActiveFedora::MetadataDatastream do |m|
|
9
|
+
m.field "alt_title", :string
|
10
|
+
end
|
11
|
+
end
|
12
|
+
obj = Foo.new()
|
13
|
+
obj.stuff.update_indexed_attributes({ [:alt_title] => {"0" => "Title"}} )
|
14
|
+
obj.save
|
15
|
+
|
16
|
+
#Update the object
|
17
|
+
obj2 = Foo.find(obj.pid)
|
18
|
+
obj2.stuff.controlGroup = 'M'
|
19
|
+
obj2.save
|
20
|
+
|
21
|
+
@obj = Foo.find(obj.pid)
|
22
|
+
end
|
23
|
+
|
24
|
+
after :all do
|
25
|
+
Object.send(:remove_const, :Foo)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should not change the datastream content" do
|
29
|
+
@obj.stuff.alt_title_values.should == ['Title']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
describe "updating a datastream's content" do
|
33
|
+
before :all do
|
34
|
+
class Foo < ActiveFedora::Base
|
35
|
+
has_metadata :name => "properties", :type => ActiveFedora::MetadataDatastream do |m|
|
36
|
+
m.field "field1", :string
|
37
|
+
end
|
38
|
+
has_metadata :name => "stuff", :type => ActiveFedora::MetadataDatastream do |m|
|
39
|
+
m.field "alt_title", :string
|
40
|
+
end
|
41
|
+
end
|
42
|
+
obj = Foo.new()
|
43
|
+
obj.properties.update_indexed_attributes({ [:field1] => {"0" => "test value"}} )
|
44
|
+
obj.stuff.update_indexed_attributes({ [:alt_title] => {"0" => "Title"}} )
|
45
|
+
obj.save
|
46
|
+
|
47
|
+
#Update the object
|
48
|
+
obj2 = Foo.find(obj.pid)
|
49
|
+
obj2.stuff.update_indexed_attributes({ [:alt_title] => {"0" => "Moo Cow"}} )
|
50
|
+
obj2.save
|
51
|
+
|
52
|
+
@obj = Foo.find(obj.pid)
|
53
|
+
end
|
54
|
+
|
55
|
+
after :all do
|
56
|
+
Object.send(:remove_const, :Foo)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have updated the one datastream" do
|
60
|
+
@obj.stuff.alt_title_values.should == ['Moo Cow']
|
61
|
+
end
|
62
|
+
it "should not have changed the other datastream" do
|
63
|
+
@obj.properties.field1_values.should == ['test value']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/unit/base_spec.rb
CHANGED
@@ -538,6 +538,11 @@ describe ActiveFedora::Base do
|
|
538
538
|
ds.dsLabel.should == nil
|
539
539
|
ds.mimeType.should == "application/octet-stream"
|
540
540
|
end
|
541
|
+
|
542
|
+
it 'should not set dsLocation if dsLocation is nil' do
|
543
|
+
ActiveFedora::Datastream.any_instance.expects(:dsLocation=).never
|
544
|
+
ds = @test_object.create_datastream("ActiveFedora::Datastream", 'NAME', {:dsLocation=>nil})
|
545
|
+
end
|
541
546
|
end
|
542
547
|
|
543
548
|
describe ".add_file_datastream" do
|
@@ -87,7 +87,7 @@ describe ActiveFedora::Datastream do
|
|
87
87
|
EOS
|
88
88
|
@test_datastream.expects(:repository).returns(@mock_repo)
|
89
89
|
@mock_repo.expects(:datastream).with(:dsid => 'abcd', :pid => @test_object.pid).returns(ds_profile)
|
90
|
-
@test_datastream.size.should ==
|
90
|
+
@test_datastream.size.should == 9999
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should default to an empty string if ds has not been saved" do
|
@@ -21,6 +21,7 @@ describe ActiveFedora::MetadataDatastream do
|
|
21
21
|
mock_inner = mock('inner object')
|
22
22
|
@test_object = ActiveFedora::Base.new
|
23
23
|
@mock_repo = mock('repository')
|
24
|
+
@mock_repo.stubs(:datastream)
|
24
25
|
@mock_repo.stubs(:datastream_dissemination=>'My Content')
|
25
26
|
mock_inner.stubs(:repository).returns(@mock_repo)
|
26
27
|
mock_inner.stubs(:pid)
|
@@ -40,14 +41,17 @@ describe ActiveFedora::MetadataDatastream do
|
|
40
41
|
|
41
42
|
describe '.save' do
|
42
43
|
it "should persist the product of .to_xml in fedora" do
|
43
|
-
@test_ds.
|
44
|
+
@test_ds.field('coverage', :string)
|
45
|
+
@test_ds.expects(:new?).returns(true).times(3)
|
44
46
|
@mock_repo.expects(:datastream).with(:pid => nil, :dsid => 'mdDs')
|
45
|
-
@mock_repo.expects(:add_datastream)
|
46
|
-
|
47
|
+
@mock_repo.expects(:add_datastream)
|
48
|
+
#@test_ds.expects(:to_xml).returns("fake xml")
|
47
49
|
@test_ds.expects(:dirty?).returns(true)
|
50
|
+
@test_ds.update_attributes(:coverage=>"Hat")
|
48
51
|
@test_ds.serialize!
|
49
52
|
@test_ds.save
|
50
53
|
@test_ds.mimeType.should == 'text/xml'
|
54
|
+
@test_ds.content.should == "<?xml version=\"1.0\"?>\n<fields>\n <coverage>Hat</coverage>\n</fields>\n"
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
@@ -1,10 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
require 'active_fedora'
|
4
|
-
require 'xmlsimple'
|
5
|
-
require 'nokogiri'
|
6
|
-
require 'equivalent-xml'
|
7
|
-
|
8
3
|
describe ActiveFedora::QualifiedDublinCoreDatastream do
|
9
4
|
|
10
5
|
before(:all) do
|
@@ -128,6 +123,7 @@ describe ActiveFedora::QualifiedDublinCoreDatastream do
|
|
128
123
|
describe 'serialize!' do
|
129
124
|
it "should call .content= with to_dc_xml" do
|
130
125
|
result = @test_ds.to_dc_xml
|
126
|
+
@test_ds.ensure_xml_loaded
|
131
127
|
@test_ds.expects(:content=).with(result)
|
132
128
|
@test_ds.expects(:dirty?).returns(true)
|
133
129
|
@test_ds.serialize!
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 3.2.
|
9
|
+
- 2
|
10
|
+
version: 3.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Zumwalt
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-01-
|
20
|
+
date: 2012-01-20 00:00:00 -06:00
|
21
21
|
default_executable:
|
22
22
|
dependencies:
|
23
23
|
- !ruby/object:Gem::Dependency
|
@@ -212,12 +212,12 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - ~>
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
hash:
|
215
|
+
hash: 13
|
216
216
|
segments:
|
217
217
|
- 0
|
218
|
-
-
|
219
|
-
-
|
220
|
-
version: 0.
|
218
|
+
- 4
|
219
|
+
- 1
|
220
|
+
version: 0.4.1
|
221
221
|
requirement: *id013
|
222
222
|
- !ruby/object:Gem::Dependency
|
223
223
|
name: rdf
|
@@ -569,8 +569,8 @@ files:
|
|
569
569
|
- lib/active_fedora/datastreams.rb
|
570
570
|
- lib/active_fedora/delegating.rb
|
571
571
|
- lib/active_fedora/digital_object.rb
|
572
|
-
- lib/active_fedora/fedora_object.rb
|
573
572
|
- lib/active_fedora/file_management.rb
|
573
|
+
- lib/active_fedora/fixture_exporter.rb
|
574
574
|
- lib/active_fedora/fixture_loader.rb
|
575
575
|
- lib/active_fedora/metadata_datastream.rb
|
576
576
|
- lib/active_fedora/metadata_datastream_helper.rb
|
@@ -582,7 +582,6 @@ files:
|
|
582
582
|
- lib/active_fedora/predicates.rb
|
583
583
|
- lib/active_fedora/property.rb
|
584
584
|
- lib/active_fedora/qualified_dublin_core_datastream.rb
|
585
|
-
- lib/active_fedora/railtie.rb
|
586
585
|
- lib/active_fedora/rdf_xml_writer.rb
|
587
586
|
- lib/active_fedora/reflection.rb
|
588
587
|
- lib/active_fedora/relationship.rb
|
@@ -639,6 +638,7 @@ files:
|
|
639
638
|
- spec/integration/datastream_spec.rb
|
640
639
|
- spec/integration/full_featured_model_spec.rb
|
641
640
|
- spec/integration/metadata_datastream_helper_spec.rb
|
641
|
+
- spec/integration/metadata_datastream_spec.rb
|
642
642
|
- spec/integration/model_spec.rb
|
643
643
|
- spec/integration/mods_article_integration_spec.rb
|
644
644
|
- spec/integration/nested_attribute_spec.rb
|
@@ -783,6 +783,7 @@ test_files:
|
|
783
783
|
- spec/integration/datastream_spec.rb
|
784
784
|
- spec/integration/full_featured_model_spec.rb
|
785
785
|
- spec/integration/metadata_datastream_helper_spec.rb
|
786
|
+
- spec/integration/metadata_datastream_spec.rb
|
786
787
|
- spec/integration/model_spec.rb
|
787
788
|
- spec/integration/mods_article_integration_spec.rb
|
788
789
|
- spec/integration/nested_attribute_spec.rb
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module ActiveFedora
|
2
|
-
|
3
|
-
#
|
4
|
-
# This is a module replacing the ActiveFedora::Base class.
|
5
|
-
#
|
6
|
-
module FedoraObject
|
7
|
-
def initialize
|
8
|
-
@inner_object = Fedora::FedoraObject.new
|
9
|
-
Fedora::Repository.instance.save @inner_object
|
10
|
-
end
|
11
|
-
|
12
|
-
def save
|
13
|
-
Fedora::Repository.instance.save(@inner_object)
|
14
|
-
end
|
15
|
-
|
16
|
-
def delete
|
17
|
-
Fedora::Repository.instance.delete(@inner_object)
|
18
|
-
end
|
19
|
-
|
20
|
-
def datastreams
|
21
|
-
datastreams = {}
|
22
|
-
self.datastreams_xml['datastream'].each do |ds|
|
23
|
-
ds.merge!({:pid => self.pid, :dsID => ds["dsid"]})
|
24
|
-
datastreams.merge!({ds["dsid"] => ActiveFedora::Datastream.new(ds)})
|
25
|
-
end
|
26
|
-
return datastreams
|
27
|
-
end
|
28
|
-
|
29
|
-
def datastreams_xml
|
30
|
-
datastreams_xml = XmlSimple.xml_in(Fedora::Repository.instance.fetch_custom(self.pid, :datastreams))
|
31
|
-
end
|
32
|
-
|
33
|
-
# Adds datastream to the object. Saves the datastream to fedora upon adding.
|
34
|
-
def add_datastream(datastream)
|
35
|
-
datastream.pid = self.pid
|
36
|
-
datastream.save
|
37
|
-
end
|
38
|
-
|
39
|
-
# DC Datastream
|
40
|
-
def dc
|
41
|
-
#dc = REXML::Document.new(datastreams["DC"].content)
|
42
|
-
return datastreams["DC"]
|
43
|
-
end
|
44
|
-
|
45
|
-
# RELS-EXT Datastream
|
46
|
-
def rels_ext
|
47
|
-
if !datastreams.has_key?("RELS-EXT")
|
48
|
-
add(ActiveFedora::RelsExtDatastream.new)
|
49
|
-
end
|
50
|
-
|
51
|
-
return datastreams["RELS-EXT"]
|
52
|
-
end
|
53
|
-
|
54
|
-
def inner_object
|
55
|
-
@inner_object
|
56
|
-
end
|
57
|
-
|
58
|
-
def pid
|
59
|
-
@inner_object.pid
|
60
|
-
end
|
61
|
-
|
62
|
-
def state
|
63
|
-
@inner_object.state
|
64
|
-
end
|
65
|
-
|
66
|
-
def owner_id
|
67
|
-
@inner_object.owner_id
|
68
|
-
end
|
69
|
-
|
70
|
-
def errors
|
71
|
-
@inner_object.errors
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|