category::map_object (public)
category::map_object [ -remove_old ] -object_id object_id \ category_id_list
Defined in packages/categories/tcl/categories-procs.tcl
Map an object to several categories.
- Switches:
- -remove_old (optional, boolean)
- -object_id (required)
- Parameters:
- Options:
- category_id_list (required)
- tcl-list of category_ids to be mapped to the object.
- -remove_old
- Modifier to be used when categorizing existing objects. Will make sure to delete all old categorizations.
- -object_id
- object to be categorized.
- Author:
- Timo Hentschel <timo@timohentschel.de>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- category_object_mapping
Source code: db_transaction { # Remove any already mapped categories if we are updating if { $remove_old_p } { db_dml remove_mapped_categories { delete from category_object_map where object_id = :object_id } } foreach category_id $category_id_list { if {$category_id ne ""} { db_dml insert_mapped_categories { insert into category_object_map (category_id, object_id) select :category_id, :object_id where not exists (select 1 from category_object_map where category_id = :category_id and object_id = :object_id); } } } # Adds categorizations to linked categories db_dml insert_linked_categories { insert into category_object_map (category_id, object_id) (select l.to_category_id as category_id, m.object_id from category_links l, category_object_map m where l.from_category_id = m.category_id and m.object_id = :object_id and not exists (select 1 from category_object_map m2 where m2.object_id = :object_id and m2.category_id = l.to_category_id)) } }XQL Not present: Generic PostgreSQL XQL file: packages/categories/tcl/categories-procs-postgresql.xql
Oracle XQL file: <fullquery name="category::map_object.insert_mapped_categories"> <querytext> insert into category_object_map (category_id, object_id) select :category_id, :object_id from dual where not exists (select 1 from category_object_map where category_id = :category_id and object_id = :object_id) </querytext> </fullquery>packages/categories/tcl/categories-procs-oracle.xql