| |
654 |
654 |
{-package_type {}} |
| |
655 |
655 |
{-package_key {}} |
| |
656 |
656 |
{-filters {}} |
| |
657 |
657 |
{-element {}} |
| |
658 |
658 |
{-node_id:required} |
| |
659 |
659 |
} { |
| |
660 |
660 |
This proc gives answers to questions such as: What are all the package_id's |
| |
661 |
661 |
(or any of the other available elements) for all the instances of package_key or package_type mounted |
| |
662 |
662 |
under node_id xxx? |
| |
663 |
663 |
|
| |
664 |
664 |
@param node_id The node for which you want to find the children. |
| |
665 |
665 |
|
| |
666 |
666 |
@option all Set this if you want all children, not just direct children |
| |
667 |
667 |
|
| |
668 |
668 |
@option package_type If specified, this will limit the returned nodes to those with an |
| |
669 |
669 |
package of the specified package type (normally apm_service or |
| |
670 |
670 |
apm_application) mounted. Conflicts with the -package_key option. |
| |
671 |
671 |
|
| |
672 |
672 |
@param package_key If specified, this will limit the returned nodes to those with a |
| |
673 |
673 |
package of the specified package key mounted. Conflicts with the |
| |
674 |
|
-package_type option. |
| |
|
674 |
-package_type option. Can take one or more packges keys as a Tcl list. |
| |
675 |
675 |
|
| |
676 |
676 |
@param filters Takes a list of { element value element value ... } for filtering |
| |
677 |
677 |
the result list. Only nodes where element is value for each of the |
| |
678 |
678 |
filters in the list will get included. For example: |
| |
679 |
679 |
-filters { package_key "acs-subsite" }. |
| |
680 |
680 |
|
| |
681 |
681 |
@param element The element of the site node you wish returned. Defaults to url, but |
| |
682 |
682 |
the following elements are available: object_type, url, object_id, |
| |
683 |
683 |
instance_name, package_type, package_id, name, node_id, directory_p. |
| |
684 |
684 |
|
| |
685 |
685 |
@return A list of URLs of the site_nodes immediately under this site node, or all children, |
| |
686 |
686 |
if the -all switch is specified. |
| |
687 |
687 |
|
| |
688 |
688 |
@author Lars Pind (lars@collaboraid.biz) |
| |
689 |
689 |
} { |
| |
690 |
690 |
if { ![empty_string_p $package_type] && ![empty_string_p $package_key] } { |
| |
691 |
691 |
error "You may specify either package_type, package_key, or filter_element, but not more than one." |
| |
692 |
692 |
} |
| |
693 |
693 |
|
| |
694 |
694 |
if { ![empty_string_p $package_type] } { |
|
| |
706 |
706 |
# by clipping the node url and last character and seeing if there |
| |
707 |
707 |
# is a / in the string. about 2x faster than the RE version. |
| |
708 |
708 |
foreach child_url [nsv_array names site_nodes "${node_url}?*"] { |
| |
709 |
709 |
if { [string first / [string range $child_url $s end-1]] < 0 } { |
| |
710 |
710 |
lappend child_urls $child_url |
| |
711 |
711 |
} |
| |
712 |
712 |
} |
| |
713 |
713 |
} else { |
| |
714 |
714 |
set child_urls [nsv_array names site_nodes "${node_url}?*"] |
| |
715 |
715 |
} |
| |
716 |
716 |
|
| |
717 |
717 |
|
| |
718 |
718 |
if { [llength $filters] > 0 } { |
| |
719 |
719 |
set return_val [list] |
| |
720 |
720 |
foreach child_url $child_urls { |
| |
721 |
721 |
array unset site_node |
| |
722 |
722 |
if {![catch {array set site_node [nsv_get site_nodes $child_url]}]} { |
| |
723 |
723 |
|
| |
724 |
724 |
set passed_p 1 |
| |
725 |
725 |
foreach { elm val } $filters { |
| |
726 |
|
if { ![string equal $site_node($elm) $val] } { |
| |
|
726 |
# package_key supports one or more package keys |
| |
|
727 |
# since we can filter on the site node pretty name |
| |
|
728 |
# we can't just treat all filter values as a list |
| |
|
729 |
if {$elm eq "package_key" && [llength $val] > 1 && [lsearch $val $site_node($elm)] < 0} { |
| |
727 |
730 |
set passed_p 0 |
| |
728 |
731 |
break |
| |
|
732 |
} elseif {($elm ne "package_key" || [llength $val] == 1) && ![string equal $site_node($elm) $val]} { |
| |
|
733 |
set passed_p 0 |
| |
|
734 |
break |
| |
729 |
735 |
} |
| |
730 |
736 |
} |
| |
731 |
737 |
if { $passed_p } { |
| |
732 |
738 |
if { ![empty_string_p $element] } { |
| |
733 |
739 |
lappend return_val $site_node($element) |
| |
734 |
740 |
} else { |
| |
735 |
741 |
lappend return_val $child_url |
| |
736 |
742 |
} |
| |
737 |
743 |
} |
| |
738 |
744 |
} |
| |
739 |
745 |
} |
| |
740 |
746 |
} elseif { ![empty_string_p $element] } { |
| |
741 |
747 |
set return_val [list] |
| |
742 |
748 |
foreach child_url $child_urls { |
| |
743 |
749 |
array unset site_node |
| |
744 |
750 |
if {![catch {array set site_node [nsv_get site_nodes $child_url]}]} { |
| |
745 |
751 |
lappend return_val $site_node($element) |
| |
746 |
752 |
} |
| |
747 |
753 |
} |
| |
748 |
754 |
} |