Category=coptot - Database Maintenance
Name=11.1. Import SMR Leaves Description as features
Description=Grabs leaves description data from INTF SMR and imports it into the data model

#OutputLevel=3

Heading=Import LeavesDescription table data from SMR table data

# Dubious documents have had their GA number pushed into Olim in the old
# system.  This converts to DOCUMENT.FORMERGANUMBER
# this allows us to search for DUBIOUS and FORMERGANUMBER to find defunct
# GA NUMBERS
ImportSQL=select * from (select (case when smr like '%sa%' then 620000 when smr like '%bo%' then 600000 when smr like '%fa%' then 631000 when smr like '%mae%' then 632000 when smr like '%ac%' then 633000 when smr like '%cv%' then 634000 when smr like '%cw%' then 635000 when smr like '%ly%' then 636000 end) + cast(substring_index(substring_index(substring_index(substring_index(smr,' ',-1), 'L', 1), 'v', 1),'}',1) as unsigned) as DOCUMENTID, replace(replace(smr, '\\{', ''), '}', '') GANUMBER, Blattzahl LEAVESDESCRIPTION, Zzorg LINECOUNTDESCRIPTION, Blattgroesse HEIGHTDESCRIPTION, Blattgroesse2 WIDTHDESCRIPTION from smr.synopsis_manuscript) t where not exists (select 1 from FEATURE f where f.DOCUMENTID=t.DOCUMENTID and FEATURECODE='LeavesDescription' and USERID='judge') order by DOCUMENTID;|INSERT INTO FEATURE (DOCUMENTID, FEATURECODE, STRINGVAL1, STRINGVAL2, USERID) VALUES ({0}, 'LeavesDescription', '{2}', 'SMR', 'judge');
#ImportSQL=select recordid, smr, (case when smr like '%sa%' then 620000 when smr like '%bo%' then 600000 when smr like '%fa%' then 631000 when smr like '%mae%' then 632000 when smr like '%ac%' then 633000 when smr like '%cv%' then 634000 when smr like '%cw%' then 635000 end) + cast(substring_index(substring_index(substring_index(substring_index(smr,' ',-1), 'L', 1), 'v', 1),'}',1) as unsigned) as n from synopsis_manuscript order by n;| \
# INSERT INTO DOCUMENT (								\
# 	\
# DOCUMENTID, 										\
# GANUMBER, 											\
# LANGUAGE,											\
# COMMENT											\
# ) VALUES ({0}, '{1}','{2}','{3}');

