2424import oracle .weblogic .deploy .util .TranslateException as TranslateException
2525from oracle .weblogic .deploy .util import CLAException
2626from oracle .weblogic .deploy .util import FileUtils
27+ from oracle .weblogic .deploy .util import PyOrderedDict
2728from oracle .weblogic .deploy .util import VariableException
2829from oracle .weblogic .deploy .compare import CompareException
2930from oracle .weblogic .deploy .exception import ExceptionHelper
@@ -86,7 +87,7 @@ def __process_args(args):
8687class ModelDiffer :
8788
8889 def __init__ (self , current_dict , past_dict ):
89- self .final_changed_model = dict ()
90+ self .final_changed_model = PyOrderedDict ()
9091 self .current_dict = current_dict
9192 self .past_dict = past_dict
9293 self .set_current = sets .Set ()
@@ -182,7 +183,7 @@ def is_dict(self,key):
182183 :param key: key of the dictionary
183184 :return: true if it is a dictionary otherwise false
184185 """
185- if self .current_dict .has_key (key ) and isinstance (self .current_dict [key ],dict ):
186+ if self .current_dict .has_key (key ) and isinstance (self .current_dict [key ], PyOrderedDict ):
186187 return 1
187188 else :
188189 return 0
@@ -274,7 +275,7 @@ def _is_alias_folder(self, path):
274275
275276 return found
276277
277- def _add_results (self , ar_changes , is_delete = False ):
278+ def _add_results (self , ar_changes , is_delete = False , is_change = False ):
278279 """
279280 Update the differences in the final model dictionary with the changes
280281 :param ar_changes: Array of changes in delimited format
@@ -290,40 +291,47 @@ def _add_results(self, ar_changes, is_delete=False):
290291 if not found_in_allowable_delete :
291292 compare_msgs .add (('WLSDPLY-05701' ,item ))
292293 continue
293-
294- splitted = item .split (PATH_TOKEN ,1 )
295- n = len (splitted )
296- result = dict ()
297- walked = []
294+ splitted = item .split (PATH_TOKEN ,1 )
295+ n = len (splitted )
296+ result = PyOrderedDict ()
297+ walked = []
298298
299299 while n > 1 :
300- tmp = dict ()
301- tmp [splitted [0 ]]= dict ()
300+ tmp = PyOrderedDict ()
301+ tmp [splitted [0 ]] = PyOrderedDict ()
302302 if len (result ) > 0 :
303303 # traverse to the leaf
304- leaf = result
304+ leaf = result
305305 for k in walked :
306306 leaf = leaf [k ]
307- leaf [splitted [0 ]]= dict ()
307+ leaf [splitted [0 ]] = PyOrderedDict ()
308308 walked .append (splitted [0 ])
309309 else :
310- result = tmp
310+ result = tmp
311311 walked .append (splitted [0 ])
312- splitted = splitted [1 ].split (PATH_TOKEN ,1 )
313- n = len (splitted )
312+ splitted = splitted [1 ].split (PATH_TOKEN ,1 )
313+ n = len (splitted )
314314 #
315315 # result is the dictionary format
316316 #
317317 leaf = result
318- value_tree = self .current_dict
318+ if is_change :
319+ value_tree = self .past_dict
320+ else :
321+ value_tree = self .current_dict
319322 for k in walked :
320323 leaf = leaf [k ]
321- value_tree = value_tree [k ]
324+ value_tree = value_tree [k ]
322325 #
323326 # walk the current dictionary and set the value
324327 #
325328 if value_tree :
326- leaf [splitted [0 ]] = value_tree [splitted [0 ]]
329+ if is_change :
330+ leaf ['# - ' + splitted [0 ]] = value_tree [splitted [0 ]]
331+ else :
332+ if value_tree [splitted [0 ]] is not None and not isinstance (value_tree [splitted [0 ]], PyOrderedDict ):
333+ self ._add_results (ar_changes , is_delete , is_change = True )
334+ leaf [splitted [0 ]] = value_tree [splitted [0 ]]
327335 else :
328336 leaf [splitted [0 ]] = None
329337
@@ -348,12 +356,12 @@ def _add_results(self, ar_changes, is_delete=False):
348356 del pointer_dict [parent_key ][app_key ]
349357 # Special handling for deleting all resources in high level
350358 if split_delete_length == 2 and app_key != 'WebAppContainer' :
351- pointer_dict [parent_key ][app_key ] = dict ()
359+ pointer_dict [parent_key ][app_key ] = PyOrderedDict ()
352360 old_keys = self .past_dict [parent_key ][app_key ].keys ()
353361 for old_key in old_keys :
354- pointer_dict [parent_key ][app_key ]['!' + old_key ] = dict ()
362+ pointer_dict [parent_key ][app_key ]['!' + old_key ] = PyOrderedDict ()
355363 else :
356- pointer_dict [parent_key ]['!' + app_key ] = dict ()
364+ pointer_dict [parent_key ]['!' + app_key ] = PyOrderedDict ()
357365
358366 def merge_dictionaries (self , dictionary , new_dictionary ):
359367 """
@@ -367,7 +375,7 @@ def merge_dictionaries(self, dictionary, new_dictionary):
367375 dictionary [key ] = new_value
368376 else :
369377 value = dictionary [key ]
370- if isinstance (value , dict ) and isinstance (new_value , dict ):
378+ if isinstance (value , PyOrderedDict ) and isinstance (new_value , PyOrderedDict ):
371379 self .merge_dictionaries (value , new_value )
372380 else :
373381 dictionary [key ] = new_value
@@ -542,6 +550,7 @@ def get_compare_msgs(self):
542550 """
543551 return compare_msgs
544552
553+
545554def debug (format_string , * arguments ):
546555 """
547556 Generic debug code.
@@ -553,6 +562,7 @@ def debug(format_string, *arguments):
553562 else :
554563 _logger .finest (format_string , arguments )
555564
565+
556566def main ():
557567 """
558568 The main entry point for the discoverDomain tool.
@@ -657,6 +667,7 @@ def main():
657667 _logger .severe ('WLSDPLY-05704' , eeString )
658668 System .exit (2 )
659669
670+
660671def format_message (key , * args ):
661672 """
662673 Get message using the bundle.
@@ -666,6 +677,7 @@ def format_message(key, *args):
666677 """
667678 return ExceptionHelper .getMessage (key , list (args ))
668679
680+
669681if __name__ == "__main__" :
670682 main ()
671683
0 commit comments