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:
category_id_list (required)
tcl-list of category_ids to be mapped to the object.
Options:
-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):
%3 test_category_object_mapping category_object_mapping (test categories) category::map_object category::map_object test_category_object_mapping->category::map_object category::delete category::delete (public) category::map_object->category::delete db_dml db_dml (public) category::map_object->db_dml db_transaction db_transaction (public) category::map_object->db_transaction Class ::Generic::Form Class ::Generic::Form (public) Class ::Generic::Form->category::map_object Generic::Form instproc generate Generic::Form instproc generate (public) Generic::Form instproc generate->category::map_object packages/categories/lib/map.tcl packages/categories/ lib/map.tcl packages/categories/lib/map.tcl->category::map_object packages/faq/www/admin/q-and-a-add-edit.tcl packages/faq/ www/admin/q-and-a-add-edit.tcl packages/faq/www/admin/q-and-a-add-edit.tcl->category::map_object packages/file-storage/www/file-add.tcl packages/file-storage/ www/file-add.tcl packages/file-storage/www/file-add.tcl->category::map_object

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

[ hide source ] | [ make this the default ]
Show another procedure: