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