7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/active_fedora/digital_object.rb', line 7
def datastream_object_for dsid, ds_spec=nil
ds_spec ||= (original_class.ds_specs[dsid] || {}).merge(:autocreate=>false)
ds = ds_spec.fetch(:type, ActiveFedora::Datastream).new(self, dsid)
attributes = {}
attributes[:asOfDateTime] ||= asOfDateTime if self.respond_to? :asOfDateTime
attributes[:dsLabel] = ds_spec[:label] if ds_spec[:label].present?
attributes[:controlGroup] = ds_spec[:control_group] if ds_spec[:control_group].present?
attributes[:versionable] = ds_spec[:versionable] unless ds_spec[:versionable].nil?
if attributes[:controlGroup]=='E'
if !ds_spec[:disseminator].present? && ds_spec[:url].present?
attributes[:dsLocation]= ds_spec[:url]
end
elsif attributes[:controlGroup]=='R'
attributes[:dsLocation]= ds_spec[:url]
end
ds.default_attributes = attributes
if ds_spec[:autocreate] ds.datastream_will_change!
end
ds
end
|