- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::acs::SiteNode
::acs::SiteNode create ...This class capsulates access to site-nodes stored in the database. It is written in a style to support the needs of the traditional Tcl-based API.
Defined in packages/acs-tcl/tcl/site-nodes-procs.tcl
- Author:
- Gustaf Neumann
Class Relations
::nx::Class create ::acs::SiteNode \ -superclass ::nx::ObjectMethods (to be applied on instances)
flush_cache (scripted, public)
<instance of acs::SiteNode> flush_cache -node_id node_id \ [ -with_subtree on|off ] [ -url url ]This is a stub method to be overloaded by some cache managers.
- Switches:
- -node_id (required)
- -with_subtree (optional, boolean)
- -url (optional)
- Testcases:
- No testcase defined.
get (scripted, public)
<instance of acs::SiteNode> get [ -url url ] \ [ -node_id node_id ]
- Switches:
- -url (optional)
- -node_id (optional)
- Returns:
- a site node from url or site-node with all its context info
- Testcases:
- No testcase defined.
if {$url eq "" && $node_id eq ""} { error "site_node::get \"must pass in either url or node_id\"" } # # Make sure, we have a node_id. # if {$node_id eq ""} { set node_id [:get_node_id -url $url] } return [:properties -node_id $node_id]get_children (scripted, public)
<instance of acs::SiteNode> get_children -node_id node_id \ [ -all ] [ -package_type package_type ] \ [ -package_key package_key ] [ -filters filters ] \ [ -element element ]Filtering happens here exactly like in the nsv-based version. If should be possible to realize (at least some of the) filtering via the SQL query.
- Switches:
- -node_id (required)
- -all (optional)
- -package_type (optional)
- -package_key (optional)
- -filters (optional)
- -element (optional)
- Testcases:
- No testcase defined.
if {$all} { # # The following query is just for PG. Note that # the query should not return the root of the # tree. # set sql [subst { WITH RECURSIVE site_node_tree(node_id, parent_id) AS ( select node_id, parent_id from site_nodes where node_id = :node_id UNION ALL select child.node_id, child.parent_id from site_node_tree, site_nodes child where child.parent_id = site_node_tree.node_id ) select [acs::dc map_function_name site_node__url(node_id)] from site_node_tree where node_id != :node_id }] if {[db_driverkey ""] eq "oracle"} { set sql [string map [list "WITH RECURSIVE" "WITH"] $sql] } set child_urls [::acs::dc list -prepare integer dbqd..[current method]-all $sql] } else { if {$package_key ne ""} { # # Simple optimization for package_keys; seems to be frequently used. # We leave the logic below unmodified, which could be optimized as well. # set package_key_clause "and package_id = object_id and package_key = :package_key" set from "site_nodes, apm_packages" } else { set package_key_clause "" set from "site_nodes" } set sql [subst { select [::acs::dc map_function_name {site_node__url(node_id)}] from $from where parent_id = :node_id $package_key_clause }] set child_urls [::acs::dc list dbqd..[current method] $sql] } if { $package_type ne "" } { lappend filters package_type $package_type } elseif { $package_key ne "" } { lappend filters package_key $package_key } if { [llength $filters] > 0 } { set return_val [list] foreach child_url $child_urls { if {![catch {set site_node [:get -url $child_url]}]} { set passed_p 1 foreach { elm val } $filters { if { [dict get $site_node $elm] ne $val } { set passed_p 0 break } } if { $passed_p } { if { $element ne "" } { lappend return_val [dict get $site_node $element] } else { lappend return_val $child_url } } } } } elseif { $element ne "" } { set return_val [list] foreach child_url $child_urls { if {![catch {set site_node [:get -url $child_url]}]} { lappend return_val [dict get $site_node $element] } } } else { set return_val $child_urls } return $return_valget_package_url (scripted, public)
<instance of acs::SiteNode> get_package_url \ -package_key package_keyLegacy interface: previous implementations of the site-nodes assumed, that there is just one site-node entry available for a package-key. This method returns just the first answer form get_urls_from_package_key
- Switches:
- -package_key (required)
- Testcases:
- No testcase defined.
return [lindex [:get_urls_from_package_key -package_key $package_key] 0]get_urls_from_object_id (scripted, public)
<instance of acs::SiteNode> get_urls_from_object_id \ -object_id object_idReturn a list of URLs for site_nodes that have the given object mounted or the empty list if there are none. The URLs are returned in descending order meaning any children will come before their parents. This ordering is useful when deleting site nodes as we must delete child site nodes before their parents.
- Switches:
- -object_id (required, integer)
- Testcases:
- No testcase defined.
set child_urls [::acs::dc list -prepare integer dbqd..[current method]-all [subst { select [acs::dc map_function_name site_node__url(node_id)] as url from site_nodes where object_id = :object_id order by url desc }]]get_urls_from_package_key (scripted, public)
<instance of acs::SiteNode> get_urls_from_package_key \ -package_key package_keyReturn potentially multiple URLs based on a package key.
- Switches:
- -package_key (required)
- Testcases:
- No testcase defined.
return [::acs::dc list -prepare varchar dbqd..[current method]-urls-from-package-key [subst { select [acs::dc map_function_name site_node__url(node_id)] from site_nodes n, apm_packages p where p.package_key = :package_key and n.object_id = p.package_id }]]
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables