active-fedora 10.2.1 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +6 -7
  4. data/.rubocop_todo.yml +55 -0
  5. data/active-fedora.gemspec +6 -10
  6. data/lib/active_fedora/aggregation/list_source.rb +2 -0
  7. data/lib/active_fedora/associations/association_scope.rb +1 -1
  8. data/lib/active_fedora/associations/builder/aggregation.rb +1 -1
  9. data/lib/active_fedora/associations/builder/association.rb +1 -1
  10. data/lib/active_fedora/associations/builder/orders.rb +11 -3
  11. data/lib/active_fedora/associations/collection_association.rb +3 -3
  12. data/lib/active_fedora/associations/contained_finder.rb +2 -2
  13. data/lib/active_fedora/associations/has_many_association.rb +2 -2
  14. data/lib/active_fedora/associations/orders_association.rb +4 -0
  15. data/lib/active_fedora/associations/rdf.rb +2 -0
  16. data/lib/active_fedora/attribute_assignment.rb +0 -1
  17. data/lib/active_fedora/attribute_methods/dirty.rb +1 -1
  18. data/lib/active_fedora/attributes.rb +1 -1
  19. data/lib/active_fedora/base.rb +4 -8
  20. data/lib/active_fedora/change_set.rb +6 -2
  21. data/lib/active_fedora/core.rb +22 -27
  22. data/lib/active_fedora/fedora_attributes.rb +1 -1
  23. data/lib/active_fedora/file/streaming.rb +1 -1
  24. data/lib/active_fedora/indexing.rb +0 -17
  25. data/lib/active_fedora/indexing_service.rb +0 -9
  26. data/lib/active_fedora/loadable_from_json.rb +12 -1
  27. data/lib/active_fedora/nested_attributes.rb +2 -2
  28. data/lib/active_fedora/orders/list_node.rb +2 -2
  29. data/lib/active_fedora/orders/ordered_list.rb +7 -3
  30. data/lib/active_fedora/orders/target_proxy.rb +4 -0
  31. data/lib/active_fedora/querying.rb +1 -1
  32. data/lib/active_fedora/railtie.rb +2 -2
  33. data/lib/active_fedora/rdf/persistence.rb +1 -0
  34. data/lib/active_fedora/rdf.rb +0 -1
  35. data/lib/active_fedora/relation/delegation.rb +4 -0
  36. data/lib/active_fedora/solr_hit.rb +0 -13
  37. data/lib/active_fedora/solr_query_builder.rb +17 -13
  38. data/lib/active_fedora/version.rb +1 -1
  39. data/lib/active_fedora.rb +0 -12
  40. data/lib/generators/active_fedora/model/model_generator.rb +1 -1
  41. data/lib/generators/active_fedora/model/templates/model.rb.erb +4 -4
  42. data/lib/tasks/active_fedora_dev.rake +1 -1
  43. data/spec/config_helper.rb +1 -1
  44. data/spec/integration/associations_spec.rb +23 -24
  45. data/spec/integration/attached_files_spec.rb +18 -8
  46. data/spec/integration/attributes_spec.rb +12 -16
  47. data/spec/integration/autosave_association_spec.rb +6 -6
  48. data/spec/integration/base_spec.rb +3 -3
  49. data/spec/integration/basic_contains_association_spec.rb +1 -1
  50. data/spec/integration/clean_connection_spec.rb +1 -1
  51. data/spec/integration/collection_association_spec.rb +2 -5
  52. data/spec/integration/date_time_properties_spec.rb +1 -17
  53. data/spec/integration/direct_container_spec.rb +12 -12
  54. data/spec/integration/directly_contains_one_association_spec.rb +11 -13
  55. data/spec/integration/fedora_solr_sync_spec.rb +2 -2
  56. data/spec/integration/file_fixity_spec.rb +6 -8
  57. data/spec/integration/file_spec.rb +32 -34
  58. data/spec/integration/has_and_belongs_to_many_associations_spec.rb +5 -5
  59. data/spec/integration/has_many_associations_spec.rb +9 -11
  60. data/spec/integration/indexing_spec.rb +2 -2
  61. data/spec/integration/indirect_container_spec.rb +11 -12
  62. data/spec/integration/json_serialization_spec.rb +4 -4
  63. data/spec/integration/query_result_builder_spec.rb +9 -21
  64. data/spec/integration/rdf_nested_attributes_spec.rb +7 -7
  65. data/spec/integration/relation_delegation_spec.rb +8 -10
  66. data/spec/integration/relation_spec.rb +13 -16
  67. data/spec/integration/scoped_query_spec.rb +3 -3
  68. data/spec/integration/solr_hit_spec.rb +4 -15
  69. data/spec/integration/versionable_spec.rb +73 -327
  70. data/spec/integration/with_metadata_spec.rb +1 -1
  71. data/spec/spec_helper.rb +52 -10
  72. data/spec/unit/active_fedora_spec.rb +1 -1
  73. data/spec/unit/aggregation/list_source_spec.rb +37 -37
  74. data/spec/unit/aggregation/ordered_reader_spec.rb +4 -4
  75. data/spec/unit/association_hash_spec.rb +17 -31
  76. data/spec/unit/attached_files_spec.rb +35 -32
  77. data/spec/unit/attributes_spec.rb +25 -25
  78. data/spec/unit/base_active_model_spec.rb +8 -8
  79. data/spec/unit/base_cma_spec.rb +1 -1
  80. data/spec/unit/base_extra_spec.rb +7 -22
  81. data/spec/unit/base_spec.rb +16 -23
  82. data/spec/unit/callback_spec.rb +2 -2
  83. data/spec/unit/change_set_spec.rb +5 -5
  84. data/spec/unit/checksum_spec.rb +2 -2
  85. data/spec/unit/code_configurator_spec.rb +1 -1
  86. data/spec/unit/core_spec.rb +62 -26
  87. data/spec/unit/default_model_mapper_spec.rb +6 -6
  88. data/spec/unit/fedora_spec.rb +3 -4
  89. data/spec/unit/file_configurator_spec.rb +96 -96
  90. data/spec/unit/file_path_builder_spec.rb +1 -1
  91. data/spec/unit/file_spec.rb +61 -61
  92. data/spec/unit/files_hash_spec.rb +9 -9
  93. data/spec/unit/filter_spec.rb +3 -3
  94. data/spec/unit/finder_methods_spec.rb +3 -3
  95. data/spec/unit/forbidden_attributes_protection_spec.rb +2 -2
  96. data/spec/unit/has_and_belongs_to_many_association_spec.rb +14 -15
  97. data/spec/unit/has_many_association_spec.rb +26 -11
  98. data/spec/unit/indexers/global_indexer_spec.rb +6 -6
  99. data/spec/unit/indexing_service_spec.rb +5 -5
  100. data/spec/unit/indexing_spec.rb +6 -6
  101. data/spec/unit/inheritance_spec.rb +11 -7
  102. data/spec/unit/loadable_from_json_spec.rb +4 -4
  103. data/spec/unit/logger_spec.rb +1 -1
  104. data/spec/unit/model_classifier_spec.rb +5 -5
  105. data/spec/unit/ordered_spec.rb +144 -147
  106. data/spec/unit/orders/list_node_spec.rb +21 -21
  107. data/spec/unit/orders/ordered_list_spec.rb +96 -96
  108. data/spec/unit/orders/reflection_spec.rb +4 -4
  109. data/spec/unit/pathing_spec.rb +4 -4
  110. data/spec/unit/persistence_spec.rb +28 -28
  111. data/spec/unit/property_spec.rb +2 -2
  112. data/spec/unit/query_spec.rb +6 -6
  113. data/spec/unit/rdf/indexing_service_spec.rb +29 -29
  114. data/spec/unit/readonly_spec.rb +5 -4
  115. data/spec/unit/reflection_spec.rb +3 -3
  116. data/spec/unit/rspec_matchers/belong_to_associated_active_fedora_object_matcher_spec.rb +9 -9
  117. data/spec/unit/rspec_matchers/have_many_associated_active_fedora_objects_matcher_spec.rb +9 -9
  118. data/spec/unit/rspec_matchers/have_predicate_matcher_spec.rb +9 -9
  119. data/spec/unit/schema_indexing_strategy_spec.rb +5 -5
  120. data/spec/unit/serializers_spec.rb +3 -4
  121. data/spec/unit/solr_config_options_spec.rb +13 -16
  122. data/spec/unit/solr_hit_spec.rb +9 -9
  123. data/spec/unit/solr_service_spec.rb +4 -10
  124. data/spec/unit/sparql_insert_spec.rb +2 -2
  125. data/spec/unit/validations_spec.rb +9 -9
  126. data/spec/unit/with_metadata/default_metadata_class_factory_spec.rb +3 -2
  127. data/spec/unit/with_metadata/metadata_node_spec.rb +3 -2
  128. metadata +17 -91
  129. data/lib/active_fedora/datastreams/nokogiri_datastreams.rb +0 -119
  130. data/lib/active_fedora/datastreams.rb +0 -6
  131. data/lib/active_fedora/nom_datastream.rb +0 -73
  132. data/lib/active_fedora/om_datastream.rb +0 -118
  133. data/lib/active_fedora/profile_indexing_service.rb +0 -11
  134. data/lib/active_fedora/qualified_dublin_core_datastream.rb +0 -158
  135. data/lib/active_fedora/rdf/datastream_indexing.rb +0 -49
  136. data/lib/active_fedora/rdf/ntriples_rdf_datastream.rb +0 -13
  137. data/lib/active_fedora/rdf/rdf_datastream.rb +0 -167
  138. data/lib/active_fedora/rdf/rdfxml_datastream.rb +0 -13
  139. data/lib/active_fedora/solr_instance_loader.rb +0 -47
  140. data/spec/fixtures/damsObjectModel.xml +0 -38
  141. data/spec/fixtures/dublin_core_rdf_descMetadata.nt +0 -13
  142. data/spec/fixtures/mixed_rdf_descMetadata.nt +0 -7
  143. data/spec/fixtures/mods_articles/mods_article1.xml +0 -98
  144. data/spec/fixtures/solr_rdf_descMetadata.nt +0 -7
  145. data/spec/integration/complex_rdf_datastream_spec.rb +0 -228
  146. data/spec/integration/datastream_rdf_nested_attributes_spec.rb +0 -179
  147. data/spec/integration/ntriples_datastream_spec.rb +0 -203
  148. data/spec/integration/om_datastream_spec.rb +0 -78
  149. data/spec/integration/solr_instance_loader_spec.rb +0 -156
  150. data/spec/samples/hydra-mods_article_datastream.rb +0 -517
  151. data/spec/samples/models/mods_article.rb +0 -9
  152. data/spec/samples/oral_history_sample.xml +0 -38
  153. data/spec/samples/oral_history_xml.xml +0 -35
  154. data/spec/samples/samples.rb +0 -2
  155. data/spec/unit/nom_datastream_spec.rb +0 -60
  156. data/spec/unit/ntriples_datastream_spec.rb +0 -170
  157. data/spec/unit/om_datastream_spec.rb +0 -294
  158. data/spec/unit/qualified_dublin_core_datastream_spec.rb +0 -119
  159. data/spec/unit/rdf_datastream_spec.rb +0 -84
  160. data/spec/unit/rdf_resource_datastream_spec.rb +0 -204
  161. data/spec/unit/rdfxml_datastream_spec.rb +0 -106
@@ -1,156 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ActiveFedora::SolrInstanceLoader do
4
- before do
5
- class MyDS < ActiveFedora::OmDatastream
6
- set_terminology do |t|
7
- t.root(path: "durh")
8
- t.foo
9
- t.bar
10
- end
11
- end
12
-
13
- class Foo < ActiveFedora::Base
14
- has_subresource 'descMetadata', class_name: 'MyDS'
15
- property :title, predicate: ::RDF::Vocab::DC.title, multiple: false
16
- property :description, predicate: ::RDF::Vocab::DC.description
17
- belongs_to :another, predicate: ActiveFedora::RDF::Fcrepo::RelsExt.isPartOf, class_name: 'Foo'
18
- has_and_belongs_to_many :dates, predicate: ::RDF::Vocab::DC.date, class_name: 'Bar'
19
- accepts_nested_attributes_for :dates, reject_if: :all_blank, allow_destroy: true
20
- end
21
- class Bar < ActiveFedora::Base
22
- property :start, predicate: ::RDF::Vocab::EDM.begin, multiple: false
23
- has_many :foos, inverse_of: :dates, class_name: 'Foo'
24
- end
25
- end
26
-
27
- let(:another) { Foo.create }
28
-
29
- let!(:obj) { Foo.create!(
30
- id: 'test-123',
31
- title: 'My Title',
32
- description: ['first desc', 'second desc'],
33
- another_id: another.id,
34
- dates_attributes: [{ start: "2003" }, { start: "1996" }]
35
- ) }
36
-
37
- after do
38
- Object.send(:remove_const, :Foo)
39
- Object.send(:remove_const, :Bar)
40
- Object.send(:remove_const, :MyDS)
41
- end
42
-
43
- context "without a solr doc" do
44
- subject { loader.object }
45
-
46
- context "with context" do
47
- let(:loader) { described_class.new(Foo, obj.id) }
48
-
49
- it "finds the document in solr" do
50
- expect(subject).to be_instance_of Foo
51
- expect(subject.title).to eq 'My Title'
52
- expect(subject.description).to match_array ['first desc', 'second desc']
53
- expect(subject.another_id).to eq another.id
54
- end
55
-
56
- it "does not be mutable" do
57
- expect { subject.title = 'Foo' }.to raise_error ActiveFedora::ReadOnlyRecord
58
- end
59
-
60
- it "loads the correct number of nested attributes" do
61
- expect(subject.date_ids.count).to eq 2
62
- end
63
-
64
- it "loads the correct number of regular attributes" do
65
- expect(subject.description.count).to eq 2
66
- end
67
- end
68
-
69
- context "without context" do
70
- let(:loader) { described_class.new(ActiveFedora::Base, obj.id) }
71
-
72
- it "finds the document in solr" do
73
- expect_any_instance_of(ActiveFedora::File).to_not receive(:retrieve_content)
74
- expect_any_instance_of(Ldp::Client).to_not receive(:get)
75
- object = loader.object
76
- expect(object).to be_instance_of Foo
77
- expect(object.title).to eq 'My Title' # object assertion
78
-
79
- # and it's frozen
80
- expect { object.title = 'changed' }.to raise_error ActiveFedora::ReadOnlyRecord
81
- expect(object.title).to eq 'My Title'
82
- end
83
- end
84
-
85
- context "with children" do
86
- let(:loader) { described_class.new(Foo, obj.id) }
87
-
88
- it "has stub implementation of the children" do
89
- expect(subject.descMetadata).to be_kind_of ActiveFedora::LoadableFromJson::SolrBackedMetadataFile
90
- end
91
- end
92
- end
93
-
94
- context "with a solr doc" do
95
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "title" => "My Title" }.to_json }
96
- let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
97
- let(:loader) { described_class.new(Foo, obj.id, doc) }
98
-
99
- subject { loader.object }
100
-
101
- it "finds the document in solr" do
102
- expect(subject).to be_instance_of Foo
103
- expect(subject.title).to eq 'My Title'
104
- end
105
- end
106
-
107
- context "when the model has imperfect json" do
108
- let(:doc) { { 'id' => 'test-123', 'has_model_ssim' => ['Foo'], 'object_profile_ssm' => profile } }
109
- let(:loader) { described_class.new(Foo, obj.id, doc) }
110
- context "when the json has extra values in it" do
111
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "title" => "My Title", "extra_value" => "Bonus values!" }.to_json }
112
- it "loads the object without trouble" do
113
- expect(loader.object).to be_instance_of Foo
114
- end
115
- end
116
-
117
- context "when the json is missing values" do
118
- let(:profile) { { "foo" => ["baz"], "bar" => "quix" }.to_json }
119
- it "loads the object without trouble" do
120
- expect(loader.object).to be_instance_of Foo
121
- end
122
- it "missing scalar should be nil" do
123
- expect(loader.object.title).to be_nil
124
- end
125
- it "missing multi-value should be []" do
126
- expect(loader.object.description).to eql([])
127
- end
128
- end
129
-
130
- context "when the json has scalar where multi-value is expected" do
131
- let(:profile) { { "foo" => ["baz"], "bar" => "quix", "description" => "test description" }.to_json }
132
- it "loads the object without trouble" do
133
- expect(loader.object).to be_instance_of Foo
134
- end
135
- it "converts the scalar to an array" do
136
- expect(loader.object.description).to eql(["test description"])
137
- end
138
- end
139
- end
140
-
141
- describe "loading system properties" do
142
- before { allow(Deprecation).to receive(:warn) }
143
- let(:obj_solr) { Foo.load_instance_from_solr(obj.id) }
144
- it "loads create_date from solr" do
145
- expect(obj.create_date).to be_present
146
- expect(obj_solr).to be_present
147
- expect(obj_solr.create_date).to be_a DateTime
148
- end
149
-
150
- it "loads modified_date from solr" do
151
- expect(obj.modified_date).to be_present
152
- expect(obj_solr).to be_present
153
- expect(obj_solr.modified_date).to be_a DateTime
154
- end
155
- end
156
- end
@@ -1,517 +0,0 @@
1
- module Hydra
2
- # This is an example of a OmDatastream that defines an OM terminology for MODS xml
3
- # It focuses on the aspects of MODS that deal with descriptive metadata for published articles
4
- # This is not the hydra-head plugin version of this OM Terminology; See https://github.com/projecthydra/hydra-head/blob/master/lib/hydra/mods_article.rb
5
- #
6
- # Things to note about the OM Terminology defined here:
7
- #
8
- # * Uses :ref terms to repeat the structures of a mods:name with a different @type on the mods:name element
9
- # * Defines a term lang_code that maps to "languageTerm[@type=code]"
10
- # * Defines a variety of terms, date, last_name, first_name & terms_of_address, that all map to mods:namePart but use varying attributes to distinguish themselves
11
- # * Uses proxy terms to define familar terms like start_page and end_page that map to non-intuitive xml structures "extent[@unit=pages]/start" and "extent[@unit=pages]/end"
12
- # * Uses proxy terms, publication_url, peer_reviewed, and title, to allow convenient access to frequently used terms
13
- #
14
- # Things to note about the additional methods it defines:
15
- #
16
- # * Defines a series of templates, person_template, organization_template, etc. for generating a whole set of xml nodes to insert into the document (note: the new OM::TemplateRegistry provides an even better way to do this)
17
- # * Defines a custom method, insert_contributor, that uses the Terminology to manipulate xml documents in specialized ways
18
- # * Defines a series of relator_term Hashes that can then be used when generating views, etc. In this case, the Hashes are hard-coded into the Class. Ideally, they might be read from a configuration file or mixed into the class using a module
19
- class ModsArticleDatastream < ActiveFedora::OmDatastream
20
- set_terminology do |t|
21
- t.root(path: "mods", xmlns: "http://www.loc.gov/mods/v3", schema: "http://www.loc.gov/standards/mods/v3/mods-3-2.xsd")
22
-
23
- t.title_info(path: "titleInfo") {
24
- t.main_title(index_as: [:facetable], path: "title", label: "title")
25
- t.language(index_as: [:facetable], path: { attribute: "lang" })
26
- }
27
- t.language{
28
- t.lang_code(index_as: [:facetable], path: "languageTerm", attributes: { type: "code" })
29
- }
30
- t.abstract
31
- t.subject {
32
- t.topic(index_as: [:facetable])
33
- }
34
- t.topic_tag(proxy: [:subject, :topic])
35
- # t.topic_tag(:index_as=>[:facetable],:path=>"subject", :default_content_path=>"topic")
36
- # This is a mods:name. The underscore is purely to avoid namespace conflicts.
37
- t.name_(index_as: [:searchable]) {
38
- # this is a namepart
39
- t.namePart(type: :string, label: "generic name")
40
- # affiliations are great
41
- t.affiliation
42
- t.institution(path: "affiliation", index_as: [:facetable], label: "organization")
43
- t.displayForm
44
- t.role(ref: [:role])
45
- t.description(index_as: [:facetable])
46
- t.date(path: "namePart", attributes: { type: "date" })
47
- t.last_name(path: "namePart", attributes: { type: "family" })
48
- t.first_name(path: "namePart", attributes: { type: "given" }, label: "first name")
49
- t.terms_of_address(path: "namePart", attributes: { type: "termsOfAddress" })
50
- t.computing_id
51
- }
52
- # lookup :person, :first_name
53
- t.person(ref: :name, attributes: { type: "personal" }, index_as: [:facetable, :stored_searchable])
54
- t.department(proxy: [:person, :description], index_as: [:facetable])
55
- t.organization(ref: :name, attributes: { type: "corporate" }, index_as: [:facetable])
56
- t.conference(ref: :name, attributes: { type: "conference" }, index_as: [:facetable])
57
- t.role(index_as: [:stored_searchable]) {
58
- t.text(path: "roleTerm", attributes: { type: "text" }, index_as: [:stored_searchable])
59
- t.code(path: "roleTerm", attributes: { type: "code" })
60
- }
61
- t.journal(path: 'relatedItem', attributes: { type: "host" }) {
62
- t.title_info(index_as: [:facetable], ref: [:title_info])
63
- t.origin_info(path: "originInfo") {
64
- t.publisher
65
- t.date_issued(path: "dateIssued")
66
- t.issuance(index_as: [:facetable])
67
- }
68
- t.issn(path: "identifier", attributes: { type: "issn" })
69
- t.issue(path: "part") {
70
- t.volume(path: "detail", attributes: { type: "volume" }, default_content_path: "number")
71
- t.level(path: "detail", attributes: { type: "number" }, default_content_path: "number")
72
- t.extent
73
- t.pages(path: "extent", attributes: { unit: "pages" }) {
74
- t.start
75
- t.end
76
- }
77
- t.start_page(proxy: [:pages, :start])
78
- t.end_page(proxy: [:pages, :end])
79
- t.publication_date(path: "date", type: :date, index_as: [:stored_searchable])
80
- }
81
- }
82
- t.note
83
- t.location(path: "location") {
84
- t.url(path: "url")
85
- }
86
- t.publication_url(proxy: [:location, :url])
87
- t.peer_reviewed(proxy: [:journal, :origin_info, :issuance], index_as: [:facetable])
88
- t.title(proxy: [:title_info, :main_title])
89
- t.journal_title(proxy: [:journal, :title_info, :main_title])
90
- end
91
-
92
- # Generates an empty Mods Article (used when you call ModsArticle.new without passing in existing xml)
93
- def self.xml_template
94
- builder = Nokogiri::XML::Builder.new do |xml|
95
- xml.mods(:version => "3.3", "xmlns:xlink" => "http://www.w3.org/1999/xlink",
96
- "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
97
- "xmlns" => "http://www.loc.gov/mods/v3",
98
- "xsi:schemaLocation" => "http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd") {
99
- xml.titleInfo(lang: "") {
100
- xml.title
101
- }
102
- xml.name(type: "personal") {
103
- xml.namePart(type: "given")
104
- xml.namePart(type: "family")
105
- xml.affiliation
106
- xml.computing_id
107
- xml.description
108
- xml.role {
109
- xml.roleTerm("Author", authority: "marcrelator", type: "text")
110
- }
111
- }
112
- xml.typeOfResource
113
- xml.genre(authority: "marcgt")
114
- xml.language {
115
- xml.languageTerm(authority: "iso639-2b", type: "code")
116
- }
117
- xml.abstract
118
- xml.subject {
119
- xml.topic
120
- }
121
- xml.relatedItem(type: "host") {
122
- xml.titleInfo {
123
- xml.title
124
- }
125
- xml.identifier(type: "issn")
126
- xml.originInfo {
127
- xml.publisher
128
- xml.dateIssued
129
- xml.issuance
130
- }
131
- xml.part {
132
- xml.detail(type: "volume") {
133
- xml.number
134
- }
135
- xml.detail(type: "number") {
136
- xml.number
137
- }
138
- xml.extent(unit: "pages") {
139
- xml.start
140
- xml.end
141
- }
142
- xml.date
143
- }
144
- }
145
- xml.location {
146
- xml.url
147
- }
148
- }
149
- end
150
- builder.doc
151
- end
152
-
153
- def prefix(name)
154
- "#{name.underscore}__"
155
- end
156
-
157
- # Generates a new Person node
158
- def self.person_template
159
- builder = Nokogiri::XML::Builder.new do |xml|
160
- xml.name(type: "personal") {
161
- xml.namePart(type: "family")
162
- xml.namePart(type: "given")
163
- xml.affiliation
164
- xml.computing_id
165
- xml.description
166
- xml.role {
167
- xml.roleTerm("Author", type: "text")
168
- }
169
- }
170
- end
171
- builder.doc.root
172
- end
173
-
174
- def self.full_name_template
175
- builder = Nokogiri::XML::Builder.new do |xml|
176
- xml.full_name(type: "personal")
177
- end
178
- builder.doc.root
179
- end
180
-
181
- # Generates a new Organization node
182
- # Uses mods:name[@type="corporate"]
183
- def self.organization_template
184
- builder = Nokogiri::XML::Builder.new do |xml|
185
- xml.name(type: "corporate") {
186
- xml.namePart
187
- xml.role {
188
- xml.roleTerm(authority: "marcrelator", type: "text")
189
- }
190
- }
191
- end
192
- builder.doc.root
193
- end
194
-
195
- # Generates a new Conference node
196
- def self.conference_template
197
- builder = Nokogiri::XML::Builder.new do |xml|
198
- xml.name(type: "conference") {
199
- xml.namePart
200
- xml.role {
201
- xml.roleTerm(authority: "marcrelator", type: "text")
202
- }
203
- }
204
- end
205
- builder.doc.root
206
- end
207
-
208
- # Inserts a new contributor (mods:name) into the mods document
209
- # creates contributors of type :person, :organization, or :conference
210
- def insert_contributor(type, _opts = {})
211
- case type.to_sym
212
- when :person
213
- node = Hydra::ModsArticleDatastream.person_template
214
- nodeset = find_by_terms(:person)
215
- when :organization
216
- node = Hydra::ModsArticleDatastream.organization_template
217
- nodeset = find_by_terms(:organization)
218
- when :conference
219
- node = Hydra::ModsArticleDatastream.conference_template
220
- nodeset = find_by_terms(:conference)
221
- else
222
- ActiveFedora.logger.warn("#{type} is not a valid argument for Hydra::ModsArticleDatastream.insert_contributor")
223
- node = nil
224
- index = nil
225
- end
226
-
227
- unless nodeset.nil?
228
- if nodeset.empty?
229
- ng_xml.root.add_child(node)
230
- index = 0
231
- else
232
- nodeset.after(node)
233
- index = nodeset.length
234
- end
235
- self.dirty = true
236
- end
237
-
238
- [node, index]
239
- end
240
-
241
- # Remove the contributor entry identified by @contributor_type and @index
242
- def remove_contributor(contributor_type, index)
243
- find_by_terms(contributor_type.to_sym => index.to_i).first.remove
244
- self.dirty = true
245
- end
246
-
247
- def self.common_relator_terms
248
- { "aut" => "Author",
249
- "clb" => "Collaborator",
250
- "com" => "Compiler",
251
- "ctb" => "Contributor",
252
- "cre" => "Creator",
253
- "edt" => "Editor",
254
- "ill" => "Illustrator",
255
- "oth" => "Other",
256
- "trl" => "Translator"
257
- }
258
- end
259
-
260
- def self.person_relator_terms
261
- { "aut" => "Author",
262
- "clb" => "Collaborator",
263
- "com" => "Compiler",
264
- "cre" => "Creator",
265
- "ctb" => "Contributor",
266
- "edt" => "Editor",
267
- "ill" => "Illustrator",
268
- "res" => "Researcher",
269
- "rth" => "Research team head",
270
- "rtm" => "Research team member",
271
- "trl" => "Translator"
272
- }
273
- end
274
-
275
- def self.conference_relator_terms
276
- {
277
- "hst" => "Host"
278
- }
279
- end
280
-
281
- def self.organization_relator_terms
282
- {
283
- "fnd" => "Funder",
284
- "hst" => "Host"
285
- }
286
- end
287
-
288
- def self.dc_relator_terms
289
- { "acp" => "Art copyist",
290
- "act" => "Actor",
291
- "adp" => "Adapter",
292
- "aft" => "Author of afterword, colophon, etc.",
293
- "anl" => "Analyst",
294
- "anm" => "Animator",
295
- "ann" => "Annotator",
296
- "ant" => "Bibliographic antecedent",
297
- "app" => "Applicant",
298
- "aqt" => "Author in quotations or text abstracts",
299
- "arc" => "Architect",
300
- "ard" => "Artistic director ",
301
- "arr" => "Arranger",
302
- "art" => "Artist",
303
- "asg" => "Assignee",
304
- "asn" => "Associated name",
305
- "att" => "Attributed name",
306
- "auc" => "Auctioneer",
307
- "aud" => "Author of dialog",
308
- "aui" => "Author of introduction",
309
- "aus" => "Author of screenplay",
310
- "aut" => "Author",
311
- "bdd" => "Binding designer",
312
- "bjd" => "Bookjacket designer",
313
- "bkd" => "Book designer",
314
- "bkp" => "Book producer",
315
- "bnd" => "Binder",
316
- "bpd" => "Bookplate designer",
317
- "bsl" => "Bookseller",
318
- "ccp" => "Conceptor",
319
- "chr" => "Choreographer",
320
- "clb" => "Collaborator",
321
- "cli" => "Client",
322
- "cll" => "Calligrapher",
323
- "clt" => "Collotyper",
324
- "cmm" => "Commentator",
325
- "cmp" => "Composer",
326
- "cmt" => "Compositor",
327
- "cng" => "Cinematographer",
328
- "cnd" => "Conductor",
329
- "cns" => "Censor",
330
- "coe" => "Contestant -appellee",
331
- "col" => "Collector",
332
- "com" => "Compiler",
333
- "cos" => "Contestant",
334
- "cot" => "Contestant -appellant",
335
- "cov" => "Cover designer",
336
- "cpc" => "Copyright claimant",
337
- "cpe" => "Complainant-appellee",
338
- "cph" => "Copyright holder",
339
- "cpl" => "Complainant",
340
- "cpt" => "Complainant-appellant",
341
- "cre" => "Creator",
342
- "crp" => "Correspondent",
343
- "crr" => "Corrector",
344
- "csl" => "Consultant",
345
- "csp" => "Consultant to a project",
346
- "cst" => "Costume designer",
347
- "ctb" => "Contributor",
348
- "cte" => "Contestee-appellee",
349
- "ctg" => "Cartographer",
350
- "ctr" => "Contractor",
351
- "cts" => "Contestee",
352
- "ctt" => "Contestee-appellant",
353
- "cur" => "Curator",
354
- "cwt" => "Commentator for written text",
355
- "dfd" => "Defendant",
356
- "dfe" => "Defendant-appellee",
357
- "dft" => "Defendant-appellant",
358
- "dgg" => "Degree grantor",
359
- "dis" => "Dissertant",
360
- "dln" => "Delineator",
361
- "dnc" => "Dancer",
362
- "dnr" => "Donor",
363
- "dpc" => "Depicted",
364
- "dpt" => "Depositor",
365
- "drm" => "Draftsman",
366
- "drt" => "Director",
367
- "dsr" => "Designer",
368
- "dst" => "Distributor",
369
- "dtc" => "Data contributor ",
370
- "dte" => "Dedicatee",
371
- "dtm" => "Data manager ",
372
- "dto" => "Dedicator",
373
- "dub" => "Dubious author",
374
- "edt" => "Editor",
375
- "egr" => "Engraver",
376
- "elg" => "Electrician ",
377
- "elt" => "Electrotyper",
378
- "eng" => "Engineer",
379
- "etr" => "Etcher",
380
- "exp" => "Expert",
381
- "fac" => "Facsimilist",
382
- "fld" => "Field director ",
383
- "flm" => "Film editor",
384
- "fmo" => "Former owner",
385
- "fpy" => "First party",
386
- "fnd" => "Funder",
387
- "frg" => "Forger",
388
- "gis" => "Geographic information specialist ",
389
- "grt" => "Graphic technician",
390
- "hnr" => "Honoree",
391
- "hst" => "Host",
392
- "ill" => "Illustrator",
393
- "ilu" => "Illuminator",
394
- "ins" => "Inscriber",
395
- "inv" => "Inventor",
396
- "itr" => "Instrumentalist",
397
- "ive" => "Interviewee",
398
- "ivr" => "Interviewer",
399
- "lbr" => "Laboratory ",
400
- "lbt" => "Librettist",
401
- "ldr" => "Laboratory director ",
402
- "led" => "Lead",
403
- "lee" => "Libelee-appellee",
404
- "lel" => "Libelee",
405
- "len" => "Lender",
406
- "let" => "Libelee-appellant",
407
- "lgd" => "Lighting designer",
408
- "lie" => "Libelant-appellee",
409
- "lil" => "Libelant",
410
- "lit" => "Libelant-appellant",
411
- "lsa" => "Landscape architect",
412
- "lse" => "Licensee",
413
- "lso" => "Licensor",
414
- "ltg" => "Lithographer",
415
- "lyr" => "Lyricist",
416
- "mcp" => "Music copyist",
417
- "mfr" => "Manufacturer",
418
- "mdc" => "Metadata contact",
419
- "mod" => "Moderator",
420
- "mon" => "Monitor",
421
- "mrk" => "Markup editor",
422
- "msd" => "Musical director",
423
- "mte" => "Metal-engraver",
424
- "mus" => "Musician",
425
- "nrt" => "Narrator",
426
- "opn" => "Opponent",
427
- "org" => "Originator",
428
- "orm" => "Organizer of meeting",
429
- "oth" => "Other",
430
- "own" => "Owner",
431
- "pat" => "Patron",
432
- "pbd" => "Publishing director",
433
- "pbl" => "Publisher",
434
- "pdr" => "Project director",
435
- "pfr" => "Proofreader",
436
- "pht" => "Photographer",
437
- "plt" => "Platemaker",
438
- "pma" => "Permitting agency",
439
- "pmn" => "Production manager",
440
- "pop" => "Printer of plates",
441
- "ppm" => "Papermaker",
442
- "ppt" => "Puppeteer",
443
- "prc" => "Process contact",
444
- "prd" => "Production personnel",
445
- "prf" => "Performer",
446
- "prg" => "Programmer",
447
- "prm" => "Printmaker",
448
- "pro" => "Producer",
449
- "prt" => "Printer",
450
- "pta" => "Patent applicant",
451
- "pte" => "Plaintiff -appellee",
452
- "ptf" => "Plaintiff",
453
- "pth" => "Patent holder",
454
- "ptt" => "Plaintiff-appellant",
455
- "rbr" => "Rubricator",
456
- "rce" => "Recording engineer",
457
- "rcp" => "Recipient",
458
- "red" => "Redactor",
459
- "ren" => "Renderer",
460
- "res" => "Researcher",
461
- "rev" => "Reviewer",
462
- "rps" => "Repository",
463
- "rpt" => "Reporter",
464
- "rpy" => "Responsible party",
465
- "rse" => "Respondent-appellee",
466
- "rsg" => "Restager",
467
- "rsp" => "Respondent",
468
- "rst" => "Respondent-appellant",
469
- "rth" => "Research team head",
470
- "rtm" => "Research team member",
471
- "sad" => "Scientific advisor",
472
- "sce" => "Scenarist",
473
- "scl" => "Sculptor",
474
- "scr" => "Scribe",
475
- "sds" => "Sound designer",
476
- "sec" => "Secretary",
477
- "sgn" => "Signer",
478
- "sht" => "Supporting host",
479
- "sng" => "Singer",
480
- "spk" => "Speaker",
481
- "spn" => "Sponsor",
482
- "spy" => "Second party",
483
- "srv" => "Surveyor",
484
- "std" => "Set designer",
485
- "stl" => "Storyteller",
486
- "stm" => "Stage manager",
487
- "stn" => "Standards body",
488
- "str" => "Stereotyper",
489
- "tcd" => "Technical director",
490
- "tch" => "Teacher",
491
- "ths" => "Thesis advisor",
492
- "trc" => "Transcriber",
493
- "trl" => "Translator",
494
- "tyd" => "Type designer",
495
- "tyg" => "Typographer",
496
- "vdg" => "Videographer",
497
- "voc" => "Vocalist",
498
- "wam" => "Writer of accompanying material",
499
- "wdc" => "Woodcutter",
500
- "wde" => "Wood -engraver",
501
- "wit" => "Witness" }
502
- end
503
-
504
- def self.valid_child_types
505
- ["data", "supporting file", "profile", "lorem ipsum", "dolor"]
506
- end
507
-
508
- def to_solr(solr_doc = {}, opts = {})
509
- solr_doc = super
510
-
511
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, ActiveFedora.index_field_mapper.solr_name('object_type', :facetable), "Article")
512
- ::Solrizer::Extractor.insert_solr_field_value(solr_doc, ActiveFedora.index_field_mapper.solr_name('mods_journal_title_info', :facetable), "Unknown") if solr_doc["mods_journal_title_info_facet"].nil?
513
-
514
- solr_doc
515
- end
516
- end
517
- end
@@ -1,9 +0,0 @@
1
- require "active-fedora"
2
- require_relative '../hydra-mods_article_datastream.rb'
3
-
4
- # This Model is used to load & index the test:fixture_mods_article1 fixture for use in tests.
5
- #
6
- # See lib/samples/sample_thing.rb for a fuller, annotated example of an ActiveFedora Model
7
- class ModsArticle < ActiveFedora::Base
8
- has_subresource "descMetadata", class_name: 'Hydra::ModsArticleDatastream'
9
- end