content-keyword-procs.tcl

Procedures for content_keywords

Location:
packages/acs-content-repository/tcl/content-keyword-procs.tcl
Created:
2004-06-09
Author:
Dave Bauer <dave@thedesignexperience.org>
CVS Identification:
$Id: content-keyword-procs.tcl,v 1.6.2.1 2019/03/13 10:11:27 antoniop Exp $

Procedures in this file

Detailed information

content::keyword::delete (public)

 content::keyword::delete -keyword_id keyword_id
Switches:
-keyword_id (required)
Returns:
0

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_content_repository_trivial_smoke_test acs_content_repository_trivial_smoke_test (test acs-content-repository) content::keyword::delete content::keyword::delete test_acs_content_repository_trivial_smoke_test->content::keyword::delete test_content_keyword content_keyword (test acs-content-repository) test_content_keyword->content::keyword::delete package_exec_plsql package_exec_plsql (public) content::keyword::delete->package_exec_plsql content::keyword::item_unassign_children content::keyword::item_unassign_children (public) content::keyword::item_unassign_children->content::keyword::delete packages/bug-tracker/www/admin/category-delete.tcl packages/bug-tracker/ www/admin/category-delete.tcl packages/bug-tracker/www/admin/category-delete.tcl->content::keyword::delete

Testcases:
acs_content_repository_trivial_smoke_test, content_keyword

content::keyword::get_children (public)

 content::keyword::get_children [ -parent_id parent_id ]

Returns the ids of the keywords having the given parent_id. Returns an empty list if there are no children.

Switches:
-parent_id (optional)
Author:
Peter Marklund

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_content_repository_trivial_smoke_test acs_content_repository_trivial_smoke_test (test acs-content-repository) content::keyword::get_children content::keyword::get_children test_acs_content_repository_trivial_smoke_test->content::keyword::get_children db_list db_list (public) content::keyword::get_children->db_list

Testcases:
acs_content_repository_trivial_smoke_test

content::keyword::get_description (public)

 content::keyword::get_description -keyword_id keyword_id
Switches:
-keyword_id (required)
Returns:
string with description

Partial Call Graph (max 5 caller/called nodes):
%3 test_content_keyword content_keyword (test acs-content-repository) content::keyword::get_description content::keyword::get_description test_content_keyword->content::keyword::get_description package_exec_plsql package_exec_plsql (public) content::keyword::get_description->package_exec_plsql

Testcases:
content_keyword

content::keyword::get_heading (public)

 content::keyword::get_heading -keyword_id keyword_id
Switches:
-keyword_id (required)
Returns:
string with heading

Partial Call Graph (max 5 caller/called nodes):
%3 test_content_keyword content_keyword (test acs-content-repository) content::keyword::get_heading content::keyword::get_heading test_content_keyword->content::keyword::get_heading package_exec_plsql package_exec_plsql (public) content::keyword::get_heading->package_exec_plsql

Testcases:
content_keyword

content::keyword::get_keyword_id (public)

 content::keyword::get_keyword_id -parent_id parent_id -heading heading

Get the keyword with the given heading under the given parent. Returns the empty string if none exists.

Switches:
-parent_id (required)
-heading (required)

Partial Call Graph (max 5 caller/called nodes):
%3 bug_tracker::install_keywords_setup bug_tracker::install_keywords_setup (public) content::keyword::get_keyword_id content::keyword::get_keyword_id bug_tracker::install_keywords_setup->content::keyword::get_keyword_id db_string db_string (public) content::keyword::get_keyword_id->db_string

Testcases:
No testcase defined.

content::keyword::get_options_flat (public)

 content::keyword::get_options_flat [ -parent_id parent_id ]

Returns a flat options list of the keywords with the given parent_id.

Switches:
-parent_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 db_list_of_lists db_list_of_lists (public) content::keyword::get_options_flat content::keyword::get_options_flat content::keyword::get_options_flat->db_list_of_lists

Testcases:
No testcase defined.

content::keyword::get_path (public)

 content::keyword::get_path -keyword_id keyword_id
