This project has retired. For details please refer to its
Attic page.
OrganizationImpl xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout.registry.infomodel;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.HashSet;
22 import java.util.Iterator;
23 import java.util.Set;
24
25 import javax.xml.registry.JAXRException;
26 import javax.xml.registry.LifeCycleManager;
27 import javax.xml.registry.UnsupportedCapabilityException;
28 import javax.xml.registry.infomodel.Organization;
29 import javax.xml.registry.infomodel.PostalAddress;
30 import javax.xml.registry.infomodel.Service;
31 import javax.xml.registry.infomodel.TelephoneNumber;
32 import javax.xml.registry.infomodel.User;
33
34
35
36
37
38
39
40
41
42 public class OrganizationImpl extends RegistryObjectImpl implements Organization
43 {
44 private User primaryContact;
45 private Set<User> users = new HashSet<User>();
46 private Set<TelephoneNumber> telephoneNumbers = new HashSet<TelephoneNumber>();
47 private Collection<Service> services = new ArrayList<Service>();
48
49 public OrganizationImpl(LifeCycleManager lifeCycleManager)
50 {
51 super(lifeCycleManager);
52 }
53
54 public User getPrimaryContact() throws JAXRException
55 {
56
57
58
59
60
61
62
63 return primaryContact;
64 }
65
66 public void setPrimaryContact(User user) throws JAXRException
67 {
68 if (user == null)
69 {
70 throw new IllegalArgumentException("primaryContact must not be null");
71 }
72
73
74
75
76
77 primaryContact = user;
78
79 if (!users.contains(user)) {
80 addUser(user);
81 }
82 }
83
84 public void addUser(User user) throws JAXRException
85 {
86 doPrimaryContactHack(user);
87
88 users.add(user);
89 ((UserImpl) user).setOrganization(this);
90 }
91
92
93
94
95
96
97
98
99 private void doPrimaryContactHack(User user) {
100
101 if (primaryContact == null && users.size() == 0) {
102 primaryContact = user;
103 }
104 }
105
106 public void addUsers(Collection collection) throws JAXRException
107 {
108
109 for (Iterator iterator = collection.iterator(); iterator.hasNext();)
110 {
111 User user = (User) iterator.next();
112 addUser(user);
113 }
114 }
115
116 public Collection<User> getUsers() throws JAXRException
117 {
118 return users;
119 }
120
121 public void removeUser(User user) throws JAXRException
122 {
123 if (user != null) {
124 users.remove(user);
125 }
126
127
128
129
130
131
132 if (!users.contains(primaryContact)) {
133 primaryContact = null;
134 }
135 }
136
137 public void removeUsers(Collection collection) throws JAXRException
138 {
139 if (collection != null) {
140 users.removeAll(collection);
141 }
142
143
144
145
146
147
148 if (!users.contains(primaryContact)) {
149 primaryContact = null;
150 }
151
152 }
153
154 public Collection<TelephoneNumber> getTelephoneNumbers(String phoneType) throws JAXRException
155 {
156 Set<TelephoneNumber> filteredNumbers;
157 if (phoneType == null)
158 {
159 filteredNumbers = telephoneNumbers;
160 } else
161 {
162 filteredNumbers = new HashSet<TelephoneNumber>(telephoneNumbers.size());
163 for (Iterator i = telephoneNumbers.iterator(); i.hasNext();)
164 {
165 TelephoneNumber number = (TelephoneNumber) i.next();
166 if (phoneType.equals(number.getType()))
167 {
168 filteredNumbers.add(number);
169 }
170 }
171 }
172 return filteredNumbers;
173 }
174
175 public void setTelephoneNumbers(Collection collection) throws JAXRException
176 {
177
178 Set<TelephoneNumber> numbers = new HashSet<TelephoneNumber>(collection.size());
179 for (Object number : collection) {
180 numbers.add((TelephoneNumber) number);
181 }
182 this.telephoneNumbers = numbers;
183 }
184
185 public void addService(Service service) throws JAXRException
186 {
187 services.add(service);
188
189
190
191
192
193
194 service.setProvidingOrganization(this);
195 }
196
197 public void addServices(Collection collection) throws JAXRException
198 {
199
200 for (Iterator iterator = collection.iterator(); iterator.hasNext();)
201 {
202 Service service = (Service) iterator.next();
203
204 addService(service);
205 }
206 }
207
208 public Collection<Service> getServices() throws JAXRException
209 {
210 return services;
211 }
212
213 public void removeService(Service service) throws JAXRException
214 {
215 services.remove(service);
216 }
217
218 public void removeServices(Collection collection) throws JAXRException
219 {
220 services.removeAll(collection);
221 }
222
223
224
225
226
227 public Organization getParentOrganization() throws JAXRException
228 {
229 throw new UnsupportedCapabilityException("Level 1 feature");
230 }
231
232 public Collection<Organization> getDescendantOrganizations() throws JAXRException
233 {
234 throw new UnsupportedCapabilityException("Level 1 feature");
235 }
236
237 public Organization getRootOrganization() throws JAXRException
238 {
239 throw new UnsupportedCapabilityException("Level 1 feature");
240 }
241
242 public void addChildOrganization(Organization organization) throws JAXRException
243 {
244 throw new UnsupportedCapabilityException("Level 1 feature");
245 }
246
247 public void addChildOrganizations(Collection collection) throws JAXRException
248 {
249 throw new UnsupportedCapabilityException("Level 1 feature");
250 }
251
252 public int getChildOrganizationCount() throws JAXRException
253 {
254 throw new UnsupportedCapabilityException("Level 1 feature");
255 }
256
257 public Collection<Organization> getChildOrganizations() throws JAXRException
258 {
259 throw new UnsupportedCapabilityException("Level 1 feature");
260 }
261
262 public void removeChildOrganization(Organization organization) throws JAXRException
263 {
264 throw new UnsupportedCapabilityException("Level 1 feature");
265 }
266
267 public void removeChildOrganizations(Collection collection) throws JAXRException
268 {
269 throw new UnsupportedCapabilityException("Level 1 feature");
270 }
271
272 public PostalAddress getPostalAddress() throws JAXRException
273 {
274 throw new UnsupportedCapabilityException("Level 1 feature");
275 }
276
277 public void setPostalAddress(PostalAddress postalAddress) throws JAXRException
278 {
279 throw new UnsupportedCapabilityException("Level 1 feature");
280 }
281 }