public static BusinessEntity getBusinessEntityFromJAXROrg(Organization org)
throws JAXRException
{
BusinessEntity biz = new BusinessEntity();
BusinessServices bss = new BusinessServices();
Vector bvect = new Vector();
try
{
//It may just be an update
Key key = org.getKey();
if(key != null ) biz.setBusinessKey(key.getId());
//Lets get the Organization attributes at the top level
String language = Locale.getDefault().getLanguage();
biz.addName(new Name(org.getName().getValue(), language));
biz.addDescription(new Description(org.getDescription().getValue()));
if(org.getPrimaryContact() != null )
biz.setAuthorizedName(org.getPrimaryContact().getPersonName().getFullName());
Collection s = org.getServices();
log.debug("?Org has services=" + s.isEmpty());
Iterator iter = s.iterator();
while (iter.hasNext())
{
BusinessService bs =
ScoutJaxrUddiHelper.getBusinessServiceFromJAXRService((Service) iter.next());
bvect.add(bs);
}
/*
* map users : JAXR has concept of 'primary contact', which is a
* special designation for one of the users, and D6.1 seems to say
* that the first UDDI user is the primary contact
*/
Contacts cts = new Contacts();
Vector cvect = new Vector();
User primaryContact = org.getPrimaryContact();
Collection users = org.getUsers();
/*
* first do primary, and then filter that out in the loop
*/
if (primaryContact != null) {
Contact ct = getContactFromJAXRUser(primaryContact);
cvect.add(ct);
}
Iterator it = users.iterator();
while (it.hasNext())
{
User u = (User) it.next();
if (u != primaryContact) {
Contact ct = getContactFromJAXRUser(u);
cvect.add(ct);
}
}
bss.setBusinessServiceVector(bvect);
cts.setContactVector(cvect);
biz.setContacts(cts);
biz.setBusinessServices(bss);