zcc 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +16 -0
- data/Manifest.txt +4 -4
- data/Rakefile +1 -1
- data/bin/zcc +352 -228
- data/examples/zcc.yaml +62 -34
- data/examples/zebra/accessfile +1 -0
- data/examples/zebra/records/0.xml +1 -0
- data/examples/zebra/shadow/remove_me +1 -0
- data/examples/zebra/tab/bib1.att +9 -56
- data/examples/zebra/tab/record.abs +215 -44
- data/examples/zebra/zcc_passw +1 -0
- data/examples/zebra/zebra.cfg +20 -15
- data/lib/zcc/cli_display.rb +64 -42
- data/lib/zcc/query.rb +30 -27
- data/lib/zcc/record.rb +38 -3
- data/lib/zcc/resultset.rb +1 -0
- data/lib/zcc/version.rb +1 -1
- data/website/index.html +7 -5
- data/website/index.txt +2 -2
- data/website/koha.html +32 -19
- data/website/koha.txt +3 -3
- data/website/stylesheets/screen.css +2 -2
- data/website/zcc.html +86 -34
- data/website/zcc.txt +49 -28
- data/website/zebra.html +15 -46
- data/website/zebra.txt +11 -47
- metadata +8 -8
- data/examples/zebra/records/0.mrc +0 -1
- data/examples/zebra/tab/marc21.abs +0 -67
- data/lib/zcc/subfieldeditor.rb +0 -70
- data/lib/zcc/zoomer.rb +0 -86
data/History.txt
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
== 0.2.0 Wed Nov 21 14:43:00 EST 2007
|
2
|
+
* This version is incompatible with previous versions.
|
3
|
+
* major changes:
|
4
|
+
* added full record editing using yaz-marcdump command line utility and
|
5
|
+
the plain text editor of your choice
|
6
|
+
* uses extended services of zoom-0.4.1 to save records to zebra database
|
7
|
+
* ability added to configure and pick from various different script to
|
8
|
+
be run over records
|
9
|
+
* minor changes:
|
10
|
+
* menu options and how choices work have changed
|
11
|
+
* shows whole record if only one is fetched
|
12
|
+
* added config option to automatically start and
|
13
|
+
kill a zebra server
|
14
|
+
|
15
|
+
|
16
|
+
|
1
17
|
== 0.1.0
|
2
18
|
* The version is incompatible with previous versions.
|
3
19
|
* major changes:
|
data/Manifest.txt
CHANGED
@@ -6,10 +6,12 @@ Rakefile
|
|
6
6
|
bin/zcc
|
7
7
|
examples/linter.pl
|
8
8
|
examples/zcc.yaml
|
9
|
+
examples/zebra/accessfile
|
9
10
|
examples/zebra/key/remove_me
|
10
11
|
examples/zebra/lock/remove_me
|
11
|
-
examples/zebra/records/0.
|
12
|
+
examples/zebra/records/0.xml
|
12
13
|
examples/zebra/register/remove_me
|
14
|
+
examples/zebra/shadow/remove_me
|
13
15
|
examples/zebra/tab/bib1.abs
|
14
16
|
examples/zebra/tab/bib1.att
|
15
17
|
examples/zebra/tab/default.idx
|
@@ -17,13 +19,13 @@ examples/zebra/tab/explain.abs
|
|
17
19
|
examples/zebra/tab/explain.att
|
18
20
|
examples/zebra/tab/explain.tag
|
19
21
|
examples/zebra/tab/gils.att
|
20
|
-
examples/zebra/tab/marc21.abs
|
21
22
|
examples/zebra/tab/numeric.chr
|
22
23
|
examples/zebra/tab/record.abs
|
23
24
|
examples/zebra/tab/sort-string-utf.chr
|
24
25
|
examples/zebra/tab/tagsetm.tag
|
25
26
|
examples/zebra/tab/usmarc.mar
|
26
27
|
examples/zebra/tab/word-phrase-utf.chr
|
28
|
+
examples/zebra/zcc_passw
|
27
29
|
examples/zebra/zebra.cfg
|
28
30
|
examples/zoomer-iterator.txt
|
29
31
|
examples/zservers.yaml
|
@@ -33,9 +35,7 @@ lib/zcc/cli_display.rb
|
|
33
35
|
lib/zcc/query.rb
|
34
36
|
lib/zcc/record.rb
|
35
37
|
lib/zcc/resultset.rb
|
36
|
-
lib/zcc/subfieldeditor.rb
|
37
38
|
lib/zcc/version.rb
|
38
|
-
lib/zcc/zoomer.rb
|
39
39
|
lib/zcc/zserver.rb
|
40
40
|
scripts/txt2html
|
41
41
|
setup.rb
|
data/Rakefile
CHANGED
@@ -73,7 +73,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
73
73
|
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
74
74
|
p.extra_deps = [
|
75
75
|
['marc','>=0.1.6'],
|
76
|
-
['zoom', '>=0.
|
76
|
+
['zoom', '>=0.4.1'],
|
77
77
|
['unicode','>=0.1'],
|
78
78
|
['highline', '>=1.2.9'],
|
79
79
|
['term-ansicolor', '>=1.0.2']
|
data/bin/zcc
CHANGED
@@ -1,228 +1,352 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
## Jason Ronallo
|
3
|
-
# July, 2007
|
4
|
-
#zcc-new
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require 'zoom'
|
8
|
-
require 'marc'
|
9
|
-
require 'highline/import'
|
10
|
-
require 'term/ansicolor'
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
require '
|
15
|
-
require '
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
require '
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
end
|
227
|
-
|
228
|
-
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
## Jason Ronallo
|
3
|
+
# July, 2007
|
4
|
+
#zcc-new
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'zoom'
|
8
|
+
require 'marc'
|
9
|
+
require 'highline/import'
|
10
|
+
require 'term/ansicolor'
|
11
|
+
require 'getoptlong'
|
12
|
+
#include Term::ANSIColor
|
13
|
+
|
14
|
+
require 'stringio'
|
15
|
+
require 'yaml'
|
16
|
+
require 'tempfile'
|
17
|
+
|
18
|
+
$KCODE = 'u'
|
19
|
+
require 'jcode'
|
20
|
+
require 'unicode'
|
21
|
+
|
22
|
+
require 'zcc'
|
23
|
+
include ZCC
|
24
|
+
$testing = false
|
25
|
+
opts = GetoptLong.new( [ '--yaml', '-y', GetoptLong::REQUIRED_ARGUMENT ],
|
26
|
+
['--testing', '-t', GetoptLong::NO_ARGUMENT]
|
27
|
+
)
|
28
|
+
opts_yaml =''
|
29
|
+
opts.each do |opt, arg|
|
30
|
+
case opt
|
31
|
+
when '--yaml'
|
32
|
+
opts_yaml = arg
|
33
|
+
when '--testing'
|
34
|
+
$testing = true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if opts_yaml.length > 0
|
39
|
+
file_yaml = opts_yaml
|
40
|
+
else
|
41
|
+
file_yaml = 'zcc.yaml'
|
42
|
+
end
|
43
|
+
|
44
|
+
termsize = HighLine::SystemExtensions.terminal_size
|
45
|
+
$term_width = termsize[0]
|
46
|
+
$term_height = termsize[1]
|
47
|
+
$clear_code = %x{clear}
|
48
|
+
HighLine.track_eof = false
|
49
|
+
|
50
|
+
##Setting up testing parameter
|
51
|
+
#$testing = ARGV[0]
|
52
|
+
#$testing = nil unless $testing == 'v' or $testing == 't'
|
53
|
+
|
54
|
+
## FIXME: make use of a 'file' version of zcc where records are not taken from zservers but from a file. Way to process a batch of records with the same scripting.
|
55
|
+
file_mode = true if ARGV[0] == 'file'
|
56
|
+
|
57
|
+
#reading in config from yaml file
|
58
|
+
begin
|
59
|
+
yamlfile = YAML.load_file( "#{file_yaml}" )
|
60
|
+
rescue Exception
|
61
|
+
puts "You must either start zcc in the same directory as a file named 'zcc.yaml' or give the '-yaml' switch with the full path to the yaml file which includes configuration information. This feature allows you to start zcc with different configuration files.\nzcc -yaml /home/jason/.zcc/zcc.yaml"
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
|
65
|
+
labels = yamlfile['labels']
|
66
|
+
scripting = yamlfile['scripting']
|
67
|
+
#puts scripting.inspect
|
68
|
+
#gets
|
69
|
+
$procs = yamlfile['procs']
|
70
|
+
|
71
|
+
TO_SHOW = yamlfile['to_show']
|
72
|
+
SHOW_PER_PAGE = yamlfile['show_per_page']
|
73
|
+
FIELDS_TO_SHOW = yamlfile['fields_to_show']
|
74
|
+
HOW_TO_SAVE = yamlfile['save_filename']
|
75
|
+
TIMESTAMP = Time.now.strftime("%Y%m%d%H%M%S")
|
76
|
+
SCRIPTING = yamlfile['scripting_on']
|
77
|
+
EDITING = yamlfile['subfield_editing']
|
78
|
+
FULL_EDITING = yamlfile['full_editing']
|
79
|
+
TEXT_EDITOR = yamlfile['text_editor']
|
80
|
+
CSV = yamlfile['csv_on']
|
81
|
+
LINTER = yamlfile['linter_on']
|
82
|
+
FORMAT_TO_SAVE = yamlfile['save_record_syntax']
|
83
|
+
ROOT = yamlfile['root']
|
84
|
+
START_ZEBRA = yamlfile['start_zebra']
|
85
|
+
KILL_ZEBRA = yamlfile['kill_zebra']
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def get_user_pass
|
90
|
+
user_pass = IO.read("#{ROOT}/zebra/zcc_passw").chomp
|
91
|
+
user, pass = user_pass.split(":")
|
92
|
+
end
|
93
|
+
USER, PASS = get_user_pass
|
94
|
+
puts "user |" + USER + "|"
|
95
|
+
puts "pass |" + PASS + "|"
|
96
|
+
|
97
|
+
def quit_routine
|
98
|
+
#print "killing zebra: "
|
99
|
+
puts $zebra_pid if $zebra_pid
|
100
|
+
Process.kill('TERM', $zebra_pid) if KILL_ZEBRA
|
101
|
+
exit
|
102
|
+
end
|
103
|
+
|
104
|
+
print $clear_code
|
105
|
+
#printed once when starting the program.
|
106
|
+
say("ZCC v. 0.2.0.\nZCC, Copyright (C) 2007 Jason Ronallo\nZcc comes with ABSOLUTELY NO WARRANTY.\nZcc is released under the terms of the GPL v.2 or later.\nSee LICENSE for full information.\n".bold)
|
107
|
+
say("Simply enter a title, LCCN or ISBN and hit enter.\nTitle: enter the title exactly as it is on the source\n for better relevancy ranking by title.\nLCCN: Include the dash, like 81-21962\nEnter ISBNs without dashes.\nNot all servers accept it, but you can also do a narrowing search\nby including an author's name after the title like so:\nFinnegans Wake :au Joyce")
|
108
|
+
say("For more help see: http://zcc.rubyforge.org/zcc.html")
|
109
|
+
|
110
|
+
#start zebra server if
|
111
|
+
if START_ZEBRA
|
112
|
+
Dir.chdir("#{ROOT}/zebra") do
|
113
|
+
$zebra_pid = fork do
|
114
|
+
STDERR.close
|
115
|
+
exec "zebrasrv @:9998 -l zebrasrv.log"
|
116
|
+
end
|
117
|
+
end
|
118
|
+
else
|
119
|
+
$zebra_pid = false
|
120
|
+
end
|
121
|
+
|
122
|
+
zservers = yamlfile['zservers']
|
123
|
+
|
124
|
+
if zservers[0][0] =~ /Include/
|
125
|
+
filename = zservers[0][0][8, 99]
|
126
|
+
contents = YAML.load_file("#{ROOT}/#{filename}")
|
127
|
+
contents.each{|c| zservers.push(c)}
|
128
|
+
zservers[0] = nil
|
129
|
+
end
|
130
|
+
zservers.compact!
|
131
|
+
|
132
|
+
zserver_objects = []
|
133
|
+
zservers.each do |server|
|
134
|
+
zserver_objects << Zserver.new(server[0], server[1], server[2], server[3])
|
135
|
+
end
|
136
|
+
|
137
|
+
server_h = Hash.new {|hash, key| hash[key] = [] }
|
138
|
+
zserver_objects.each {|z| server_h[z.group] << z}
|
139
|
+
|
140
|
+
groups = []
|
141
|
+
server_h.each_key{|k| groups << k}
|
142
|
+
groups.uniq!
|
143
|
+
groups.sort!
|
144
|
+
|
145
|
+
loop {
|
146
|
+
search_term = ask("\nEnter search. [ISBN, title, LCCN (with dash), or :q to quit]\nsearch> ".boldz, String){ |q| q.readline = true }
|
147
|
+
quit_routine if search_term == ':q'
|
148
|
+
|
149
|
+
taken = ResultSet.new
|
150
|
+
groups.each do |group|
|
151
|
+
print $clear_code
|
152
|
+
servers = server_h[group]
|
153
|
+
query = Query.new(search_term, servers)
|
154
|
+
results = query.search(TO_SHOW)
|
155
|
+
results.index_pos = SHOW_PER_PAGE - 1
|
156
|
+
if results.records.empty?
|
157
|
+
puts "There are no results from group #{group} servers!\n\n\n"
|
158
|
+
another_group = ask("Do you want to continue searching the next group of servers? [y], anything ".boldz)
|
159
|
+
if another_group == 'y' || another_group == ''
|
160
|
+
next
|
161
|
+
else
|
162
|
+
print $clear_code
|
163
|
+
break
|
164
|
+
end
|
165
|
+
end
|
166
|
+
results.rank_by_relevance!
|
167
|
+
return_value = zcc_select_good_marc(results, 'multi')
|
168
|
+
quit_routine if return_value == 'quit'
|
169
|
+
taken << results
|
170
|
+
break if return_value == 'done'
|
171
|
+
end
|
172
|
+
|
173
|
+
taken.remove_unselected!
|
174
|
+
next if taken.empty?
|
175
|
+
continue = true
|
176
|
+
print $clear_code
|
177
|
+
#say("\aThis is your combined result set.\nWe will winnow until you choose ".white.bold.on_black + "'done'".red.bold + "\nor you unselect all records.".white.bold.on_black)
|
178
|
+
#sleep 1
|
179
|
+
while continue
|
180
|
+
return_value = zcc_select_good_marc(taken, 'winnow')
|
181
|
+
quit_routine if return_value == 'quit'
|
182
|
+
continue = false if taken.selected_length == 0
|
183
|
+
continue = false if return_value == 'done'
|
184
|
+
end
|
185
|
+
taken.remove_unselected!
|
186
|
+
unless taken.length == 0
|
187
|
+
puts "Here are the records you've selected for processing:"
|
188
|
+
taken.each do |record|
|
189
|
+
puts record.title
|
190
|
+
end
|
191
|
+
#sleep 2
|
192
|
+
end
|
193
|
+
|
194
|
+
taken.records.each do |final_taken|
|
195
|
+
#puts final_taken.class; STDIN.gets
|
196
|
+
#SCRIPTING and EDITING
|
197
|
+
def which_script scripting
|
198
|
+
loop do
|
199
|
+
choose do |scripting_menu|
|
200
|
+
scripting_menu.layout = :list
|
201
|
+
scripting_menu.index = :number
|
202
|
+
scripting_menu.readline = true
|
203
|
+
scripting_menu.shell = true
|
204
|
+
scripting_menu.prompt = "Enter which script you would like to run on this record: "
|
205
|
+
scripting_menu.select_by = :index_or_name
|
206
|
+
scripting_menu.choice(:none, "No script will be run.") {|cmd, d| return 'none'}
|
207
|
+
scripting.each do |key, value|
|
208
|
+
unless key == 'start' || key == 'end'
|
209
|
+
scripting_menu.choice(key, "no help, ha!") do |cmd, d|
|
210
|
+
if cmd == :help
|
211
|
+
next
|
212
|
+
else
|
213
|
+
return scripting[cmd]
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def display_record record
|
223
|
+
print $clear_code
|
224
|
+
print "\a"
|
225
|
+
say("#{ZCC.zcc_marc_str_bold(record.to_s, 'record')}")
|
226
|
+
end
|
227
|
+
|
228
|
+
if SCRIPTING
|
229
|
+
display_record(final_taken)
|
230
|
+
picked_scripting = which_script scripting
|
231
|
+
display_record(final_taken)
|
232
|
+
say("SCRIPTING...".bold.white.on_black)
|
233
|
+
final_taken.local_script(scripting["start"]) if scripting["start"] && picked_scripting != 'none'
|
234
|
+
final_taken.local_script(picked_scripting) unless picked_scripting == 'none'
|
235
|
+
final_taken.local_script(scripting["end"]) if scripting["end"] && picked_scripting != 'none'
|
236
|
+
end
|
237
|
+
|
238
|
+
if EDITING
|
239
|
+
display_record(final_taken)
|
240
|
+
edit = ask("Would you like to " + "edit any subfields".headline + " in this record [yes or ANYTHING]? ")
|
241
|
+
if edit == ('y' or 'yes')
|
242
|
+
print $clear_code
|
243
|
+
say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
|
244
|
+
puts final_taken.class
|
245
|
+
final_taken.edit
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
|
250
|
+
if FULL_EDITING
|
251
|
+
display_record(final_taken)
|
252
|
+
edit2 = ask("Would you like to " + "edit".headline + " this record in" + " #{TEXT_EDITOR} ".headline + "[yes or ANYTHING]? ")
|
253
|
+
if edit2 == ('y' or 'yes')
|
254
|
+
print $clear_code
|
255
|
+
say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
|
256
|
+
final_taken.full_edit
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
print $clear_code
|
261
|
+
say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
|
262
|
+
say("#{ZCC.zcc_marc_str_bold(final_taken.to_s, 'record')}")
|
263
|
+
say("#{'-'*20}FINAL RECORD#{'-'*20}".headline)
|
264
|
+
to_save_or_not_to_save = ask("Would you like to keep this FINAL RECORD? (ANYTHING or n)")
|
265
|
+
|
266
|
+
if to_save_or_not_to_save == 'n'
|
267
|
+
next #if continue? == 'again'
|
268
|
+
end
|
269
|
+
|
270
|
+
if CSV
|
271
|
+
display_record(final_taken)
|
272
|
+
say("Label making time!".headline)
|
273
|
+
csv = final_taken.marc_to_csv(labels)
|
274
|
+
print "Final csv:\n#{csv}\n"
|
275
|
+
end
|
276
|
+
|
277
|
+
print $clear_code
|
278
|
+
clear_code_do = false
|
279
|
+
|
280
|
+
|
281
|
+
#saves in the directory in which zcc was run
|
282
|
+
if HOW_TO_SAVE == 'search_term'
|
283
|
+
filename = search_term.gsub(' ','_')
|
284
|
+
elsif HOW_TO_SAVE == 'timestamp'
|
285
|
+
filename = TIMESTAMP
|
286
|
+
end
|
287
|
+
|
288
|
+
FORMAT_TO_SAVE.each do |format|
|
289
|
+
if format == 'marc'
|
290
|
+
puts
|
291
|
+
aFile = File.new("#{filename}\.mrc","a+")
|
292
|
+
aFile.write(final_taken.marc.to_marc)
|
293
|
+
puts "#{final_taken.marc['245']['a']} saved in #{filename}\.mrc"
|
294
|
+
aFile.close
|
295
|
+
puts
|
296
|
+
elsif format == 'xml'
|
297
|
+
#puts final_taken.marc.to_xml
|
298
|
+
aFile = File.new("#{filename}\.xml","a+")
|
299
|
+
aFile.write(final_taken.marc.to_xml)
|
300
|
+
puts "#{final_taken.marc['245']['a']} saved in #{filename}\.xml"
|
301
|
+
aFile.close
|
302
|
+
elsif format == 'zebra'
|
303
|
+
#create the recordID which zebra will use to index
|
304
|
+
t = Time.now
|
305
|
+
the_time = "%10.6f" % t.to_f
|
306
|
+
final_taken.marc.append(MARC::DataField.new('901', '0', '1', ['a', "#{the_time}"])) unless final_taken.marc['901'] && final_taken.marc['901']['a']
|
307
|
+
|
308
|
+
#connect to zebrasrv and insert record
|
309
|
+
conn = ZOOM::Connection.new('user' => USER, 'password' => PASS).connect('localhost:9998/zcc')
|
310
|
+
p = conn.package
|
311
|
+
p.wait_action = 'waitIfPossible'
|
312
|
+
p.action = 'specialUpdate'
|
313
|
+
p.record = final_taken.marc.to_xml
|
314
|
+
p.send('update')
|
315
|
+
p.send('commit')
|
316
|
+
puts "Finished commit of #{final_taken.marc['245']['a']} to zebra server."
|
317
|
+
|
318
|
+
#place backup filesystem copy in zebra directory
|
319
|
+
#with extended services the record is saved to zebra internal store
|
320
|
+
#this also saves it to the file system
|
321
|
+
File.open("#{ROOT}/zebra/records/#{final_taken.marc['901']['a']}\.xml", "w") do |f|
|
322
|
+
f.write final_taken.marc.to_xml
|
323
|
+
end
|
324
|
+
elsif format == 'koha2'
|
325
|
+
puts
|
326
|
+
out = Tempfile.new("koha2-")
|
327
|
+
out << final_taken.marc.to_marc
|
328
|
+
out.close
|
329
|
+
koha_save = `perl /usr/local/koha/intranet/scripts/misc/migration_tools/bulkmarcimport.pl -v 6 -file #{out.path}`
|
330
|
+
puts koha_save
|
331
|
+
puts
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
if CSV
|
336
|
+
puts
|
337
|
+
csvFile = File.new("csv-#{filename}\.txt","a+")
|
338
|
+
csvFile.write(csv)
|
339
|
+
puts "csv for #{final_taken.marc['245']['a']} saved in csv-#{filename}\.txt"
|
340
|
+
csvFile.close
|
341
|
+
puts
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
|