iView home page
iView Multimedia Forum Index

FAQ FAQ     SearchSearch     MemberlistMemberlist     UsergroupsUsergroups    RegisterRegister  
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

too slow code moving annotations to sqlite ....

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> AppleScript
View previous topic :: View next topic  
Author Message
imigra



Joined: 04 Dec 2005
Posts: 2

PostPosted: Tue Apr 22, 2008 11:12 pm    Post subject: too slow code moving annotations to sqlite .... Reply with quote

hi there,

i'm not a programmer, but i concocted this piece of applescript (most of the code comes from various examples) in order to save my old iview catalogs to sqlite databases so i can get to the data in the future if i should need it from within another dam solution. it is very slow though. i suppose this is because of all the set and get commands. any sugestions to make it faster?

thanks,
imigra

-- Copiar todos os campos iptc de um catálogo iview para uma base de dados sqlite

tell application "Database Events"
launch
end tell

set theOutputFolder to choose folder with prompt "Please select an output folder, a database called iview will be created there:"
tell application "Database Events"
make new database with properties {name:"iview", location:theOutputFolder}
end tell

set theSelection to GetSelection()
tell window 1 of application "iView MediaPro"
set numProc to 1
set totalselec to count of theSelection
repeat with p_srcImg in theSelection
set Annots to annotations of p_srcImg
if (numProc mod 10 = 0) then
display dialog ("Processing file " & numProc & " of " & totalselec) buttons {"OK"} default button 1 giving up after 2
end if
set numProc to numProc + 1
-- nome da foto
set p_ann_name to name of p_srcImg
-- iptc da foto
-- info normal
set p_ann_description to caption of p_srcImg
set p_ann_description_writer to annotation writer of p_srcImg
set p_ann_date_created to event date of p_srcImg
set p_ann_headline to headline of p_srcImg
set p_ann_instructions to instructions of p_srcImg
set p_ann_creator_title to author title of p_srcImg
set p_ann_provider to credit of p_srcImg
set p_ann_source to source of p_srcImg
set p_ann_url to url of p_srcImg
set p_ann_list_of_scenes to scenes of p_srcImg
set p_ann_list_of_subject_codes to subject codes of p_srcImg
set p_ann_genre to genre of p_srcImg
set p_ann_usage_terms to usage terms of p_srcImg
set p_ann_job_identifier to transmission of p_srcImg
set p_ann_primary_category to primary category of p_srcImg
set p_ann_copyright_notice to copyright of p_srcImg
set p_ann_status to status of p_srcImg
set p_ann_event to event of p_srcImg

-- info pessoal
set p_ann_creator to author of p_srcImg
set p_ann_title to product of p_srcImg
set p_ann_creator_address to creator address of p_srcImg
set p_ann_creator_city to creator city of p_srcImg
set p_ann_creator_state to creator state of p_srcImg
set p_ann_creator_post_code to creator post code of p_srcImg
set p_ann_creator_country to creator country of p_srcImg
set p_ann_creator_phone to creator phone of p_srcImg
set p_ann_creator_email to creator email of p_srcImg
set p_ann_creator_URL to creator URL of p_srcImg

-- info geo
set p_ann_city to city of p_srcImg
set p_ann_state to state of p_srcImg
set p_ann_country to country of p_srcImg
set p_ann_location to location of p_srcImg
set p_ann_country_code to country code of p_srcImg

-- info campos com info múltipla
set p_ann_list_of_categories to categories of p_srcImg as list
set p_ann_list_of_keyword to keywords of p_srcImg as list
set p_ann_list_of_people to people of p_srcImg as list

-- guardar os mesmos campos como string, motivos de segurança
set sp_ann_list_of_categories to categories of p_srcImg as string
set sp_ann_list_of_keyword to keywords of p_srcImg as string
set sp_ann_list_of_people to people of p_srcImg as string


--rating e label
set p_ann_rating to rating of p_srcImg
set p_ann_label to label index of p_srcImg