Switches:
-keyword_id (required)
Returns:
"/" delimited path in the keyword tree to the supplied keyword

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::get_path content::keyword::get_path content::keyword::get_path->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::is_assigned (public)

 content::keyword::is_assigned -item_id item_id -keyword_id keyword_id \
    [ -recurse recurse ]
Switches:
-item_id (required)
-keyword_id (required)
-recurse (optional)
Returns:
t or f

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::is_assigned content::keyword::is_assigned content::keyword::is_assigned->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::is_leaf (public)

 content::keyword::is_leaf -keyword_id keyword_id
Switches:
-keyword_id (required)
Returns:
t or f

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::is_leaf content::keyword::is_leaf content::keyword::is_leaf->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::item_assign (public)

 content::keyword::item_assign -item_id item_id -keyword_id keyword_id \
    [ -context_id context_id ] [ -creation_user creation_user ] \
    [ -creation_ip creation_ip ]
Switches:
-item_id (required)
-keyword_id (required)
-context_id (optional)
-creation_user (optional)
-creation_ip (optional)
Associate a keyword with a CR item.
Returns:
0

Partial Call Graph (max 5 caller/called nodes):
%3 bug_tracker::bug::edit bug_tracker::bug::edit (public) content::keyword::item_assign content::keyword::item_assign bug_tracker::bug::edit->content::keyword::item_assign bug_tracker::bug::new bug_tracker::bug::new (public) bug_tracker::bug::new->content::keyword::item_assign package_exec_plsql package_exec_plsql (public) content::keyword::item_assign->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::item_get_assigned (public)

 content::keyword::item_get_assigned -item_id item_id \
    [ -parent_id parent_id ]

Returns a list of all keywords assigned to the given cr_item. If parent_id is supplied, only keywords that are children of parent_id are listed.

Switches:
-item_id (required)
-parent_id (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 bug_tracker::bug::notification_info::get_notification_info bug_tracker::bug::notification_info::get_notification_info (private) content::keyword::item_get_assigned content::keyword::item_get_assigned bug_tracker::bug::notification_info::get_notification_info->content::keyword::item_get_assigned packages/bug-tracker/www/bug.tcl packages/bug-tracker/ www/bug.tcl packages/bug-tracker/www/bug.tcl->content::keyword::item_get_assigned db_list db_list (public) content::keyword::item_get_assigned->db_list

Testcases:
No testcase defined.

content::keyword::item_unassign (public)

 content::keyword::item_unassign -item_id item_id \
    -keyword_id keyword_id
Switches:
-item_id (required)
-keyword_id (required)
Returns:
0

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::item_unassign content::keyword::item_unassign content::keyword::item_unassign->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::item_unassign_children (public)

 content::keyword::item_unassign_children -item_id item_id \
    -parent_id parent_id

Unassign all the keywords attached to a content item that are children of keyword parent_id. Returns the supplied item_id for convenience.

Switches:
-item_id (required)
-parent_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 content::keyword::delete content::keyword::delete (public) db_dml db_dml (public) content::keyword::item_unassign_children content::keyword::item_unassign_children content::keyword::item_unassign_children->content::keyword::delete content::keyword::item_unassign_children->db_dml

Testcases:
No testcase defined.

content::keyword::new (public)

 content::keyword::new -heading heading [ -description description ] \
    [ -parent_id parent_id ] [ -keyword_id keyword_id ] \
    [ -creation_date creation_date ] [ -creation_user creation_user ] \
    [ -creation_ip creation_ip ] [ -object_type object_type ]
Switches:
-heading (required)
-description (optional)
-parent_id (optional)
-keyword_id (optional)
-creation_date (optional)
-creation_user (optional)
-creation_ip (optional)
-object_type (optional)
Returns:
keyword_id of created keyword

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_content_repository_trivial_smoke_test acs_content_repository_trivial_smoke_test (test acs-content-repository) content::keyword::new content::keyword::new test_acs_content_repository_trivial_smoke_test->content::keyword::new test_content_keyword content_keyword (test acs-content-repository) test_content_keyword->content::keyword::new package_exec_plsql package_exec_plsql (public) content::keyword::new->package_exec_plsql bug_tracker::install_keywords_setup bug_tracker::install_keywords_setup (public) bug_tracker::install_keywords_setup->content::keyword::new bug_tracker::project_new bug_tracker::project_new (public) bug_tracker::project_new->content::keyword::new packages/bug-tracker/www/admin/category-edit.tcl packages/bug-tracker/ www/admin/category-edit.tcl packages/bug-tracker/www/admin/category-edit.tcl->content::keyword::new

Testcases:
acs_content_repository_trivial_smoke_test, content_keyword

content::keyword::set_description (public)

 content::keyword::set_description -keyword_id keyword_id \
    -description description
Switches:
-keyword_id (required)
-description (required)
Returns:
0

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::set_description content::keyword::set_description content::keyword::set_description->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::set_heading (public)

 content::keyword::set_heading -keyword_id keyword_id -heading heading
Switches:
-keyword_id (required)
-heading (required)
Returns:
0

Partial Call Graph (max 5 caller/called nodes):
%3 packages/bug-tracker/www/admin/category-edit.tcl packages/bug-tracker/ www/admin/category-edit.tcl content::keyword::set_heading content::keyword::set_heading packages/bug-tracker/www/admin/category-edit.tcl->content::keyword::set_heading package_exec_plsql package_exec_plsql (public) content::keyword::set_heading->package_exec_plsql

Testcases:
No testcase defined.

content::keyword::write_to_file (public)

 content::keyword::write_to_file -item_id item_id -root_path root_path
Switches:
-item_id (required)
-root_path (required)

Partial Call Graph (max 5 caller/called nodes):
%3 package_exec_plsql package_exec_plsql (public) content::keyword::write_to_file content::keyword::write_to_file content::keyword::write_to_file->package_exec_plsql

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {
    
    Procedures for content_keywords
    
    @author Dave Bauer (dave@thedesignexperience.org)
    @creation-date 2004-06-09
    @cvs-id $Id: content-keyword-procs.tcl,v 1.6.2.1 2019/03/13 10:11:27 antoniop Exp $
}

namespace eval ::content::keyword {}

d_proc -public content::keyword::write_to_file {
    -item_id:required
    -root_path:required
} {
    @param item_id
    @param root_path
} {
    return [package_exec_plsql -var_list [list \
        [list item_id $item_id ] \
        [list root_path $root_path ] \
    ] content_keyword write_to_file]
}


d_proc -public content::keyword::delete {
    -keyword_id:required
} {
    @param keyword_id
    @return 0 
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
    ] content_keyword del]
}


