view · edit · sidebar · attach · print · history

20110726-update-new-user-stock-format-bbmb_ch-inject-local-xml-order-xmlconv_bbmb_ch

<< | Index | >>


  1. Check all groups from ywsarti
  2. Make a method to set group 'Apo' for all users
  3. Test xmlconv
  4. Inject local order file (xml file)
  5. Testcases bbmb.ch

Goal/Estimate/Evaluation
  • Change user group / 100% / 100%
  • Inject xml local order file / 80% / 100%
Milestones
  • Check all groups
  • Make a method to set the group 'Apo' (hard coding)
  • Confirm accessibility
  • Test xmlconv
    1. Make admin command to inject a xml order file
  • Test bbmb.ch
Summary
Commits
Keep in Mind
  • fix update_stock (more smartly)

Check all groups from ywsarti

File

Run

$ ruby pickup_all_groups.rb > ywsbezber_new

Result

Upload it to the test server

Make a method to set group 'Apo' for all users

Experiment (src/custom/behavior.rb#update_users)

    def update_users
      users = []
      map = user_map
      update_values(:users, USER_MAP) { |values|
        unless(/Konditionskunde/.match(values[:address1]))
          if(uid = map[values[:customer_id]])
            values[:uid] = uid
          else
            values[:klass] = HospitalUser
          end
          # updated users must be in the group 'Apo'
          # Apo group is granted to access all the products
          # See ywsbezber
          values[:group_short] = 'Apo'
          users.push(values)
        end
      }
      users unless users.empty?
    end

Run

  • reboot bin/bbmbd
masa@masa ~/ywesee/bbmb.ch $ cd log/mnemonic/
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ rm *.*
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cp ~/work/mnemonic_local_update_all_kund_bak/*.* .
masa@masa ~/ywesee/bbmb.ch/log/mnemonic $ cd ../..
masa@masa ~/ywesee/bbmb.ch $ bin/admin
ch.bbmb.globopharm> overwrite_customer_ids_by_email '/home/masa/work/new_data/new_customer_id_ean_email.dat'
-> 27
ch.bbmb.globopharm> replace_customer_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_user_ids.csv'
-> 123
ch.bbmb.globopharm> replace_article_ids_gag_to_alloga '/home/masa/work/new_data/actual_gag_ean_allo_stock_ids.csv'
-> 284
ch.bbmb.globopharm> update
-> 

Result

Test xmlconv

Experiment (lib/xmlconv/util/application.rb#masa)

module XmlConv
  module Util
    class Application
      def masa
        'masa'
      end

Run

  • bin/xmlconv
masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ bin/xmlconvd config="etc/xmlconv.yml"

Result

  • bin/admin
masa@masa ~/ywesee/globopharm.xmlconv.bbmb.ch $ bin/admin server_url="druby://localhost:10012"
ch.xmlconv> masa
-> masa

Next

  • Make a admin command to inject a xml order file
  • Confirm the transfer to ftp server

Experiment (lib/lib/xmlconv/util/application.rb#inject_xml_order)

      def inject_xml_order
        drb_url = "druby://localhost:9999"
        name_short = 'gag'
        inject_id = '123456'
        src = File.read('/home/masa/work/input.xml')
        transaction = XmlConv::Util::Transaction.new
        xml_doc = REXML::Document.new(src)
        bdd = XmlConv::Conversion::PharmaciePlusBdd.convert(xml_doc)
        transaction.instance_eval('@model = bdd')

        XmlConv::PostProcess::Bbmb.inject(drb_url, name_short, inject_id, transaction)
        rescue => e
          open('/home/masa/work/log1.dat', 'w') do |out|
            out.print e
          end
      end

Result

  • failed

Test yaml methods

Run

masa@masa ~/work $ ruby yaml_save.rb > test.yml
masa@masa ~/work $ ruby yaml_load.rb 
#<Test:0x7f109aba23e8 @val="hellooo">
"hellooo"

Note

  • If the same class is defined when a yaml file is loaded by 'load_documents' method, the instance is restored
  • If the class is not defined when a yaml file is loaded, the object becomes an instance of YAML::Object

Inject local order file (xml file)

Polling process

  1. lib/xmlconv/util/application.rb#start_polling
  2. XmlConv::Util::PollingManager.new(@system).poll_sources
  3. lib/xmlconv/util/polling_manager.rb#poll_sources
  4. lib/xmlconv/util/polling_manager.rb#load_sources: load polling.yml and retunr YAML:Object as a block argument
  5. lib/xmlconv/util/polling_manager.rb#poll
  6. lib/xmlconv/util/polling_manager.rb#filtered_transaction

Note (key point)

  • The result of filtered_transaction is the argument of execute method

Experiment (Using PollingMission. it is for the polling of local order file)

 polling_file: "/home/masa/work/polling.yml"
  • lib/xmlconv/util/application.rb
require 'conversion/pharmacieplus_bdd'
require 'conversion/bdd_i2'
require 'postprocess/bbmb'

Run

  • bin/bbmbd
  • bin/xmlconvd config="etc/xmlconv.yml"
  • copy input.xml (order file) to /home/masa/work/xml_orders
 masa@masa ~/work $ cp input.xml xml_orders/

Wait for a minute (because the polling thread execute start_polling method once a minute)

Result

  • polling_bak directory is created and xml_orders/input.xml is deleted
masa@masa ~/work $ ls
input.xml  polling_bak  polling.yml  xml_orders
  • on the ftp server

Summary

In order to polling local files (inject the orders to the ftp server)

  1. add some require application.rb
  2. add some setting information in polling.yml (Use PollingMission class)
  3. copy a order file to the directory which is set in polling.yml
  4. (after one minute automatically the file is injected)

Testcases bbmb.ch

Current status

187 tests, 764 assertions, 20 failures, 28 errors

view · edit · sidebar · attach · print · history
Page last modified on July 26, 2011, at 04:58 PM