Default values for MetadataDatastream

4 views
Skip to first unread message

Willy Mene

unread,
Nov 5, 2009, 3:24:30 PM11/5/09
to active...@googlegroups.com
We would like to have a default value for one of our fields in a
MetadataDatastream.

My first attempt at this was to set the value of that particular field
in the objects initializer, but found any existing values in Fedora
were being appended to the default. Digging through the code, I found
that ActiveFedora::Base objects are initialized, then the datastream
xml is parsed, and then the values are appended to whatever is in
memory. This is done through:

ActiveFedora::Base#deserialize and
ActiveFedora::MetadataDatastream#from_xml

So instead of re-writing/overriding these methods, I wanted to see if
there was interest in having default values in MetadataDatastreams as
a new feature. It could go something like this:

class MyObj < ActiveFedora::Base

has_metadata :name => "my_properties", :type =>
ActiveFedora::MetadataDatastream do |m|
m.field "some_field", :string, :default_value => 'some default value'
...
end
...
end

Any thoughts?

Willy

Matthew Zumwalt

unread,
Nov 6, 2009, 1:02:18 AM11/6/09
to active...@googlegroups.com
This sounds practical to me, though I'm fuzzy about exactly when the defaults would be applied.  In Rails/ActiveRecord, the defaults are applied at the SQL-level (usually handled by the database itself).  We don't have it quite so easy.

Could you post a feature request in Redmine?

Matt Zumwalt
MediaShelf, LLC




--

You received this message because you are subscribed to the Google Groups "ActiveFedora / Ruby + Fedora Commons" group.
To post to this group, send email to active...@googlegroups.com.
To unsubscribe from this group, send email to active-fedor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/active-fedora?hl=en.



Reply all
Reply to author
Forward
0 new messages