Class: SoarSr::Associations
- Inherits:
-
Handler
show all
- Includes:
- Jsender
- Defined in:
- lib/soar_sr/associations.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?
Instance Method Details
#associate_service_component_with_domain_perspective(service_component, domain_perspective) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/soar_sr/associations.rb', line 47
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/soar_sr/associations.rb', line 70
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/soar_sr/associations.rb', line 140
def delete_all_domain_perspective_associations(domain_perspective)_{
domain_perspective = standardize(domain_perspective)
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/soar_sr/associations.rb', line 92
def disassociate_service_component_from_domain_perspective(domain_perspective, service_component)_{
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, '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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
# File 'lib/soar_sr/associations.rb', line 116
def disassociate_service_from_domain_perspective(domain_perspective, service)_{
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, '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)_{
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
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_component_has_domain_perspective_associations?(service_component) ⇒ 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
|