active-fedora 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -417,11 +417,27 @@ module ActiveFedora
417
417
  case predicate
418
418
  when :has_model, "hasModel", :hasModel
419
419
  xmlns="info:fedora/fedora-system:def/model#"
420
+ begin
421
+ rel_predicate = self.class.predicate_lookup(predicate,xmlns)
422
+ rescue UnregisteredPredicateError
423
+ xmlns = nil
424
+ rel_predicate = nil
425
+ end
420
426
  else
421
427
  xmlns="info:fedora/fedora-system:def/relations-external#"
428
+ begin
429
+ rel_predicate = self.class.predicate_lookup(predicate,xmlns)
430
+ rescue UnregisteredPredicateError
431
+ xmlns = nil
432
+ rel_predicate = nil
433
+ end
434
+ end
435
+
436
+ unless xmlns && rel_predicate
437
+ rel_predicate, xmlns = self.class.find_predicate(predicate)
422
438
  end
423
439
  # puts ". #{predicate} #{target} #{xmlns}"
424
- xml.root.elements["rdf:Description"].add_element(self.class.predicate_lookup(predicate), {"xmlns" => "#{xmlns}", "rdf:resource"=>target})
440
+ xml.root.elements["rdf:Description"].add_element(rel_predicate, {"xmlns" => "#{xmlns}", "rdf:resource"=>target})
425
441
  end
426
442
  end
427
443
  xml.to_s
@@ -747,7 +763,7 @@ module ActiveFedora
747
763
  if predicate_mappings[namespace].has_key?(predicate)
748
764
  return predicate_mappings[namespace][predicate]
749
765
  else
750
- throw UnregisteredPredicateError
766
+ raise ActiveFedora::UnregisteredPredicateError
751
767
  end
752
768
  end
753
769
  return predicate
@@ -764,7 +780,21 @@ module ActiveFedora
764
780
  def default_predicate_namespace
765
781
  predicate_config[:default_namespace]
766
782
  end
783
+
784
+ def find_predicate(predicate)
785
+ predicate_mappings.each do |namespace,predicates|
786
+ if predicates.fetch(predicate,nil)
787
+ return predicates[predicate], namespace
788
+ end
789
+ end
790
+ debugger
791
+ raise ActiveFedora::UnregisteredPredicateError
792
+ end
793
+
767
794
 
768
795
  end
769
796
  end
797
+
798
+ class UnregisteredPredicateError < RuntimeError; end
799
+
770
800
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveFedora
2
- VERSION = "2.2.2"
2
+ VERSION = "2.2.3"
3
3
  end
@@ -122,7 +122,7 @@ class Fedora::FedoraObject < Fedora::BaseObject
122
122
  end
123
123
 
124
124
  def owner_id=(new_owner_id)
125
- self.attributes.merge!({:ownerID => new_owner_id})
125
+ self.attributes.merge!({:ownerId => new_owner_id})
126
126
  end
127
127
 
128
128
  def profile
@@ -63,4 +63,12 @@ describe Fedora::FedoraObject do
63
63
 
64
64
  end
65
65
 
66
+ describe ".owner_id=" do
67
+ it "should update the attributes hash with ownerId attribute" do
68
+ @test_object.owner_id.should be_nil
69
+ @test_object.owner_id="fooTest"
70
+ @test_object.attributes[:ownerId].should == "fooTest"
71
+ end
72
+ end
73
+
66
74
  end
@@ -495,6 +495,11 @@ describe ActiveFedora::SemanticNode do
495
495
  SpecNode.predicate_lookup(:is_part_of).should == "isPartOf"
496
496
  SpecNode.predicate_lookup(:is_member_of).should == "isMemberOf"
497
497
  SpecNode.predicate_lookup("isPartOfCollection").should == "isPartOfCollection"
498
+ SpecNode.predicate_config[:predicate_mapping].merge!({"some_namespace"=>{:has_foo=>"hasFOO"}})
499
+ SpecNode.find_predicate(:has_foo).should == ["hasFOO","some_namespace"]
500
+ SpecNode.predicate_lookup(:has_foo,"some_namespace").should == "hasFOO"
501
+ #SpecNode.predicate_lookup(:has_foo)
502
+ lambda { SpecNode.predicate_lookup(:has_foo) }.should raise_error ActiveFedora::UnregisteredPredicateError
498
503
  end
499
504
 
500
505
  it 'should provide #relationships_to_rels_ext' do
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: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 2
9
- - 2
10
- version: 2.2.2
9
+ - 3
10
+ version: 2.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Zumwalt
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-05 00:00:00 Z
19
+ date: 2011-06-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: solr-ruby