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