Module: Search

Included in:
PEngine
Defined in:
lib/bizLogic/search.rb

Overview

Copyright © 2007-2008 Orangery Technology Limited You can redistribute it and/or modify it under the same terms as Ruby.

Instance Method Summary collapse

Instance Method Details

#executeSearch(product, params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bizLogic/search.rb', line 5

def executeSearch(product,params)
  
  mypredicate = ""
  params.each do |k,v|
    if (v.class.name == 'HashWithIndifferentAccess')
      mypredicate << explodeHash(v)
    end
  end

  open("#{File.dirname(__FILE__)}/xquery1") {|f| @query = f.read }
  @query = @query.gsub("PRODUCT","#{product}").gsub("PREDICATE",mypredicate[0..-5])
  
  persist = Persist.instance
  result = persist.find(@query)
end

#explodeHash(h) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bizLogic/search.rb', line 21

def explodeHash(h)
  predicate = ""
  h.each do |k,v|
    if (v.class.name == 'HashWithIndifferentAccess')
      predicate << explodeHash(v)
    elsif (v.class.name == "String")
      if (v.length > 0)
        predicate << "$result//#{k} =\"#{v}\" and "
      end
    end
  end
  predicate
end