active-fedora 9.0.2 → 9.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/History.txt +85 -0
  3. data/README.md +2 -4
  4. data/active-fedora.gemspec +1 -0
  5. data/lib/active_fedora.rb +5 -0
  6. data/lib/active_fedora/associations/builder/has_many.rb +1 -1
  7. data/lib/active_fedora/associations/collection_association.rb +1 -18
  8. data/lib/active_fedora/associations/contains_association.rb +3 -1
  9. data/lib/active_fedora/associations/has_and_belongs_to_many_association.rb +12 -10
  10. data/lib/active_fedora/attached_files.rb +6 -3
  11. data/lib/active_fedora/change_set.rb +2 -2
  12. data/lib/active_fedora/core.rb +26 -38
  13. data/lib/active_fedora/core/fedora_id_translator.rb +12 -0
  14. data/lib/active_fedora/core/fedora_uri_translator.rb +9 -0
  15. data/lib/active_fedora/errors.rb +4 -0
  16. data/lib/active_fedora/fedora_attributes.rb +25 -1
  17. data/lib/active_fedora/file.rb +2 -15
  18. data/lib/active_fedora/inheritable_accessors.rb +26 -0
  19. data/lib/active_fedora/nom_datastream.rb +6 -4
  20. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -4
  21. data/lib/active_fedora/reflection.rb +3 -1
  22. data/lib/active_fedora/relation/finder_methods.rb +36 -5
  23. data/lib/active_fedora/version.rb +1 -1
  24. data/lib/active_fedora/versions_graph.rb +7 -8
  25. data/spec/integration/associations_spec.rb +64 -21
  26. data/spec/integration/belongs_to_association_spec.rb +118 -47
  27. data/spec/integration/collection_association_spec.rb +46 -0
  28. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +178 -139
  29. data/spec/integration/query_result_builder_spec.rb +2 -2
  30. data/spec/integration/versionable_spec.rb +38 -1
  31. data/spec/samples/samples.rb +0 -1
  32. data/spec/spec_helper.rb +1 -0
  33. data/spec/unit/base_spec.rb +98 -0
  34. data/spec/unit/change_set_spec.rb +4 -2
  35. data/spec/unit/core/fedora_id_translator_spec.rb +20 -0
  36. data/spec/unit/core/fedora_uri_translator_spec.rb +19 -0
  37. data/spec/unit/core_spec.rb +50 -0
  38. data/spec/unit/has_many_association_spec.rb +27 -2
  39. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -6
  40. data/spec/unit/reflection_spec.rb +44 -0
  41. data/spec/unit/simple_datastream_spec.rb +32 -0
  42. metadata +23 -13
  43. data/spec/samples/marpa-dc_datastream.rb +0 -102
  44. data/spec/samples/models/audio_record.rb +0 -29
  45. data/spec/samples/models/image.rb +0 -5
  46. data/spec/samples/models/oral_history.rb +0 -36
  47. data/spec/samples/models/seminar.rb +0 -29
  48. data/spec/samples/models/seminar_audio_file.rb +0 -32
  49. data/spec/samples/oral_history_sample_model.rb +0 -30
  50. data/spec/samples/special_thing.rb +0 -44