d_proc -public content::keyword::get_description {
    -keyword_id:required
} {
    @param keyword_id

    @return string with description 
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
    ] content_keyword get_description]
}


d_proc -public content::keyword::get_heading {
    -keyword_id:required
} {
    @param keyword_id

    @return string with heading
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
    ] content_keyword get_heading]
}


d_proc -public content::keyword::get_path {
    -keyword_id:required
} {
    @param keyword_id

    @return "/" delimited path in the keyword tree to the supplied keyword
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
    ] content_keyword get_path]
}


d_proc -public content::keyword::is_assigned {
    -item_id:required
    -keyword_id:required
    {-recurse ""}
} {
    @param item_id
    @param keyword_id
    @param recurse

    @return t or f
} {
    return [package_exec_plsql -var_list [list \
        [list item_id $item_id ] \
        [list keyword_id $keyword_id ] \
        [list recurse $recurse ] \
    ] content_keyword is_assigned]
}


d_proc -public content::keyword::is_leaf {
    -keyword_id:required
} {
    @param keyword_id

    @return t or f
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
    ] content_keyword is_leaf]
}


d_proc -public content::keyword::item_assign {
    -item_id:required
    -keyword_id:required
    {-context_id ""}
    {-creation_user ""}
    {-creation_ip ""}
} {
    @param item_id
    @param keyword_id
    @param context_id
    @param creation_user
    @param creation_ip

    Associate a keyword with a CR item.

    @return 0
} {
    return [package_exec_plsql -var_list [list \
        [list item_id $item_id ] \
        [list keyword_id $keyword_id ] \
        [list context_id $context_id ] \
        [list creation_user $creation_user ] \
        [list creation_ip $creation_ip ] \
    ] content_keyword item_assign]
}