--inserir campo na bd
tell application "Database Events"
tell database "iview"
set theRecord to make new record with properties {name:p_ann_name}
tell theRecord
make new field with properties {name:"p_ann_description", value:p_ann_description}
make new field with properties {name:"p_ann_description_writer", value:p_ann_description_writer}
make new field with properties {name:"p_ann_date_created", value:p_ann_date_created}
make new field with properties {name:"p_ann_headline", value:p_ann_headline}
make new field with properties {name:"p_ann_instructions", value:p_ann_instructions}
make new field with properties {name:"p_ann_creator_title", value:p_ann_creator_title}
make new field with properties {name:"p_ann_provider", value:p_ann_provider}
make new field with properties {name:"p_ann_source", value:p_ann_source}
make new field with properties {name:"p_ann_url", value:p_ann_url}
make new field with properties {name:"p_ann_list_of_scenes", value:p_ann_list_of_scenes}
make new field with properties {name:"p_ann_list_of_subject_codes", value:p_ann_list_of_subject_codes}
make new field with properties {name:"p_ann_genre", value:p_ann_genre}
make new field with properties {name:"p_ann_usage_terms", value:p_ann_usage_terms}
make new field with properties {name:"p_ann_usage_terms", value:p_ann_usage_terms}
make new field with properties {name:"p_ann_job_identifier", value:p_ann_job_identifier}
make new field with properties {name:"p_ann_primary_category", value:p_ann_primary_category}
make new field with properties {name:"p_ann_copyright_notice", value:p_ann_copyright_notice}
-- make new field with properties {name:"p_ann_status to status", value:p_ann_status to status}
make new field with properties {name:"p_ann_event", value:p_ann_event}
make new field with properties {name:"p_ann_creator", value:p_ann_creator}
make new field with properties {name:"p_ann_title", value:p_ann_title}
make new field with properties {name:"p_ann_creator_address", value:p_ann_creator_address}
make new field with properties {name:"p_ann_creator_city", value:p_ann_creator_city}
make new field with properties {name:"p_ann_creator_state", value:p_ann_creator_state}
make new field with properties {name:"p_ann_creator_post_code", value:p_ann_creator_post_code}
make new field with properties {name:"p_ann_creator_country", value:p_ann_creator_country}
make new field with properties {name:"p_ann_creator_phone", value:p_ann_creator_phone}
make new field with properties {name:"p_ann_creator_email", value:p_ann_creator_email}
make new field with properties {name:"p_ann_creator_URL", value:p_ann_creator_URL}
make new field with properties {name:"p_ann_city", value:p_ann_city}
make new field with properties {name:"p_ann_state", value:p_ann_state}
make new field with properties {name:"p_ann_country", value:p_ann_country}
make new field with properties {name:"p_ann_location", value:p_ann_location}
make new field with properties {name:"p_ann_country_code", value:p_ann_country_code}
make new field with properties {name:"p_ann_list_of_categories", value:p_ann_list_of_categories}
make new field with properties {name:"p_ann_list_of_keyword", value:p_ann_list_of_keyword}
make new field with properties {name:"p_ann_list_of_people", value:p_ann_list_of_people}
-- mesmos campos como string, medida de segurança
make new field with properties {name:"sp_ann_list_of_categories", value:sp_ann_list_of_categories}
make new field with properties {name:"sp_ann_list_of_keyword", value:sp_ann_list_of_keyword}
make new field with properties {name:"sp_ann_list_of_people", value:sp_ann_list_of_people}

make new field with properties {name:"p_ann_rating", value:p_ann_rating}
make new field with properties {name:"p_ann_label", value:p_ann_label}
end tell

end tell
end tell
end repeat
end tell


tell application "Database Events"
save database 1
end tell

tell application "Database Events"
quit
end tell


on GetSelection()
set selectedItems to {}
tell application "iView MediaPro"
if catalog 1 exists then set selectedItems to the selection of catalog 1
end tell
if number of items in selectedItems is 0 then
display dialog ¬
"You need to select at least one media item in the current catalog in order to use this script." buttons {"OK"} default button ¬
"OK" with icon note giving up after 10
error number -128
end if
return selectedItems
end GetSelection
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    iView Multimedia Forum Index -> AppleScript All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



  © iView Multimedia Ltd. | All Rights Reserved Privacy Policy | Copyright | Site Map