ruby-fedora 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 1.0.5 2009-17-10
2
+
3
+ * Minor fixes to handling of object properties
4
+
1
5
  == 1.0.4 2009-07-10
2
6
 
3
7
  !! Not Backwards Compatible with Fedora < 3.2.* !!
@@ -25,33 +25,48 @@ class Fedora::FedoraObject < Fedora::BaseObject
25
25
  ####
26
26
  # Attribute Accessors
27
27
  ####
28
-
29
- # TODO: Create appropriate attribute accessors for these values.
30
- # Where applicable, make sure that attributes are written to and read from self.attributes
31
- # [pid, label, create_date, modified_date, fedora_object_type, contentModel, state, ownerID, behavior_def, behavior_mech,]
32
- # API-M Search Value Equivalents: [pid, label, cDate, mDate, fType, cModel, state, ownerId, bDef, bMech,]
33
- # TODO: Mix In DC attribute finders/accessors
34
- # TODO: Make sure that fedora_object_type and contentModel are juggled properly.
35
- def retrieve_attr_from_fedora
36
- self.attributes.merge!(profile)
37
- object_rexml = REXML::Document.new(object_xml)
38
- self.attributes.merge!({
39
- :state => object_rexml.root.elements["objectProperties/property[@NAME='info:fedora/fedora-system:def/model#state']"].attributes["value"],
40
- :create_date => object_rexml.root.elements["objectProperties/property[@NAME='info:fedora/fedora-system:def/model#createdDate']"].attributes["value"],
41
- :modified_date => object_rexml.root.elements["objectProperties/property[@NAME='info:fedora/fedora-system:def/model#lastModifiedDate']"].attributes["value"],
42
- :label => object_rexml.root.elements["objectProperties/property[@NAME='info:fedora/fedora-system:def/model#label']"].attributes["value"]
43
- })
44
28
 
29
+
30
+ def load_attributes_from_fedora
31
+ #self.attributes.merge!(profile)
32
+ attributes.merge!(properties_from_fedora)
33
+ end
34
+
35
+ # Reads all object properties from the object's FOXML into a hash. Provides slightly more info than .profile, including the object state.
36
+ def properties_from_fedora
37
+ object_rexml = REXML::Document.new(object_xml)
38
+ properties = {
39
+ :pid => object_rexml.root.attributes["PID"],
40
+ :state => object_rexml.root.elements["//foxml:property[@NAME='info:fedora/fedora-system:def/model#state']"].attributes["VALUE"],
41
+ :create_date => object_rexml.root.elements["//foxml:property[@NAME='info:fedora/fedora-system:def/model#createdDate']"].attributes["VALUE"],
42
+ :modified_date => object_rexml.root.elements["//foxml:property[@NAME='info:fedora/fedora-system:def/view#lastModifiedDate']"].attributes["VALUE"],
43
+ :owner_id => object_rexml.root.elements['//foxml:property[@NAME="info:fedora/fedora-system:def/model#ownerId"]'].attributes['VALUE']
44
+ }
45
+ label_element = object_rexml.root.elements["//foxml:property[@NAME='info:fedora/fedora-system:def/model#label']"]
46
+ if label_element
47
+ properties.merge!({:label => label_element.attributes["VALUE"]})
48
+ end
49
+ return properties
45
50
  end
46
51
 
47
52
  def create_date
48
- profile[:create_date]
49
- #self.attributes[:cDate]
53
+ if attributes[:create_date]
54
+ return attributes[:create_date]
55
+ elsif !new_object?
56
+ properties_from_fedora[:create_date]
57
+ else
58
+ return nil
59
+ end
50
60
  end
51
61
 
52
62
  def modified_date
53
- profile[:create_date]
54
- #self.attributes[:mDate]
63
+ if attributes[:modified_date]
64
+ return attributes[:modified_date]
65
+ elsif !new_object?
66
+ properties_from_fedora[:modified_date]
67
+ else
68
+ return nil
69
+ end
55
70
  end
56
71
 
57
72
 
@@ -64,7 +79,13 @@ class Fedora::FedoraObject < Fedora::BaseObject
64
79
  end
65
80
 
66
81
  def state
67
- self.attributes[:state]
82
+ if attributes[:state]
83
+ return attributes[:state]
84
+ elsif !new_object?
85
+ properties_from_fedora[:state]
86
+ else
87
+ return nil
88
+ end
68
89
  end
69
90
 
70
91
  def state=(new_state)
@@ -76,7 +97,13 @@ class Fedora::FedoraObject < Fedora::BaseObject
76
97
  end
77
98
 
78
99
  def label
79
- self.attributes[:label]
100
+ if attributes[:label]
101
+ return attributes[:label]
102
+ elsif !new_object?
103
+ properties_from_fedora[:label]
104
+ else
105
+ return nil
106
+ end
80
107
  end
81
108
 
82
109
  def label=(new_label)
@@ -85,7 +112,13 @@ class Fedora::FedoraObject < Fedora::BaseObject
85
112
 
86
113
  # Get the object and read its @ownerId from the profile
87
114
  def owner_id
88
- self.attributes[:ownerID]
115
+ if attributes[:owner_id]
116
+ return attributes[:owner_id]
117
+ elsif !new_object?
118
+ properties_from_fedora[:owner_id]
119
+ else
120
+ return nil
121
+ end
89
122
  end
90
123
 
91
124
  def owner_id=(new_owner_id)
@@ -3,7 +3,7 @@ gem 'xml-simple'
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__) unless
4
4
  $LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
5
5
  module Fedora #:nodoc:
6
- VERSION = '1.0.4'
6
+ VERSION = '1.0.5'
7
7
  end
8
8
  #extended to remove facets dep
9
9
  class Hash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MediaShelf
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-10 00:00:00 -05:00
12
+ date: 2009-07-20 00:00:00 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency