| 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 | 2 | Association asso = new AssociationImpl(lcm); |
| 104 | 2 | Object[] arr = orgs.toArray(); |
| 105 | 2 | asso.setSourceObject((RegistryObject)arr[0]); |
| 106 | 2 | asso.setTargetObject((RegistryObject)arr[1]); |
| 107 | 2 | 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 | 0 | } |
| 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 | 0 | } |
| 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 | 0 | } |
| 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 | 75 | List<BusinessEntity> bizEntityList = bizdetail.getBusinessEntity(); |
| 206 | 75 | if (bizEntityList.size() != 1) { |
| 207 | 0 | throw new JAXRException("Unexpected count of organizations in BusinessDetail: " + bizEntityList.size()); |
| 208 | |
} |
| 209 | 75 | BusinessEntity entity = bizEntityList.get(0); |
| 210 | 75 | List<Name> namesList = entity.getName(); |
| 211 | 75 | List<Description> descriptionList = entity.getDescription(); |
| 212 | |
|
| 213 | 75 | Organization org = new OrganizationImpl(lifeCycleManager); |
| 214 | 75 | if ((namesList != null) && (namesList.size() > 0)) { |
| 215 | 75 | InternationalString is = null; |
| 216 | 75 | for (Name n : namesList) { |
| 217 | 77 | if (is == null) { |
| 218 | 75 | is = getIString(n.getLang(), n.getValue(), lifeCycleManager); |
| 219 | |
} else { |
| 220 | 2 | is.setValue(getLocale(n.getLang()), n.getValue()); |
| 221 | |
} |
| 222 | 77 | } |
| 223 | 75 | org.setName(is); |
| 224 | |
} |
| 225 | 75 | if ((descriptionList != null) && (descriptionList.size() > 0)) { |
| 226 | 58 | InternationalString is = null; |
| 227 | 58 | for (Description desc : descriptionList) { |
| 228 | 60 | if (is == null) { |
| 229 | 58 | is = getIString(desc.getLang(), desc.getValue(), lifeCycleManager); |
| 230 | |
} else { |
| 231 | 2 | is.setValue(getLocale(desc.getLang()), desc.getValue()); |
| 232 | |
} |
| 233 | 60 | } |
| 234 | 58 | org.setDescription(is); |
| 235 | |
} |
| 236 | |
|
| 237 | 75 | org.setKey(lifeCycleManager.createKey(entity.getBusinessKey())); |
| 238 | |
|
| 239 | |
|
| 240 | 75 | BusinessServices services = entity.getBusinessServices(); |
| 241 | 75 | List<BusinessService> bizServiceList = services.getBusinessService(); |
| 242 | 75 | for (BusinessService businessService : bizServiceList) { |
| 243 | 26 | org.addService(getService(businessService, lifeCycleManager)); |
| 244 | 26 | } |
| 245 | |
|
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | 75 | Contacts contacts = entity.getContacts(); |
| 256 | 75 | List<Contact> contactList = contacts.getContact(); |
| 257 | 75 | boolean isFirst=true; |
| 258 | 75 | for (Contact contact : contactList) { |
| 259 | 91 | User user = new UserImpl(null); |
| 260 | 91 | String pname = contact.getPersonName(); |
| 261 | 91 | user.setType(contact.getUseType()); |
| 262 | 91 | user.setPersonName(new PersonNameImpl(pname)); |
| 263 | |
|
| 264 | 91 | List<Email> emailList = contact.getEmail(); |
| 265 | 91 | ArrayList<EmailAddress> tempEmails = new ArrayList<EmailAddress>(); |
| 266 | 91 | for (Email email : emailList) { |
| 267 | 68 | tempEmails.add(new EmailAddressImpl(email.getValue(), null)); |
| 268 | 68 | } |
| 269 | 91 | user.setEmailAddresses(tempEmails); |
| 270 | |
|
| 271 | 91 | List<Address> addressList = contact.getAddress(); |
| 272 | 91 | ArrayList<PostalAddress> tempAddresses = new ArrayList<PostalAddress>(); |
| 273 | 91 | for (Address address : addressList) { |
| 274 | 68 | ArrayList<AddressLine> addressLineList = new ArrayList<AddressLine>(address.getAddressLine()); |
| 275 | 68 | AddressLine[] alines = new AddressLine[addressLineList.size()]; |
| 276 | 68 | addressLineList.toArray(alines); |
| 277 | |
|
| 278 | 68 | PostalAddress pa = getPostalAddress(alines); |
| 279 | 68 | tempAddresses.add(pa); |
| 280 | 68 | } |
| 281 | 91 | user.setPostalAddresses(tempAddresses); |
| 282 | |
|
| 283 | 91 | List<Phone> phoneList = contact.getPhone(); |
| 284 | 91 | ArrayList<TelephoneNumber> tempPhones = new ArrayList<TelephoneNumber>(); |
| 285 | 91 | for (Phone phone : phoneList) { |
| 286 | 68 | TelephoneNumberImpl tni = new TelephoneNumberImpl(); |
| 287 | 68 | tni.setType(phone.getUseType()); |
| 288 | 68 | tni.setNumber(phone.getValue()); |
| 289 | 68 | tempPhones.add(tni); |
| 290 | 68 | } |
| 291 | 91 | user.setTelephoneNumbers(tempPhones); |
| 292 | 91 | if (isFirst) { |
| 293 | 75 | isFirst=false; |
| 294 | 75 | org.setPrimaryContact(user); |
| 295 | |
} else { |
| 296 | 16 | org.addUser(user); |
| 297 | |
} |
| 298 | 91 | } |
| 299 | |
|
| 300 | |
|
| 301 | 75 | DiscoveryURLs durls = entity.getDiscoveryURLs(); |
| 302 | 75 | if (durls != null) |
| 303 | |
{ |
| 304 | 75 | List<DiscoveryURL> discoveryURL_List = durls.getDiscoveryURL(); |
| 305 | 75 | for (DiscoveryURL discoveryURL : discoveryURL_List) { |
| 306 | 75 | ExternalLink link = new ExternalLinkImpl(lifeCycleManager); |
| 307 | 75 | link.setExternalURI(discoveryURL.getValue()); |
| 308 | 75 | org.addExternalLink(link); |
| 309 | 75 | } |
| 310 | |
} |
| 311 | |
|
| 312 | 75 | org.addExternalIdentifiers(getExternalIdentifiers(entity.getIdentifierBag(), lifeCycleManager)); |
| 313 | 75 | org.addClassifications(getClassifications(entity.getCategoryBag(), lifeCycleManager)); |
| 314 | |
|
| 315 | 75 | return org; |
| 316 | |
} |
| 317 | |
|
| 318 | |
private static PostalAddress getPostalAddress(AddressLine[] addressLineArr) throws JAXRException { |
| 319 | 68 | PostalAddress pa = new PostalAddressImpl(); |
| 320 | 68 | HashMap<String, String> hm = new HashMap<String, String>(); |
| 321 | 476 | for (AddressLine anAddressLineArr : addressLineArr) { |
| 322 | 408 | hm.put(anAddressLineArr.getKeyValue(), anAddressLineArr.getValue()); |
| 323 | |
} |
| 324 | |
|
| 325 | 68 | if (hm.containsKey("STREET_NUMBER")) { |
| 326 | 68 | pa.setStreetNumber(hm.get("STREET_NUMBER")); |
| 327 | |
} |
| 328 | |
|
| 329 | 68 | if (hm.containsKey("STREET")) { |
| 330 | 68 | pa.setStreet(hm.get("STREET")); |
| 331 | |
} |
| 332 | |
|
| 333 | 68 | if (hm.containsKey("CITY")) { |
| 334 | 68 | pa.setCity(hm.get("CITY")); |
| 335 | |
} |
| 336 | |
|
| 337 | 68 | if (hm.containsKey("COUNTRY")) { |
| 338 | 68 | pa.setCountry(hm.get("COUNTRY")); |
| 339 | |
} |
| 340 | |
|
| 341 | 68 | if (hm.containsKey("POSTALCODE")) { |
| 342 | 68 | pa.setPostalCode(hm.get("POSTALCODE")); |
| 343 | |
} |
| 344 | |
|
| 345 | 68 | if (hm.containsKey("STATE")) { |
| 346 | 68 | pa.setStateOrProvince(hm.get("STATE")); |
| 347 | |
} |
| 348 | |
|
| 349 | 68 | return pa; |
| 350 | |
} |
| 351 | |
|
| 352 | |
private static InternationalString getIString(String lang, String str, LifeCycleManager lifeCycleManager) |
| 353 | |
throws JAXRException |
| 354 | |
{ |
| 355 | 133 | if (str!=null) { |
| 356 | 133 | 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 | 46 | Service serve = new ServiceImpl(lifeCycleManager); |
| 372 | |
|
| 373 | 46 | String keystr = businessService.getServiceKey(); |
| 374 | |
|
| 375 | 46 | if (keystr != null) |
| 376 | |
{ |
| 377 | 46 | serve.setKey(lifeCycleManager.createKey(keystr)); |
| 378 | |
} |
| 379 | |
|
| 380 | 46 | List<Name> namesList = businessService.getName(); |
| 381 | 46 | List<Description> descriptionList = businessService.getDescription(); |
| 382 | |
|
| 383 | 46 | InternationalString is = null; |
| 384 | 46 | for (Name n : namesList) { |
| 385 | 48 | if (is == null) { |
| 386 | 46 | is = lifeCycleManager.createInternationalString(getLocale(n.getLang()), n.getValue()); |
| 387 | |
} else { |
| 388 | 2 | is.setValue(getLocale(n.getLang()), n.getValue()); |
| 389 | |
} |
| 390 | 48 | } |
| 391 | 46 | serve.setName(is); |
| 392 | |
|
| 393 | 46 | InternationalString dis = null; |
| 394 | 46 | for (Description desc : descriptionList) { |
| 395 | 48 | if (dis == null) { |
| 396 | 46 | dis = lifeCycleManager.createInternationalString(getLocale(desc.getLang()), desc.getValue()); |
| 397 | |
} else { |
| 398 | 2 | dis.setValue(getLocale(desc.getLang()), desc.getValue()); |
| 399 | |
} |
| 400 | 48 | } |
| 401 | 46 | for (int i = 0; i < namesList.size(); i++) { |
| 402 | |
|
| 403 | |
} |
| 404 | 46 | serve.setDescription(dis); |
| 405 | |
|
| 406 | |
|
| 407 | 46 | BindingTemplates bts = businessService.getBindingTemplates(); |
| 408 | 46 | List<BindingTemplate> bindingTemplateList = bts.getBindingTemplate(); |
| 409 | 46 | for (BindingTemplate bindingTemplate : bindingTemplateList) { |
| 410 | 42 | serve.addServiceBinding(getServiceBinding(bindingTemplate, lifeCycleManager)); |
| 411 | 42 | } |
| 412 | 46 | serve.addClassifications(getClassifications(businessService.getCategoryBag(), lifeCycleManager)); |
| 413 | |
|
| 414 | 46 | 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 | 0 | } |
| 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 | 48 | ServiceBinding serviceBinding = new ServiceBindingImpl(lifeCycleManager); |
| 447 | |
|
| 448 | 48 | String keystr = businessTemplate.getServiceKey(); |
| 449 | 48 | if (keystr != null) |
| 450 | |
{ |
| 451 | 48 | Service svc = new ServiceImpl(lifeCycleManager); |
| 452 | 48 | svc.setKey(lifeCycleManager.createKey(keystr)); |
| 453 | 48 | ((ServiceBindingImpl)serviceBinding).setService(svc); |
| 454 | |
} |
| 455 | 48 | String bindingKey = businessTemplate.getBindingKey(); |
| 456 | 48 | if(bindingKey != null) serviceBinding.setKey(new KeyImpl(bindingKey)); |
| 457 | |
|
| 458 | |
|
| 459 | 48 | AccessPoint access = businessTemplate.getAccessPoint(); |
| 460 | 48 | if (access != null) serviceBinding.setAccessURI(access.getValue()); |
| 461 | |
|
| 462 | |
|
| 463 | 48 | Description desc = null; |
| 464 | 48 | if (businessTemplate.getDescription().size()>0) desc = businessTemplate.getDescription().get(0); |
| 465 | 48 | if (desc!=null) { |
| 466 | 48 | serviceBinding.setDescription(new InternationalStringImpl(desc.getValue())); |
| 467 | |
} |
| 468 | |
|
| 469 | |
|
| 470 | 48 | TModelInstanceDetails details = businessTemplate.getTModelInstanceDetails(); |
| 471 | 48 | List<TModelInstanceInfo> tmodelInstanceInfoList = details.getTModelInstanceInfo(); |
| 472 | |
|
| 473 | 48 | for (TModelInstanceInfo info: tmodelInstanceInfoList) |
| 474 | |
{ |
| 475 | 4 | if (info!=null && info.getInstanceDetails()!=null) { |
| 476 | 4 | InstanceDetails idetails = info.getInstanceDetails(); |
| 477 | 4 | Collection<ExternalLink> elinks = getExternalLinks(idetails.getOverviewDoc(),lifeCycleManager); |
| 478 | 4 | SpecificationLink slink = new SpecificationLinkImpl(lifeCycleManager); |
| 479 | 4 | slink.addExternalLinks(elinks); |
| 480 | 4 | serviceBinding.addSpecificationLink(slink); |
| 481 | |
|
| 482 | 4 | ConceptImpl c = new ConceptImpl(lifeCycleManager); |
| 483 | 4 | c.setExternalLinks(elinks); |
| 484 | 4 | c.setKey(lifeCycleManager.createKey(info.getTModelKey())); |
| 485 | 4 | c.setName(lifeCycleManager.createInternationalString(idetails.getInstanceParms())); |
| 486 | 4 | c.setValue(idetails.getInstanceParms()); |
| 487 | |
|
| 488 | 4 | slink.setSpecificationObject(c); |
| 489 | |
} |
| 490 | 4 | } |
| 491 | |
|
| 492 | 48 | HostingRedirector hr = businessTemplate.getHostingRedirector(); |
| 493 | 48 | 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 | 48 | return serviceBinding; |
| 501 | |
} |
| 502 | |
|
| 503 | |
public static Concept getConcept(TModelDetail tModelDetail, LifeCycleManager lifeCycleManager) |
| 504 | |
throws JAXRException |
| 505 | |
{ |
| 506 | 4 | Concept concept = new ConceptImpl(lifeCycleManager); |
| 507 | 4 | List<TModel> tmodelList = tModelDetail.getTModel(); |
| 508 | 4 | for (TModel tmodel : tmodelList) { |
| 509 | 4 | concept.setKey(lifeCycleManager.createKey(tmodel.getTModelKey())); |
| 510 | 8 | concept.setName(lifeCycleManager.createInternationalString(getLocale(tmodel.getName().getLang()), |
| 511 | 4 | tmodel.getName().getValue())); |
| 512 | |
|
| 513 | 4 | Description desc = getDescription(tmodel); |
| 514 | 4 | if( desc != null ) { |
| 515 | 8 | concept.setDescription(lifeCycleManager.createInternationalString(getLocale(desc.getLang()), |
| 516 | 4 | desc.getValue())); |
| 517 | |
} |
| 518 | |
|
| 519 | 4 | concept.addExternalIdentifiers(getExternalIdentifiers(tmodel.getIdentifierBag(), lifeCycleManager)); |
| 520 | 4 | concept.addClassifications(getClassifications(tmodel.getCategoryBag(), lifeCycleManager)); |
| 521 | 4 | } |
| 522 | 4 | 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 | 0 | 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 | 0 | 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 | 0 | tModelInfo.getName().getValue())); |
| 552 | |
|
| 553 | 0 | return concept; |
| 554 | |
} |
| 555 | |
|
| 556 | |
private static Description getDescription( TModel tmodel ) |
| 557 | |
{ |
| 558 | 4 | Description desc = null; |
| 559 | 4 | if (tmodel.getDescription().size()>0) desc=tmodel.getDescription().get(0); |
| 560 | 4 | return desc; |
| 561 | |
} |
| 562 | |
|
| 563 | |
|
| 564 | |
|
| 565 | |
|
| 566 | |
|
| 567 | |
|
| 568 | |
|
| 569 | |
|
| 570 | |
public static Collection getClassifications(CategoryBag categoryBag, LifeCycleManager lifeCycleManager) |
| 571 | |
throws JAXRException { |
| 572 | 125 | Collection<Classification> classifications = null; |
| 573 | 125 | if (categoryBag != null) { |
| 574 | 30 | classifications = new ArrayList<Classification>(); |
| 575 | 30 | List<KeyedReference> keyedReferenceList = categoryBag.getKeyedReference(); |
| 576 | 30 | for (KeyedReference keyedReference : keyedReferenceList) { |
| 577 | 30 | Classification classification = new ClassificationImpl(lifeCycleManager); |
| 578 | 30 | classification.setValue(keyedReference.getKeyValue()); |
| 579 | 30 | classification.setName(new InternationalStringImpl(keyedReference.getKeyName())); |
| 580 | 30 | String tmodelKey = keyedReference.getTModelKey(); |
| 581 | 30 | if (tmodelKey != null) { |
| 582 | 30 | ClassificationScheme scheme = new ClassificationSchemeImpl(lifeCycleManager); |
| 583 | 30 | scheme.setKey(new KeyImpl(tmodelKey)); |
| 584 | 30 | classification.setClassificationScheme(scheme); |
| 585 | |
} |
| 586 | 30 | classifications.add(classification); |
| 587 | 30 | } |
| 588 | |
} |
| 589 | 125 | return classifications; |
| 590 | |
} |
| 591 | |
|
| 592 | |
public static Collection<ExternalLink> getExternalLinks(OverviewDoc overviewDoc , LifeCycleManager lifeCycleManager) |
| 593 | |
throws JAXRException |
| 594 | |
{ |
| 595 | 4 | ArrayList<ExternalLink> alist = new ArrayList<ExternalLink>(1); |
| 596 | 4 | if(overviewDoc != null) |
| 597 | |
{ |
| 598 | 4 | String descStr = ""; |
| 599 | 4 | Description desc = null; |
| 600 | 4 | if (overviewDoc.getDescription().size()>0) desc = overviewDoc.getDescription().get(0); |
| 601 | 4 | if (desc !=null) descStr = desc.getValue(); |
| 602 | 4 | alist.add(lifeCycleManager.createExternalLink(overviewDoc.getOverviewURL(),descStr)); |
| 603 | |
} |
| 604 | |
|
| 605 | 4 | 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 | 79 | Collection<ExternalIdentifier> extidentifiers = null; |
| 619 | 79 | 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 | 79 | return extidentifiers; |
| 638 | |
} |
| 639 | |
|
| 640 | |
private static Locale getLocale(String lang) { |
| 641 | 241 | if (lang == null || lang.trim().length() == 0) { |
| 642 | 2 | return Locale.getDefault(); |
| 643 | 239 | } else if (lang.equalsIgnoreCase(Locale.getDefault().getLanguage())) { |
| 644 | 223 | return Locale.getDefault(); |
| 645 | |
} else { |
| 646 | 16 | return new Locale(lang); |
| 647 | |
} |
| 648 | |
} |
| 649 | |
|
| 650 | |
} |