Class: Fedora::FedoraObject
Instance Attribute Summary collapse
Attributes inherited from BaseObject
#attributes, #blob, #errors, #new_object
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseObject
#[], #new_object?
Constructor Details
#initialize(attrs = nil) ⇒ FedoraObject
Parameters
- attrs<Hash>
-
fedora object attributes (see below)
Attributes (attrs)
- namespace<Symbol>
- pid<Symbol>
- state<Symbol>
- label<Symbol>
- contentModel<Symbol>
- objectXMLFormat<Symbol>
- ownerID<Symbol>
-
-
20
21
22
23
|
# File 'lib/fedora/fedora_object.rb', line 20
def initialize(attrs = nil)
super
end
|
Instance Attribute Details
#target_repository ⇒ Object
Returns the value of attribute target_repository.
6
7
8
|
# File 'lib/fedora/fedora_object.rb', line 6
def target_repository
@target_repository
end
|
Class Method Details
.object_xml(pid = pid) ⇒ Object
147
148
149
|
# File 'lib/fedora/fedora_object.rb', line 147
def self.object_xml(pid=pid)
Fedora::Repository.instance.fetch_custom(pid, :objectXML)
end
|
Instance Method Details
#create_date ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'lib/fedora/fedora_object.rb', line 52
def create_date
if attributes[:create_date]
return attributes[:create_date]
elsif !new_object?
properties_from_fedora[:create_date]
else
return nil
end
end
|
#label ⇒ Object
99
100
101
102
103
104
105
106
107
|
# File 'lib/fedora/fedora_object.rb', line 99
def label
if attributes[:label]
return attributes[:label]
elsif !new_object?
properties_from_fedora[:label]
else
return nil
end
end
|
#label=(new_label) ⇒ Object
109
110
111
|
# File 'lib/fedora/fedora_object.rb', line 109
def label=(new_label)
self.attributes[:label] = new_label
end
|
#load_attributes_from_fedora ⇒ Object
30
31
32
33
|
# File 'lib/fedora/fedora_object.rb', line 30
def load_attributes_from_fedora
attributes.merge!(profile)
end
|
#modified_date ⇒ Object
62
63
64
65
66
67
68
69
70
|
# File 'lib/fedora/fedora_object.rb', line 62
def modified_date
if attributes[:modified_date]
return attributes[:modified_date]
elsif !new_object?
properties_from_fedora[:modified_date]
else
return nil
end
end
|
#object_xml ⇒ Object
143
144
145
|
# File 'lib/fedora/fedora_object.rb', line 143
def object_xml
Fedora::Repository.instance.fetch_custom(pid, :objectXML)
end
|
#owner_id ⇒ Object
Get the object and read its @ownerId from the profile
114
115
116
117
118
119
120
121
122
|
# File 'lib/fedora/fedora_object.rb', line 114
def owner_id
if attributes[:owner_id]
return attributes[:owner_id]
elsif !new_object?
properties_from_fedora[:owner_id]
else
return nil
end
end
|
#owner_id=(new_owner_id) ⇒ Object
124
125
126
|
# File 'lib/fedora/fedora_object.rb', line 124
def owner_id=(new_owner_id)
self.attributes.merge!({:ownerId => new_owner_id})
end
|
#pid ⇒ Object
73
74
75
|
# File 'lib/fedora/fedora_object.rb', line 73
def pid
self.attributes[:pid]
end
|
#pid=(new_pid) ⇒ Object
77
78
79
|
# File 'lib/fedora/fedora_object.rb', line 77
def pid=(new_pid)
self.attributes.merge!({:pid => new_pid})
end
|
#profile ⇒ Object
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/fedora/fedora_object.rb', line 128
def profile
retrieved_profile = XmlSimple.xml_in(Fedora::Repository.instance.fetch_custom(self.pid, :profile))
label = retrieved_profile["objLabel"].first unless retrieved_profile["objLabel"].first == {}
profile_hash = Hash[:pid => retrieved_profile["pid"],
:owner_id => retrieved_profile["objOwnerId"].first,
:label => label,
:create_date => retrieved_profile["objCreateDate"].first,
:modified_date => retrieved_profile["objLastModDate"].first,
:methods_list_url => retrieved_profile["objDissIndexViewURL"].first,
:datastreams_list_url => retrieved_profile["objItemIndexViewURL"].first,
:state => retrieved_profile["objState"].first
]
end
|
#properties_from_fedora ⇒ Object
Reads all object properties from the object’s FOXML into a hash. Provides slightly more info than .profile, including the object state.
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/fedora/fedora_object.rb', line 36
def properties_from_fedora
return profile
end
|
#state ⇒ Object
81
82
83
84
85
86
87
88
89
|
# File 'lib/fedora/fedora_object.rb', line 81
def state
if attributes[:state]
return attributes[:state]
elsif !new_object?
properties_from_fedora[:state]
else
return nil
end
end
|
#state=(new_state) ⇒ Object
91
92
93
94
95
96
97
|
# File 'lib/fedora/fedora_object.rb', line 91
def state=(new_state)
if ["I", "A", "D"].include? new_state
self.attributes[:state] = new_state
else
raise 'The object state of "' + new_state + '" is invalid. The allowed values for state are: A (active), D (deleted), and I (inactive).'
end
end
|
#uri ⇒ Object
152
153
154
|
# File 'lib/fedora/fedora_object.rb', line 152
def uri
"fedora:info/#{pid}"
end
|
#url ⇒ String
Returns url of the datastream in Fedora, without the repository userinfo.
157
158
159
160
|
# File 'lib/fedora/fedora_object.rb', line 157
def url
repo_url = Fedora::Repository.instance.fedora_url
return "#{repo_url.scheme}://#{repo_url.host}:#{repo_url.port}#{repo_url.path}/objects/#{pid}"
end
|