public static RelatedBusinessesList getRelatedBusinessesList(FindRelatedBusinesses body, EntityManager em) throws DispositionReportFaultMessage {
return getRelatedBusinessesList(body, em, null, null);
}
public static RelatedBusinessesList getRelatedBusinessesList(FindRelatedBusinesses body, EntityManager em, Date modifiedAfter, Date modifiedBefore) throws DispositionReportFaultMessage {
RelatedBusinessesList result = new RelatedBusinessesList();
result.setBusinessKey(body.getBusinessKey());
ListDescription listDesc = new ListDescription();
result.setListDescription(listDesc);
// Either one of the businessKey, fromKey or toKey will be passed. This is considered the "focal" business to which related businesses must be
// found. Rather than use a query, it seems simpler to take advantage of the model's publisher assertion collections.
org.uddi.api_v3.RelatedBusinessInfos relatedBusinessInfos = new org.uddi.api_v3.RelatedBusinessInfos();
if (body.getBusinessKey() != null ) {
InquiryHelper.getRelatedBusinesses(em, Direction.FROM_KEY, body.getBusinessKey(), body.getKeyedReference(), relatedBusinessInfos, modifiedAfter, modifiedBefore);
InquiryHelper.getRelatedBusinesses(em, Direction.TO_KEY, body.getBusinessKey(), body.getKeyedReference(), relatedBusinessInfos, modifiedAfter, modifiedBefore);
}
else if (body.getFromKey() != null) {
InquiryHelper.getRelatedBusinesses(em, Direction.FROM_KEY, body.getFromKey(), body.getKeyedReference(), relatedBusinessInfos, modifiedAfter, modifiedBefore);
result.setBusinessKey(body.getFromKey());
} else if (body.getToKey() != null) {
InquiryHelper.getRelatedBusinesses(em, Direction.TO_KEY, body.getToKey(), body.getKeyedReference(), relatedBusinessInfos, modifiedAfter, modifiedBefore);
result.setBusinessKey(body.getToKey());
}
if (relatedBusinessInfos.getRelatedBusinessInfo().size() > 0) {
// TODO: Do proper pagination!
listDesc.setActualCount(relatedBusinessInfos.getRelatedBusinessInfo().size());
listDesc.setIncludeCount(relatedBusinessInfos.getRelatedBusinessInfo().size());
listDesc.setListHead(1);
result.setRelatedBusinessInfos(relatedBusinessInfos);
}
return result;
}