package-procs.tcl

Procs to help build PL/SQL packages

Location:
packages/acs-subsite/tcl/package-procs.tcl
Created:
Wed Dec 27 16:02:44 2000
Author:
mbryzek@arsdigita.com
CVS Identification:
$Id: package-procs.tcl,v 1.40.2.10 2022/10/15 17:07:45 gustafn Exp $

Procedures in this file

Detailed information

package_attribute_default (private)

 package_attribute_default [ -min_n_values min_n_values ] \
    [ -attr_default attr_default ] object_type table column

Returns a sql value to be used as the default in a pl/sql function or procedure parameter list. This is a special case, hardcoded function that specifies defaults for standard acs_object attributes.

Switches:
-min_n_values
(defaults to "0") (optional)
Used to determine if an argument is required (e.g. required = min_n_values != 0)
-attr_default
(optional)
The default values for this attribute as specified in the attributes table.
Parameters:
object_type - The object type that owns the attribute we are using. Used only to set a default for acs_object.object_type stored (either table_name from the attribute or for the object_type)
table - The table in which the value of this attribute is stored (either table_name from the attribute or for the object_type)
column - The column in which the value of this attribute is stored (either column_name or attribute_name from the attributes table)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/28/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_create_attribute_list package_create_attribute_list (private) package_attribute_default package_attribute_default package_create_attribute_list->package_attribute_default db_map db_map (public) package_attribute_default->db_map ns_dbquotevalue ns_dbquotevalue package_attribute_default->ns_dbquotevalue

Testcases:
No testcase defined.

package_create (private)

 package_create [ -debug_p debug_p ] object_type

Creates a packages with a new function and delete procedure for the specified object type. This function uses metadata exclusively to create the package. Resets the package_object_view cache Throws an error if the specified object type does not exist or is not dynamic

Switches:
-debug_p
(defaults to "f") (optional)
If "t" then we return a text block containing the sql to create the package. Setting debug_p to t will not create the package.
Parameters:
object_type - The object type for which to create a package
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/27/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_recreate_hierarchy package_recreate_hierarchy (public) package_create package_create package_recreate_hierarchy->package_create acs_object_type::get acs_object_type::get (public) package_create->acs_object_type::get db_exec_plsql db_exec_plsql (public) package_create->db_exec_plsql db_string db_string (public) package_create->db_string package_generate_body package_generate_body (private) package_create->package_generate_body package_generate_spec package_generate_spec (private) package_create->package_generate_spec

Testcases:
No testcase defined.

package_create_attribute_list (private)

 package_create_attribute_list [ -supertype supertype ] \
    [ -object_name object_name ] [ -limit_to limit_to ] \
    [ -table table ] [ -column column ] [ -column_value column_value ] \
    object_type

Generates the list of attributes for this object type. Each element in the list is (table_name, column_name, default_value, column_value) where default_value and column_value are optional. Note that if either of table_name, id_column is unspecified, we retrieve the values for both from the acs_object_types table

Switches:
-supertype
(optional)
The supertype of the object we are creating. If specified, along with object_name, we lookup the parameters to supertype.object_name and include any missing parameters in our argument list.
-object_name
(optional)
The name of the function / procedure we are creating. See supertype for explanation.
-limit_to
(optional)
If empty, this argument is ignored. Otherwise, it is a list of all the columns to be included in the attribute list. Any attribute whose column_name is not in this list is then ignored.
-table
(optional)
The table_name for this object_type (from the acs_object_types tables)
-column
(optional)
The id_column for this object_type (from the acs_object_types tables)
-column_value
(optional)
The value for this column in the present calling function. Useful when you are calling supertype function and need to refer to the supertype argument by a different name locally.
Parameters:
object_type - The object type for which we are generating attributes
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_generate_body package_generate_body (private) package_create_attribute_list package_create_attribute_list package_generate_body->package_create_attribute_list acs_object_type::get acs_object_type::get (public) package_create_attribute_list->acs_object_type::get db_foreach db_foreach (public) package_create_attribute_list->db_foreach package_attribute_default package_attribute_default (private) package_create_attribute_list->package_attribute_default package_table_columns_for_type package_table_columns_for_type (private) package_create_attribute_list->package_table_columns_for_type util_memoize util_memoize (public) package_create_attribute_list->util_memoize

Testcases:
No testcase defined.

package_exec_plsql (public)

 package_exec_plsql [ -var_list var_list ] package_name object_name

Calls a pl/[pg]sql proc/func defined within the object type's package. Use of this Tcl API proc avoids the need for the developer to write separate SQL for each RDBMS we support.

