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.Collection; |
20 | |
import java.util.Collections; |
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.Association; |
29 | |
import javax.xml.registry.infomodel.Classification; |
30 | |
import javax.xml.registry.infomodel.Concept; |
31 | |
import javax.xml.registry.infomodel.ExternalIdentifier; |
32 | |
import javax.xml.registry.infomodel.ExternalLink; |
33 | |
import javax.xml.registry.infomodel.InternationalString; |
34 | |
import javax.xml.registry.infomodel.Key; |
35 | |
import javax.xml.registry.infomodel.Organization; |
36 | |
import javax.xml.registry.infomodel.RegistryObject; |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
public class RegistryObjectImpl extends ExtensibleObjectImpl implements RegistryObject |
47 | |
{ |
48 | |
private final LifeCycleManager lifeCycleManager; |
49 | |
private Key key; |
50 | 0 | private InternationalString name = new InternationalStringImpl(); |
51 | 0 | private InternationalString desc = new InternationalStringImpl(); |
52 | |
|
53 | 0 | private Set<Classification> classifications = new HashSet<Classification>(); |
54 | 0 | private Set<Association> associations = new HashSet<Association>(); |
55 | 0 | private Set<ExternalIdentifier> externalIds = new HashSet<ExternalIdentifier>(); |
56 | 0 | private Set<ExternalLink> externalLinks = new HashSet<ExternalLink>(); |
57 | |
|
58 | |
|
59 | |
private OrganizationImpl submittingOrganization; |
60 | |
|
61 | |
public RegistryObjectImpl(LifeCycleManager lifeCycleManager) |
62 | 0 | { |
63 | 0 | this.lifeCycleManager = lifeCycleManager; |
64 | 0 | } |
65 | |
|
66 | |
public RegistryObjectImpl(LifeCycleManager lifeCycleManager, InternationalString n) |
67 | 0 | { |
68 | 0 | this.lifeCycleManager = lifeCycleManager; |
69 | 0 | name = n; |
70 | 0 | } |
71 | |
|
72 | |
public Key getKey() |
73 | |
{ |
74 | 0 | return key; |
75 | |
} |
76 | |
|
77 | |
public InternationalString getDescription() |
78 | |
{ |
79 | 0 | return desc; |
80 | |
} |
81 | |
|
82 | |
public void setDescription(InternationalString description) |
83 | |
{ |
84 | 0 | this.desc = description; |
85 | 0 | } |
86 | |
|
87 | |
public InternationalString getName() |
88 | |
{ |
89 | 0 | return name; |
90 | |
} |
91 | |
|
92 | |
public void setName(InternationalString name) |
93 | |
{ |
94 | 0 | this.name = name; |
95 | 0 | } |
96 | |
|
97 | |
public void setKey(Key k) |
98 | |
{ |
99 | 0 | key = k; |
100 | 0 | } |
101 | |
|
102 | |
public String toXML() throws JAXRException |
103 | |
{ |
104 | 0 | throw new UnsupportedCapabilityException("toXML is not supported"); |
105 | |
} |
106 | |
|
107 | |
public void addClassification(Classification classification) |
108 | |
{ |
109 | 0 | classifications.add(classification); |
110 | 0 | } |
111 | |
|
112 | |
public void addClassifications(Collection collection) |
113 | |
{ |
114 | 0 | if (collection!=null) { |
115 | 0 | for (Object classification : collection) { |
116 | 0 | classifications.add((Classification)classification); |
117 | |
} |
118 | |
} |
119 | 0 | } |
120 | |
|
121 | |
public void removeClassification(Classification classification) |
122 | |
{ |
123 | 0 | classifications.remove(classification); |
124 | 0 | } |
125 | |
|
126 | |
public void removeClassifications(Collection collection) |
127 | |
{ |
128 | 0 | classifications.removeAll(collection); |
129 | 0 | } |
130 | |
|
131 | |
public Collection getClassifications() |
132 | |
{ |
133 | 0 | return Collections.unmodifiableSet(classifications); |
134 | |
} |
135 | |
|
136 | |
public void setClassifications(Collection collection) |
137 | |
{ |
138 | 0 | Set<Classification> newClassifications = new HashSet<Classification>(collection.size()); |
139 | 0 | for (Object classification : collection) { |
140 | 0 | newClassifications.add((Classification) classification); |
141 | |
} |
142 | 0 | classifications = newClassifications; |
143 | 0 | } |
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
public void addAssociation(Association association) |
154 | |
throws JAXRException |
155 | |
{ |
156 | 0 | associations.add(association); |
157 | |
|
158 | 0 | association.setSourceObject(this); |
159 | 0 | } |
160 | |
|
161 | |
public void addAssociations(Collection collection) throws JAXRException |
162 | |
{ |
163 | 0 | for (Object association : collection) { |
164 | 0 | addAssociation((Association) association); |
165 | |
} |
166 | 0 | } |
167 | |
|
168 | |
public Collection<Association> getAssociations() throws JAXRException |
169 | |
{ |
170 | 0 | return Collections.unmodifiableSet(associations); |
171 | |
} |
172 | |
|
173 | |
public void setAssociations(Collection collection) |
174 | |
{ |
175 | 0 | Set<Association> newAssociations = new HashSet<Association>(collection.size()); |
176 | 0 | for (Object association : collection) { |
177 | 0 | newAssociations.add((Association) association); |
178 | |
} |
179 | 0 | associations = newAssociations; |
180 | 0 | } |
181 | |
|
182 | |
public void removeAssociation(Association association) |
183 | |
{ |
184 | 0 | associations.remove(association); |
185 | 0 | } |
186 | |
|
187 | |
public void removeAssociations(Collection collection) |
188 | |
{ |
189 | 0 | associations.removeAll(collection); |
190 | 0 | } |
191 | |
|
192 | |
public void addExternalIdentifier(ExternalIdentifier externalIdentifier) |
193 | |
{ |
194 | 0 | externalIds.add(externalIdentifier); |
195 | 0 | ((ExternalIdentifierImpl) externalIdentifier).setRegistryObject(this); |
196 | 0 | } |
197 | |
|
198 | |
public void addExternalIdentifiers(Collection collection) |
199 | |
{ |
200 | 0 | if (collection!=null) { |
201 | 0 | for (Object externalId : collection) { |
202 | 0 | externalIds.add((ExternalIdentifier) externalId); |
203 | 0 | ((ExternalIdentifierImpl) externalId).setRegistryObject(this); |
204 | |
} |
205 | |
} |
206 | 0 | } |
207 | |
|
208 | |
public void removeExternalIdentifier(ExternalIdentifier externalIdentifier) |
209 | |
{ |
210 | 0 | externalIds.remove(externalIdentifier); |
211 | 0 | ((ExternalIdentifierImpl) externalIdentifier).setRegistryObject(null); |
212 | 0 | } |
213 | |
|
214 | |
public void removeExternalIdentifiers(Collection collection) |
215 | |
{ |
216 | |
|
217 | 0 | Iterator iter = collection.iterator(); |
218 | 0 | while (iter != null && iter.hasNext()) |
219 | |
{ |
220 | 0 | ExternalIdentifier externalId = (ExternalIdentifier) iter.next(); |
221 | 0 | ((ExternalIdentifierImpl) externalId).setRegistryObject(null); |
222 | 0 | } |
223 | 0 | externalIds.removeAll(collection); |
224 | 0 | } |
225 | |
|
226 | |
public Collection<ExternalIdentifier> getExternalIdentifiers() |
227 | |
{ |
228 | 0 | return Collections.unmodifiableSet(externalIds); |
229 | |
} |
230 | |
|
231 | |
public void setExternalIdentifiers(Collection collection) |
232 | |
{ |
233 | 0 | Set<ExternalIdentifier> newExternalIds = new HashSet<ExternalIdentifier>(collection.size()); |
234 | 0 | for (Object externalId : collection) { |
235 | 0 | newExternalIds.add((ExternalIdentifier) externalId); |
236 | |
} |
237 | 0 | externalIds = newExternalIds; |
238 | 0 | } |
239 | |
|
240 | |
public void addExternalLink(ExternalLink externalLink) |
241 | |
{ |
242 | 0 | externalLinks.add(externalLink); |
243 | 0 | ((ExternalLinkImpl) externalLink).addLinkedObject(this); |
244 | 0 | } |
245 | |
|
246 | |
public void addExternalLinks(Collection collection) |
247 | |
{ |
248 | 0 | for (Object externalLink : collection) { |
249 | 0 | externalLinks.add((ExternalLink) externalLink); |
250 | 0 | ((ExternalLinkImpl) externalLink).addLinkedObject(this); |
251 | |
} |
252 | 0 | } |
253 | |
|
254 | |
public void removeExternalLink(ExternalLink externalLink) |
255 | |
{ |
256 | 0 | ((ExternalLinkImpl) externalLink).removeLinkedObject(this); |
257 | 0 | externalLinks.remove(externalLink); |
258 | 0 | } |
259 | |
|
260 | |
public void removeExternalLinks(Collection collection) |
261 | |
{ |
262 | 0 | Iterator iter = collection.iterator(); |
263 | 0 | while (iter != null && iter.hasNext()) |
264 | |
{ |
265 | 0 | ExternalLink externalLink = (ExternalLink) iter.next(); |
266 | 0 | ((ExternalLinkImpl) externalLink).removeLinkedObject(this); |
267 | 0 | } |
268 | 0 | externalLinks.removeAll(collection); |
269 | 0 | } |
270 | |
|
271 | |
public Collection<ExternalLink> getExternalLinks() |
272 | |
{ |
273 | 0 | return Collections.unmodifiableSet(externalLinks); |
274 | |
} |
275 | |
|
276 | |
public void setExternalLinks(Collection collection) |
277 | |
{ |
278 | 0 | Set<ExternalLink> newExternalLinks = new HashSet<ExternalLink>(collection.size()); |
279 | 0 | for (Object externalLink : collection) { |
280 | 0 | newExternalLinks.add((ExternalLink) externalLink); |
281 | |
} |
282 | 0 | externalLinks = newExternalLinks; |
283 | 0 | } |
284 | |
|
285 | |
public Organization getSubmittingOrganization() |
286 | |
{ |
287 | 0 | return submittingOrganization; |
288 | |
} |
289 | |
|
290 | |
public LifeCycleManager getLifeCycleManager() |
291 | |
{ |
292 | 0 | return lifeCycleManager; |
293 | |
} |
294 | |
|
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
|
300 | |
|
301 | |
|
302 | |
|
303 | |
public boolean equals(Object obj) |
304 | |
{ |
305 | 0 | if (obj == this) return true; |
306 | 0 | if (obj == null || !this.getClass().equals(obj.getClass())) return false; |
307 | 0 | final RegistryObjectImpl other = (RegistryObjectImpl) obj; |
308 | 0 | return this.key != null && key.equals(other.key); |
309 | |
} |
310 | |
|
311 | |
public int hashCode() |
312 | |
{ |
313 | 0 | return key == null ? 0 : key.hashCode(); |
314 | |
} |
315 | |
|
316 | |
|
317 | |
|
318 | |
|
319 | |
|
320 | |
public Collection getAuditTrail() throws JAXRException |
321 | |
{ |
322 | 0 | throw new UnsupportedCapabilityException("Level 1 feature"); |
323 | |
} |
324 | |
|
325 | |
public Collection getAssociatedObjects() throws JAXRException |
326 | |
{ |
327 | 0 | throw new UnsupportedCapabilityException("Level 1 feature"); |
328 | |
} |
329 | |
|
330 | |
public Concept getObjectType() throws JAXRException |
331 | |
{ |
332 | 0 | throw new UnsupportedCapabilityException("Level 1 feature"); |
333 | |
} |
334 | |
|
335 | |
public Collection getRegistryPackages() throws JAXRException |
336 | |
{ |
337 | 0 | throw new UnsupportedCapabilityException("Level 1 feature"); |
338 | |
} |
339 | |
} |