d_proc -public content::keyword::item_unassign {
    -item_id:required
    -keyword_id:required
} {
    @param item_id
    @param keyword_id

    @return 0
} {
    return [package_exec_plsql -var_list [list \
        [list item_id $item_id ] \
        [list keyword_id $keyword_id ] \
    ] content_keyword item_unassign]
}


d_proc -public content::keyword::new {
    -heading:required
    {-description ""}
    {-parent_id ""}
    {-keyword_id ""}
    -creation_date
    {-creation_user ""}
    {-creation_ip ""}
    -object_type
} {
    @param heading
    @param description
    @param parent_id
    @param keyword_id
    @param creation_date
    @param creation_user
    @param creation_ip
    @param object_type

    @return keyword_id of created keyword
} {
    set var_list [list \
        [list heading $heading ] \
        [list description $description ] \
        [list parent_id $parent_id ] \
        [list keyword_id $keyword_id ] \
        [list creation_user $creation_user ] \
        [list creation_ip $creation_ip ] \
    ]
    if {[info exists creation_date] && $creation_date ne ""} {
        lappend var_list [list creation_date $creation_date ]
    }
    if {[info exists object_type] && $object_type ne ""} {
        lappend var_list [list object_type $object_type ]
    }
    return [package_exec_plsql -var_list $var_list content_keyword new]
}


d_proc -public content::keyword::set_description {
    -keyword_id:required
    -description:required
} {
    @param keyword_id
    @param description
    @return 0
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
        [list description $description ] \
    ] content_keyword set_description]
}


d_proc -public content::keyword::set_heading {
    -keyword_id:required
    -heading:required
} {
    @param keyword_id
    @param heading
    @return 0
} {
    return [package_exec_plsql -var_list [list \
        [list keyword_id $keyword_id ] \
        [list heading $heading ] \
    ] content_permission set_heading]
}


d_proc -public content::keyword::get_children {
    {-parent_id ""}
} {
    Returns the ids of the keywords having the given parent_id. Returns
    an empty list if there are no children.

    @author Peter Marklund
} {
    return [db_list select_child_keywords {
        select keyword_id
        from cr_keywords
        where parent_id = :parent_id
    }]
}

d_proc -public content::keyword::get_keyword_id {
    {-parent_id:required}
    {-heading:required}
} {
    Get the keyword with the given heading under the given parent.
    Returns the empty string if none exists.
} {
    return [db_string select_keyword_id {
    select keyword_id 
    from   cr_keywords
    where  parent_id = :parent_id
    and    heading = :heading
    } -default {}]
}

d_proc -public content::keyword::get_options_flat {
    {-parent_id ""}
} {
    Returns a flat options list of the keywords with the given parent_id.
} {
    return [db_list_of_lists select_keyword_options {
        select heading, keyword_id
        from   cr_keywords
        where  ((:parent_id is null and parent_id is null) or parent_id = :parent_id)
        order  by lower(heading)
    }]
}

d_proc -public content::keyword::item_get_assigned {
    {-item_id:required}
    {-parent_id}
} {
    Returns a list of all keywords assigned to the given cr_item.

    If parent_id is supplied, only keywords that are children of
    parent_id are listed.
} {
    if {[info exists parent_id]} {
        set keyword_list [db_list get_child_keywords {
            select km.keyword_id
            from cr_item_keyword_map km,
                 cr_keywords kw
            where km.item_id = :item_id
            and   kw.parent_id = :parent_id
            and   kw.keyword_id = km.keyword_id
    }]
    } else {
        set keyword_list [db_list get_keywords {
            select keyword_id from cr_item_keyword_map
            where item_id = :item_id
    }]
    }

    return $keyword_list
}


d_proc -public content::keyword::item_unassign_children {
    {-item_id:required}
    {-parent_id:required}
} {
    Unassign all the keywords attached to a content item
    that are children of keyword parent_id.

    Returns the supplied item_id for convenience.
} {
    db_dml item_unassign_children {
    delete from cr_item_keyword_map
    where item_id = :item_id
    and   keyword_id in (select p.keyword_id
                         from   cr_keywords p
                         where  p.parent_id = :parent_id)
    }
    return $item_id
}

#
# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: