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