Switches:
-var_list
(optional)
A list of pairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value
Parameters:
package_name - The PL/[pg]SQL package
object_name - The PL/[pg]SQL function within the package
Returns:
empty string for procs, function return value for funcs

Example:


    set var_list [list  [list group_id $group_id]]

    package_exec_plsql -var_list $var_list group delete

    
Author:
Don Baccus <dhogaza@pacifier.com>
Created:
12/31/2003

Partial Call Graph (max 5 caller/called nodes):
%3 test_auth_authenticate auth_authenticate (test acs-authentication) package_exec_plsql package_exec_plsql test_auth_authenticate->package_exec_plsql db_exec_plsql db_exec_plsql (public) package_exec_plsql->db_exec_plsql package_function_p package_function_p (private) package_exec_plsql->package_function_p package_plsql_args package_plsql_args (private) package_exec_plsql->package_plsql_args content::extlink::copy content::extlink::copy (public) content::extlink::copy->package_exec_plsql content::extlink::is_extlink content::extlink::is_extlink (public) content::extlink::is_extlink->package_exec_plsql content::extlink::new content::extlink::new (public) content::extlink::new->package_exec_plsql content::folder::delete content::folder::delete (public) content::folder::delete->package_exec_plsql content::folder::get_index_page content::folder::get_index_page (public) content::folder::get_index_page->package_exec_plsql

Testcases:
auth_authenticate

package_function_p (private)

 package_function_p -object_name object_name package_name
Switches:
-object_name
(required)
Parameters:
package_name
Returns:
true if the package's object is a function.

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) package_function_p package_function_p package_exec_plsql->package_function_p db_0or1row db_0or1row (public) package_function_p->db_0or1row

Testcases:
No testcase defined.

package_generate_body (private)

 package_generate_body object_type

Generates plsql to create the package body

Parameters:
object_type - The name of the object type for which we are creating the package
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
10/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_create package_create (private) package_generate_body package_generate_body package_create->package_generate_body acs_object_type::get acs_object_type::get (public) package_generate_body->acs_object_type::get db_list db_list (public) package_generate_body->db_list db_map db_map (public) package_generate_body->db_map package_create_attribute_list package_create_attribute_list (private) package_generate_body->package_create_attribute_list

Testcases:
No testcase defined.

package_generate_spec (private)

 package_generate_spec object_type

Generates pl/sql to create a package specification. Does not execute the pl/sql - simply returns it.

Parameters:
object_type - The object for which to create a package spec
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
10/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_create package_create (private) package_generate_spec package_generate_spec package_create->package_generate_spec acs_object_type::get acs_object_type::get (public) package_generate_spec->acs_object_type::get db_map db_map (public) package_generate_spec->db_map

Testcases:
No testcase defined.

package_insert_default_comment (private)

 package_insert_default_comment

Returns a string to be used verbatim as the default comment we insert into meta-generated packages and package bodies. If we have a connection, we grab the user's name from ad_conn user_id.

Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/29/2000

Partial Call Graph (max 5 caller/called nodes):
%3 acs_user::get_element acs_user::get_element (public) db_string db_string (public) package_insert_default_comment package_insert_default_comment package_insert_default_comment->acs_user::get_element package_insert_default_comment->db_string

Testcases:
No testcase defined.

package_instantiate_object (public)

 package_instantiate_object [ -creation_user creation_user ] \
    [ -creation_ip creation_ip ] [ -package_name package_name ] \
    [ -var_list var_list ] [ -extra_vars extra_vars ] \
    [ -start_with start_with ] [ -form_id form_id ] \
    [ -variable_prefix variable_prefix ] object_type

Creates a new object of the specified type by calling the associated PL/SQL package new function.

Switches:
-creation_user
(optional)
The current user. Defaults to [ad_conn user_id] if not specified and there is a connection
-creation_ip
(optional)
The current user's IP address. Defaults to [ad_conn peeraddr] if not specified and there is a connection
-package_name
(optional)
The PL/SQL package associated with this object type. Defaults to acs_object_types.package_name
-var_list
(optional)
A list of pairs of additional attributes and their values to pass to the constructor. Each pair is a list of two elements: key => value
-extra_vars
(optional)
an ns_set of extra vars
-start_with
(optional)
The object type to start with when gathering attributes for this object type. Defaults to the object type.
-form_id
(optional)
The form id from templating form system if we're using the forms API to specify attributes
-variable_prefix
(optional)
Parameters:
object_type - The object type of the object we are instantiating
Returns:
The object id of the newly created object

Example:


    template::form create add_group
    template::element create add_group group_name -value "Publisher"

    set var_list [list  [list context_id $context_id]   [list group_id $group_id]]

    return [package_instantiate_object  -start_with "group"  -var_list $var_list  -form_id "add_group"  "group"]

    
