ad_library { Supporting procs for ACS Object Types @author Yonatan Feldman (yon@arsdigita.com) @creation-date August 13, 2000 @cvs-id $Id: object-type-procs.tcl,v 1.4 2011/03/13 22:56:22 donb Exp $ } namespace eval object_type {} ad_proc -public object_type::new { -object_type:required -pretty_name:required -pretty_plural:required {-supertype acs_object} {-table_name ""} {-package_name ""} {-abstract_p f} {-type_extension_table ""} {-name_method ""} {-create_table_p f} {-dynamic_p t} -attributes } { Create a new object type, with an initial set of attributes. Optionally create the type's SQL table and type attribute SQL columns. For detailed information on the various parameters to this procedure, please read the developer's documentation for the SQL procedures which do the actual type and attribute creation. @param object_type The name of the type to create. @param pretty_name The human-readable name of the type to create. @param pretty_plural Plural human-readable name of the type to create. @param supertype Supertype of the type to create (default "acs_object"). @param table_name Optional name of the associated SQL table for the new type. Default will be the name of the new type appended with "_t". @param package_name Optional name of the associated SQL package used to manipulate objects of this type. Note: the acs-object-management does it with a Tcl API. @param abstract_p If true, the type's abstract (no attributes). @param type_extension_table Optional table to extend acs_object_types information for the new type. Rarely used. Probably shouldn't be used. @param name_method Optional name of a SQL procedure which returns the name of an object of this type. @param create_table_p If true, create the table and attribute columns automatically. Defaults to false for backwards compatibility with existing ways of doing things, but having this procedure create the SQL table and columns is commended and convenient. @param dynamic_p If true, it's a dynamic type that can be manipulated by the admin UI. @param attributes A list of attributes and their qualifiers of the form: \{ attr_name \{ (qualifiers in array get format) \} \{ attr_name_2 \{ (qualifers) \} } { set var_list [list \ [list object_type $object_type] \ [list pretty_name $pretty_name] \ [list pretty_plural $pretty_plural] \ [list supertype $supertype] \ [list table_name $table_name] \ [list package_name $package_name] \ [list abstract_p $abstract_p] \ [list type_extension_table $type_extension_table] \ [list name_method $name_method] \ [list create_table_p $create_table_p] \ [list dynamic_p $dynamic_p]] db_transaction { package_exec_plsql -var_list $var_list acs_object_type create_type if { [info exists attributes] } { foreach {name attr_info} $attributes { set params [list -object_type $object_type -attribute_name $name] if { $create_table_p } { lappend params -create_column_p lappend params t } foreach {param value} $attr_info { lappend params -$param lappend params $value } eval [concat object_type::attribute::new $params] } } package_exec_plsql \ -var_list [list [list object_type $object_type]] acs_object_type refresh_view } } ad_proc -public object_type::delete { -object_type:required {-drop_table_p f} {-drop_children_p f} } { Delete an object type, and optionally its subtypes and any other tables or views which depend on it. @param object_type The object type to delete. @param cascade_p If true, delete the type's objects. @param drop_table_p If true (recommended) drop the table associated with the object type. @param drop_children_p If true (recommended) drop all subtypes dependent on this type. } { set var_list [list \ [list object_type $object_type] \ [list drop_table_p $drop_table_p] \ [list drop_children_p $drop_children_p]] package_exec_plsql -var_list $var_list acs_object_type drop_type object_type::flush_cache -object_type $object_type } ad_proc -public object_type::get { -object_type:required -array:required } { Get info about an object type. Returns columns