active-fedora 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/.hg/00changelog.i +0 -0
  4. data/.hg/branch +1 -0
  5. data/.hg/branch.cache +2 -0
  6. data/.hg/dirstate +0 -0
  7. data/.hg/hgrc +2 -0
  8. data/.hg/requires +2 -0
  9. data/.hg/store/00changelog.i +0 -0
  10. data/.hg/store/00manifest.i +0 -0
  11. data/.hg/store/data/.hgignore.i +0 -0
  12. data/.hg/store/data/.hgtags.i +0 -0
  13. data/.hg/store/data/_c_o_p_y_i_n_g.txt.i +0 -0
  14. data/.hg/store/data/_c_o_y_i_n_g._l_e_s_s_e_r.txt.i +0 -0
  15. data/.hg/store/data/_history.txt.i +0 -0
  16. data/.hg/store/data/_license.txt.i +0 -0
  17. data/.hg/store/data/_manifest.txt.i +0 -0
  18. data/.hg/store/data/_post_install.txt.i +0 -0
  19. data/.hg/store/data/_r_e_a_d_m_e.rdoc.i +0 -0
  20. data/.hg/store/data/_r_e_a_d_m_e.txt.i +0 -0
  21. data/.hg/store/data/_rakefile.i +0 -0
  22. data/.hg/store/data/_v_e_r_s_i_o_n.i +0 -0
  23. data/.hg/store/data/active-fedora.gemspec.i +0 -0
  24. data/.hg/store/data/active__fedora/_history.txt.i +0 -0
  25. data/.hg/store/data/active__fedora/_manifest.txt.i +0 -0
  26. data/.hg/store/data/active__fedora/_post_install.txt.i +0 -0
  27. data/.hg/store/data/active__fedora/_r_e_a_d_m_e.rdoc.i +0 -0
  28. data/.hg/store/data/active__fedora/_rakefile.i +0 -0
  29. data/.hg/store/data/active__fedora/lib/active__fedora.rb.i +0 -0
  30. data/.hg/store/data/active__fedora/script/console.i +0 -0
  31. data/.hg/store/data/active__fedora/script/destroy.i +0 -0
  32. data/.hg/store/data/active__fedora/script/generate.i +0 -0
  33. data/.hg/store/data/active__fedora/spec/active__fedora__spec.rb.i +0 -0
  34. data/.hg/store/data/active__fedora/spec/spec__helper.rb.i +0 -0
  35. data/.hg/store/data/config/fedora.yml.i +0 -0
  36. data/.hg/store/data/config/solr__mappings.yml.i +0 -0
  37. data/.hg/store/data/config/solr__mappings__af__0.1.yml.i +0 -0
  38. data/.hg/store/data/config/solr__mappings__bl__2.4.yml.i +0 -0
  39. data/.hg/store/data/lib/active-fedora.rb.i +0 -0
  40. data/.hg/store/data/lib/active__fedora.rb.i +0 -0
  41. data/.hg/store/data/lib/active__fedora/base.rb.i +0 -0
  42. data/.hg/store/data/lib/active__fedora/content__model.rb.i +0 -0
  43. data/.hg/store/data/lib/active__fedora/datastream.rb.i +0 -0
  44. data/.hg/store/data/lib/active__fedora/fedora__object.rb.i +0 -0
  45. data/.hg/store/data/lib/active__fedora/metadata__datastream.rb.i +0 -0
  46. data/.hg/store/data/lib/active__fedora/model.rb.i +0 -0
  47. data/.hg/store/data/lib/active__fedora/property.rb.i +0 -0
  48. data/.hg/store/data/lib/active__fedora/qualified__dublin__core__datastream.rb.i +0 -0
  49. data/.hg/store/data/lib/active__fedora/relationship.rb.i +0 -0
  50. data/.hg/store/data/lib/active__fedora/rels__ext__datastream.rb.i +0 -0
  51. data/.hg/store/data/lib/active__fedora/semantic__node.rb.i +0 -0
  52. data/.hg/store/data/lib/active__fedora/solr__mapper.rb.i +0 -0
  53. data/.hg/store/data/lib/active__fedora/solr__service.rb.i +0 -0
  54. data/.hg/store/data/lib/fedora/base.rb.i +0 -0
  55. data/.hg/store/data/lib/fedora/connection.rb.i +0 -0
  56. data/.hg/store/data/lib/fedora/datastream.rb.i +0 -0
  57. data/.hg/store/data/lib/fedora/fedora__object.rb.i +0 -0
  58. data/.hg/store/data/lib/fedora/formats.rb.i +0 -0
  59. data/.hg/store/data/lib/fedora/generic__search.rb.i +0 -0
  60. data/.hg/store/data/lib/fedora/repository.rb.i +0 -0
  61. data/.hg/store/data/lib/ruby-fedora.rb.i +0 -0
  62. data/.hg/store/data/lib/util/class__level__inheritable__attributes.rb.i +0 -0
  63. data/.hg/store/data/script/console.i +0 -0
  64. data/.hg/store/data/script/destroy.i +0 -0
  65. data/.hg/store/data/script/generate.i +0 -0
  66. data/.hg/store/data/solr/config/schema-1.5.xml.i +0 -0
  67. data/.hg/store/data/solr/config/schema.xml.i +0 -0
  68. data/.hg/store/data/solr/config/solrconfig-1.5.xml.i +0 -0
  69. data/.hg/store/data/spec/fixtures/changeme155.xml.i +0 -0
  70. data/.hg/store/data/spec/fixtures/dino.jpg.i +0 -0
  71. data/.hg/store/data/spec/fixtures/minivan.jpg.d +0 -0
  72. data/.hg/store/data/spec/fixtures/minivan.jpg.i +0 -0
  73. data/.hg/store/data/spec/fixtures/test__12.foxml.xml.i +0 -0
  74. data/.hg/store/data/spec/integration/active__fedora/base__spec.rb.i +0 -0
  75. data/.hg/store/data/spec/integration/active__fedora/datastream__spec.rb.i +0 -0
  76. data/.hg/store/data/spec/integration/active__fedora/fedora__object__spec.rb.i +0 -0
  77. data/.hg/store/data/spec/integration/active__fedora/full__featured__model__spec.rb.i +0 -0
  78. data/.hg/store/data/spec/integration/active__fedora/model__spec.rb.i +0 -0
  79. data/.hg/store/data/spec/integration/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  80. data/.hg/store/data/spec/integration/active__fedora/semantic__node__spec.rb.i +0 -0
  81. data/.hg/store/data/spec/integration/base__file__management__spec.rb.i +0 -0
  82. data/.hg/store/data/spec/integration/base__spec.rb.i +0 -0
  83. data/.hg/store/data/spec/integration/bug__spec.rb.i +0 -0
  84. data/.hg/store/data/spec/integration/datastream__spec.rb.i +0 -0
  85. data/.hg/store/data/spec/integration/datastreams__crud__spec.rb.i +0 -0
  86. data/.hg/store/data/spec/integration/fedora__object__spec.rb.i +0 -0
  87. data/.hg/store/data/spec/integration/full__featured__model__spec.rb.i +0 -0
  88. data/.hg/store/data/spec/integration/model__spec.rb.i +0 -0
  89. data/.hg/store/data/spec/integration/rels__ext__datastream__spec.rb.i +0 -0
  90. data/.hg/store/data/spec/integration/repository__spec.rb.i +0 -0
  91. data/.hg/store/data/spec/integration/rf__fedora__object__spec.rb.i +0 -0
  92. data/.hg/store/data/spec/integration/semantic__node__spec.rb.i +0 -0
  93. data/.hg/store/data/spec/integration/solr__service__spec.rb.i +0 -0
  94. data/.hg/store/data/spec/samples/models/audio__record.rb.i +0 -0
  95. data/.hg/store/data/spec/samples/models/image.rb.i +0 -0
  96. data/.hg/store/data/spec/samples/models/oral__history.rb.i +0 -0
  97. data/.hg/store/data/spec/samples/models/seminar.rb.i +0 -0
  98. data/.hg/store/data/spec/samples/models/seminar__audio__file.rb.i +0 -0
  99. data/.hg/store/data/spec/samples/oh__qdc.xml.i +0 -0
  100. data/.hg/store/data/spec/samples/oral__history.rb.i +0 -0
  101. data/.hg/store/data/spec/samples/oral__history__sample.xml.i +0 -0
  102. data/.hg/store/data/spec/samples/oral__history__sample__model.rb.i +0 -0
  103. data/.hg/store/data/spec/samples/oral__history__xml.xml.i +0 -0
  104. data/.hg/store/data/spec/spec.opts.i +0 -0
  105. data/.hg/store/data/spec/spec__helper.rb.i +0 -0
  106. data/.hg/store/data/spec/unit/active__fedora/base__cma__spec.rb.i +0 -0
  107. data/.hg/store/data/spec/unit/active__fedora/base__extra__spec.rb.i +0 -0
  108. data/.hg/store/data/spec/unit/active__fedora/base__spec.rb.i +0 -0
  109. data/.hg/store/data/spec/unit/active__fedora/content__model__spec.rb.i +0 -0
  110. data/.hg/store/data/spec/unit/active__fedora/datastream__spec.rb.i +0 -0
  111. data/.hg/store/data/spec/unit/active__fedora/inheritance__spec.rb.i +0 -0
  112. data/.hg/store/data/spec/unit/active__fedora/metadata__datastream__spec.rb.i +0 -0
  113. data/.hg/store/data/spec/unit/active__fedora/model__spec.rb.i +0 -0
  114. data/.hg/store/data/spec/unit/active__fedora/property__spec.rb.i +0 -0
  115. data/.hg/store/data/spec/unit/active__fedora/qualified__dublin__core__datastream__spec.rb.i +0 -0
  116. data/.hg/store/data/spec/unit/active__fedora/relationship__spec.rb.i +0 -0
  117. data/.hg/store/data/spec/unit/active__fedora/rels__ext__datastream__spec.rb.i +0 -0
  118. data/.hg/store/data/spec/unit/active__fedora/semantic__node__spec.rb.i +0 -0
  119. data/.hg/store/data/spec/unit/active__fedora/solr__service__spec.rb.i +0 -0
  120. data/.hg/store/data/spec/unit/active__fedora__spec.rb.i +0 -0
  121. data/.hg/store/data/spec/unit/base__cma__spec.rb.i +0 -0
  122. data/.hg/store/data/spec/unit/base__datastream__management__spec.rb.i +0 -0
  123. data/.hg/store/data/spec/unit/base__extra__spec.rb.i +0 -0
  124. data/.hg/store/data/spec/unit/base__file__management__spec.rb.i +0 -0
  125. data/.hg/store/data/spec/unit/base__loader__spec.rb.i +0 -0
  126. data/.hg/store/data/spec/unit/base__spec.rb.i +0 -0
  127. data/.hg/store/data/spec/unit/connection__spec.rb.i +0 -0
  128. data/.hg/store/data/spec/unit/content__model__spec.rb.i +0 -0
  129. data/.hg/store/data/spec/unit/datastream__concurrency__spec.rb.i +0 -0
  130. data/.hg/store/data/spec/unit/datastream__spec.rb.i +0 -0
  131. data/.hg/store/data/spec/unit/fedora__object__spec.rb.i +0 -0
  132. data/.hg/store/data/spec/unit/inheritance__spec.rb.i +0 -0
  133. data/.hg/store/data/spec/unit/metadata__datastream__spec.rb.i +0 -0
  134. data/.hg/store/data/spec/unit/model__spec.rb.i +0 -0
  135. data/.hg/store/data/spec/unit/property__spec.rb.i +0 -0
  136. data/.hg/store/data/spec/unit/qualified__dublin__core__datastream__spec.rb.i +0 -0
  137. data/.hg/store/data/spec/unit/relationship__spec.rb.i +0 -0
  138. data/.hg/store/data/spec/unit/rels__ext__datastream__spec.rb.i +0 -0
  139. data/.hg/store/data/spec/unit/repository__spec.rb.i +0 -0
  140. data/.hg/store/data/spec/unit/rf__datastream__spec.rb.i +0 -0
  141. data/.hg/store/data/spec/unit/semantic__node__spec.rb.i +0 -0
  142. data/.hg/store/data/spec/unit/solr__config__options__spec.rb.i +0 -0
  143. data/.hg/store/data/spec/unit/solr__mapper__spec.rb.i +0 -0
  144. data/.hg/store/data/spec/unit/solr__service__spec.rb.i +0 -0
  145. data/.hg/store/data/tasks/rspec.rake.i +0 -0
  146. data/.hg/store/undo +0 -0
  147. data/.hg/undo.branch +1 -0
  148. data/.hg/undo.dirstate +0 -0
  149. data/.hgignore +7 -0
  150. data/.hgtags +14 -0
  151. data/COPYING.txt +674 -0
  152. data/COYING.LESSER.txt +165 -0
  153. data/History.txt +34 -0
  154. data/LICENSE +20 -0
  155. data/License.txt +58 -0
  156. data/Manifest.txt +1 -1
  157. data/README.rdoc +13 -54
  158. data/README.txt +59 -0
  159. data/Rakefile +35 -0
  160. data/VERSION +1 -0
  161. data/active-fedora.gemspec +359 -0
  162. data/config/fedora.yml +16 -0
  163. data/config/solr_mappings.yml +14 -0
  164. data/config/solr_mappings_af_0.1.yml +16 -0
  165. data/config/solr_mappings_bl_2.4.yml +14 -0
  166. data/lib/active_fedora.rb +66 -6
  167. data/lib/active_fedora/base.rb +59 -23
  168. data/lib/active_fedora/datastream.rb +1 -1
  169. data/lib/active_fedora/metadata_datastream.rb +14 -7
  170. data/lib/active_fedora/model.rb +4 -4
  171. data/lib/active_fedora/rels_ext_datastream.rb +1 -1
  172. data/lib/active_fedora/semantic_node.rb +4 -3
  173. data/lib/active_fedora/solr_mapper.rb +17 -0
  174. data/lib/active_fedora/solr_service.rb +44 -2
  175. data/lib/fedora/base.rb +38 -0
  176. data/lib/fedora/connection.rb +210 -0
  177. data/lib/fedora/datastream.rb +56 -0
  178. data/lib/fedora/fedora_object.rb +161 -0
  179. data/lib/fedora/formats.rb +30 -0
  180. data/lib/fedora/generic_search.rb +71 -0
  181. data/lib/fedora/repository.rb +287 -0
  182. data/lib/ruby-fedora.rb +20 -0
  183. data/lib/util/class_level_inheritable_attributes.rb +23 -0
  184. data/script/console +15 -0
  185. data/script/destroy +14 -0
  186. data/script/generate +14 -0
  187. data/solr/config/schema-1.5.xml +468 -0
  188. data/solr/config/schema.xml +174 -212
  189. data/solr/config/solrconfig-1.5.xml +1069 -0
  190. data/spec/active_fedora_spec.rb +7 -0
  191. data/spec/fixtures/changeme155.xml +255 -0
  192. data/spec/fixtures/dino.jpg +0 -0
  193. data/spec/fixtures/minivan.jpg +0 -0
  194. data/spec/fixtures/test_12.foxml.xml +121 -0
  195. data/spec/integration/base_file_management_spec.rb +20 -0
  196. data/spec/integration/base_spec.rb +196 -0
  197. data/spec/integration/bug_spec.rb +57 -0
  198. data/spec/integration/datastream_spec.rb +60 -0
  199. data/spec/integration/datastreams_crud_spec.rb +208 -0
  200. data/spec/integration/fedora_object_spec.rb +77 -0
  201. data/spec/integration/full_featured_model_spec.rb +207 -0
  202. data/spec/integration/model_spec.rb +54 -0
  203. data/spec/integration/rels_ext_datastream_spec.rb +67 -0
  204. data/spec/integration/repository_spec.rb +297 -0
  205. data/spec/integration/rf_fedora_object_spec.rb +95 -0
  206. data/spec/integration/semantic_node_spec.rb +95 -0
  207. data/spec/integration/solr_service_spec.rb +33 -0
  208. data/spec/samples/models/audio_record.rb +29 -0
  209. data/spec/samples/models/image.rb +5 -0
  210. data/spec/samples/models/oral_history.rb +50 -0
  211. data/spec/samples/models/seminar.rb +29 -0
  212. data/spec/samples/models/seminar_audio_file.rb +34 -0
  213. data/spec/samples/oh_qdc.xml +32 -0
  214. data/spec/samples/oral_history_sample.xml +38 -0
  215. data/spec/samples/oral_history_sample_model.rb +39 -0
  216. data/spec/samples/oral_history_xml.xml +35 -0
  217. data/spec/spec.opts +5 -0
  218. data/spec/spec_helper.rb +41 -0
  219. data/spec/unit/active_fedora_spec.rb +15 -0
  220. data/spec/unit/base_cma_spec.rb +25 -0
  221. data/spec/unit/base_datastream_management_spec.rb +119 -0
  222. data/spec/unit/base_extra_spec.rb +108 -0
  223. data/spec/unit/base_file_management_spec.rb +90 -0
  224. data/spec/unit/base_loader_spec.rb +43 -0
  225. data/spec/unit/base_spec.rb +584 -0
  226. data/spec/unit/connection_spec.rb +25 -0
  227. data/spec/unit/content_model_spec.rb +51 -0
  228. data/spec/unit/datastream_concurrency_spec.rb +59 -0
  229. data/spec/unit/datastream_spec.rb +85 -0
  230. data/spec/unit/fedora_object_spec.rb +66 -0
  231. data/spec/unit/inheritance_spec.rb +46 -0
  232. data/spec/unit/metadata_datastream_spec.rb +290 -0
  233. data/spec/unit/model_spec.rb +186 -0
  234. data/spec/unit/property_spec.rb +50 -0
  235. data/spec/unit/qualified_dublin_core_datastream_spec.rb +177 -0
  236. data/spec/unit/relationship_spec.rb +77 -0
  237. data/spec/unit/rels_ext_datastream_spec.rb +99 -0
  238. data/spec/unit/repository_spec.rb +136 -0
  239. data/spec/unit/rf_datastream_spec.rb +49 -0
  240. data/spec/unit/semantic_node_spec.rb +354 -0
  241. data/spec/unit/solr_config_options_spec.rb +98 -0
  242. data/spec/unit/solr_mapper_spec.rb +31 -0
  243. data/spec/unit/solr_service_spec.rb +83 -0
  244. data/tasks/hoe.rake +0 -0
  245. data/tasks/rspec.rake +29 -0
  246. metadata +373 -55
@@ -0,0 +1,95 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'active_fedora'
4
+
5
+ describe ActiveFedora::SemanticNode do
6
+
7
+ before(:all) do
8
+ class SpecNode
9
+ include ActiveFedora::SemanticNode
10
+ has_relationship "collection_members", :has_collection_member
11
+ end
12
+ @node = SpecNode.new
13
+ class SpecModel < ActiveFedora::Base
14
+ has_relationship("parts", :is_part_of, :inbound => true)
15
+ has_relationship("containers", :is_member_of)
16
+ end
17
+
18
+ @test_object = SpecModel.new
19
+ @test_object.save
20
+
21
+ @part1 = ActiveFedora::Base.new()
22
+ @part1.add_relationship(:is_part_of, @test_object)
23
+ @part1.save
24
+ @part2 = ActiveFedora::Base.new()
25
+ @part2.add_relationship(:is_part_of, @test_object)
26
+ @part2.save
27
+
28
+
29
+ @container1 = ActiveFedora::Base.new()
30
+ @container1.save
31
+ @container2 = ActiveFedora::Base.new()
32
+ @container2.save
33
+
34
+ @test_object.add_relationship(:is_member_of, @container1)
35
+ @test_object.add_relationship(:is_member_of, @container2)
36
+ @test_object.save
37
+ end
38
+
39
+ after(:all) do
40
+ @part1.delete
41
+ @part2.delete
42
+ @container1.delete
43
+ @container2.delete
44
+ @test_object.delete
45
+
46
+ Object.send(:remove_const, :SpecModel)
47
+
48
+ end
49
+
50
+ describe '#has_relationship' do
51
+ it "should create useable finders" do
52
+ spec_node = SpecNode.new
53
+ spec_node.collection_members.should == []
54
+ rel = ActiveFedora::Relationship.new(:subject => :self, :predicate => :has_collection_member, :object => @test_object.pid)
55
+ spec_node.add_relationship(rel)
56
+ collection_members = spec_node.collection_members
57
+ collection_members.length.should == 1
58
+ collection_members.first.pid.should == @test_object.pid
59
+ collection_members.first.class.should == @test_object.class
60
+ end
61
+ it "should create useable inbound finders if :inbound is set to true"
62
+ end
63
+
64
+ describe "inbound relationship finders" do
65
+ it "should return an array of Base objects" do
66
+ parts = @test_object.parts
67
+ parts.each do |part|
68
+ part.should be_kind_of(ActiveFedora::Base)
69
+ end
70
+ end
71
+ it "_ids should return an array of pids" do
72
+ ids = @test_object.parts_ids
73
+ ids.each do |id|
74
+ id.should satisfy {|id| id == @part1.pid || @part2.pid}
75
+ end
76
+ end
77
+ end
78
+
79
+ describe "outbound relationship finders" do
80
+ it "should return an array of Base objects" do
81
+ containers = @test_object.containers
82
+ containers.length.should > 0
83
+ containers.each do |container|
84
+ container.should be_kind_of(ActiveFedora::Base)
85
+ end
86
+ end
87
+ it "_ids should return an array of pids" do
88
+ ids = @test_object.containers_ids
89
+ ids.each do |id|
90
+ id.should satisfy {|id| id == @container1.pid || @container2.pid}
91
+ end
92
+ end
93
+ end
94
+
95
+ end
@@ -0,0 +1,33 @@
1
+ require File.join( File.dirname(__FILE__), "../spec_helper" )
2
+
3
+ require 'active_fedora'
4
+
5
+ include ActiveFedora
6
+
7
+
8
+ describe ActiveFedora::SolrService do
9
+ describe "#reify_solr_results" do
10
+ before(:all) do
11
+ class FooObject < ActiveFedora::Base
12
+ end
13
+ @test_object = ActiveFedora::Base.new
14
+ @foo_object = FooObject.new
15
+ @test_object.save
16
+ @foo_object.save
17
+ end
18
+ after(:all) do
19
+ @test_object.delete
20
+ @foo_object.delete
21
+ end
22
+ it "should return an array of objects that are of the class stored in active_fedora_model_s" do
23
+ query = "id\:#{SolrService.escape_uri_for_query(@test_object.pid)} OR id\:#{SolrService.escape_uri_for_query(@foo_object.pid)}"
24
+ solr_result = SolrService.instance.conn.query(query)
25
+ result = ActiveFedora::SolrService.reify_solr_results(solr_result)
26
+ result.length.should == 2
27
+ result.each do |r|
28
+ (r.class == ActiveFedora::Base || r.class == FooObject).should be_true
29
+ end
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,5 @@
1
+ require 'active-fedora'
2
+
3
+ class Image
4
+ include ActiveFedora::Model
5
+ end
@@ -0,0 +1,50 @@
1
+ require 'active-fedora'
2
+
3
+ include ActiveFedora
4
+ include SemanticNode
5
+
6
+ class OralHistory < ActiveFedora::Base
7
+ include Model
8
+
9
+
10
+ # Imitating DataMapper ...
11
+
12
+ has_relationship "parts", :is_part_of, :inbound => true
13
+
14
+ # These are all the properties that don't quite fit into Qualified DC
15
+ # Put them on the object itself (in the properties datastream) for now.
16
+ has_metadata :name => "properties", :type => MetadataDatastream do |m|
17
+ field "alt_title", :string
18
+ field "narrator", :string
19
+ field "interviewer", :integer
20
+ field "transcript_editor", :text
21
+ field "bio", :string
22
+ field "notes", :text
23
+ field "hard_copy_availability", :text
24
+ field "hard_copy_location", :text
25
+ field "other_contributors", :string
26
+ field "restrictions", :text
27
+ end
28
+
29
+ has_metadata :name => "dublin_core", :type => QualifiedDublinCoreDatastream do |m|
30
+ # Default :multiple => true
31
+ #
32
+ # on retrieval, these will be pluralized and returned as arrays
33
+ # ie. subject_entries = my_oral_history.dublin_core.subjects
34
+ #
35
+ # aimint to use method-missing to support calling methods like
36
+ # my_oral_history.subjects OR my_oral_history.titles OR EVEN my_oral_history.title whenever possible
37
+
38
+ #field :name => "subject_heading", :string, {:xml_node => "subject", :encoding => "LCSH"}
39
+ end
40
+
41
+ has_metadata :name => "significant_passages" do |m|
42
+ field "significant_passage", :text
43
+ end
44
+
45
+ has_metadata :name => "sensitive_passages" do |m|
46
+ field "sensitive_passage", :text
47
+ end
48
+
49
+
50
+ end
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,34 @@
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
+ #has_metadata "dublin_core", :type => ActiveFedora::MetadataDatastream::QualifiedDublinCore
32
+
33
+
34
+ end
@@ -0,0 +1,32 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <wrapper xmlns:foxml="info:fedora/fedora-system:def/foxml#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
4
+
5
+ <foxml:datastream ID='dublin_core' STATE='A' CONTROL_GROUP='X' VERSIONABLE='true'>
6
+ <foxml:datastreamVersion SIZE='1726' ID='dublin_core.0' MIMETYPE='text/xml' LABEL='' CREATED='2009-01-15T17:55:49.277Z'>
7
+ <foxml:xmlContent>
8
+ <dc xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:dcterms='http://purl.org/dc/terms/'>
9
+ <dcterms:type xsi:type='DCMITYPE'>sound</dcterms:type>
10
+ <dcterms:medium>medium</dcterms:medium>
11
+ <dcterms:rights>rights</dcterms:rights>
12
+ <dcterms:language>English</dcterms:language>
13
+ <dcterms:temporal>tmp</dcterms:temporal>
14
+ <dcterms:subject>kw1</dcterms:subject>
15
+ <dcterms:subject>kw2</dcterms:subject>
16
+ <dcterms:creator>creator</dcterms:creator>
17
+ <dcterms:title>title</dcterms:title>
18
+ <dcterms:extent>extent</dcterms:extent>
19
+ <dcterms:format>audio/x-wav</dcterms:format>
20
+ <dcterms:subject xsi:type='LCSH'>sh1</dcterms:subject>
21
+ <dcterms:subject xsi:type='LCSH'>sh2</dcterms:subject>
22
+ <dcterms:spatial>sp1</dcterms:spatial>
23
+ <dcterms:spatial>sp2</dcterms:spatial>
24
+ <dcterms:publisher>jwa</dcterms:publisher>
25
+ <dcterms:alternative>alt</dcterms:alternative>
26
+ <dcterms:description>desc</dcterms:description>
27
+ <dcterms:date>datestr</dcterms:date>
28
+ </dc>
29
+ </foxml:xmlContent>
30
+ </foxml:datastreamVersion>
31
+ </foxml:datastream>
32
+ </wrapper>
@@ -0,0 +1,38 @@
1
+ <xml>
2
+ <fields>
3
+ <system_create_date>2008-07-02T05:09:42.015Z</system_create_date>
4
+ <system_modified_date>2008-09-29T21:21:52.892Z</system_modified_date>
5
+ <active_fedora_model_field>OralHistory</active_fedora_model_field>
6
+ <id>changeme:14527</id>
7
+ <subject_heading>subject heading</subject_heading>
8
+ <type>type</type>
9
+ <rights>rights</rights>
10
+ <publisher>publisher</publisher>
11
+ <creation_date>creation date</creation_date>
12
+ <identifier>jwa:sample_pid</identifier>
13
+ <format>format</format>
14
+ <extent>extent</extent>
15
+ <language>language</language>
16
+ <description>description</description>
17
+ <title>title</title>
18
+ <medium>medium</medium>
19
+ <spatial_coverage>spatial coverage</spatial_coverage>
20
+ <alt_title>alt_title</alt_title>
21
+ <temporal_coverage>temporal coverage</temporal_coverage>
22
+ <subject>subject</subject>
23
+ <creator>creator</creator>
24
+ <abstract>abstract</abstract>
25
+ <other_contributors>Sally Ride</other_contributors>
26
+ <transcript_editor>Transcript Editor</transcript_editor>
27
+ <restrictions>None</restrictions>
28
+ <bio>Biographic info</bio>
29
+ <series>My Series</series>
30
+ <notes>My Note</notes>
31
+ <location>location</location>
32
+ <hard_copy_availability>Yes</hard_copy_availability>
33
+ <narrator>Narrator</narrator>
34
+ <hard_copy_location>Archives</hard_copy_location>
35
+ <interviewer>Interviewer</interviewer>
36
+ </fields>
37
+ <content/>
38
+ </xml>
@@ -0,0 +1,39 @@
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::MetadataDatastream 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 do |m|
21
+ m.field "creation_date", :date, :xml_node => "date"
22
+ m.field "abstract", :text, :xml_node => "abstract"
23
+ m.field "rights", :text, :xml_node => "rights"
24
+ m.field "subject_heading", :string, :xml_node => "subject", :encoding => "LCSH"
25
+ m.field "spatial_coverage", :string, :xml_node => "spatial", :encoding => "TGN"
26
+ m.field "temporal_coverage", :string, :xml_node => "temporal", :encoding => "Period"
27
+ m.field "type", :string, :xml_node => "type", :encoding => "DCMITYPE"
28
+ m.field "alt_title", :string, :xml_node => "alternative"
29
+ end
30
+
31
+ has_metadata :name => "significant_passages", :type => ActiveFedora::MetadataDatastream do |m|
32
+ m.field "significant_passage", :text
33
+ end
34
+
35
+ has_metadata :name => "sensitive_passages", :type => ActiveFedora::MetadataDatastream do |m|
36
+ m.field "sensitive_passage", :text
37
+ end
38
+
39
+ end
@@ -0,0 +1,35 @@
1
+ <doc>
2
+ <field name="system_create_date">2008-07-02T05:09:42.015Z</field>
3
+ <field name="system_modified_date">2008-09-29T21:21:52.892Z</field>
4
+ <field name="active_fedora_model_field">OralHistory</field>
5
+ <field name="id">changeme:13919</field>
6
+ <field name="subject_heading_field">subject heading</field>
7
+ <field name="type_field">type</field>
8
+ <field name="rights_text">rights</field>
9
+ <field name="publisher_field">publisher</field>
10
+ <field name="creation_date">creation date</field>
11
+ <field name="identifier_field">jwa:sample_pid</field>
12
+ <field name="format_field">format</field>
13
+ <field name="extent_field">extent</field>
14
+ <field name="language_field">language</field>
15
+ <field name="description_field">description</field>
16
+ <field name="title_field">title</field>
17
+ <field name="medium_field">medium</field>
18
+ <field name="spatial_coverage_field">spatial coverage</field>
19
+ <field name="alt_title_field">alt_title</field>
20
+ <field name="temporal_coverage_field">temporal coverage</field>
21
+ <field name="subject_field">subject</field>
22
+ <field name="creator_field">creator</field>
23
+ <field name="abstract_text">abstract</field>
24
+ <field name="other_contributors_field">Sally Ride</field>
25
+ <field name="transcript_editor_text">Transcript Editor</field>
26
+ <field name="restrictions_text">None</field>
27
+ <field name="bio_field">Biographic info</field>
28
+ <field name="series_field">My Series</field>
29
+ <field name="notes_text">My Note</field>
30
+ <field name="location_field">location</field>
31
+ <field name="hard_copy_availability_text">Yes</field>
32
+ <field name="narrator_field">Narrator</field>
33
+ <field name="hard_copy_location_text">Archives</field>
34
+ <field name="interviewer_integer">Interviewer</field>
35
+ </doc>
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
5
+
@@ -0,0 +1,41 @@
1
+ require 'rubygems'
2
+ gem 'mocha'
3
+ require 'ruby-debug'
4
+ require 'mocha'
5
+ require 'ruby-fedora'
6
+ begin
7
+ require 'spec'
8
+ rescue LoadError
9
+ gem 'rspec'
10
+ require 'spec'
11
+ end
12
+
13
+
14
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
15
+ Dir[File.join(File.dirname(__FILE__)+'/../lib/')+'**/*.rb'].each{|x| require x}
16
+ $VERBOSE=nil
17
+
18
+ # This loads the Fedora and Solr config info from /config/fedora.yml
19
+ # You can load it from a different location by passing a file path as an argument.
20
+ ActiveFedora.init(File.join(File.dirname(__FILE__), "..", "config", "fedora.yml"))
21
+
22
+ Spec::Runner.configure do |config|
23
+ config.mock_with :mocha
24
+ end
25
+
26
+ #TEST_FEDORA_URL = 'http://fedoraAdmin:fedoraAdmin@127.0.0.1:8080/fedora'
27
+ #TEST_SOLR_URL = 'http://127.0.0.1:8080/solr'
28
+ #Fedora::Repository.register(TEST_FEDORA_URL)
29
+ #ActiveFedora::SolrService.register(TEST_SOLR_URL)
30
+
31
+
32
+
33
+ def fixture(file)
34
+ File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
35
+ end
36
+
37
+ def validate_xml(xml, expected_root)
38
+ root = REXML::Document.new(xml).root
39
+ root.should_not be_nil
40
+ root.name.should == expected_root
41
+ end