Authors:
Michael Bryzek <mbryzek@arsdigita.com>
Ben Adida <ben@openforce.net>
Created:
02/01/2001

Partial Call Graph (max 5 caller/called nodes):
%3 test_auth_authenticate auth_authenticate (test acs-authentication) package_instantiate_object package_instantiate_object test_auth_authenticate->package_instantiate_object test_auth_create_user auth_create_user (test acs-authentication) test_auth_create_user->package_instantiate_object test_category_tree_procs category_tree_procs (test categories) test_category_tree_procs->package_instantiate_object test_object_p object_p (test acs-tcl) test_object_p->package_instantiate_object _ _ (public) package_instantiate_object->_ acs_object_type::get acs_object_type::get (public) package_instantiate_object->acs_object_type::get ad_conn ad_conn (public) package_instantiate_object->ad_conn db_exec_plsql db_exec_plsql (public) package_instantiate_object->db_exec_plsql package_object_attribute_list package_object_attribute_list (public) package_instantiate_object->package_object_attribute_list bug_tracker::bug::insert bug_tracker::bug::insert (public) bug_tracker::bug::insert->package_instantiate_object calendar::new calendar::new (public) calendar::new->package_instantiate_object content::folder::new content::folder::new (public) content::folder::new->package_instantiate_object forum::message::new forum::message::new (public) forum::message::new->package_instantiate_object forum::new forum::new (public) forum::new->package_instantiate_object

Testcases:
auth_authenticate, auth_create_user, object_p, category_tree_procs

package_object_attribute_list (public)

 package_object_attribute_list [ -start_with start_with ] \
    [ -include_storage_types include_storage_types ] object_type

Returns a list of lists all the attributes (column name or attribute_name) to be used for this object type. Each list elements contains: (attribute_id, table_name, attribute_name, pretty_name, datatype, required_p, default_value)

Switches:
-start_with
(defaults to "acs_object") (optional)
The highest parent object type for which to include attributes
-include_storage_types
(defaults to "type_specific") (optional)
Parameters:
object_type - The object type for which to include attributes
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/29/2000

Partial Call Graph (max 5 caller/called nodes):
%3 test_content_item content_item (test acs-content-repository) package_object_attribute_list package_object_attribute_list test_content_item->package_object_attribute_list test_image_new image_new (test acs-content-repository) test_image_new->package_object_attribute_list db_list_of_lists db_list_of_lists (public) package_object_attribute_list->db_list_of_lists attribute::add_form_elements attribute::add_form_elements (public) attribute::add_form_elements->package_object_attribute_list content::revision::new content::revision::new (public) content::revision::new->package_object_attribute_list package_instantiate_object package_instantiate_object (public) package_instantiate_object->package_object_attribute_list package_object_view_helper package_object_view_helper (private) package_object_view_helper->package_object_attribute_list

Testcases:
image_new, content_item

package_object_view (public)

 package_object_view [ -refresh_p refresh_p ] \
    [ -start_with start_with ] object_type

Returns a select statement to be used as an inner view for selecting out all the attributes for the object_type. util_memoizes the result

Switches:
-refresh_p
(defaults to "f") (optional)
If t, force a reload of the cache
-start_with
(defaults to "acs_object") (optional)
The highest parent object type for which to include attributes
Parameters:
object_type - The object for which to create a package spec
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
10/2000

Partial Call Graph (max 5 caller/called nodes):
%3 attribute::multirow attribute::multirow (public) package_object_view package_object_view attribute::multirow->package_object_view package_object_view_helper package_object_view_helper (private) package_object_view->package_object_view_helper package_object_view_reset package_object_view_reset (public) package_object_view->package_object_view_reset util_memoize util_memoize (public) package_object_view->util_memoize

Testcases:
No testcase defined.

package_object_view_helper (private)

 package_object_view_helper [ -start_with start_with ] object_type

Returns a select statement to be used as an inner view for selecting out all the attributes for the object_type.

Switches:
-start_with
(defaults to "acs_object") (optional)
The highest parent object type for which to include attributes
Parameters:
object_type - The object for which to create a package spec
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
10/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_object_view package_object_view (public) package_object_view_helper package_object_view_helper package_object_view->package_object_view_helper acs_object_type::get acs_object_type::get (public) package_object_view_helper->acs_object_type::get package_object_attribute_list package_object_attribute_list (public) package_object_view_helper->package_object_attribute_list

Testcases:
No testcase defined.

package_object_view_reset (public)

 package_object_view_reset object_type

Resets the cached views for all chains (e.g. all variations of start_with in package_object_view) for the specified object type.

