Preview of ActiveFedora DSL
We have been working hard on creating a Domain Specific Language for declaring object models in ActiveFedora. We settled on a syntax based on DataMapper.
Here are sample Model declarations for Audio Records and Oral Histories that we are using in a current project. Keep in mind that this is just a teaser. The syntax is likely to change over the next few months.
require 'active-fedora'
class AudioRecord
include ActiveFedora::Model
relationship "parents", :is_part_of, [nil, :oral_history]
# Also considering...
#has n, :parents, {:predicate => :is_part_of, :likely_types => [nil, :oral_history]}
# OR
# is_part_of [:oral_history]
property "date_recorded", :date
property "file_name", :string
property "duration", :string
property "notes", :text
datastream "compressed", ["audio/mpeg"], :multiple => true
datastream "uncompressed", ["audio/wav", "audio/aiff"], :multiple => true
end
Note that we are making it possible to inject custom methods into a class that search against RDF predicates. This way, thanks to line 9 below, calling oral_history.parts will return everything pointing at the oral history object with info:fedora/isPartOf. We are also thinking of supporting constraint paramaters like oral_history.parts(:type => AudioRecord), which would only return the parts that are of type AudioRecord.
require 'active-fedora'
class OralHistory
# Imitating DataMapper ...
include ActiveFedora::Model
relationship "parts", :is_part_of, [:audio_record], :inbound => true
# These are all the properties that don't quite fit into Qualified DC
# Put them on the object itself (in the properties datastream) for now.
property "alt_title", :string
property "narrator", :string
property "interviewer", :integer
property "transcript_editor", :text
property "bio", :string
property "notes", :text
property "hard_copy_availability", :text
property "hard_copy_location", :text
has_metadata "dublin_core", :type => ActiveFedora::MetadataDatastream::QualifiedDublinCore do |m|
# Default :multiple => true, :refinements => :none
#
# on retrieval, these will be pluralized and returned as arrays
# ie. subject_entries = my_oral_history.dublin_core.subjects
#
# aiming to use method_missing to support calling methods like
# my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
m.field "identifier", :string, :refinements => ["info:fedora", "info:doi"]
m.field "title", :text, {:multiple => false, :required => true}
m.field "subject", :text, :refinements => ["dcterms:LCSH", :none]
m.field "date", :date
m.field "language", :text
m.field "location", :text
m.field "coverage", :text, :refinements => ["dcterms:TGN"]
m.field "temporal", :text, :refinements => ["dcterms:Period"]
m.field "abstract", :text
m.field "rights", :text
m.field "type", :text
m.field "SizeOrDuration", :text
m.field "format", :text
m.field "medium", :text
end
has_metadata "significant_passages" do |m|
m.field "significant_passage", :text
end
has_metadata "sensitive_passages" do |m|
m.field "sensitive_passage", :text
end
end