active-fedora 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ begin
24
24
  gem.add_dependency("activeresource")
25
25
  gem.add_dependency("mediashelf-loggable")
26
26
  gem.add_dependency("equivalent-xml")
27
+ gem.add_dependency("facets")
27
28
 
28
29
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
29
30
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active-fedora}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Matt Zumwalt", "McClain Looney"]
12
- s.date = %q{2011-04-08}
12
+ s.date = %q{2011-05-02}
13
13
  s.description = %q{ActiveFedora provides for creating and managing objects in the Fedora Repository Architecture.}
14
14
  s.email = %q{matt.zumwalt@yourmediashelf.com}
15
15
  s.extra_rdoc_files = [
@@ -182,6 +182,7 @@ Gem::Specification.new do |s|
182
182
  "VERSION",
183
183
  "active-fedora.gemspec",
184
184
  "config/fedora.yml",
185
+ "config/predicate_mappings.yml",
185
186
  "config/solr_mappings.yml",
186
187
  "config/solr_mappings_af_0.1.yml",
187
188
  "config/solr_mappings_bl_2.4.yml",
@@ -288,58 +289,6 @@ Gem::Specification.new do |s|
288
289
  s.rubyforge_project = %q{rubyfedora}
289
290
  s.rubygems_version = %q{1.3.7}
290
291
  s.summary = %q{A convenience libary for manipulating MODS (Metadata Object Description Schema) documents.}
291
- s.test_files = [
292
- "spec/integration/base_file_management_spec.rb",
293
- "spec/integration/base_find_by_fields_spec.rb",
294
- "spec/integration/base_loader_spec.rb",
295
- "spec/integration/base_spec.rb",
296
- "spec/integration/bug_spec.rb",
297
- "spec/integration/datastream_spec.rb",
298
- "spec/integration/datastreams_crud_spec.rb",
299
- "spec/integration/fedora_object_spec.rb",
300
- "spec/integration/full_featured_model_spec.rb",
301
- "spec/integration/metadata_datastream_helper_spec.rb",
302
- "spec/integration/model_spec.rb",
303
- "spec/integration/mods_article_integration_spec.rb",
304
- "spec/integration/nokogiri_datastream_spec.rb",
305
- "spec/integration/rels_ext_datastream_spec.rb",
306
- "spec/integration/repository_spec.rb",
307
- "spec/integration/rf_fedora_object_spec.rb",
308
- "spec/integration/semantic_node_spec.rb",
309
- "spec/integration/solr_service_spec.rb",
310
- "spec/samples/models/audio_record.rb",
311
- "spec/samples/models/image.rb",
312
- "spec/samples/models/oral_history.rb",
313
- "spec/samples/models/seminar.rb",
314
- "spec/samples/models/seminar_audio_file.rb",
315
- "spec/samples/oral_history_sample_model.rb",
316
- "spec/spec_helper.rb",
317
- "spec/unit/active_fedora_spec.rb",
318
- "spec/unit/base_cma_spec.rb",
319
- "spec/unit/base_datastream_management_spec.rb",
320
- "spec/unit/base_extra_spec.rb",
321
- "spec/unit/base_file_management_spec.rb",
322
- "spec/unit/base_named_datastream_spec.rb",
323
- "spec/unit/base_spec.rb",
324
- "spec/unit/connection_spec.rb",
325
- "spec/unit/content_model_spec.rb",
326
- "spec/unit/datastream_concurrency_spec.rb",
327
- "spec/unit/datastream_spec.rb",
328
- "spec/unit/fedora_object_spec.rb",
329
- "spec/unit/inheritance_spec.rb",
330
- "spec/unit/metadata_datastream_spec.rb",
331
- "spec/unit/model_spec.rb",
332
- "spec/unit/nokogiri_datastream_spec.rb",
333
- "spec/unit/property_spec.rb",
334
- "spec/unit/qualified_dublin_core_datastream_spec.rb",
335
- "spec/unit/relationship_spec.rb",
336
- "spec/unit/rels_ext_datastream_spec.rb",
337
- "spec/unit/repository_spec.rb",
338
- "spec/unit/rf_datastream_spec.rb",
339
- "spec/unit/semantic_node_spec.rb",
340
- "spec/unit/solr_config_options_spec.rb",
341
- "spec/unit/solr_service_spec.rb"
342
- ]
343
292
 
344
293
  if s.respond_to? :specification_version then
345
294
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -383,6 +332,26 @@ Gem::Specification.new do |s|
383
332
  s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
384
333
  s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
385
334
  s.add_development_dependency(%q<ruby-debug>, [">= 0"])
335
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
336
+ s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
337
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
338
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
339
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
340
+ s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
341
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
342
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
343
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
344
+ s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
345
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
346
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
347
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
348
+ s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
349
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
350
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
351
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
352
+ s.add_development_dependency(%q<rspec>, ["< 2.0.0"])
353
+ s.add_development_dependency(%q<mocha>, [">= 0.9.8"])
354
+ s.add_development_dependency(%q<ruby-debug>, [">= 0"])
386
355
  s.add_runtime_dependency(%q<solr-ruby>, [">= 0.0.6"])
387
356
  s.add_runtime_dependency(%q<xml-simple>, [">= 1.0.12"])
388
357
  s.add_runtime_dependency(%q<mime-types>, [">= 1.16"])
@@ -393,6 +362,7 @@ Gem::Specification.new do |s|
393
362
  s.add_runtime_dependency(%q<activeresource>, [">= 0"])
394
363
  s.add_runtime_dependency(%q<mediashelf-loggable>, [">= 0"])
395
364
  s.add_runtime_dependency(%q<equivalent-xml>, [">= 0"])
365
+ s.add_runtime_dependency(%q<facets>, [">= 0"])
396
366
  else
397
367
  s.add_dependency(%q<active-fedora>, [">= 0"])
398
368
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -431,6 +401,26 @@ Gem::Specification.new do |s|
431
401
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
432
402
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
433
403
  s.add_dependency(%q<ruby-debug>, [">= 0"])
404
+ s.add_dependency(%q<jeweler>, [">= 0"])
405
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
406
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
407
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
408
+ s.add_dependency(%q<jeweler>, [">= 0"])
409
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
410
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
411
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
412
+ s.add_dependency(%q<jeweler>, [">= 0"])
413
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
414
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
415
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
416
+ s.add_dependency(%q<jeweler>, [">= 0"])
417
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
418
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
419
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
420
+ s.add_dependency(%q<jeweler>, [">= 0"])
421
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
422
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
423
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
434
424
  s.add_dependency(%q<solr-ruby>, [">= 0.0.6"])
435
425
  s.add_dependency(%q<xml-simple>, [">= 1.0.12"])
436
426
  s.add_dependency(%q<mime-types>, [">= 1.16"])
@@ -441,6 +431,7 @@ Gem::Specification.new do |s|
441
431
  s.add_dependency(%q<activeresource>, [">= 0"])
442
432
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
443
433
  s.add_dependency(%q<equivalent-xml>, [">= 0"])
434
+ s.add_dependency(%q<facets>, [">= 0"])
444
435
  end
445
436
  else
446
437
  s.add_dependency(%q<active-fedora>, [">= 0"])
@@ -480,6 +471,26 @@ Gem::Specification.new do |s|
480
471
  s.add_dependency(%q<rspec>, ["< 2.0.0"])
481
472
  s.add_dependency(%q<mocha>, [">= 0.9.8"])
482
473
  s.add_dependency(%q<ruby-debug>, [">= 0"])
474
+ s.add_dependency(%q<jeweler>, [">= 0"])
475
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
476
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
477
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
478
+ s.add_dependency(%q<jeweler>, [">= 0"])
479
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
480
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
481
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
482
+ s.add_dependency(%q<jeweler>, [">= 0"])
483
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
484
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
485
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
486
+ s.add_dependency(%q<jeweler>, [">= 0"])
487
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
488
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
489
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
490
+ s.add_dependency(%q<jeweler>, [">= 0"])
491
+ s.add_dependency(%q<rspec>, ["< 2.0.0"])
492
+ s.add_dependency(%q<mocha>, [">= 0.9.8"])
493
+ s.add_dependency(%q<ruby-debug>, [">= 0"])
483
494
  s.add_dependency(%q<solr-ruby>, [">= 0.0.6"])
484
495
  s.add_dependency(%q<xml-simple>, [">= 1.0.12"])
485
496
  s.add_dependency(%q<mime-types>, [">= 1.16"])
@@ -490,6 +501,7 @@ Gem::Specification.new do |s|
490
501
  s.add_dependency(%q<activeresource>, [">= 0"])
491
502
  s.add_dependency(%q<mediashelf-loggable>, [">= 0"])
492
503
  s.add_dependency(%q<equivalent-xml>, [">= 0"])
504
+ s.add_dependency(%q<facets>, [">= 0"])
493
505
  end
494
506
  end
495
507
 
@@ -0,0 +1,47 @@
1
+ # The default namespace maps to the default namespace for generating rels_ext from solr
2
+ :default_namespace: info:fedora/fedora-system:def/relations-external#
3
+
4
+ # namespace mappings---
5
+ # you can add specific mappings for your institution by providing the following:
6
+ # namespace_uri:
7
+ # :relationship_symbol: relationship_identifier
8
+ #
9
+ # For example, if you have the following element in your rels_ext:
10
+ #
11
+ # <oai:itemID>oai:example.edu:changeme:500</oai:itemID>
12
+ #
13
+ # With the last two lines of this file uncommented, the relationships hash of your object will include:
14
+ # :oai_item_id => ["info:fedora/oai:example.edu:changeme:500"]
15
+ #
16
+ # With the last two lines of this file commented out, the relationships hash of your object will include:
17
+ # "oai_itemID" => ["info:fedora/oai:example.edu:changeme:500"]
18
+ #
19
+ :predicate_mapping:
20
+ info:fedora/fedora-system:def/relations-external#:
21
+ :is_derivation_of: isDerivationOf
22
+ :is_metadata_for: isMetadataFor
23
+ :is_member_of_collection: isMemberOfCollection
24
+ :has_derivation: hasDerivation
25
+ :is_annotation_of: isAnnotationOf
26
+ :is_constituent_of: isConstituentOf
27
+ :is_dependent_of: isDependentOf
28
+ :has_collection_member: hasCollectionMember
29
+ :has_annotation: hasAnnotation
30
+ :has_constituent: hasConstituent
31
+ :has_dependent: hasDependent
32
+ :is_part_of: isPartOf
33
+ :has_equivalent: hasEquivalent
34
+ :is_subset_of: isSubsetOf
35
+ :is_description_of: isDescriptionOf
36
+ :is_member_of: isMemberOf
37
+ :has_model: hasModel
38
+ :conforms_to: conformsTo
39
+ :has_metadata: hasMetadata
40
+ :has_subset: hasSubset
41
+ :has_description: hasDescription
42
+ :has_part: hasPart
43
+ :has_member: hasMember
44
+ info:fedora/fedora-system:def/model#:
45
+ :has_model: hasModel
46
+ # http://www.openarchives.org/OAI/2.0/:
47
+ # :oai_item_id: itemID
@@ -28,13 +28,17 @@ ENABLE_SOLR_UPDATES = true unless defined?(ENABLE_SOLR_UPDATES)
28
28
  module ActiveFedora #:nodoc:
29
29
 
30
30
  class << self
31
- attr_accessor :solr_config, :fedora_config
31
+ attr_accessor :solr_config, :fedora_config, :predicate_config_path
32
32
  end
33
33
 
34
34
  # The configuration hash that gets used by RSolr.connect
35
35
  @solr_config ||= {}
36
36
  @fedora_config ||= {}
37
-
37
+
38
+ # Initializes ActiveFedora's connection to Fedora and Solr based on the info in fedora.yml
39
+ # If RAILS_ENV is set, it will use that environment. Defaults to "development".
40
+ # @param [String] config_path (optional) the path to fedora.yml
41
+ # If config_path is not provided and RAILS_ROOT is set, it will look in RAILS_ENV/config/fedora.yml. Otherwise, it will look in your config/fedora.yml. Failing that, it will use localhost urls.
38
42
  def self.init( config_path=nil )
39
43
 
40
44
  config_env = defined?(RAILS_ENV) ? RAILS_ENV : "development"
@@ -43,10 +47,14 @@ module ActiveFedora #:nodoc:
43
47
  if defined?(RAILS_ROOT)
44
48
  config_path = "#{RAILS_ROOT}/config/fedora.yml"
45
49
  else
46
- config_path = File.join(File.dirname(__FILE__), "..", "config", "fedora.yml")
47
- logger.info "Using the default fedora.yml that comes with active-fedora. 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."
50
+ config_path = File.join("config","fedora.yml")
51
+ unless File.exist?(config_path)
52
+ config_path = File.join(File.dirname(__FILE__), "..", "config", "fedora.yml")
53
+ logger.info "Using the default fedora.yml that comes with active-fedora. 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."
54
+ end
48
55
  end
49
56
  end
57
+
50
58
 
51
59
  logger.info("FEDORA: loading ActiveFedora config from #{File.expand_path(config_path)}")
52
60
 
@@ -67,6 +75,18 @@ module ActiveFedora #:nodoc:
67
75
  Fedora::Repository.register(ActiveFedora.fedora_config[:url])
68
76
  logger.info("FEDORA: initialized Fedora as: #{Fedora::Repository.instance.inspect}")
69
77
 
78
+ # Retrieve the valid path for the predicate mappings config file
79
+ pred_config_paths = [File.dirname(config_path),File.join(File.dirname(__FILE__),"..","config")]
80
+ pred_config_paths.each do |path|
81
+ testfile = File.join(path,"predicate_mappings.yml")
82
+ if File.exist?(testfile)
83
+ @predicate_config_path = testfile
84
+ break
85
+ end
86
+ end
87
+ raise "Could not find predicate_mappings.yml in these locations: #{pred_config_paths.join("; ")}." unless @predicate_config_path
88
+
89
+
70
90
  end
71
91
 
72
92
  def self.solr
@@ -80,6 +100,10 @@ module ActiveFedora #:nodoc:
80
100
  def self.logger
81
101
  @logger ||= defined?(RAILS_DEFAULT_LOGGER) ? RAILS_DEFAULT_LOGGER : Logger.new(STDOUT)
82
102
  end
103
+
104
+ def self.predicate_config
105
+ @predicate_config_path
106
+ end
83
107
  end
84
108
 
85
109
 
@@ -225,6 +225,12 @@ module ActiveFedora
225
225
  keys = datastreams.keys
226
226
  next_index = keys.select {|v| v =~ /(#{prefix}\d*$)/}.length + 1
227
227
  new_dsid = prefix.to_s + next_index.to_s
228
+ while keys.include?(new_dsid)
229
+ next_index += 1
230
+ new_dsid = prefix.to_s + next_index.to_s
231
+ end
232
+ new_dsid
233
+
228
234
  # while keys.include?(new_dsid)
229
235
  # next_index += 1
230
236
  # new_dsid = prefix.to_s + rand(range).to_s
@@ -1,3 +1,4 @@
1
+ require 'facets/string/titlecase'
1
2
  module ActiveFedora
2
3
  class ContentModel < Base
3
4
  CMODEL_NAMESPACE = "afmodel"
@@ -34,7 +34,11 @@ module ActiveFedora
34
34
  def self.from_xml(tmpl, node)
35
35
  # node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*").each do |f|
36
36
  node.xpath("./foxml:datastreamVersion[last()]/foxml:xmlContent/rdf:RDF/rdf:Description/*", {"rdf"=>"http://www.w3.org/1999/02/22-rdf-syntax-ns#", "foxml"=>"info:fedora/fedora-system:def/foxml#"}).each do |f|
37
- r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>ActiveFedora::SemanticNode::PREDICATE_MAPPINGS.invert[f.name], :object=>f["resource"])
37
+ ns_mapping = self.predicate_mappings[f.namespace.href]
38
+ predicate = ns_mapping ? ns_mapping.invert[f.name] : nil
39
+ predicate = "#{f.namespace.prefix}_#{f.name}" if predicate.nil?
40
+ object = f["resource"] ? f["resource"] : f.inner_text
41
+ r = ActiveFedora::Relationship.new(:subject=>:self, :predicate=>predicate, :object=>object)
38
42
  tmpl.add_relationship(r)
39
43
  end
40
44
  tmpl.send(:dirty=, false)
@@ -65,7 +69,7 @@ module ActiveFedora
65
69
  # Solr must be synchronized with RELS-EXT data in Fedora.
66
70
  def from_solr(solr_doc)
67
71
  #cycle through all possible predicates
68
- PREDICATE_MAPPINGS.keys.each do |predicate|
72
+ self.class.predicate_mappings[self.class.default_predicate_namespace].keys.each do |predicate|
69
73
  predicate_symbol = ActiveFedora::SolrService.solr_name(predicate, :symbol)
70
74
  value = (solr_doc[predicate_symbol].nil? ? solr_doc[predicate_symbol.to_s]: solr_doc[predicate_symbol])
71
75
  unless value.nil?
@@ -5,34 +5,11 @@ module ActiveFedora
5
5
 
6
6
  attr_accessor :internal_uri, :named_relationship_desc, :relationships_are_dirty, :load_from_solr
7
7
 
8
- PREDICATE_MAPPINGS = Hash[:is_member_of => "isMemberOf",
9
- :has_member => "hasMember",
10
- :is_part_of => "isPartOf",
11
- :has_part => "hasPart",
12
- :is_member_of_collection => "isMemberOfCollection",
13
- :has_collection_member => "hasCollectionMember",
14
- :is_constituent_of => "isConstituentOf",
15
- :has_constituent => "hasConstituent",
16
- :is_subset_of => "isSubsetOf",
17
- :has_subset => "hasSubset",
18
- :is_derivation_of => "isDerivationOf",
19
- :has_derivation => "hasDerivation",
20
- :is_dependent_of => "isDependentOf",
21
- :has_dependent => "hasDependent",
22
- :is_description_of => "isDescriptionOf",
23
- :has_description => "hasDescription",
24
- :is_metadata_for => "isMetadataFor",
25
- :has_metadata => "hasMetadata",
26
- :is_annotation_of => "isAnnotationOf",
27
- :has_annotation => "hasAnnotation",
28
- :has_equivalent => "hasEquivalent",
29
- :conforms_to => "conformsTo",
30
- :has_model => "hasModel"]
31
- PREDICATE_MAPPINGS.freeze
32
-
8
+
33
9
  def self.included(klass)
34
10
  klass.extend(ClassMethods)
35
11
  end
12
+
36
13
  def assert_kind_of(n, o,t)
37
14
  raise "Assertion failure: #{n}: #{o} is not of type #{t}" unless o.kind_of?(t)
38
15
  end
@@ -473,7 +450,7 @@ module ActiveFedora
473
450
  # this object's RELS-EXT datastream
474
451
  #
475
452
  # Word of caution - The same predicate may not be used twice for two inbound or two outbound relationships. However, it may be used twice if one is inbound
476
- # and one is outbound as shown in the example above. A full list of possible predicates are defined by PREDICATE_MAPPINGS
453
+ # and one is outbound as shown in the example above. A full list of possible predicates are defined by predicate_mappings
477
454
  #
478
455
  # For the oral_history relationship in the example above the following helper methods are created:
479
456
  # oral_history: returns array of OralHistory objects that have this AudioRecord with predicate :has_part
@@ -759,19 +736,32 @@ module ActiveFedora
759
736
  xml.to_s
760
737
  end
761
738
 
762
- # If predicate is a symbol, looks up the predicate in the PREDICATE_MAPPINGS
739
+ # If predicate is a symbol, looks up the predicate in the predicate_mappings
763
740
  # If predicate is not a Symbol, returns the predicate untouched
764
- # @throws UnregisteredPredicateError if the predicate is a symbol but is not found in the PREDICATE_MAPPINGS
765
- def predicate_lookup(predicate)
741
+ # @throws UnregisteredPredicateError if the predicate is a symbol but is not found in the predicate_mappings
742
+ def predicate_lookup(predicate,namespace="info:fedora/fedora-system:def/relations-external#")
766
743
  if predicate.class == Symbol
767
- if PREDICATE_MAPPINGS.has_key?(predicate)
768
- return PREDICATE_MAPPINGS[predicate]
744
+ if predicate_mappings[namespace].has_key?(predicate)
745
+ return predicate_mappings[namespace][predicate]
769
746
  else
770
747
  throw UnregisteredPredicateError
771
748
  end
772
749
  end
773
750
  return predicate
774
751
  end
752
+
753
+ def predicate_config
754
+ @@predicate_config ||= YAML::load(File.open(ActiveFedora.predicate_config)) if File.exist?(ActiveFedora.predicate_config)
755
+ end
756
+
757
+ def predicate_mappings
758
+ predicate_config[:predicate_mapping]
759
+ end
760
+
761
+ def default_predicate_namespace
762
+ predicate_config[:default_namespace]
763
+ end
764
+
775
765
  end
776
766
  end
777
767
  end
@@ -82,7 +82,8 @@ describe ActiveFedora::RelsExtDatastream do
82
82
  end
83
83
 
84
84
  it "should load relationships from fedora into parent object" do
85
- ActiveFedora::SemanticNode::PREDICATE_MAPPINGS.each_key do |p|
85
+ class SpecNode; include ActiveFedora::SemanticNode; end
86
+ SpecNode.predicate_mappings[SpecNode.default_predicate_namespace].each_key do |p|
86
87
  @test_object.add_relationship(p, "demo:#{rand(100)}")
87
88
  end
88
89
  @test_object.save
@@ -90,7 +91,7 @@ describe ActiveFedora::RelsExtDatastream do
90
91
  @test_object.relationships[:self].should have_key(:is_member_of)
91
92
  ActiveFedora::Base.load_instance(@test_object.pid).relationships.should == @test_object.relationships
92
93
  end
93
-
94
+
94
95
  describe '#from_solr' do
95
96
 
96
97
  it "should respond_to from_solr" do