fedora-migrate 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +19 -0
  5. data/Gemfile +7 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +31 -0
  8. data/Rakefile +5 -0
  9. data/config/fedora.yml +14 -0
  10. data/config/fedora3.yml +12 -0
  11. data/config/jetty.yml +6 -0
  12. data/config/solr.yml +15 -0
  13. data/fedora-migrate.gemspec +30 -0
  14. data/lib/fedora-migrate.rb +82 -0
  15. data/lib/fedora_migrate/datastream_mover.rb +78 -0
  16. data/lib/fedora_migrate/errors.rb +7 -0
  17. data/lib/fedora_migrate/file_configurator.rb +34 -0
  18. data/lib/fedora_migrate/hooks.rb +11 -0
  19. data/lib/fedora_migrate/logger.rb +36 -0
  20. data/lib/fedora_migrate/migration_options.rb +11 -0
  21. data/lib/fedora_migrate/mover.rb +44 -0
  22. data/lib/fedora_migrate/object_mover.rb +62 -0
  23. data/lib/fedora_migrate/permissions.rb +32 -0
  24. data/lib/fedora_migrate/permissions_mover.rb +31 -0
  25. data/lib/fedora_migrate/rdf_datastream_mover.rb +28 -0
  26. data/lib/fedora_migrate/rdf_datastream_parser.rb +29 -0
  27. data/lib/fedora_migrate/rels_ext_datastream_mover.rb +90 -0
  28. data/lib/fedora_migrate/repository_migrator.rb +60 -0
  29. data/lib/fedora_migrate/rights_metadata.rb +281 -0
  30. data/lib/fedora_migrate/rubydora_connection.rb +21 -0
  31. data/lib/fedora_migrate/triple_converter.rb +39 -0
  32. data/lib/fedora_migrate/version.rb +3 -0
  33. data/lib/tasks/fedora-migrate.rake +45 -0
  34. data/spec/fixtures/datastreams/rdf_ntriples_datastream.txt +2 -0
  35. data/spec/fixtures/datastreams/sufia-rb68xc089-characterization.xml +27 -0
  36. data/spec/fixtures/objects/f3-migration-a.xml +110 -0
  37. data/spec/fixtures/objects/gf-versioned-content.xml +2776 -0
  38. data/spec/fixtures/objects/sufia-batch-gf-1.xml +94 -0
  39. data/spec/fixtures/objects/sufia-batch-gf-2.xml +93 -0
  40. data/spec/fixtures/objects/sufia-batch.xml +51 -0
  41. data/spec/integration/content_versions_spec.rb +42 -0
  42. data/spec/integration/fedora3_interface_spec.rb +23 -0
  43. data/spec/integration/object_migration_spec.rb +112 -0
  44. data/spec/integration/permission_migration_spec.rb +13 -0
  45. data/spec/integration/rdf_migration_spec.rb +22 -0
  46. data/spec/integration/relationship_migration_spec.rb +51 -0
  47. data/spec/integration/repository_migration_spec.rb +59 -0
  48. data/spec/spec_helper.rb +39 -0
  49. data/spec/support/example_model.rb +36 -0
  50. data/spec/unit/datastream_mover_spec.rb +39 -0
  51. data/spec/unit/fedora_migrate_spec.rb +19 -0
  52. data/spec/unit/file_configurator_spec.rb +17 -0
  53. data/spec/unit/mover_spec.rb +39 -0
  54. data/spec/unit/object_mover_spec.rb +38 -0
  55. data/spec/unit/permissions_mover_spec.rb +53 -0
  56. data/spec/unit/rdf_datastream_mover_spec.rb +8 -0
  57. data/spec/unit/rdf_datastream_parser_spec.rb +38 -0
  58. data/spec/unit/rels_ext_datastream_mover_spec.rb +36 -0
  59. data/spec/unit/repository_migrator_spec.rb +43 -0
  60. data/spec/unit/rubydora_connection_spec.rb +25 -0
  61. data/spec/unit/triple_converter_spec.rb +35 -0
  62. data/tasks/dev.rake +37 -0
  63. metadata +246 -0
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe FedoraMigrate::RelsExtDatastreamMover do
4
+
5
+ context "with a target" do
6
+
7
+ before do
8
+ allow_any_instance_of(FedoraMigrate::RelsExtDatastreamMover).to receive(:retrieve_subject).and_return("subject")
9
+ allow_any_instance_of(FedoraMigrate::RelsExtDatastreamMover).to receive(:retrieve_object).and_return("object")
10
+ end
11
+
12
+ subject do
13
+ FedoraMigrate::RelsExtDatastreamMover.new(
14
+ FedoraMigrate.source.connection.find("sufia:rb68xc11m")
15
+ )
16
+ end
17
+
18
+ describe "#relationships" do
19
+ it "should parse the source's RELS-EXT datastream for relationships" do
20
+ expect(subject.relationships).to include(:part_of => ["object"])
21
+ end
22
+ end
23
+
24
+ describe "#ng_xml" do
25
+ it "should return a Nokogiri document of the object's RELS-EXT datastream" do
26
+ expect(subject.ng_xml).to be_kind_of(Nokogiri::XML::Document)
27
+ end
28
+ end
29
+
30
+ describe "#has_relationships?" do
31
+ it { is_expected.to have_relationships }
32
+ end
33
+
34
+ end
35
+
36
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+
3
+ describe FedoraMigrate::RepositoryMigrator do
4
+
5
+ let(:namespace) { "sufia" }
6
+
7
+ it { is_expected.to respond_to(:source_objects) }
8
+ it { is_expected.to respond_to(:results) }
9
+ it { is_expected.to respond_to(:namespace) }
10
+
11
+ describe "#results" do
12
+ specify "are initially empty" do
13
+ expect(subject.results).to eql([])
14
+ end
15
+ end
16
+
17
+ context "without a given namespace" do
18
+ describe "#namespace" do
19
+ specify "is given in the repository profile" do
20
+ expect(subject.namespace).to eql("changeme")
21
+ end
22
+ end
23
+ end
24
+
25
+ context "with a given namespace" do
26
+ subject { FedoraMigrate::RepositoryMigrator.new(namespace) }
27
+ describe "#namespace" do
28
+ specify "is the one provided" do
29
+ expect(subject.namespace).to eql(namespace)
30
+ end
31
+ end
32
+ describe "#source_objects" do
33
+ it "should reuturn an array of all digital objects from Rubydora" do
34
+ expect(subject.source_objects.collect { |o| o.pid }).to include("sufia:rb68xc089", "sufia:rb68xc11m")
35
+ end
36
+ it "should exclude fedora-system objects" do
37
+ expect(subject.source_objects).to_not include("fedora-system:ContentModel-3.0")
38
+ expect(subject.source_objects.count).to eql 5
39
+ end
40
+ end
41
+ end
42
+
43
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe FedoraMigrate::RubydoraConnection do
4
+ describe 'initialize' do
5
+
6
+ let (:fedora_url) { "http://my.fedora3.instance" }
7
+
8
+ subject {
9
+ FedoraMigrate::RubydoraConnection.new timeout: 3600, validateChecksum: true, url: fedora_url
10
+ }
11
+
12
+ specify "a timeout" do
13
+ expect(subject.connection.client.options[:timeout]).to eql(3600)
14
+ end
15
+
16
+ specify "validate a checksum" do
17
+ expect(subject.connection.config[:validateChecksum]).to be true
18
+ end
19
+
20
+ specify "a Fedora3 url" do
21
+ expect(subject.connection.client.url).to eql fedora_url
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec_helper'
2
+
3
+ describe FedoraMigrate::TripleConverter do
4
+
5
+ context "given an RDF triple / " do
6
+ subject { FedoraMigrate::TripleConverter.new('<info:fedora/sufia:xp68km39w> <http://purl.org/dc/terms/title> "Sample Migration Object A" .') }
7
+ specify "it parses the triple for the object" do
8
+ expect(subject.object).to eql "Sample Migration Object A"
9
+ end
10
+ specify "it parses the triple for the predicate" do
11
+ expect(subject.predicate).to eql ::RDF::DC.title
12
+ end
13
+ end
14
+
15
+ context "given a non-DC RDF triple / " do
16
+ subject { FedoraMigrate::TripleConverter.new( '<info:fedora/sufia:xp68km39w> <http://purl.org/dc/terms/baz> "Sample Migration Object A" .') }
17
+ before do
18
+ expect(FedoraMigrate::Logger).to receive(:warn)
19
+ end
20
+ specify "it returns a null predicate" do
21
+ expect(subject.predicate).to be nil
22
+ end
23
+ end
24
+
25
+ context "given a malformed triple / " do
26
+ before do
27
+ expect(FedoraMigrate::Logger).to receive(:warn)
28
+ end
29
+ subject { FedoraMigrate::TripleConverter.new( '<info:fedora/sufia:xp68km39w> <http://purl.org/dc/terms/title> Object not enclosed with quotes .') }
30
+ specify "it returns a nul object" do
31
+ expect(subject.object).to be nil
32
+ end
33
+ end
34
+
35
+ end
data/tasks/dev.rake ADDED
@@ -0,0 +1,37 @@
1
+ require 'fedora-migrate'
2
+ require 'rspec/core'
3
+ require 'rspec/core/rake_task'
4
+ require 'jettywrapper'
5
+ Jettywrapper.url = "https://github.com/projecthydra/hydra-jetty/archive/fedora-4/migrate.zip"
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ desc "Run continuous integration tests"
10
+ task ci: ['jetty:clean', 'jetty:start', 'fixtures:load', 'spec']
11
+
12
+ namespace :fixtures do
13
+
14
+ desc "Load Fedora3 fixtures for testing; use FIXTURE_PATH= for your own"
15
+ task :load do
16
+ repo = FedoraMigrate.source
17
+ path = ENV["FIXTURE_PATH"] || "spec/fixtures/objects"
18
+ Dir.glob(File.join(path,"*.xml")).each do |f|
19
+ fixture = File.open(f)
20
+ begin
21
+ repo.connection.ingest(file: fixture.read)
22
+ rescue
23
+ puts "Failed to load #{fixture.path} (skipping)"
24
+ end
25
+ end
26
+ end
27
+
28
+ desc "Remove all objects from Fedora3"
29
+ task :unload do
30
+ repo = FedoraMigrate.source
31
+ repo.connection.search("").collect { |o| o.delete }
32
+ end
33
+
34
+ desc "Reload fixtures into Fedora3"
35
+ task reload: [:unload, :load]
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,246 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fedora-migrate
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Wead
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubydora
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hydra-head
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 9.0.0.beta1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 9.0.0.beta1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: jettywrapper
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: equivalent-xml
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: sufia
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 6.0.0.beta1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 6.0.0.beta1
125
+ description: Migrates data (models, datastreams, content) from a Fedora3 repository
126
+ to Fedora4
127
+ email:
128
+ - amsterdamos@gmail.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - ".gitignore"
134
+ - ".rspec"
135
+ - ".travis.yml"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - config/fedora.yml
141
+ - config/fedora3.yml
142
+ - config/jetty.yml
143
+ - config/solr.yml
144
+ - fedora-migrate.gemspec
145
+ - lib/fedora-migrate.rb
146
+ - lib/fedora_migrate/datastream_mover.rb
147
+ - lib/fedora_migrate/errors.rb
148
+ - lib/fedora_migrate/file_configurator.rb
149
+ - lib/fedora_migrate/hooks.rb
150
+ - lib/fedora_migrate/logger.rb
151
+ - lib/fedora_migrate/migration_options.rb
152
+ - lib/fedora_migrate/mover.rb
153
+ - lib/fedora_migrate/object_mover.rb
154
+ - lib/fedora_migrate/permissions.rb
155
+ - lib/fedora_migrate/permissions_mover.rb
156
+ - lib/fedora_migrate/rdf_datastream_mover.rb
157
+ - lib/fedora_migrate/rdf_datastream_parser.rb
158
+ - lib/fedora_migrate/rels_ext_datastream_mover.rb
159
+ - lib/fedora_migrate/repository_migrator.rb
160
+ - lib/fedora_migrate/rights_metadata.rb
161
+ - lib/fedora_migrate/rubydora_connection.rb
162
+ - lib/fedora_migrate/triple_converter.rb
163
+ - lib/fedora_migrate/version.rb
164
+ - lib/tasks/fedora-migrate.rake
165
+ - spec/fixtures/datastreams/rdf_ntriples_datastream.txt
166
+ - spec/fixtures/datastreams/sufia-rb68xc089-characterization.xml
167
+ - spec/fixtures/objects/f3-migration-a.xml
168
+ - spec/fixtures/objects/gf-versioned-content.xml
169
+ - spec/fixtures/objects/sufia-batch-gf-1.xml
170
+ - spec/fixtures/objects/sufia-batch-gf-2.xml
171
+ - spec/fixtures/objects/sufia-batch.xml
172
+ - spec/integration/content_versions_spec.rb
173
+ - spec/integration/fedora3_interface_spec.rb
174
+ - spec/integration/object_migration_spec.rb
175
+ - spec/integration/permission_migration_spec.rb
176
+ - spec/integration/rdf_migration_spec.rb
177
+ - spec/integration/relationship_migration_spec.rb
178
+ - spec/integration/repository_migration_spec.rb
179
+ - spec/spec_helper.rb
180
+ - spec/support/example_model.rb
181
+ - spec/unit/datastream_mover_spec.rb
182
+ - spec/unit/fedora_migrate_spec.rb
183
+ - spec/unit/file_configurator_spec.rb
184
+ - spec/unit/mover_spec.rb
185
+ - spec/unit/object_mover_spec.rb
186
+ - spec/unit/permissions_mover_spec.rb
187
+ - spec/unit/rdf_datastream_mover_spec.rb
188
+ - spec/unit/rdf_datastream_parser_spec.rb
189
+ - spec/unit/rels_ext_datastream_mover_spec.rb
190
+ - spec/unit/repository_migrator_spec.rb
191
+ - spec/unit/rubydora_connection_spec.rb
192
+ - spec/unit/triple_converter_spec.rb
193
+ - tasks/dev.rake
194
+ homepage: ''
195
+ licenses:
196
+ - APACHE2
197
+ metadata: {}
198
+ post_install_message:
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 2.4.5
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: Migrate Hydra-based repository data from Fedora3 to Fedora4
218
+ test_files:
219
+ - spec/fixtures/datastreams/rdf_ntriples_datastream.txt
220
+ - spec/fixtures/datastreams/sufia-rb68xc089-characterization.xml
221
+ - spec/fixtures/objects/f3-migration-a.xml
222
+ - spec/fixtures/objects/gf-versioned-content.xml
223
+ - spec/fixtures/objects/sufia-batch-gf-1.xml
224
+ - spec/fixtures/objects/sufia-batch-gf-2.xml
225
+ - spec/fixtures/objects/sufia-batch.xml
226
+ - spec/integration/content_versions_spec.rb
227
+ - spec/integration/fedora3_interface_spec.rb
228
+ - spec/integration/object_migration_spec.rb
229
+ - spec/integration/permission_migration_spec.rb
230
+ - spec/integration/rdf_migration_spec.rb
231
+ - spec/integration/relationship_migration_spec.rb
232
+ - spec/integration/repository_migration_spec.rb
233
+ - spec/spec_helper.rb
234
+ - spec/support/example_model.rb
235
+ - spec/unit/datastream_mover_spec.rb
236
+ - spec/unit/fedora_migrate_spec.rb
237
+ - spec/unit/file_configurator_spec.rb
238
+ - spec/unit/mover_spec.rb
239
+ - spec/unit/object_mover_spec.rb
240
+ - spec/unit/permissions_mover_spec.rb
241
+ - spec/unit/rdf_datastream_mover_spec.rb
242
+ - spec/unit/rdf_datastream_parser_spec.rb
243
+ - spec/unit/rels_ext_datastream_mover_spec.rb
244
+ - spec/unit/repository_migrator_spec.rb
245
+ - spec/unit/rubydora_connection_spec.rb
246
+ - spec/unit/triple_converter_spec.rb