aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/db_import.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2011-05-05 22:11:58 -0400
committerRalph Amissah <ralph@amissah.com>2011-05-05 22:11:58 -0400
commita9642d67f69d83d3fdb56ab115ef3c10bcd1895c (patch)
tree352c633d6b60a54a9ef74ff143162ac07c981b18 /lib/sisu/v3/db_import.rb
parentdebian/changelog (3.0.7-1) (diff)
parentv3: i18n, sysenv, class variable to prevent unnecessary re-construction of hash (diff)
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib/sisu/v3/db_import.rb')
-rw-r--r--lib/sisu/v3/db_import.rb31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb
index f1e7f064..541399a9 100644
--- a/lib/sisu/v3/db_import.rb
+++ b/lib/sisu/v3/db_import.rb
@@ -96,17 +96,17 @@ module SiSU_DB_import
@col[:lid] ||=0
@col[:lid]=@driver_sqlite3 \
? @conn.execute( sql ).join.to_i \
- : @conn.execute( sql ) { |x| x.fetch_all.to_s.to_i }
+ : @conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
rescue
puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/
end
@col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty?
sql='SELECT MAX(nid) FROM endnotes'
begin
- @id_n ||=0
@id_n=@driver_sqlite3 \
? @conn.execute( sql ).join.to_i \
- : @id_n=@conn.execute( sql ) { |x| x.fetch_all.to_s.to_i }
+ : @id_n=@conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
+ @id_n ||=0
rescue
puts "#{__FILE__}:#{__LINE__}" if @opt.cmd =~/M/
end
@@ -120,7 +120,13 @@ module SiSU_DB_import
@dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here
SiSU_Screen::Ansi.new(@opt.cmd,"#{@db.psql.db}::#{@opt.fns}").puts_blue if @opt.cmd =~/vVM/
SiSU_Screen::Ansi.new(@opt.cmd,'Marshal Load',@fnc).puts_grey if @opt.cmd =~/v/
- select_first_match=%{ SELECT metadata_and_text.tid FROM metadata_and_text WHERE metadata_and_text.src_filename = '#{@opt.fns}'; }
+#%
+ select_first_match=%{
+ SELECT metadata_and_text.tid
+ FROM metadata_and_text
+ WHERE metadata_and_text.src_filename = '#{@opt.fns}'
+ AND metadata_and_text.language_document_char = '#{@opt.lng}'
+ ;}
file_exist=@sql_type=~/sqlite/ \
? @conn.get_first_value(select_first_match) \
: @conn.select_one(select_first_match)
@@ -187,7 +193,7 @@ module SiSU_DB_import
else
if file_exist
@db=SiSU_Env::Info_db.new
- puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}"
+ puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} in language code #{cX.blue}#{@opt.lng}#{cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}"
end
end
end
@@ -215,18 +221,18 @@ module SiSU_DB_import
#@tp[:title]=@md.title.full
#special_character_escape(@tp[:title])
#@tp[:title_f],@tp[:title_i]='title, ',"'#{@tp[:title]}', "
- sql='SELECT MAX(tid) FROM metadata_and_text'
+ sql='SELECT MAX(tid) FROM metadata_and_text;'
begin
@@id_t ||=0
id_t=if @driver_sqlite3
@conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i }
- else @conn.execute( sql ) { |x| x.fetch_all.to_s.to_i }
+ else
+ @conn.execute( sql ) { |x| x.fetch_all.flatten[0] }
end
@@id_t=id_t if id_t
rescue
puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
end
- @@id_t =0 if @col[:lid].nil? or @col[:lid].to_s.empty?
@@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title:
puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} if @opt.cmd =~/vVM/
end
@@ -421,7 +427,8 @@ module SiSU_DB_import
txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
end
if txt
- en={ type: 'endnotes',
+ en={
+ type: 'endnotes',
id: @id_n,
lid: @col[:lid],
nr: nr,
@@ -459,7 +466,8 @@ module SiSU_DB_import
txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
end
if txt
- en={ type: 'endnotes_asterisk',
+ en={
+ type: 'endnotes_asterisk',
id: @id_n,
lid: @col[:lid],
nr: nr,
@@ -497,7 +505,8 @@ module SiSU_DB_import
txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n}
end
if txt
- en={ type: 'endnotes_plus',
+ en={
+ type: 'endnotes_plus',
id: @id_n,
lid: @col[:lid],
nr: nr,