Parameters:
object_type
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Partial Call Graph (max 5 caller/called nodes):
%3 group_type::delete group_type::delete (public) package_object_view_reset package_object_view_reset group_type::delete->package_object_view_reset package_create package_create (private) package_create->package_object_view_reset package_object_view package_object_view (public) package_object_view->package_object_view_reset packages/acs-subsite/www/admin/rel-types/delete-2.tcl packages/acs-subsite/ www/admin/rel-types/delete-2.tcl packages/acs-subsite/www/admin/rel-types/delete-2.tcl->package_object_view_reset db_foreach db_foreach (public) package_object_view_reset->db_foreach util_memoize_cached_p util_memoize_cached_p (public) package_object_view_reset->util_memoize_cached_p util_memoize_flush util_memoize_flush (public) package_object_view_reset->util_memoize_flush

Testcases:
No testcase defined.

package_plsql_args (private)

 package_plsql_args [ -object_name object_name ] package_name

Return a list of parameters expected to a plsql function defined within a given package and cache these per thread. Changes in the interface will require a server restart.

Switches:
-object_name
(defaults to "NEW") (optional)
The function name which we're looking up
Parameters:
package_name - The package which owns the function
Returns:
list of parameters
Author:
Ben Adida <ben@openforce.net>
Created:
11/2001

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) package_plsql_args package_plsql_args package_exec_plsql->package_plsql_args package_instantiate_object package_instantiate_object (public) package_instantiate_object->package_plsql_args db_list db_list (public) package_plsql_args->db_list

Testcases:
No testcase defined.

package_recreate_hierarchy (public)

 package_recreate_hierarchy object_type

Recreates all the packages for the hierarchy starting with the specified object type down to a leaf. Resets the package_object_view cache. Note: Only updates packages for dynamic objects (those with dynamic_p set to t)

Parameters:
object_type - The object type for which to recreate packages, including all children types.
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/28/2000

Partial Call Graph (max 5 caller/called nodes):
%3 group_type::new group_type::new (public) package_recreate_hierarchy package_recreate_hierarchy group_type::new->package_recreate_hierarchy packages/acs-subsite/www/admin/attributes/add-2.tcl packages/acs-subsite/ www/admin/attributes/add-2.tcl packages/acs-subsite/www/admin/attributes/add-2.tcl->package_recreate_hierarchy packages/acs-subsite/www/admin/attributes/delete-2.tcl packages/acs-subsite/ www/admin/attributes/delete-2.tcl packages/acs-subsite/www/admin/attributes/delete-2.tcl->package_recreate_hierarchy rel_types::new rel_types::new (public) rel_types::new->package_recreate_hierarchy db_list db_list (public) package_recreate_hierarchy->db_list package_create package_create (private) package_recreate_hierarchy->package_create util_memoize_cached_p util_memoize_cached_p (public) package_recreate_hierarchy->util_memoize_cached_p util_memoize_flush util_memoize_flush (public) package_recreate_hierarchy->util_memoize_flush

Testcases:
No testcase defined.

package_table_columns_for_type (private)

 package_table_columns_for_type object_type

Generates the list of tables and columns that are parameters of the object named NEW for PL/SQL package associated with this object type.

Note we limit the argument list to only object_type to make it possible to use util_memoize_flush to clear any cached values for this procedure.

Parameters:
object_type - The object type for which we are generating the list
Returns:
a list of lists where each list element is a pair of table name, column name
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/2000

Partial Call Graph (max 5 caller/called nodes):
%3 package_create_attribute_list package_create_attribute_list (private) package_table_columns_for_type package_table_columns_for_type package_create_attribute_list->package_table_columns_for_type acs_object_type::get acs_object_type::get (public) package_table_columns_for_type->acs_object_type::get db_list_of_lists db_list_of_lists (public) package_table_columns_for_type->db_list_of_lists

Testcases:
No testcase defined.

package_type_dynamic_p (public)

 package_type_dynamic_p object_type

Returns 1 if the object type is dynamic. 0 otherwise

Parameters:
object_type
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
12/30/2000

Partial Call Graph (max 5 caller/called nodes):
%3 packages/acs-subsite/www/admin/attributes/add-2.tcl packages/acs-subsite/ www/admin/attributes/add-2.tcl package_type_dynamic_p package_type_dynamic_p packages/acs-subsite/www/admin/attributes/add-2.tcl->package_type_dynamic_p packages/acs-subsite/www/admin/attributes/add.tcl packages/acs-subsite/ www/admin/attributes/add.tcl packages/acs-subsite/www/admin/attributes/add.tcl->package_type_dynamic_p db_0or1row db_0or1row (public) package_type_dynamic_p->db_0or1row

Testcases:
No testcase defined.
[ show source ]