view · edit · sidebar · attach · print · history

20110825-limitation-feedback-email-links-migel-drb-client-oddb_org

<< | Index | >>


  1. Simplify Limitation text link
  2. Snapback link in limitation view
  3. Feedback link?

Estimate/Evaluation:
  • Migel drb client in oddb.org / 100% / 90%
Milestones
  1. Limitation link
  2. Limitation view (snapback link)
  3. FB, Email links (-> Segmentation fault, gd lib error)
Summary
Commits
Keep in Mind
  • How to import data from csv with DRbUndumped module
  • How to check the class of DRbObject in drb server side
ToDo
  • Testcases oddb.org, migel

Simplify Limitation text link

Now (z.B.)

Goal (z.B.)

Note

  • Limitation text belongs not only to Migelid (Product) but also to Group and Subgroup

Experiment

  • src/util/validator.rb
  STRING = [
...
      :migel_limitation,
...
  • src/state/global.rb
      def migel_search
        if migel_code = @session.user_input(:migel_code) and product = @session.search_migel_products(migel_code).first
          ODDB::State::Migel::Items.new(@session, ODDB::Migel::Items.new(product))
        elsif migel_code = @session.user_input(:migel_product) and product = @session.search_migel_products(migel_code).first
          ODDB::State::Migel::Product.new(@session, product)
        elsif migel_code = @session.user_input(:migel_subgroup) and subgroup = @session.app.search_migel_subgroup(migel_code)
          ODDB::State::Migel::Subgroup.new(@session, subgroup)
        elsif migel_code = @session.user_input(:migel_group) and group = @session.app.search_migel_group(migel_code)
          ODDB::State::Migel::Group.new(@session, group)
        elsif migel_code = @session.user_input(:migel_limitation) and limitation_text = @session.app.search_migel_limitation(migel_code)
          ODDB::State::Migel::LimitationText.new(@session, limitation_text)
        else
          self
        end
      end
  • src/util/oddbapp.rb
    def search_migel_limitation(migel_code)
      case migel_code.length
      when 2 # Group
        if group = MIGEL_SERVER.group.find_by_migel_code(migel_code)
          group.limitation_text
        end
      when 4 # Subgroup
        code = migel_code.split(/(\d\d)/).select{|x| !x.empty?}.join('.')
        if subgroup = MIGEL_SERVER.subgroup.find_by_migel_code(code)
           subgroup.limitation_text
        end
      when 9 # Product (Migel::Model::Migelid) z.B. 150101001
        code = migel_code.split(/(\d\d)/).select{|x| !x.empty?}.join('.')
        if migelid = MIGEL_SERVER.migelid.find_by_migel_code(code)
           migelid.limitation_text
        end
      end
    end

Access

Result

NoMethodError
undefined method `parent' for #<Migel::Util::Multilingual:0x7f1de01701d8>
/home/masa/ywesee/oddb.org/src/remote/multilingual.rb:29:in `method_missing'
/home/masa/ywesee/oddb.org/src/view/migel/limitationtext.rb:39:in `limitation_text_title'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `send'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `create'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:280:in `compose_component'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:209:in `compose'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `each'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `compose'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:55:in `init'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/component.rb:138:in `initialize'
/home/masa/ywesee/oddb.org/src/view/publictemplate.rb:53:in `new'
/home/masa/ywesee/oddb.org/src/view/publictemplate.rb:53:in `content'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `send'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `create'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:280:in `compose_component'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:209:in `compose'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `each'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:203:in `compose'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:55:in `init'
/home/masa/ywesee/oddb.org/src/view/publictemplate.rb:50:in `init'
/home/masa/ywesee/oddb.org/src/view/privatetemplate.rb:16:in `init'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/component.rb:138:in `initialize'
/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:285:in `new'
/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:285:in `view'
/usr/lib64/ruby/site_ruby/1.8/sbsm/state.rb:197:in `to_html'
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:529:in `to_html'
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:177:in `drb_process'
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `synchronize'
/usr/lib64/ruby/site_ruby/1.8/sbsm/session.rb:174:in `drb_process'
/usr/lib64/ruby/1.8/drb/drb.rb:1555:in `__send__'
/usr/lib64/ruby/1.8/drb/drb.rb:1555:in `perform_without_block'
/usr/lib64/ruby/1.8/drb/drb.rb:1515:in `perform'
/usr/lib64/ruby/1.8/drb/drb.rb:1589:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1585:in `loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1585:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1581:in `start'
/usr/lib64/ruby/1.8/drb/drb.rb:1581:in `main_loop'
/usr/lib64/ruby/1.8/drb/drb.rb:1430:in `run'
/usr/lib64/ruby/1.8/drb/drb.rb:1427:in `start'
/usr/lib64/ruby/1.8/drb/drb.rb:1427:in `run'
/usr/lib64/ruby/1.8/drb/drb.rb:1347:in `initialize'
/usr/lib64/ruby/1.8/drb/drb.rb:1627:in `new'
/usr/lib64/ruby/1.8/drb/drb.rb:1627:in `start_service'
bin/oddbd:38

Note

  • 'parent' method is called for @limitation_text in the LimitationText view.
  • Migel::Model::Migelid.limitation_text is a Multilingual instance
  • ODDB::Migel::Product.limitation_text is a ODDB::LimitationText instance
  • ODDB::LimitationText has 'parent' method. (actually Persistence module method)
  • But Multilingual class does not have the 'parent' method

Question

  • How to define the 'parent' method
  • A problem is that a limitation_text instance is not created when a Migelid instance is created
  • Probably it is created when a migelid instance is updated

Solution

  • Make a link of parent property of limitation_text when the instance is updated
  • oddb.org/src/remote/multilingual.rb
      def parent=(parent)
        # This is used when Migel::Importer updates the limitaion_text
        @parent = parent
      end
      def parent(arg)
        # This is used when limitation_text is shown in ODDB::View::LimitationText
        @parent
      end

  • lib/migel/util/multilingual.rb
      def parent=(parent)
        # This is used when Migel::Importer updates the limitaion_text
        @parent = parent
      end
      def parent(arg)
        # This is used when limitation_text is shown in ODDB::View::LimitationText
        @parent
      end

  • lib/migel/importer.rb
..
      group.limitation_text.send(language.to_s + '=', text) unless(text.empty?)
      group.limitation_text.parent = group
..
        subgroup.limitation_text.send(language.to_s + '=', text)
        subgroup.limitation_text.parent = subgroup
..
  • lib/migel/model/migelid.rb
      def update_multilingual(data, language)
        data.keys.each do |key|
          self.send(key).send(language.to_s + '=', data[key])
        end
        if @limitation_text
          @limitation_text.parent = self
        end
      end

Restore database

masa@masa ~/ywesee/migel $ sudo -u postgres dropdb migel
masa@masa ~/ywesee/migel $ sudo -u postgres createdb -E UTF8 -T template0 migel
masa@masa ~/ywesee/migel $ bin/migeld
migel> Migel::Importer.new.update('data/csv/migel_de_test.csv','de')
-> Array

Access

Result

error in SBSM::Session#http_headers: /de/gcc/migel_search/migel_limitation/150101001
NoMethodError
undefined method `parent' for #<DRb::DRbUnknown:0x7f6c50ca3208>
/home/masa/ywesee/oddb.org/src/view/migel/limitationtext.rb:39:in `limitation_text_title'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `send'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:66:in `create'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:280:in `compose_component'
/usr/lib64/ruby/site_ruby/1.8/htmlgrid/composite.rb:209:in `compose'
  • lib/migel/util/multilingual.rb
    class Multilingual
      include DRb::DRbUndumped

Access

Result

Note

  • The limitation title is shown but the limitation text is not shown
  • Maybe because the difference between ODDB::LimitationText and Multilingual classes

Question

  • How to show data in the LimitationText view

Problem

  • The following disturbs importing data from a csv file.
  • lib/migel/util/multilingual.rb
    class Multilingual
      include DRb::DRbUndumped

Note

  • But the limitation title is not shown without the DRbUndumped above.
  • For the moment, after importing data, include DRbUndumped module, and reboot migeld
  • Then limitation title is shown

Experiment

  • migeld server side
migel> Migel::Model::Migelid.find_by_migel_code('15.01.01.00.1').limitation_text
-> Limitation: Nur bei durch Krankheit oder Unfall bedingter Inkontinenz wie z. B. Multipler Sklerose, Querschnittlähmung, cerebraler Lähmung, Morbus Parkinson, Demenz.
migel> Migel::Model::Migelid.find_by_migel_code('15.01.01.00.1').limitation_text.de
-> Limitation: Nur bei durch Krankheit oder Unfall bedingter Inkontinenz wie z. B. Multipler Sklerose, Querschnittlähmung, cerebraler Lähmung, Morbus Parkinson, Demenz.
  • oddb client side
ch.oddb> search_migel_limitation('150101001').class
-> DRb::DRbObject
ch.oddb> search_migel_limitation('150101001').de
-> Limitation: Nur bei durch Krankheit oder Unfall bedingter Inkontinenz wie z. B. Multipler Sklerose, Querschnittlähmung, cerebraler Lähmung, Morbus Parkinson, Demenz.
ch.oddb> search_migel_limitation('150101001')
-> Limitation: Nur bei durch Krankheit oder Unfall bedingter Inkontinenz wie z. B. Multipler Sklerose, Querschnittlähmung, cerebraler Lähmung, Morbus Parkinson, Demenz.

Note

  • Actually, it succeeds to call the limitation_text data from the client side
  • The view class is ODDB::View::Migel::LimitationText
module ODDB
  module View
    module Migel
class LimitationTextInnerComposite < View::Drugs::LimitationTextInnerComposite
  DEFAULT_CLASS = HtmlGrid::Value
  def subgroup(model, session)
    product = model.parent(@session.app)
    if(lim = product.subgroup.limitation_text)
      lim.send(@session.language)
    end
  end
  def group(model, session)
    product = model.parent(@session.app)
    if(lim = product.group.limitation_text)
      lim.send(@session.language)
    end
  end
end
  • ODDB::View::Drugs::LimitationTextInnerComposite
module ODDB
  module View
    module Drugs
class LimitationTextInnerComposite < HtmlGrid::Composite
  COMPONENTS = {}
  DEFAULT_CLASS = View::Chapter
  def init
    yy = 0
    lang = @session.language.intern
    if(@model.respond_to?(lang) && @model.send(lang))
      components.store([0,yy], lang)
      yy += 1
    end
    super
  end
end

Note

  • Nothing special

Key point

  • Definitely, the difference between ODDB::LimitationText and Multilingual classes

Note

  • It may be related to HtmlGrid::Value class

Experiment

  • lib/migel/util/multilingual.rb
      def de
        @canonical[:de]
      end
  • src/remote/multilingual.rb
      def de
        @canonical[:de]
      end

Access

Point

  • The following respond_to?(lang) becomes false in src/view/drugs/limitationtext.rb
class LimitationTextInnerComposite < HtmlGrid::Composite
  def init
    yy = 0
    lang = @session.language.intern
    if(@model.respond_to?(lang) && @model.send(lang))
      components.store([0,yy], lang)
      yy += 1
    end
  • Then the no components are added in the view
  • The reason we can use 'de' method for the limitation_text (Multilingual) is for 'method_missing' method
  • Even if it works by using method_missing method, the respond_to? method does not return 'true'

Result

  • migelid (prodcut) limitaion
  • subgroup limitation

Snapback link in limitation view

  • lib/migel/model/migelid.rb
      def parent(app = nil)
        @subgroup
      end
  • lib/migel/model/subgroup.rb
      def parent(app = nil)
        @group
      end
  • lib/migel/model/group.rb
      def parent(app = nil)
        nil
      end

  • lib/migel/util/multilingual.rb
      # For PointerSteps (snapback links)
      def pointer_descr
        'Limitation'
      end

      def structural_ancestors(app)
        #[@parent.subgroup.group, @parent.subgroup, @parent]
        ancestors = []
        me = self
        while parent = me.parent
          ancestors.unshift parent
          me = parent
        end
        ancestors
      end

  • src/remote/multilingual.rb
      # For PointerSteps (snapback links)
      def pointer_descr
        'Limitation'
      end

      def structural_ancestors(app)
        #[@parent.subgroup.group, @parent.subgroup, @parent]
        ancestors = []
        me = self
        while parent = me.parent
          ancestors.unshift parent
          me = parent
        end
        ancestors
      end

  • src/view/migel/limitationtext.rb
class LimitationText < View::PrivateTemplate
  CONTENT = View::Migel::LimitationTextComposite
  SNAPBACK_EVENT = :result
  def backtracking(model, session=@session)
    ODDB::View::Migel::PointerSteps.new(model, @session, self)
  end
end

Access

Result

  • migelid limitation
  • subgroup limitation

Feedback? Feedback link

Problem

  • Segmentation fault when 'FB' is clicked

Console log

/home/masa/.gem/ruby/1.8/gems/gd2-1.1.1/lib/gd2/font.rb:234: [BUG] Segmentation fault
ruby 1.8.6 (2009-06-08) [x86_64-linux]

Abgebrochen

Note

  • Email link does not work either with the same error

Ruby/GD test


References

Note

  • I confirmed the samples above working
view · edit · sidebar · attach · print · history
Page last modified on August 26, 2011, at 07:21 AM