Changeset 243

Show
Ignore:
Timestamp:
12/15/06 15:02:38 (2 years ago)
Author:
sacha
Message:

added support to select party for dynamic stuff.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/message-handling-refactor-branch/bin/run-command-center.rb

    r231 r243  
    9898end 
    9999 
    100 def directive_dynamic_menu cpas_command, previous = nil, output = nil, number_directives = 1 
     100def directive_dynamic_menu party_name, cpas_command, previous = nil, output = nil, number_directives = 1 
    101101  puts "                       HefeWeizen Main Directive Dynamic Menu" 
    102102  puts "-------------------------------------------------------------------------------" 
    103103  puts "D - Directive Menu     S - Show Statistics       T - Top program       Q - Quit" 
     104  puts "                       PARTY  :: #{party_name}" 
    104105  puts "" 
    105106  puts "N - set number of directives to copy. currently: #{number_directives}" 
     
    108109  cpas_command.sort.each{ | entry | 
    109110    command = entry[1] 
    110 # } |||  #{short_info_structure command[1]}" 
     111    # } |||  #{short_info_structure command[1]}" 
    111112    puts sprintf( "%1$*2$s %3$s", command[0], -40, short_info_structure(command[1])) 
    112113  } 
     
    142143end 
    143144 
    144 def work_directive_dynamic_menu cpas_info, number_directives 
     145def work_directive_dynamic_menu party_name, cpas_info, number_directives 
    145146  cpas_command = get_cpas_command cpas_info 
    146147  number_directives = number_directives 
    147   directive_dynamic_menu cpas_command, nil, nil, number_directives 
     148  directive_dynamic_menu party_name, cpas_command, nil, nil, number_directives 
    148149  while true do 
    149150    output = nil 
     
    188189        file << directive 
    189190        file.close 
    190         command = "mv #{file_name} /var/spool/hefeweizen/coronation/outgoing/directives"  
     191        command = "mv #{file_name} /var/spool/hefeweizen/#{party_name.downcase}/outgoing/directives"  
    191192        system command 
    192193        output =  command 
     
    195196 
    196197    system "clear" 
    197     directive_dynamic_menu cpas_command, input, output, number_directives 
     198    directive_dynamic_menu party_name, cpas_command, input, output, number_directives 
    198199  end 
    199200end 
     
    235236      return 
    236237    when "D" 
     238 
     239      party_name, cpa_path = get_party_and_cpa 
    237240      system "clear" 
    238241       
    239       cpas = Hash.new 
    240       cpa_filename = "#{@config['CONFIG_DIR']}/#{@config['SYSTEMS_DIR']}/Coronation/trading_agreements/cpa_test.xml" 
    241  
    242 #      require "#{@config['LIB_DIR']}/hefeweizen_library_cpa" 
     242      cpa_filename = cpa_path 
     243 
     244      # require "#{@config['LIB_DIR']}/hefeweizen_library_cpa" 
    243245      require "../src/hefeweizen_library_cpa" 
    244246      cpa = HefeWeizen::HefeWeizenLibrary::CPA.create(cpa_filename, @config) 
    245       party_name = "Coronation" 
    246       party_identities = [ { :type => "string", :id => "coronation" },  
    247                           { :type => "urn:li.coronation.b2b", :id => "coronation_test_system"} ] 
     247 
     248      party_identities = nil 
     249      if party_name == "Coronation" then 
     250        party_identities = [ { :type => "string", :id => "coronation" },  
     251                             { :type => "urn:li.coronation.b2b", :id => "coronation_test_system"} ] 
     252      else 
     253        party_identities = [ { :type => "string", :id => "gnaraloo" },  
     254                             { :type => "urn:li.gnaraloo.b2b", :id => "gnaraloo_test_system"} ] 
     255      end 
    248256 
    249257      cpas_info = [cpa.setup_all_ebMS_header_infos( cpa.id, party_name, party_identities )] 
    250       number_directives = work_directive_dynamic_menu cpas_info, number_directives 
     258      number_directives = work_directive_dynamic_menu party_name, cpas_info, number_directives 
    251259    when "S" 
    252260      output = %x(sh ./run-statistics.sh) 
     
    294302end 
    295303 
     304 
     305def get_party_and_cpa 
     306  puts "Getting the cpa and selecting the party." 
     307  puts "Select organisation:" 
     308  parties = Dir.glob "#{@config['CONFIG_DIR']}/#{@config['SYSTEMS_DIR']}/*" 
     309  party_selection = Hash.new 
     310  counter = 1 
     311  parties.each{ | party | 
     312    party_selection[counter] = party 
     313    puts "#{counter.to_s}. #{File.basename party}" 
     314    counter += 1 
     315  } 
     316  selected = false 
     317  party_path = nil 
     318  while selected == false do 
     319    puts "Your selection: " 
     320    selected_organisation = gets 
     321    if party_selection.has_key? selected_organisation.to_i then 
     322      selected = true 
     323      party_path = party_selection[selected_organisation.to_i] 
     324    else 
     325      puts "#{selected_organisation} is an invalid entry. Please select again." 
     326    end 
     327  end 
     328 
     329  party_name = File.basename party_path 
     330   
     331  puts "Select CPA:" 
     332  cpas = Hash.new 
     333  cpa_path = nil 
     334  counter = 1 
     335  available_cpas = Dir.glob "#{party_path}/trading_agreements/*" 
     336  available_cpas.each{ | cpa | 
     337    cpas[counter] = cpa 
     338    puts "#{counter.to_s}. #{File.basename cpa}" 
     339    counter += 1 
     340  } 
     341  selected = false 
     342  while selected == false do 
     343    puts "Your selection: " 
     344    selected_cpa = gets 
     345    if cpas.has_key? selected_cpa.to_i then 
     346      selected = true 
     347      cpa_path = cpas[selected_cpa.to_i] 
     348    else 
     349      puts "#{selected_cpa} is invalid. Please select again." 
     350    end 
     351  end 
     352   
     353  return party_name, cpa_path 
     354end 
    296355 
    297356def main_menu previous = nil, output = nil