aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4/db_import.rb
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-09-21 00:57:26 -0400
committerRalph Amissah <ralph@amissah.com>2013-09-21 00:57:26 -0400
commit1f3f3a745f89dc0d7d85edb12e5b95940e8872dd (patch)
treed55b7ab58ac6f19c8a26939ad9e0da41ebf99748 /lib/sisu/v4/db_import.rb
parentdebian/changelog (4.2.3-2) (diff)
parentRakefile to assist in placing sisu markup under po4a management (sisu_manual) (diff)
Merge tag 'sisu_4.2.4' into debian/sid
SiSU 4.2.4
Diffstat (limited to 'lib/sisu/v4/db_import.rb')
-rw-r--r--lib/sisu/v4/db_import.rb30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/sisu/v4/db_import.rb b/lib/sisu/v4/db_import.rb
index 240efd67..0384795a 100644
--- a/lib/sisu/v4/db_import.rb
+++ b/lib/sisu/v4/db_import.rb
@@ -209,6 +209,26 @@ module SiSU_DbImport
end
def pf_db_import_transaction_close
end
+ def book_idx_hash_to_str(book_idx)
+ book_idx=book_idx ? book_idx : ''
+ book_idx_str,book_subidx_part='',''
+ if not book_idx.empty?
+ book_idx_str=''
+ book_idx.each_pair do |k0,v0|
+ book_idx_str << %{#{k0}+#{v0[:plus]}}
+ book_subidx_part=''
+ if v0[:sub].length > 0
+ v0[:sub].each do |subterms|
+ subterms.each_pair do |k1,v1|
+ book_subidx_part << %{\n #{k1}+#{v1[:plus]} | }
+ end
+ end
+ book_idx_str=book_idx_str + ':' + book_subidx_part
+ end
+ end
+ end
+ book_idx_str
+ end
def db_import_metadata #% import documents - populate database
print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } if @opt.cmd =~/vVM/
@tp={}
@@ -285,7 +305,7 @@ module SiSU_DbImport
plaintext=@col[:body].dup
plaintext=strip_markup(plaintext)
@col[:plaintext]=clean_searchable_text(plaintext)
- book_idx=data.idx ? data.idx : ''
+ book_idx=book_idx_hash_to_str(data.idx)
@col[:book_idx]=clean_searchable_text(book_idx)
if @en[0] then @en_a,@en_z=@en[0].first,@en[0].last
end
@@ -321,7 +341,7 @@ module SiSU_DbImport
plaintext=@col[:body].dup
plaintext=strip_markup(plaintext)
@col[:plaintext]=clean_searchable_text(plaintext)
- book_idx=data.idx ? data.idx : ''
+ book_idx=book_idx_hash_to_str(data.idx)
@col[:book_idx]=clean_searchable_text(book_idx)
@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]
@@ -353,7 +373,7 @@ module SiSU_DbImport
plaintext=@col[:body].dup
plaintext=strip_markup(plaintext)
@col[:plaintext]=clean_searchable_text(plaintext)
- book_idx=data.idx ? data.idx : ''
+ book_idx=book_idx_hash_to_str(data.idx)
@col[:book_idx]=clean_searchable_text(book_idx)
@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]
@@ -383,7 +403,7 @@ module SiSU_DbImport
plaintext=@col[:body].dup
plaintext=strip_markup(plaintext)
@col[:plaintext]=clean_searchable_text(plaintext)
- book_idx=data.idx ? data.idx : ''
+ book_idx=book_idx_hash_to_str(data.idx)
@col[:book_idx]=clean_searchable_text(book_idx)
@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]
@@ -441,7 +461,7 @@ module SiSU_DbImport
plaintext=@col[:body].dup
plaintext=strip_markup(plaintext)
@col[:plaintext]=clean_searchable_text(plaintext)
- book_idx=data.idx ? data.idx : ''
+ book_idx=book_idx_hash_to_str(data.idx)
@col[:book_idx]=clean_searchable_text(book_idx)
t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint)
@tuple_array << t.tuple