1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.ws.scout.util; |
18 | |
|
19 | |
import java.util.ArrayList; |
20 | |
import java.util.Collection; |
21 | |
import java.util.HashMap; |
22 | |
import java.util.Iterator; |
23 | |
import java.util.List; |
24 | |
import java.util.Locale; |
25 | |
|
26 | |
import javax.xml.registry.JAXRException; |
27 | |
import javax.xml.registry.LifeCycleManager; |
28 | |
import javax.xml.registry.infomodel.Association; |
29 | |
import javax.xml.registry.infomodel.Classification; |
30 | |
import javax.xml.registry.infomodel.ClassificationScheme; |
31 | |
import javax.xml.registry.infomodel.Concept; |
32 | |
import javax.xml.registry.infomodel.EmailAddress; |
33 | |
import javax.xml.registry.infomodel.ExternalIdentifier; |
34 | |
import javax.xml.registry.infomodel.ExternalLink; |
35 | |
import javax.xml.registry.infomodel.InternationalString; |
36 | |
import javax.xml.registry.infomodel.Organization; |
37 | |
import javax.xml.registry.infomodel.PostalAddress; |
38 | |
import javax.xml.registry.infomodel.RegistryObject; |
39 | |
import javax.xml.registry.infomodel.Service; |
40 | |
import javax.xml.registry.infomodel.ServiceBinding; |
41 | |
import javax.xml.registry.infomodel.SpecificationLink; |
42 | |
import javax.xml.registry.infomodel.TelephoneNumber; |
43 | |
import javax.xml.registry.infomodel.User; |
44 | |
|
45 | |
import org.uddi.api_v3.*; |
46 | |
import org.apache.ws.scout.registry.infomodel.AssociationImpl; |
47 | |
import org.apache.ws.scout.registry.infomodel.ClassificationImpl; |
48 | |
import org.apache.ws.scout.registry.infomodel.ClassificationSchemeImpl; |
49 | |
import org.apache.ws.scout.registry.infomodel.ConceptImpl; |
50 | |
import org.apache.ws.scout.registry.infomodel.EmailAddressImpl; |
51 | |
import org.apache.ws.scout.registry.infomodel.ExternalIdentifierImpl; |
52 | |
import org.apache.ws.scout.registry.infomodel.ExternalLinkImpl; |
53 | |
import org.apache.ws.scout.registry.infomodel.InternationalStringImpl; |
54 | |
import org.apache.ws.scout.registry.infomodel.KeyImpl; |
55 | |
import org.apache.ws.scout.registry.infomodel.OrganizationImpl; |
56 | |
import org.apache.ws.scout.registry.infomodel.PersonNameImpl; |
57 | |
import org.apache.ws.scout.registry.infomodel.PostalAddressImpl; |
58 | |
import org.apache.ws.scout.registry.infomodel.ServiceBindingImpl; |
59 | |
import org.apache.ws.scout.registry.infomodel.ServiceImpl; |
60 | |
import org.apache.ws.scout.registry.infomodel.SpecificationLinkImpl; |
61 | |
import org.apache.ws.scout.registry.infomodel.TelephoneNumberImpl; |
62 | |
import org.apache.ws.scout.registry.infomodel.UserImpl; |
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | 0 | public class ScoutUddiV3JaxrHelper |
72 | |
{ |
73 | |
public static Association getAssociation(Collection orgs, |
74 | |
LifeCycleManager lcm) |
75 | |
throws JAXRException |
76 | |
{ |
77 | 0 | Association asso = new AssociationImpl(lcm); |
78 | 0 | Object[] arr = orgs.toArray(); |
79 | 0 | asso.setSourceObject((RegistryObject)arr[0]); |
80 | 0 | asso.setTargetObject((RegistryObject)arr[1]); |
81 | 0 | return asso; |
82 | |
} |
83 | |
|
84 | |
public static Organization getOrganization(BusinessEntity businessEntity, |
85 | |
LifeCycleManager lifeCycleManager) |
86 | |
throws JAXRException |
87 | |
{ |
88 | 0 | List<Name> namesList = businessEntity.getName(); |
89 | 0 | Name n = null; |
90 | 0 | if (namesList.size()>0) n = namesList.get(0); |
91 | |
|
92 | 0 | List<Description> descriptionList = businessEntity.getDescription(); |
93 | 0 | Description desc =null; |
94 | 0 | if (descriptionList.size()>0) desc = descriptionList.get(0); |
95 | |
|
96 | 0 | Organization org = new OrganizationImpl(lifeCycleManager); |
97 | 0 | if(n != null ) { |
98 | 0 | org.setName(getIString(n.getLang(), n.getValue(), lifeCycleManager)); |
99 | |
} |
100 | 0 | if( desc != null) { |
101 | 0 | org.setDescription(getIString(desc.getLang(), desc.getValue(), lifeCycleManager)); |
102 | |
} |
103 | 0 | org.setKey(lifeCycleManager.createKey(businessEntity.getBusinessKey())); |
104 | |
|
105 | |
|
106 | 0 | BusinessServices services = businessEntity.getBusinessServices(); |
107 | 0 | if(services != null) |
108 | |
{ |
109 | 0 | List<BusinessService> bizServiceList = services.getBusinessService(); |
110 | 0 | for (BusinessService businessService : bizServiceList) { |
111 | 0 | org.addService(getService(businessService, lifeCycleManager)); |
112 | |
} |
113 | |
} |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | 0 | Contacts contacts = businessEntity.getContacts(); |
126 | 0 | if(contacts != null) |
127 | |
{ |
128 | 0 | List<Contact> contactList = contacts.getContact(); |
129 | 0 | if (contactList!=null) { |
130 | 0 | boolean isFirst=true; |
131 | 0 | for (Contact contact : contactList) { |
132 | 0 | User user = new UserImpl(null); |
133 | 0 | List<PersonName> pname = contact.getPersonName(); |
134 | 0 | if (pname != null && pname.size() > 0) { |
135 | 0 | String name = pname.get(0).getValue(); |
136 | 0 | user.setPersonName(new PersonNameImpl(name)); |
137 | |
} |
138 | 0 | if (isFirst) { |
139 | 0 | isFirst=false; |
140 | 0 | org.setPrimaryContact(user); |
141 | |
} else { |
142 | 0 | org.addUser(user); |
143 | |
} |
144 | 0 | } |
145 | |
} |
146 | |
} |
147 | |
|
148 | |
|
149 | 0 | DiscoveryURLs durls = businessEntity.getDiscoveryURLs(); |
150 | 0 | if (durls != null) |
151 | |
{ |
152 | 0 | List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL(); |
153 | 0 | for (DiscoveryURL discoveryURL : discoveryURL_List) { |
154 | 0 | ExternalLink link = new ExternalLinkImpl(lifeCycleManager); |
155 | 0 | link.setExternalURI(discoveryURL.getValue()); |
156 | 0 | org.addExternalLink(link); |
157 | 0 | } |
158 | |
} |
159 | |
|
160 | 0 | org.addExternalIdentifiers(getExternalIdentifiers(businessEntity.getIdentifierBag(), lifeCycleManager)); |
161 | 0 | org.addClassifications(getClassifications(businessEntity.getCategoryBag(), lifeCycleManager)); |
162 | |
|
163 | 0 | return org; |
164 | |
} |
165 | |
|
166 | |
|
167 | |
public static Organization getOrganization(BusinessDetail bizdetail, |
168 | |
LifeCycleManager lifeCycleManager) |
169 | |
throws JAXRException |
170 | |
{ |
171 | 0 | List<BusinessEntity> bizEntityList = bizdetail.getBusinessEntity(); |
172 | 0 | if (bizEntityList.size() != 1) { |
173 | 0 | throw new JAXRException("Unexpected count of organizations in BusinessDetail: " + bizEntityList.size()); |
174 | |
} |
175 | 0 | BusinessEntity entity = bizEntityList.get(0); |
176 | 0 | Name n = null; |
177 | 0 | if (entity.getName().size()>0) n = entity.getName().get(0); |
178 | |
|
179 | 0 | List<Description> descriptionList = entity.getDescription(); |
180 | 0 | Description desc =null; |
181 | 0 | if (descriptionList.size()>0) desc = descriptionList.get(0); |
182 | |
|
183 | 0 | Organization org = new OrganizationImpl(lifeCycleManager); |
184 | 0 | if( n != null ) { |
185 | 0 | org.setName(getIString(n.getLang(), n.getValue(), lifeCycleManager)); |
186 | |
} |
187 | 0 | if( desc != null ) { |
188 | 0 | org.setDescription(getIString(desc.getLang(), desc.getValue(), lifeCycleManager)); |
189 | |
} |
190 | 0 | org.setKey(lifeCycleManager.createKey(entity.getBusinessKey())); |
191 | |
|
192 | |
|
193 | 0 | BusinessServices services = entity.getBusinessServices(); |
194 | 0 | if (services != null) { |
195 | 0 | List<BusinessService> bizServiceList = services.getBusinessService(); |
196 | 0 | for (BusinessService businessService : bizServiceList) { |
197 | 0 | org.addService(getService(businessService, lifeCycleManager)); |
198 | |
} |
199 | |
} |
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
|
210 | 0 | Contacts contacts = entity.getContacts(); |
211 | 0 | if (contacts != null) { |
212 | 0 | List<Contact> contactList = contacts.getContact(); |
213 | 0 | boolean isFirst=true; |
214 | 0 | for (Contact contact : contactList) { |
215 | 0 | User user = new UserImpl(null); |
216 | 0 | List<PersonName> pnames = (List<PersonName>) contact.getPersonName(); |
217 | 0 | String pname = null; |
218 | 0 | if (pnames != null && pnames.size() > 0) { |
219 | 0 | PersonName personname = pnames.get(0); |
220 | 0 | pname = personname.getValue(); |
221 | |
} |
222 | 0 | user.setType(contact.getUseType()); |
223 | 0 | user.setPersonName(new PersonNameImpl(pname)); |
224 | |
|
225 | 0 | List<Email> emailList = contact.getEmail(); |
226 | 0 | ArrayList<EmailAddress> tempEmails = new ArrayList<EmailAddress>(); |
227 | 0 | for (Email email : emailList) { |
228 | 0 | tempEmails.add(new EmailAddressImpl(email.getValue(), null)); |
229 | |
} |
230 | 0 | user.setEmailAddresses(tempEmails); |
231 | |
|
232 | 0 | List<Address> addressList = contact.getAddress(); |
233 | 0 | ArrayList<PostalAddress> tempAddresses = new ArrayList<PostalAddress>(); |
234 | 0 | for (Address address : addressList) { |
235 | 0 | ArrayList<AddressLine> addressLineList = new ArrayList<AddressLine>(address.getAddressLine()); |
236 | 0 | AddressLine[] alines = new AddressLine[addressLineList.size()]; |
237 | 0 | addressLineList.toArray(alines); |
238 | |
|
239 | 0 | PostalAddress pa = getPostalAddress(alines); |
240 | 0 | tempAddresses.add(pa); |
241 | 0 | } |
242 | 0 | user.setPostalAddresses(tempAddresses); |
243 | |
|
244 | 0 | List<Phone> phoneList = contact.getPhone(); |
245 | 0 | ArrayList<TelephoneNumber> tempPhones = new ArrayList<TelephoneNumber>(); |
246 | 0 | for (Phone phone : phoneList) { |
247 | 0 | TelephoneNumberImpl tni = new TelephoneNumberImpl(); |
248 | 0 | tni.setType(phone.getUseType()); |
249 | 0 | tni.setNumber(phone.getValue()); |
250 | 0 | tempPhones.add(tni); |
251 | 0 | } |
252 | 0 | user.setTelephoneNumbers(tempPhones); |
253 | 0 | if (isFirst) { |
254 | 0 | isFirst=false; |
255 | 0 | org.setPrimaryContact(user); |
256 | |
} else { |
257 | 0 | org.addUser(user); |
258 | |
} |
259 | 0 | } |
260 | |
} |
261 | |
|
262 | 0 | DiscoveryURLs durls = entity.getDiscoveryURLs(); |
263 | 0 | if (durls != null) |
264 | |
{ |
265 | 0 | List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL(); |
266 | 0 | for (DiscoveryURL discoveryURL : discoveryURL_List) { |
267 | 0 | ExternalLink link = new ExternalLinkImpl(lifeCycleManager); |
268 | 0 | link.setExternalURI(discoveryURL.getValue()); |
269 | 0 | org.addExternalLink(link); |
270 | 0 | } |
271 | |
} |
272 | |
|
273 | 0 | org.addExternalIdentifiers(getExternalIdentifiers(entity.getIdentifierBag(), lifeCycleManager)); |
274 | 0 | org.addClassifications(getClassifications(entity.getCategoryBag(), lifeCycleManager)); |
275 | |
|
276 | 0 | return org; |
277 | |
} |
278 | |
|
279 | |
private static PostalAddress getPostalAddress(AddressLine[] addressLineArr) throws JAXRException { |
280 | 0 | PostalAddress pa = new PostalAddressImpl(); |
281 | 0 | HashMap<String, String> hm = new HashMap<String, String>(); |
282 | 0 | for (AddressLine anAddressLineArr : addressLineArr) { |
283 | 0 | hm.put(anAddressLineArr.getKeyName(), anAddressLineArr.getKeyValue()); |
284 | |
} |
285 | |
|
286 | 0 | if (hm.containsKey("STREET_NUMBER")) { |
287 | 0 | pa.setStreetNumber(hm.get("STREET_NUMBER")); |
288 | |
} |
289 | |
|
290 | 0 | if (hm.containsKey("STREET")) { |
291 | 0 | pa.setStreet(hm.get("STREET")); |
292 | |
} |
293 | |
|
294 | 0 | if (hm.containsKey("CITY")) { |
295 | 0 | pa.setCity(hm.get("CITY")); |
296 | |
} |
297 | |
|
298 | 0 | if (hm.containsKey("COUNTRY")) { |
299 | 0 | pa.setCountry(hm.get("COUNTRY")); |
300 | |
} |
301 | |
|
302 | 0 | if (hm.containsKey("POSTALCODE")) { |
303 | 0 | pa.setPostalCode(hm.get("POSTALCODE")); |
304 | |
} |
305 | |
|
306 | 0 | if (hm.containsKey("STATE")) { |
307 | 0 | pa.setStateOrProvince(hm.get("STATE")); |
308 | |
} |
309 | |
|
310 | 0 | return pa; |
311 | |
} |
312 | |
|
313 | |
private static InternationalString getIString(String lang, String str, LifeCycleManager lifeCycleManager) |
314 | |
throws JAXRException |
315 | |
{ |
316 | 0 | if (str!=null) { |
317 | 0 | return lifeCycleManager.createInternationalString(getLocale(lang), str); |
318 | |
} else { |
319 | 0 | return null; |
320 | |
} |
321 | |
} |
322 | |
|
323 | |
public static InternationalString getIString(String str, LifeCycleManager lifeCycleManager) |
324 | |
throws JAXRException |
325 | |
{ |
326 | 0 | return lifeCycleManager.createInternationalString(str); |
327 | |
} |
328 | |
|
329 | |
public static Service getService(BusinessService businessService, LifeCycleManager lifeCycleManager) |
330 | |
throws JAXRException |
331 | |
{ |
332 | 0 | Service serve = new ServiceImpl(lifeCycleManager); |
333 | |
|
334 | 0 | String keystr = businessService.getServiceKey(); |
335 | |
|
336 | 0 | if (keystr != null) |
337 | |
{ |
338 | 0 | serve.setKey(lifeCycleManager.createKey(keystr)); |
339 | |
} |
340 | |
|
341 | 0 | Name n = null; |
342 | 0 | if (businessService.getName().size()>0) n = businessService.getName().get(0); |
343 | |
|
344 | 0 | if (n != null) { |
345 | 0 | String name = n.getValue(); |
346 | 0 | serve.setName(lifeCycleManager.createInternationalString(getLocale(n.getLang()), name)); |
347 | |
} |
348 | |
|
349 | 0 | Description desc =null; |
350 | 0 | if (businessService.getDescription().size()>0) desc = businessService.getDescription().get(0); |
351 | 0 | if (desc != null ) { |
352 | 0 | serve.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue())); |
353 | |
} |
354 | |
|
355 | |
|
356 | 0 | BindingTemplates bts = businessService.getBindingTemplates(); |
357 | 0 | if (bts != null) { |
358 | 0 | List<BindingTemplate> bindingTemplateList = bts.getBindingTemplate(); |
359 | 0 | for (BindingTemplate bindingTemplate : bindingTemplateList) { |
360 | 0 | serve.addServiceBinding(getServiceBinding(bindingTemplate, lifeCycleManager)); |
361 | |
} |
362 | |
} |
363 | 0 | serve.addClassifications(getClassifications(businessService.getCategoryBag(), lifeCycleManager)); |
364 | |
|
365 | 0 | return serve; |
366 | |
} |
367 | |
|
368 | |
public static Service getService(ServiceInfo serviceInfo, LifeCycleManager lifeCycleManager) |
369 | |
throws JAXRException |
370 | |
{ |
371 | 0 | Service service = new ServiceImpl(lifeCycleManager); |
372 | |
|
373 | 0 | String keystr = serviceInfo.getServiceKey(); |
374 | |
|
375 | 0 | if (keystr != null) |
376 | |
{ |
377 | 0 | service.setKey(lifeCycleManager.createKey(keystr)); |
378 | |
} |
379 | |
|
380 | 0 | Name n = null; |
381 | 0 | if (serviceInfo.getName().size()>0) n = serviceInfo.getName().get(0); |
382 | 0 | if (n != null) { |
383 | 0 | String name = n.getValue(); |
384 | 0 | service.setName(lifeCycleManager.createInternationalString(getLocale(n.getLang()), name)); |
385 | |
} |
386 | 0 | return service; |
387 | |
} |
388 | |
|
389 | |
public static ServiceBinding getServiceBinding(BindingTemplate businessTemplate, LifeCycleManager lifeCycleManager) |
390 | |
throws JAXRException |
391 | |
{ |
392 | 0 | ServiceBinding serviceBinding = new ServiceBindingImpl(lifeCycleManager); |
393 | |
|
394 | 0 | String keystr = businessTemplate.getServiceKey(); |
395 | 0 | if (keystr != null) |
396 | |
{ |
397 | 0 | Service svc = new ServiceImpl(lifeCycleManager); |
398 | 0 | svc.setKey(lifeCycleManager.createKey(keystr)); |
399 | 0 | ((ServiceBindingImpl)serviceBinding).setService(svc); |
400 | |
} |
401 | 0 | String bindingKey = businessTemplate.getBindingKey(); |
402 | 0 | if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey)); |
403 | |
|
404 | |
|
405 | 0 | AccessPoint access = businessTemplate.getAccessPoint(); |
406 | 0 | if (access != null) serviceBinding.setAccessURI(access.getValue()); |
407 | |
|
408 | |
|
409 | 0 | Description desc = null; |
410 | 0 | if (businessTemplate.getDescription().size()>0) desc = businessTemplate.getDescription().get(0); |
411 | 0 | if (desc!=null) { |
412 | 0 | serviceBinding.setDescription(new InternationalStringImpl(desc.getValue())); |
413 | |
} |
414 | |
|
415 | |
|
416 | 0 | TModelInstanceDetails details = businessTemplate.getTModelInstanceDetails(); |
417 | 0 | if (details != null) { |
418 | 0 | List<TModelInstanceInfo> tmodelInstanceInfoList = details.getTModelInstanceInfo(); |
419 | |
|
420 | 0 | for (TModelInstanceInfo info: tmodelInstanceInfoList) |
421 | |
{ |
422 | 0 | if (info!=null && info.getInstanceDetails()!=null) { |
423 | 0 | InstanceDetails idetails = info.getInstanceDetails(); |
424 | 0 | Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lifeCycleManager); |
425 | 0 | SpecificationLink slink = new SpecificationLinkImpl(lifeCycleManager); |
426 | 0 | slink.addExternalLinks(elinks); |
427 | 0 | serviceBinding.addSpecificationLink(slink); |
428 | |
|
429 | 0 | ConceptImpl c = new ConceptImpl(lifeCycleManager); |
430 | 0 | c.setExternalLinks(elinks); |
431 | 0 | c.setKey(lifeCycleManager.createKey(info.getTModelKey())); |
432 | 0 | c.setName(lifeCycleManager.createInternationalString(idetails.getInstanceParms())); |
433 | 0 | c.setValue(idetails.getInstanceParms()); |
434 | |
|
435 | 0 | slink.setSpecificationObject(c); |
436 | 0 | } |
437 | |
} |
438 | |
} |
439 | 0 | HostingRedirector hr = businessTemplate.getHostingRedirector(); |
440 | 0 | if(hr != null) |
441 | |
{ |
442 | 0 | ServiceBinding sb = lifeCycleManager.createServiceBinding(); |
443 | 0 | sb.setKey(new KeyImpl(hr.getBindingKey())); |
444 | 0 | serviceBinding.setTargetBinding(sb); |
445 | |
} |
446 | |
|
447 | 0 | return serviceBinding; |
448 | |
} |
449 | |
|
450 | |
public static Concept getConcept(TModelDetail tModelDetail, LifeCycleManager lifeCycleManager) |
451 | |
throws JAXRException |
452 | |
{ |
453 | 0 | Concept concept = new ConceptImpl(lifeCycleManager); |
454 | 0 | List<TModel> tmodelList = tModelDetail.getTModel(); |
455 | 0 | for (TModel tmodel : tmodelList) { |
456 | 0 | concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey())); |
457 | 0 | concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()), |
458 | |
tmodel.getName().getValue())); |
459 | |
|
460 | 0 | Description desc = getDescription(tmodel); |
461 | 0 | if( desc != null ) { |
462 | 0 | concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), |
463 | |
desc.getValue())); |
464 | |
} |
465 | |
|
466 | 0 | concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager)); |
467 | 0 | concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager)); |
468 | 0 | } |
469 | 0 | return concept; |
470 | |
} |
471 | |
|
472 | |
public static Concept getConcept(TModel tmodel, LifeCycleManager lifeCycleManager) |
473 | |
throws JAXRException |
474 | |
{ |
475 | 0 | Concept concept = new ConceptImpl(lifeCycleManager); |
476 | 0 | concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey())); |
477 | 0 | concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()), |
478 | |
tmodel.getName().getValue())); |
479 | |
|
480 | 0 | Description desc = getDescription(tmodel); |
481 | 0 | if (desc != null) { |
482 | 0 | concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), |
483 | |
desc.getValue())); |
484 | |
} |
485 | |
|
486 | 0 | concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager)); |
487 | 0 | concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager)); |
488 | |
|
489 | 0 | return concept; |
490 | |
} |
491 | |
|
492 | |
public static Concept getConcept(TModelInfo tModelInfo, LifeCycleManager lifeCycleManager) |
493 | |
throws JAXRException |
494 | |
{ |
495 | 0 | Concept concept = new ConceptImpl(lifeCycleManager); |
496 | 0 | concept.setKey(lifeCycleManager.createKey(tModelInfo.getTModelKey())); |
497 | 0 | concept.setName(lifeCycleManager.createInternationalString(getLocale(tModelInfo.getName().getLang()), |
498 | |
tModelInfo.getName().getValue())); |
499 | |
|
500 | 0 | return concept; |
501 | |
} |
502 | |
|
503 | |
private static Description getDescription( TModel tmodel ) |
504 | |
{ |
505 | 0 | Description desc = null; |
506 | 0 | if (tmodel.getDescription().size()>0) desc=tmodel.getDescription().get(0); |
507 | 0 | return desc; |
508 | |
} |
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
public static Collection getClassifications(CategoryBag categoryBag, LifeCycleManager lifeCycleManager) |
518 | |
throws JAXRException { |
519 | 0 | Collection<Classification> classifications = null; |
520 | 0 | if (categoryBag != null) { |
521 | 0 | classifications = new ArrayList<Classification>(); |
522 | 0 | List<KeyedReference> keyedReferenceList = categoryBag.getKeyedReference(); |
523 | 0 | for (KeyedReference keyedReference : keyedReferenceList) { |
524 | 0 | Classification classification = new ClassificationImpl(lifeCycleManager); |
525 | 0 | classification.setValue(keyedReference.getKeyValue()); |
526 | 0 | classification.setName(new InternationalStringImpl(keyedReference.getKeyName())); |
527 | 0 | String tmodelKey = keyedReference.getTModelKey(); |
528 | 0 | if (tmodelKey != null) { |
529 | 0 | ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager); |
530 | 0 | scheme.setKey(new KeyImpl(tmodelKey)); |
531 | 0 | classification.setClassificationScheme(scheme); |
532 | |
} |
533 | 0 | classifications.add(classification); |
534 | 0 | } |
535 | |
} |
536 | 0 | return classifications; |
537 | |
} |
538 | |
|
539 | |
public static Collection<ExternalLink> getExternalLinks(List<OverviewDoc> overviewDocs, LifeCycleManager lifeCycleManager) |
540 | |
throws JAXRException |
541 | |
{ |
542 | 0 | ArrayList<ExternalLink> alist = new ArrayList<ExternalLink>(); |
543 | 0 | if((overviewDocs != null) && (overviewDocs.size() != 0)) |
544 | |
{ |
545 | 0 | Iterator docIter = overviewDocs.iterator(); |
546 | 0 | while (docIter.hasNext()) { |
547 | 0 | OverviewDoc overviewDoc = (OverviewDoc) docIter.next(); |
548 | 0 | String descStr = ""; |
549 | 0 | Description desc = null; |
550 | 0 | if (overviewDoc.getDescription().size()>0) desc = overviewDoc.getDescription().get(0); |
551 | 0 | if (desc !=null) descStr = desc.getValue(); |
552 | 0 | alist.add(lifeCycleManager.createExternalLink(overviewDoc.getOverviewURL().toString(),descStr)); |
553 | |
|
554 | 0 | } |
555 | |
} |
556 | 0 | return alist; |
557 | |
} |
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
public static Collection getExternalIdentifiers(IdentifierBag identifierBag, LifeCycleManager lifeCycleManager) |
568 | |
throws JAXRException { |
569 | 0 | Collection<ExternalIdentifier> extidentifiers = null; |
570 | 0 | if (identifierBag != null) { |
571 | 0 | extidentifiers = new ArrayList<ExternalIdentifier>(); |
572 | |
|
573 | 0 | List<KeyedReference> keyedReferenceList = identifierBag.getKeyedReference(); |
574 | 0 | for (KeyedReference keyedReference : keyedReferenceList) { |
575 | 0 | ExternalIdentifier extId = new ExternalIdentifierImpl(lifeCycleManager); |
576 | 0 | extId.setValue(keyedReference.getKeyValue()); |
577 | 0 | extId.setName(new InternationalStringImpl(keyedReference.getKeyName())); |
578 | |
|
579 | 0 | String tmodelKey = keyedReference.getTModelKey(); |
580 | 0 | if (tmodelKey != null) { |
581 | 0 | ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager); |
582 | 0 | scheme.setKey(new KeyImpl(tmodelKey)); |
583 | 0 | extId.setIdentificationScheme(scheme); |
584 | |
} |
585 | 0 | extidentifiers.add(extId); |
586 | 0 | } |
587 | |
} |
588 | 0 | return extidentifiers; |
589 | |
} |
590 | |
|
591 | |
private static Locale getLocale(String lang) { |
592 | 0 | if (lang == null || lang.trim().length() == 0) { |
593 | 0 | return Locale.getDefault(); |
594 | 0 | } else if (lang.equalsIgnoreCase(Locale.getDefault().getLanguage())) { |
595 | 0 | return Locale.getDefault(); |
596 | |
} else { |
597 | 0 | return new Locale(lang); |
598 | |
} |
599 | |
} |
600 | |
|
601 | |
} |