aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v3/db_import.rb24
-rw-r--r--lib/sisu/v3/db_load_tuple.rb36
-rw-r--r--lib/sisu/v3/db_select.rb12
-rw-r--r--lib/sisu/v3/dbi_discreet.rb22
4 files changed, 55 insertions, 39 deletions
diff --git a/lib/sisu/v3/db_import.rb b/lib/sisu/v3/db_import.rb
index 3bb6e210..e4f90e1d 100644
--- a/lib/sisu/v3/db_import.rb
+++ b/lib/sisu/v3/db_import.rb
@@ -69,8 +69,8 @@ module SiSU_DbImport
@@dl=nil
@@hname=nil
attr_accessor :tp
- def initialize(opt,conn,file,sql_type='pg')
- @opt,@conn,@file,@sql_type=opt,conn,file,sql_type
+ def initialize(opt,conn,file_maint,sql_type='pg')
+ @opt,@conn,@file_maint,@sql_type=opt,conn,file_maint,sql_type
@cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
@env=SiSU_Env::InfoEnv.new(@opt.fns)
@dal="#{@env.processing_path.dal}"
@@ -239,7 +239,7 @@ module SiSU_DbImport
end
################ CLEAR ##############
SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple)
- t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file)
+ t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file_maint)
tuple=t.tuple
tuple
end
@@ -283,7 +283,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::LoadDocuments.new(@conn,@col,@opt,@file)
+ t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple
case @col[:lev]
when /1/; @col[:lv1]+=1
@@ -314,7 +314,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::LoadDocuments.new(@conn,@col,@opt,@file)
+ t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple
@col[:lev]=@col[:plaintext]=@col[:body]=''
elsif data.is==:heading \
@@ -344,7 +344,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::LoadDocuments.new(@conn,@col,@opt,@file)
+ t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple
@col[:lev]=@col[:plaintext]=@col[:body]=''
elsif data.is==:heading \
@@ -372,7 +372,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::LoadDocuments.new(@conn,@col,@opt,@file)
+ t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple
@col[:lev]=@col[:plaintext]=@col[:body]=''
elsif data.of==:structure \
@@ -423,7 +423,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::LoadDocuments.new(@conn,@col,@opt,@file)
+ t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple
@en,@en_ast,@en_pls=[],[],[]
@col[:en_a]=@col[:en_z]=nil
@@ -461,7 +461,7 @@ module SiSU_DbImport
id_t: @@id_t,
hash: digest_clean
}
- t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file)
+ t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint)
@tuple_array << t.tuple
end
end
@@ -500,7 +500,7 @@ module SiSU_DbImport
id_t: @@id_t,
hash: digest_clean
}
- t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file)
+ t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint)
@tuple_array << t.tuple
end
end
@@ -539,7 +539,7 @@ module SiSU_DbImport
id_t: @@id_t,
hash: digest_clean
}
- t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file)
+ t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint)
@tuple_array << t.tuple
end
end
@@ -678,7 +678,7 @@ module SiSU_DbImport
if FileTest.file?("#{@md.file.output_path.sisupod.dir}/#{@md.file.base_filename.sisupod}")==true
f[:sisupod],u[:sisupod]='sisupod,', "'#{@md.file.output_path.sisupod.url}/#{@md.file.base_filename.sisupod}',"
end
- t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file)
+ t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file_maint)
tuple=t.tuple
rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error
ensure
diff --git a/lib/sisu/v3/db_load_tuple.rb b/lib/sisu/v3/db_load_tuple.rb
index c3273ace..5b263411 100644
--- a/lib/sisu/v3/db_load_tuple.rb
+++ b/lib/sisu/v3/db_load_tuple.rb
@@ -62,8 +62,8 @@ module SiSU_DbTuple
class LoadDocuments
require_relative 'param' # param.rb
include SiSU_Param
- def initialize(conn,col,opt,file)
- @conn,@col,@opt,@file=conn,col,opt,file
+ def initialize(conn,col,opt,file_maint)
+ @conn,@col,@opt,@file_maint=conn,col,opt,file_maint
@col[:lev]=@col[:lev].to_i
unless @col[:lev]=~/^[1-6]/ \
or @col[:lev]==1 \
@@ -87,14 +87,14 @@ module SiSU_DbTuple
end
if @opt.cmd =~/M/
if @opt.cmd =~/V/
- puts @file.inspect
+ puts @file_maint.inspect
puts sql_entry
end
- @file.puts sql_entry
+ @file_maint.puts sql_entry
else
if @opt.cmd =~/V/
puts sql_entry
- @file.puts sql_entry
+ @file_maint.puts sql_entry
end
end
if @opt.cmd =~/v/
@@ -115,8 +115,8 @@ module SiSU_DbTuple
end
end
class LoadMetadata #< SiSU_DbColumns::Columns
- def initialize(conn,id,md,file)
- @conn,@id,@md,@file=conn,id,md,file
+ def initialize(conn,id,md,file_maint)
+ @conn,@id,@md,@file_maint=conn,id,md,file_maint
@tp=SiSU_DbColumns::Columns.new(md)
end
def tuple
@@ -291,40 +291,40 @@ tid)
#{@id}
);"
if @md.opt.cmd =~/M/
- puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file.inspect}"
- @file.puts sql_entry
+ puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file_maint.inspect}"
+ @file_maint.puts sql_entry
else
- @file.puts sql_entry if @md.opt.cmd =~/V/
+ @file_maint.puts sql_entry if @md.opt.cmd =~/V/
end
sql_entry
end
end
class LoadUrls
- def initialize(conn,f,u,id,opt,file)
- @conn,@f,@u,@id,@opt,@file=conn,f,u,id,opt,file
+ def initialize(conn,f,u,id,opt,file_maint)
+ @conn,@f,@u,@id,@opt,@file_maint=conn,f,u,id,opt,file_maint
end
def tuple
sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) " +
"VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});"
if @opt.cmd =~/M/
- @file.puts sql_entry
+ @file_maint.puts sql_entry
else
- @file.puts sql_entry if @opt.cmd =~/V/
+ @file_maint.puts sql_entry if @opt.cmd =~/V/
end
sql_entry
end
end
class LoadEndnotes
- def initialize(conn,en,opt,file)
- @conn,@en,@opt,@file=conn,en,opt,file
+ def initialize(conn,en,opt,file_maint)
+ @conn,@en,@opt,@file_maint=conn,en,opt,file_maint
end
def tuple
sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) " +
"VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');"
if @opt.cmd =~/M/
- @file.puts sql_entry
+ @file_maint.puts sql_entry
else
- @file.puts sql_entry if @opt.cmd =~/V/
+ @file_maint.puts sql_entry if @opt.cmd =~/V/
end
sql_entry
end
diff --git a/lib/sisu/v3/db_select.rb b/lib/sisu/v3/db_select.rb
index 52fbe8ba..ec6c91dc 100644
--- a/lib/sisu/v3/db_select.rb
+++ b/lib/sisu/v3/db_select.rb
@@ -62,15 +62,15 @@ module SiSU_DbSelect
def initialize(opt,conn='',sql_type='pg')
@opt,@conn,@sql_type=opt,conn,sql_type
@db=SiSU_Env::InfoDb.new
- @file=sql_maintenance_file
- @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
- @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+ @file_maint=sql_maintenance_file
+ @sdb=SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb
+ @sdb_index=SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type) # db_dbi.rb
@sdb_no=SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb
if @opt.mod.inspect =~/update|import/
- @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file,@sql_type)
- @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type)
+ @sdb_import=SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type)
+ @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type)
elsif @opt.mod.inspect =~/remove/
- @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file,@sql_type)
+ @sdb_remove_doc=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type)
end
end
def db_exist?
diff --git a/lib/sisu/v3/dbi_discreet.rb b/lib/sisu/v3/dbi_discreet.rb
index 61ab3a3d..8f7f0c53 100644
--- a/lib/sisu/v3/dbi_discreet.rb
+++ b/lib/sisu/v3/dbi_discreet.rb
@@ -81,6 +81,7 @@ module SiSU_DBI_Discreet #% database building
end
@output_path=@md.file.output_path.sqlite_discreet.dir
@filename=@md.file.base_filename.sqlite_discreet
+ @file_maint=sql_maintenance_file
@file="#{@output_path}/#{@filename}"
end
def build
@@ -114,8 +115,8 @@ module SiSU_DBI_Discreet #% database building
def create_and_populate
db=SiSU_Env::DbOp.new(@md)
conn=db.sqlite_discreet.conn_sqlite3
- sdb=SiSU_DbDBI::Create.new(@opt,conn,@file,'sqlite')
- sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,'sqlite')
+ sdb=SiSU_DbDBI::Create.new(@opt,conn,@file_maint,'sqlite')
+ sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file_maint,'sqlite')
sdb.output_dir?
begin
SiSU_Screen::Ansi.new(@opt.cmd,'SQLite',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi unless @opt.cmd =~/q/
@@ -128,7 +129,7 @@ module SiSU_DBI_Discreet #% database building
sdb.create_table.urls
sdb_index.create_indexes
db_exist?(db,conn)
- sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file,'sqlite')
+ sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,'sqlite')
sdb_import.marshal_load
tell=SiSU_Screen::Ansi.new(@opt.cmd,"sqlite3 #{db.sqlite.db} database?")
tell.puts_grey if @opt.cmd =~/v/
@@ -154,6 +155,21 @@ module SiSU_DBI_Discreet #% database building
end
def populate
end
+ def sql_maintenance_file
+ file=if @opt.inspect =~/M/
+ x=if @opt.fns and not @opt.fns.empty?
+ @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns
+ puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.cmd =~/M/
+ @db=SiSU_Env::InfoDb.new
+ @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql"
+ File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+')
+ elsif @opt.fns and @opt.fns.inspect =~/create/; nil #sort variations later
+ else nil
+ end
+ else nil
+ end
+ file
+ end
end
end
__END__