Class: SoarSr::Associations

Inherits:
ThreadedHandler show all
Includes:
Jsender
Defined in:
lib/soar_sr/associations.rb

Instance Attribute Summary

Attributes inherited from ThreadedHandler

#max_threads

Attributes inherited from Handler

#registry

Instance Method Summary collapse

Methods inherited from ThreadedHandler

#initialize

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::ThreadedHandler

Instance Method Details

#associate_service_component_with_domain_perspective(service_component, domain_perspective) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/soar_sr/associations.rb', line 76

def associate_service_component_with_domain_perspective(service_component, domain_perspective)_{
  service_component = standardize(service_component)      
  domain_perspective = standardize(domain_perspective)            
  provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
  provided?(service_component, 'service component') and registered?(service_component, 'service-components')
  service_component_id = compile_domain_id('service-components', service_component)
  type_registered =  which_type_registered?(domain_perspective)

  meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective) if type_registered == 'domains'
  meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if type_registered == 'teams'

  raise ValidationError, 'already associated' if meta['associations']['service_components'][service_component_id]

  meta['associations']['service_components'][service_component_id] = true

  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta) if type_registered == 'domains'
  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('teams', domain_perspective, meta) if type_registered == 'teams'

  authorized?(result) and identifier?(result, 'domain perspective')
  success
}end

#associate_service_component_with_service(service, access_point, description = '') ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/soar_sr/associations.rb', line 23

def associate_service_component_with_service(service, access_point, description = '')_{
  service = standardize(service)
  authorize
  provided?(service, 'service') and provided?(access_point, 'access point') and uri?(access_point)
  result = @uddi.add_service_uri(service, access_point)
  authorized?(result) and identifier?(result, 'service')
  success('service or access point')         
}end

#associate_service_with_domain_perspective(service, domain_perspective) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/soar_sr/associations.rb', line 98

def associate_service_with_domain_perspective(service, domain_perspective)_{
  service = standardize(service)      
  domain_perspective = standardize(domain_perspective)            
  provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
  provided?(service, 'service') and registered?(service, 'services')

  service_id = compile_domain_id('services', service)

  type_registered =  which_type_registered?(domain_perspective)      
  meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective) if type_registered == 'domains'
  meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if type_registered == 'teams'

  raise ValidationError, 'already associated' if meta['associations']['services'][service_id]

  meta['associations']['services'][service_id] = true

  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta) if type_registered == 'domains'
  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('teams', domain_perspective, meta) if type_registered == 'teams'
  authorized?(result) and identifier?(result, 'domain perspective')
  success
}end

#delete_all_domain_perspective_associations(domain_perspective) ⇒ Object



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/soar_sr/associations.rb', line 168

def delete_all_domain_perspective_associations(domain_perspective)_{
  domain_perspective = standardize(domain_perspective)            
  # byebug
  provided?(domain_perspective, 'domain perspective')
  associations = domain_perspective_associations(domain_perspective)['data']['associations']
  associations['service_components'] ||= {}
  associations['services'] ||= {}
  associations['service_components'].each do |id, value|
    disassociate_service_component_from_domain_perspective(domain_perspective, extract_domain_name('service-components', id))
  end
  associations['services'].each do |id, value|
    disassociate_service_from_domain_perspective(domain_perspective, extract_domain_name('services', id))
  end
  success
}end

#disassociate_service_component_from_domain_perspective(domain_perspective, service_component) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/soar_sr/associations.rb', line 120

def disassociate_service_component_from_domain_perspective(domain_perspective, service_component)_{
  service_component = standardize(service_component)      
  domain_perspective = standardize(domain_perspective)            
  # byebug
  provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
  provided?(service_component, 'service component') and registered?(service_component, 'service-components')

  service_component_id = compile_domain_id('service-components', service_component)

  type_registered =  which_type_registered?(domain_perspective)      
  meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective) if type_registered == 'domains'
  meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if type_registered == 'teams'

  raise ValidationError, 'not associated' if not meta['associations']['service_components'][service_component_id]

  meta['associations']['service_components'].delete(service_component_id)

  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta) if type_registered == 'domains'
  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('teams', domain_perspective, meta) if type_registered == 'teams'

  authorized?(result) and identifier?(result, 'domain perspective')
  success
}end