@@ -1,102 +0,0 @@
1
- require "active-fedora"
2
- module Marpa
3
-
4
- # This is an example of a OmDatastream that defines a terminology for Dublin Core xml
5
- #
6
- # Some things to observe about this Class:
7
- # * Defines a couple of custom terms, tibetan_title and english_title, that map to dc:title with varying @language attributes
8
- # * Indicates which terms should be indexed as facets using :index_as=>[:facetable]
9
- # * Defines an xml template that is an empty dublin core xml document with three namespaces set
10
- # * Sets the namespace using :xmlns argument on the root term
11
- # * Does not override or extend to_solr, so the default solrization approach will be used (Solrizer::XML::TerminologyBasedSolrizer)
12
- #
13
- class DcDatastream < ActiveFedora::OmDatastream
14
-
15
- set_terminology do |t|
16
- t.root(:path=>"dc", :xmlns=>'http://purl.org/dc/terms/')
17
- t.tibetan_title(:path=>"title", :attributes=>{:language=>"tibetan"})
18
- t.english_title(:path=>"title", :attributes=>{:language=>:none})
19
- t.contributor(:index_as=>[:facetable])
20
- t.coverage
21
- t.creator
22
- t.description
23
- t.format
24
- t.identifier
25
- t.language(:index_as=>[:facetable])
26
- t.publisher
27
- t.relation
28
- t.source
29
- t.title
30
- t.abstract
31
- t.accessRights
32
- t.accrualMethod
33
- t.accrualPeriodicity
34
- t.accrualPolicy
35
- t.alternative
36
- t.audience
37
- t.available
38
- t.bibliographicCitation
39
- t.conformsTo
40
- t.contributor
41
- t.coverage
42
- t.created
43
- t.creator
44
- t.date(:index_as=>[:facetable])
45
- t.dateAccepted
46
- t.dateCopyrighted
47
- t.dateSubmitted
48
- t.description
49
- t.educationLevel
50
- t.extent
51
- t.format
52
- t.hasFormat
53
- t.hasPart
54
- t.hasVersion
55
- t.identifier
56
- t.instructionalMethod
57
- t.isFormatOf
58
- t.isPartOf
59
- t.isReferencedBy
60
- t.isReplacedBy
61
- t.isRequiredBy
62
- t.issued
63
- t.isVersionOf
64
- t.language(:index_as=>[:facetable])
65
- t.license
66
- t.mediator
67
- t.medium
68
- t.modified
69
- t.provenance
70
- t.publisher
71
- t.references
72
- t.relation
73
- t.replaces
74
- t.requires
75
- t.rights
76
- t.rightsHolder
77
- t.source
78
- t.spatial(:index_as=>[:facetable])
79
- t.subject(:index_as=>[:facetable])
80
- t.tableOfContents
81
- t.temporal
82
- t.type
83
- t.valid
84
- end
85
-
86
- def self.xml_template
87
- builder = Nokogiri::XML::Builder.new do |xml|
88
- xml.dc("xmlns"=>'http://purl.org/dc/terms/',
89
- "xmlns:dcterms"=>'http://purl.org/dc/terms/',
90
- "xmlns:xsi"=>'http://www.w3.org/2001/XMLSchema-instance') {
91
- }
92
- end
93
- return builder.doc
94
- end
95
-
96
- def prefix
97
- "#{dsid.underscore}__"
98
- end
99
-
100
-
101
- end
102
- end
@@ -1,29 +0,0 @@
1
- require 'active-fedora'
2
-
3
- class AudioRecord
4
-
5
- include ActiveFedora::Model
6
-
7
- # This seems a bit strange, since this Class might be used outside of Oral Histories.
8
- # From this perspective, it makes more sense to put triples on the containing object, not on the children...
9
-
10
- relationship "parents", :is_part_of, [nil, :oral_history]
11
- #has n, :parents, {:predicate => :is_part_of, :likely_types => [nil, :oral_history]}
12
- # OR
13
- # is_part_of [:oral_history]
14
-
15
- property "date_recorded", :date
16
- property "file_name", :string
17
- property "duration", :string
18
- property "notes", :text
19
-
20
- # This doesn't make sense when you have both compressed and uncompressed in the same object!
21
- # Probably better to rely on the file size in datastreamVersion "SIZE" attribute from Fedora anyway
22
- #property "file_size", :integer
23
-
24
- #property "restriction", :text
25
-
26
- datastream "compressed", ["audio/mpeg"], :multiple => true
27
- datastream "uncompressed", ["audio/wav", "audio/aiff"], :multiple => true
28
-
29
- end
@@ -1,5 +0,0 @@
1
- require 'active-fedora'
2
-
3
- class Image
4
- include ActiveFedora::Model
5
- end
@@ -1,36 +0,0 @@
1
- require 'active-fedora'
2
-
3
- class OralHistory < ActiveFedora::Base
4
- # Imitating DataMapper ...
5
-
6
- has_many :parts, :property=>:is_part_of
7
-
8
- # These are all the properties that don't quite fit into Qualified DC
9
- # Put them on the object itself (in the properties datastream) for now.
10
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
11
- field "alt_title", :string
12
- field "narrator", :string
13
- field "interviewer", :integer
14
- field "transcript_editor", :text
15
- field "bio", :string
16
- field "notes", :text
17
- field "hard_copy_availability", :text
18
- field "hard_copy_location", :text
19
- field "other_contributors", :string
20
- field "restrictions", :text
21
- end
22
-
23
- has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream do |m|
24
- # Default :multiple => true
25
- #
26
- # on retrieval, these will be pluralized and returned as arrays
27
- # ie. subject_entries = my_oral_history.dublin_core.subjects
28
- #
29
- # aimint to use method-missing to support calling methods like
30
- # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
31
-
32
- #field :name => "subject_heading", :string, {:xml_node => "subject", :encoding => "LCSH"}
33
- end
34
-
35
-
36
- end
@@ -1,29 +0,0 @@
1
- require 'active-fedora'
2
-
3
- class Seminar
4
-
5
- include ActiveFedora::Model
6
-
7
- # Imitating DataMapper ...
8
-
9
- relationship "parts", :is_part_of, [:seminar_audio_file], :inbound => true
10
- #has n, :parts, {:predicate => :is_part_of, :likely_types => [:seminar_audio_file], :inbound => true}
11
- # OR
12
- # has_parts [:seminar_audio_file]
13
-
14
- property "title_wylie", :text # Note: reserving title_tibetan for actual UTF-8 tibetan text
15
- property "title_english", :text
16
- property "original_media_format", :text
17
- property "original_media_number_of_units", :integer
18
- property "author_name_wylie", :text
19
- property "author_name_english", :text
20
- property "location", :string
21
- property "date_recorded", :date
22
- property "file_name", :string
23
- property "duration", :string
24
- property "file_size", :integer
25
- property "restriction", :text
26
- property "uri", :string
27
- property "notes", :text
28
-
29
- end
@@ -1,32 +0,0 @@
1
- require 'active-fedora'
2
-
3
- class SeminarAudioFile
4
-
5
- include ActiveFedora::Model
6
-
7
- # Imitating DataMapper ...
8
-
9
- relationship "parent", :is_part_of, :seminar
10
- #has n, :parents, {:predicate => :is_part_of, :likely_types => [:seminar]}
11
- # OR
12
- # is_part_of :seminar
13
-
14
- property "date_recorded", :date
15
- property "file_name", :string
16
- property "duration", :string
17
- property "uri", :string
18
- property "notes", :text
19
-
20
- # TODO: Figure out how to declare access restrictions
21
- #property "restriction", :text
22
- set_restrictions ["public", "private"]
23
-
24
- # A file_size property doesn't make sense when you have both compressed and uncompressed in the same object!
25
- # Probably better to rely on the file size in datastreamVersion "SIZE" attribute from Fedora anyway
26
- #property "file_size", :integer
27
-
28
- datastream "compressed", ["audio/mpeg"], :multiple => true
29
- datastream "uncompressed", ["audio/wav", "audio/aiff"], :multiple => true
30
-
31
-
32
- end
@@ -1,30 +0,0 @@
1
- require "active_fedora"
2
- class OralHistorySampleModel < ActiveFedora::Base
3
-
4
- #has_relationship "parts", :is_part_of, :inbound => true
5
-
6
- has_metadata :name => "properties", :type => ActiveFedora::SimpleDatastream do |m|
7
- m.field "narrator", :string
8
- m.field "interviewer", :string
9
- m.field "transcript_editor", :text
10
- m.field "bio", :string
11
- m.field "notes", :text
12
- m.field "hard_copy_availability", :text
13
- m.field "hard_copy_location", :text
14
- m.field "other_contributor", :string
15
- m.field "restrictions", :text
16
- m.field "series", :string
17
- m.field "location", :string
18
- end
19
-
20
- has_metadata :name => "dublin_core", :type => ActiveFedora::QualifiedDublinCoreDatastream
21
-
22
- has_metadata :name => "significant_passages", :type => ActiveFedora::SimpleDatastream do |m|
23
- m.field "significant_passage", :text
24
- end
25
-
26
- has_metadata :name => "sensitive_passages", :type => ActiveFedora::SimpleDatastream do |m|
27
- m.field "sensitive_passage", :text
28
- end
29
-
30
- end
@@ -1,44 +0,0 @@
1
- require "samples/marpa-dc_datastream.rb"
2
-
3
- # This is an example of an ActiveFedora Model
4
- #
5
- # Some of the datastream ids were chosen based on the Hydra modeling conventions. You don't have to follow them in your work.
6
- # ActiveFedora itself has no notion of those conventions, but we do encourage you to use them.
7
- #
8
- # The Hydra conventions encourage you to have a datastream with this dsid whose contents are descriptive metadata like MODS or Dublin Core. They especially encourage MODS.
9
- # The descMetadata dsid is a Hydra convention for a datastream with descriptive metadata contents, like MODS or Dublin Core. They especially encourage MODS.
10
- # The rightsMetadata dsid is also a convention provided by the Hydra Common Metadata "content model"
11
- #
12
- # For more info on the Hydra conventions, see the documentation on "Common Metadata content model" in https://wiki.duraspace.org/display/hydra/Hydra+content+models+and+disseminators
13
- # Note that on the wiki, "content model" is often used to refer to Fedora CModels and/or abstract/notional models. The Common Metadata content model is an example of this.
14
- # The wiki includes a page that attempts to shed some light on the question of "What is a content model?" https://wiki.duraspace.org/display/hydra/Don't+call+it+a+'content+model'!
15
- class SpecialThing < ActiveFedora::Base
16
-
17
- #
18
- # DATASTREAMS
19
- #
20
-
21
- # This declares a datastream with Datastream ID (dsid) of "descMetadata"
22
- # The descMetadata datastream is bound to the Hydra::ModsArticleDatastream class that's defined in lib/active_fedora/samples
23
- # Any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::ModsArticleDatastream class
24
- has_metadata "descMetadata", type: Hydra::ModsArticleDatastream
25
-
26
- # This declares a datastream with Datastream ID (dsid) of "rightsMetadata"
27
- # Like the descMetadata datastream, any time you load a Fedora object using an instance of SampleModel, the instance will assume its descMetadata datastream conforms to the assumptions in Hydra::RightsMetadataDatastream class
28
- has_metadata "rightsMetadata", type: Hydra::RightsMetadataDatastream
29
-
30
- # This is not part of the Hydra conventions
31
- # Adding an extra datastream called "extraMetadataForFun" that is bound to the Marpa::DcDatastream class
32
- has_metadata "extraMetadataForFun", type: Marpa::DcDatastream
33
-
34
- #
35
- # RELATIONSHIPS
36
- #
37
-
38
- # This is an example of how you can add a custom relationship to a model
39
- # This will allow you to call .derivation on instances of the model to get the _outbound_ "hasDerivation" relationship in the RELS-EXT datastream
40
- belongs_to :derivation, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasDerivation, class_name: 'SpecialThing'
41
-
42
- # This will allow you to call .inspirations on instances of the model to get a list of all of the objects that assert "hasDerivation" relationships pointing at this object
43
- has_many :inspirations, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.hasDerivation, class_name: 'SpecialThing'
44
- end