Class: SoarSr::Search

Inherits:
Handler show all
Includes:
Jsender
Defined in:
lib/soar_sr/search.rb

Instance Attribute Summary

Attributes inherited from Handler

#registry

Instance Method Summary collapse

Methods inherited from Handler

#authorize, #initialize

Methods inherited from Validator

#authorized?, #contact?, #credentials?, #identifier?, #key_provided?, #length_at_least?, #meta?, #one_of, #present?, #provided?, #type?, #uri?, #wadl?

Constructor Details

This class inherits a constructor from SoarSr::Handler

Instance Method Details

#query_service_by_pattern(pattern) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/soar_sr/search.rb', line 8

def query_service_by_pattern(pattern)_{
  provided?(pattern, 'pattern')
  result = @uddi.find_services
  list = {}        
  if has_data?(result, 'services')
    result['data']['services'].each do |service, name|
      detail = @uddi.get_service(service)
      if has_data?(detail, 'description')
        found = false
        dss = nil
        detail['data']['description'].each do |description|
          found = true if (description and description.include?(pattern))
          dss = description.gsub("dss:", "").strip if (description and description.include?('dss:'))
        end
        list[service] = detail if ((dss and (@dss and check_dss(service))) or (not dss)) and found
      end
    end
  end

  success_data({ 'services' => list })
}end

#search_domain_perspective(domain_perspective, pattern) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/soar_sr/search.rb', line 72

def search_domain_perspective(domain_perspective, pattern)_{
  domain_perspective = standardize(domain_perspective)            
  provided?(domain_perspective, 'domain perspective') and registered?(domain_perspective, 'domains')

  found = {}
  data = @registry.associations.domain_perspective_associations(domain_perspective)['data']['associations']
  services = {}
  service_components = {}
  services_list = data['services']
  service_components_list = data['service_components']
  services_list.each do |service, detail|
    data = @uddi.get_service(service)['data']
    services[extract_domain_name('services', service)] = data if search_for_pattern_in_hash_values(data, pattern)
  end
  service_components_list.each do |service_component, detail|
    data = @uddi.get_service_component(service_component)['data']
    service_components[extract_domain_name('services-components', service_component)] = data if search_for_pattern_in_hash_values(data, pattern)
  end
  found = services.merge!(service_components)
  success_data({'services' => found})
}end

#search_for_service(pattern, include_service_components = true, full_text = true) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/soar_sr/search.rb', line 34

def search_for_service(pattern, include_service_components = true, full_text = true)_{
  provided?(pattern, 'pattern') and length_at_least?(pattern, 4, 'pattern')

  services = {}
  service_components = {}
  services_list = @uddi.find_services(pattern)['data']['services'] if not include_service_components
  services_list, service_components_list = @registry.services.find_services_and_service_components(nil) if include_service_components
  services_list.each do |service, detail|
    service_name = extract_domain_name('services', service)
    if full_text
      data = @uddi.get_service(service)['data'] if full_text
      if search_for_pattern_in_hash_values(data, pattern)
        services[service_name] = data
        services[service_name]['uris'] = @registry.services.service_uris(service_name)['data']['bindings']
      end
    else
      if service_name == service
        services[service_name] = detail
        services[service_name]['uris'] = @registry.services.service_uris(service_name)['data']['bindings']
      end
    end
  end
  if (include_service_components)
    service_components_list.each do |service_component, detail|
      service_name = extract_domain_name('services-components', service_component)
      if full_text
        data = @uddi.get_service_component(service_component)['data']
        service_components[service_name] = data if search_for_pattern_in_hash_values(data, pattern)
      else
        service_components[service_name] = detail if service_name == service_component
      end
    end
  end
  found = services.merge!(service_components)

  success_data({'services' => found})
}end

#search_for_service_by_name(name) ⇒ Object



30
31
32
# File 'lib/soar_sr/search.rb', line 30

def search_for_service_by_name(name)      
  search_for_service(name, false, false)
end