#disassociate_service_from_domain_perspective(domain_perspective, service) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/soar_sr/associations.rb', line 144

def disassociate_service_from_domain_perspective(domain_perspective, service)_{
  service = standardize(service)      
  domain_perspective = standardize(domain_perspective)            
  # byebug
  provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
  provided?(service, 'service') and registered?(service, 'services')

  service_id = compile_domain_id('services', service)

  type_registered =  which_type_registered?(domain_perspective)      
  meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective) if type_registered == 'domains'
  meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if type_registered == 'teams'

  raise ValidationError, 'not associated' if not meta['associations']['services'][service_id]

  meta['associations']['services'].delete(service_id)

  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('domains', domain_perspective, meta) if type_registered == 'domains'
  result = @registry.domain_perspectives.configure_meta_for_domain_perspective('teams', domain_perspective, meta) if type_registered == 'teams'

  authorized?(result) and identifier?(result, 'domain perspective')
  success
}end

#domain_perspective_associations(domain_perspective) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/soar_sr/associations.rb', line 32

def domain_perspective_associations(domain_perspective)_{
  # byebug
  domain_perspective = standardize(domain_perspective)      
  provided?(domain_perspective, 'domain perspective') and any_registered?(domain_perspective)
  meta = @registry.domain_perspectives.meta_for_domain_perspective('domains', domain_perspective) if type_registered?(domain_perspective, 'domains')
  meta = @registry.domain_perspectives.meta_for_domain_perspective('teams', domain_perspective) if type_registered?(domain_perspective, 'teams')
  success_data(meta)
}end

#domain_perspective_has_associations?(domain_perspective) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/soar_sr/associations.rb', line 41

def domain_perspective_has_associations?(domain_perspective)
  domain_perspective = standardize(domain_perspective)            
  associations = domain_perspective_associations(domain_perspective)['data']['associations']
  (associations['service_components'].size > 0) or (associations['services'].size > 0)
end

#service_associations(service) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/soar_sr/associations.rb', line 47

def service_associations(service)_{
  service = standardize(service)            
  provided?(service, 'service') and registered?(service, 'services')
  result = @registry.services.service_uris(service)

  bindings = result['data']['bindings']
  bindings ||= {}
  uris = {}
  bindings.each do |id, detail|
    uris[id] = detail['access_point']
  end

  service = {'id' => compile_domain_id('services', service), 'uris' => uris, 'associations' => { 'domain_perspectives' => {}}}
  domain_perspectives = @registry.domain_perspectives.list_domain_perspectives['data']['domain_perspectives']

  threads = []
  services = []
  domain_perspectives.each do |name, details|
    threads, services = domain_perspective_associations_threaded(threads, name, service, services)
  end
  join_threads(threads)
  services.each do |sv|
    service['associations']['domain_perspectives'] = 
      Hash::deep_merge(service['associations']['domain_perspectives'],
                       sv['associations']['domain_perspectives'])
  end
  success_data(service)
}end

#service_component_has_domain_perspective_associations?(service_component) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/soar_sr/associations.rb', line 9

def service_component_has_domain_perspective_associations?(service_component)_{
  service_component = standardize(service_component)
  provided?(service_component, 'service component')
  service_component_id = compile_domain_id('service-components', service_component)
  domain_perspectives = @registry.domain_perspectives.list_domain_perspectives['data']['domain_perspectives']
  domain_perspectives.each do |name, detail|
    service_components = domain_perspective_associations(name)['data']['associations']['service_components']
    service_components.each do |id, value|
      return true if (id == service_component_id) and (value)
    end
  end
  false      
}end