diff options
Diffstat (limited to 'lib/sisu/v3dv/db_import.rb')
-rw-r--r-- | lib/sisu/v3dv/db_import.rb | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/lib/sisu/v3dv/db_import.rb b/lib/sisu/v3dv/db_import.rb index 2659f4c1..adbe5af5 100644 --- a/lib/sisu/v3dv/db_import.rb +++ b/lib/sisu/v3dv/db_import.rb @@ -72,7 +72,7 @@ module SiSU_DbImport def initialize(opt,conn,file,sql_type='pg') @opt,@conn,@file,@sql_type=opt,conn,file,sql_type @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) @dal="#{@env.processing_path.dal}" if @opt.fns.empty? or @opt.cmd.empty?; @fnb='' else @@ -85,7 +85,7 @@ module SiSU_DbImport @col=Hash.new('') @col[:ocn]='' @counter={} - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new if @sql_type=='sqlite' @driver_sqlite3=(@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ ? true @@ -112,8 +112,8 @@ module SiSU_DbImport end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0 - @db=SiSU_Env::Info_db.new - @@dl ||=SiSU_Env::Info_env.new.digest.length + @db=SiSU_Env::InfoDb.new + @@dl ||=SiSU_Env::InfoEnv.new.digest.length end def marshal_load require_relative 'dal' # dal.rb @@ -167,7 +167,7 @@ module SiSU_DbImport puts "Error code: #{e.err}" puts "Error message: #{e.errstr}" puts "Error SQLSTATE: #{e.state}" - SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} @@ -178,7 +178,7 @@ module SiSU_DbImport puts "#{__FILE__}:#{__LINE__}" end rescue - SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" sql=File.new(sqlfn,'w') t_d.each {|i| sql.puts i} @@ -192,7 +192,7 @@ module SiSU_DbImport end else if file_exist - @db=SiSU_Env::Info_db.new + @db=SiSU_Env::InfoDb.new 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 @@ -238,7 +238,7 @@ module SiSU_DbImport end ################ CLEAR ############## SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) - t=SiSU_DbTuple::Load_metadata.new(@conn,@@id_t,@md,@file) + t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file) tuple=t.tuple tuple end @@ -278,7 +278,7 @@ module SiSU_DbImport end if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end - t=SiSU_DbTuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple case @col[:lev] when /1/; @col[:lv1]+=1 @@ -298,7 +298,7 @@ module SiSU_DbImport @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus @@ -309,7 +309,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' elsif data.is=='heading' and data.ln==5 @@ -325,7 +325,7 @@ module SiSU_DbImport @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus @@ -336,7 +336,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' elsif data.is=='heading' and data.ln==6 @@ -352,7 +352,7 @@ module SiSU_DbImport @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any @col[:body]=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus @@ -363,7 +363,7 @@ module SiSU_DbImport @en_a,@en_z=@en[0].first,@en[0].last if @en[0] @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @col[:lev]=@col[:plaintext]=@col[:body]='' else #% regular text @@ -375,11 +375,11 @@ module SiSU_DbImport @@hname=@col[:seg].to_s else @@hname end - @env=SiSU_Env::Info_env.new(@md.fns) + @env=SiSU_Env::InfoEnv.new(@md.fns) @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" txt=endnotes(txt).extract_any if @sql_type=~/pg/ \ - and txt.size > (SiSU_DbColumns::Column_size.new.document_clean - 1) #% examine pg build & remove limitation + and txt.size > (SiSU_DbColumns::ColumnSize.new.document_clean - 1) #% examine pg build & remove limitation puts "\n\nTOO LARGE (TXT - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nTEXT BODY\n#{@col[:body].size} object #{@col[:ocn]} -> #{@col[:body].slice(0..500)}") @@ -410,7 +410,7 @@ module SiSU_DbImport @col[:plaintext]=@col[:body].dup @col[:plaintext]=strip_markup(@col[:plaintext]) @col[:plaintext]=clean_searchable_text(@col[:plaintext]) - t=SiSU_DbTuple::Load_documents.new(@conn,@col,@opt,@file) + t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file) @tuple_array << t.tuple @en,@en_ast,@en_pls=[],[],[] @col[:en_a]=@col[:en_z]=nil @@ -427,7 +427,7 @@ module SiSU_DbImport special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) strip_markup(txt) - if txt.size > (SiSU_DbColumns::Column_size.new.endnote_clean - 1) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -448,7 +448,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -466,7 +466,7 @@ module SiSU_DbImport special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) strip_markup(txt) - if txt.size > (SiSU_DbColumns::Column_size.new.endnote_clean - 1) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -487,7 +487,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -505,7 +505,7 @@ module SiSU_DbImport special_character_escape(txt) body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) strip_markup(txt) - if txt.size > (SiSU_DbColumns::Column_size.new.endnote_clean - 1) + if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") @@ -526,7 +526,7 @@ module SiSU_DbImport id_t: @@id_t, hash: digest_clean } - t=SiSU_DbTuple::Load_endnotes.new(@conn,en,@opt,@file) + t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file) @tuple_array << t.tuple end end @@ -535,7 +535,7 @@ module SiSU_DbImport end end end - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end @tuple_array @@ -598,7 +598,7 @@ module SiSU_DbImport def db_import_urls(dbi_unit,content) #% import documents OID - populate database begin @fnc=content - @env=SiSU_Env::Info_env.new(@opt.fns) + @env=SiSU_Env::InfoEnv.new(@opt.fns) base=@env.url.root out=@env.path.output f,u={},{} @@ -654,9 +654,9 @@ module SiSU_DbImport if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tgz")==true f[:sisupod],u[:sisupod]='sisupod,', "'#{base}/#{@fnb}/#{@opt.fns}.tgz'," end - t=SiSU_DbTuple::Load_urls.new(@conn,f,u,@@id_t,@opt,@file) + t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file) tuple=t.tuple - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error ensure end tuple |