workflow-tree-procs.tcl

Procs for building trees of data.

Location:
packages/workflow/tcl/workflow-tree-procs.tcl
Created:
2004/09/27
Author:
helsleya@cs.ucr.edu
CVS Identification:
$Id: workflow-tree-procs.tcl,v 1.3 2013/09/17 19:10:35 gustafn Exp $

Procedures in this file

Detailed information

workflow::tree::sorter::create (public)

 workflow::tree::sorter::create -multirow multirow -sort_by sort_by

Initiliaze a bunch of state variables for a connect by ordered tree.

Example:


    # Create a 'sorter' to sort the data
    tree::sorter::create -multirow categories_tree -sort_by sort_key
    
    # Get the data
    db_multirow -extend {sort_key} categories_tree categories_tree_sql {
	select  lpad(' ', 6*4*(level-1) + 1, ' ') || name as name,
	category_id,
	name as rawname,
	level
	from  categories
	connect by prior category_id    = parent_category_id
	start with parent_category_id   = category.lookup('//Personnel Title')
    } {
	set sort_key [tree::sorter::make_full_key_for       -multirow     categories_tree   -partial_key  $rawname          -id           $category_id      -level        $level]
    }
    
    # Sort the data
    tree::sorter::sort -multirow categories_tree
    

Switches:
-multirow (required)
The name of the multirow data-source to make sort-keys for.
-sort_by (required)
The name of the column that will be populated with the sort-key.
Author:
helsleya@cs.ucr.edu
See Also:
  • tree::sorter::make_full_key_for
  • tree::sorter::sort

Partial Call Graph (max 5 caller/called nodes):
%3 packages/workflow/www/admin/workflow-ae.tcl packages/workflow/ www/admin/workflow-ae.tcl workflow::tree::sorter::create workflow::tree::sorter::create packages/workflow/www/admin/workflow-ae.tcl->workflow::tree::sorter::create packages/workflow/www/admin/workflow-clone.tcl packages/workflow/ www/admin/workflow-clone.tcl packages/workflow/www/admin/workflow-clone.tcl->workflow::tree::sorter::create

Testcases:
No testcase defined.

workflow::tree::sorter::make_full_key_for (public)

 workflow::tree::sorter::make_full_key_for -multirow multirow \
    -partial_key partial_key -id id -level level

Make a key that can be stored with the given row in a connect by-ordered tree. This updates some state variables and makes a key from their values. Once all rows are processed, a call to tree::sorter::sort should be made to sort the multirow data.

Switches:
-multirow (required)
The name of the multirow data-source to make a sort-key for.
-partial_key (required)
The primary field by which the tree will be (hierarchically) sorted.
-id (required)
The ID to be used as a tie-breaker when sorting. This should be a candidate-key.
-level (required)
The depth of the node uniquely identified by id
Returns:
A key for sorting rows in a tree
Author:
helsleya@cs.ucr.edu
See Also:
  • tree::sorter::create
  • tree::sorter::sort

Partial Call Graph (max 5 caller/called nodes):
%3 packages/workflow/www/admin/workflow-ae.tcl packages/workflow/ www/admin/workflow-ae.tcl workflow::tree::sorter::make_full_key_for workflow::tree::sorter::make_full_key_for packages/workflow/www/admin/workflow-ae.tcl->workflow::tree::sorter::make_full_key_for packages/workflow/www/admin/workflow-clone.tcl packages/workflow/ www/admin/workflow-clone.tcl packages/workflow/www/admin/workflow-clone.tcl->workflow::tree::sorter::make_full_key_for

Testcases:
No testcase defined.

workflow::tree::sorter::sort (public)

 workflow::tree::sorter::sort -multirow multirow

Sort the given multirow using the full-sort-keys built earlier by the calls to tree::sorter proc tree::sorter::make_full_key_for created with tree::sorter::create.

Switches:
-multirow (required)
The name of the multirow data-source to be sorted.
Author:
helsleya@cs.ucr.edu
See Also:
  • tree::sorter::create
  • tree::sorter::make_full_key_for

Partial Call Graph (max 5 caller/called nodes):
%3 packages/workflow/www/admin/workflow-ae.tcl packages/workflow/ www/admin/workflow-ae.tcl workflow::tree::sorter::sort workflow::tree::sorter::sort packages/workflow/www/admin/workflow-ae.tcl->workflow::tree::sorter::sort packages/workflow/www/admin/workflow-clone.tcl packages/workflow/ www/admin/workflow-clone.tcl packages/workflow/www/admin/workflow-clone.tcl->workflow::tree::sorter::sort

Testcases:
No testcase defined.

workflow::tree::sorter::sort_list_of_lists (public)

 workflow::tree::sorter::sort_list_of_lists -list list -sort_by sort_by \
    -object_id object_id -parent_object_id parent_object_id

Sort the given list-of-lists. The list should have 3-4 columns:

  • Display Name (should have any padding you want)
  • Object ID
  • Parent Object ID
  • Object Name

The display name is the only column which is not critical for sorting the tree.

Example:


    # Get a list that can be used as the options of a 'select' widget in ad_form
    set directories [db_list_of_lists get_directories {
	select  lpad(' ', (level-1)*4*6 + 1, ' ') || directory_name as directory_name,
	                 directory_id,
	                 parent_directory_id,
	                 directory_name
	           from  directories
	         start   with parent_directory_id    is null
	         connect by prior directory_id       = parent_directory_id
    }]
     
    # Sort the options
    set directories [tree::sorter::sort_lists_of_lists -list $directories -sort_by 3 -object_id 1 -parent_object_id 2]
    

Switches:
-list (required)
The list-of-lists that should be sorted as a tree.
-sort_by (required)
The index of the element in each row which should be used to sort by.
-object_id (required)
The index of the element in each row which uniquely identifies it.
-parent_object_id (required)
The index of the element in each row which contains the unique identifier of its parent.
Author:
helsleya@cs.ucr.edu

Partial Call Graph (max 5 caller/called nodes):
%3

Testcases:
No testcase defined.
[ show source ]