Skip to content

Commit 165e97b

Browse files
committed
Include appDeployments in model traverse base class; refactor to simplify recursion
1 parent 73e13b6 commit 165e97b

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

core/src/main/python/wlsdeploy/tool/util/filters/model_traverse.py

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from wlsdeploy.aliases.aliases import Aliases
55
from wlsdeploy.aliases.location_context import LocationContext
6+
from wlsdeploy.aliases.model_constants import APP_DEPLOYMENTS
67
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
78
from wlsdeploy.aliases.model_constants import RESOURCES
89
from wlsdeploy.aliases.model_constants import TOPOLOGY
@@ -21,45 +22,29 @@ def __init__(self, model_context, wlst_mode, exception_type):
2122
self._logger = PlatformLogger('wlsdeploy.model_traverse')
2223

2324
def traverse_model(self, root_dict):
24-
section_names = [DOMAIN_INFO, TOPOLOGY, RESOURCES]
25+
section_names = [DOMAIN_INFO, TOPOLOGY, RESOURCES, APP_DEPLOYMENTS]
2526
for section_name in section_names:
26-
self.traverse_section(section_name, root_dict,
27-
self._aliases.get_model_section_top_level_folder_names(section_name))
27+
self.traverse_section(root_dict, section_name)
2828

29-
def traverse_section(self, model_section_key, model_dict, valid_section_folders):
30-
if model_section_key not in model_dict.keys():
29+
def traverse_section(self, model_dict, section_name):
30+
if section_name not in model_dict.keys():
3131
return
3232

3333
# only specific top-level sections have attributes
34-
attribute_location = self._aliases.get_model_section_attribute_location(model_section_key)
35-
valid_attr_infos = []
36-
34+
valid_attribute_names = []
35+
attribute_location = self._aliases.get_model_section_attribute_location(section_name)
3736
if attribute_location is not None:
38-
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(attribute_location)
39-
40-
model_section_dict = model_dict[model_section_key]
41-
# use items(), not iteritems(), to avoid ConcurrentModificationException if dict is modified
42-
for section_dict_key, section_dict_value in model_section_dict.items():
43-
# section_dict_key is the name of a folder or attribute in the section.
44-
45-
if section_dict_key in valid_attr_infos:
46-
# section_dict_key is the name of an attribute in the section
47-
self.traverse_attribute(model_section_dict, section_dict_key, attribute_location)
37+
valid_attribute_names = self._aliases.get_model_attribute_names_and_types(attribute_location)
4838

49-
elif section_dict_key in valid_section_folders:
50-
# section_dict_key is a folder under the model section
51-
52-
# Append section_dict_key to location context
53-
model_location = LocationContext()
54-
model_location.append_location(section_dict_key)
55-
56-
# Call self.traverse_folder() passing in section_dict_value as the model_node to process
57-
self.traverse_folder(section_dict_value, model_location)
39+
model_location = LocationContext()
40+
model_section_dict = model_dict[section_name]
41+
valid_folder_names = self._aliases.get_model_section_top_level_folder_names(section_name)
42+
self.traverse_node_elements(model_section_dict, model_location, valid_folder_names, valid_attribute_names)
5843

5944
def traverse_folder(self, model_node, model_location):
6045
"""
6146
Traverse a folder that may have named sub-folders (such as Server), artificial named sub-folders (such
62-
as a security provider type), or its own sub-folders and attributes (such as .
47+
as a security provider type), or its own sub-folders and attributes (such as JTA).
6348
"""
6449

6550
# avoid checking folder type if is_artificial_type_folder
@@ -86,19 +71,22 @@ def traverse_folder(self, model_node, model_location):
8671
self.traverse_node(model_node, model_location)
8772

8873
def traverse_node(self, model_node, model_location):
74+
valid_folder_names = self._aliases.get_model_subfolder_names(model_location)
75+
valid_attribute_names = self._aliases.get_model_attribute_names(model_location)
76+
self.traverse_node_elements(model_node, model_location, valid_folder_names, valid_attribute_names)
77+
78+
def traverse_node_elements(self, model_node, model_location, valid_folder_names, valid_attribute_names):
8979
"""
9080
Traverse a node that contains only attributes, non-named sub-folders, and artificial type folders.
9181
"""
92-
valid_folder_keys = self._aliases.get_model_subfolder_names(model_location)
93-
valid_attr_infos = self._aliases.get_model_attribute_names_and_types(model_location)
9482

9583
# use items(), not iteritems(), to avoid ConcurrentModificationException if node is modified
9684
for key, value in model_node.items():
97-
if key in valid_folder_keys:
85+
if key in valid_folder_names:
9886
new_location = LocationContext(model_location).append_location(key)
9987
self.traverse_folder(value, new_location)
10088

101-
elif key in valid_attr_infos:
89+
elif key in valid_attribute_names:
10290
self.traverse_attribute(model_node, key, model_location)
10391

10492
else:

0 commit comments

Comments
 (0)