active-fedora 3.1.0.pre4 → 3.1.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_fedora.rb +1 -0
- data/lib/active_fedora/fixture_loader.rb +46 -0
- data/lib/active_fedora/version.rb +1 -1
- metadata +4 -3
data/lib/active_fedora.rb
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
module ActiveFedora
|
2
|
+
class FixtureLoader
|
3
|
+
attr_accessor :path
|
4
|
+
|
5
|
+
def initialize(path)
|
6
|
+
self.path = path
|
7
|
+
end
|
8
|
+
|
9
|
+
def filename_for_pid(pid)
|
10
|
+
File.join(path, "#{pid.gsub(":","_")}.foxml.xml")
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.delete(pid)
|
14
|
+
begin
|
15
|
+
ActiveFedora::Base.load_instance(pid).delete
|
16
|
+
1
|
17
|
+
rescue ActiveFedora::ObjectNotFoundError
|
18
|
+
logger.debug "The object #{pid} has already been deleted (or was never created)."
|
19
|
+
0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def reload(pid)
|
24
|
+
self.class.delete(pid)
|
25
|
+
import_and_index(pid)
|
26
|
+
end
|
27
|
+
|
28
|
+
def import_and_index(pid)
|
29
|
+
body = self.class.import_to_fedora(filename_for_pid(pid))
|
30
|
+
self.class.index(pid)
|
31
|
+
body
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.index(pid)
|
35
|
+
solrizer = Solrizer::Fedora::Solrizer.new
|
36
|
+
solrizer.solrize(pid)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.import_to_fedora(filename)
|
40
|
+
file = File.new(filename, "r")
|
41
|
+
result = ActiveFedora::RubydoraConnection.instance.connection.ingest(:file=>file.read)
|
42
|
+
raise "Failed to ingest the fixture." unless result
|
43
|
+
result.body
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-fedora
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1923832019
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
9
|
- 0
|
10
10
|
- pre
|
11
|
-
-
|
12
|
-
version: 3.1.0.
|
11
|
+
- 5
|
12
|
+
version: 3.1.0.pre5
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Matt Zumwalt
|
@@ -579,6 +579,7 @@ files:
|
|
579
579
|
- lib/active_fedora/datastream_hash.rb
|
580
580
|
- lib/active_fedora/delegating.rb
|
581
581
|
- lib/active_fedora/fedora_object.rb
|
582
|
+
- lib/active_fedora/fixture_loader.rb
|
582
583
|
- lib/active_fedora/metadata_datastream.rb
|
583
584
|
- lib/active_fedora/metadata_datastream_helper.rb
|
584
585
|
- lib/active_fedora/model.rb
|