FindRelatedBusinesses findRelatedBusiness = subscriptionFilter.getFindRelatedBusinesses();
RelatedBusinessesList relatedBusinessList = InquiryHelper.getRelatedBusinessesList(findRelatedBusiness, em, startPointDate, endPointDate);
result.setRelatedBusinessesList(relatedBusinessList);
}
if (subscriptionFilter.getGetBindingDetail() != null) {
GetBindingDetail getDetail = subscriptionFilter.getGetBindingDetail();
// Running through the key list here to determine the deleted keys and store the existing entities.
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
List<org.apache.juddi.model.BindingTemplate> existingList = new ArrayList<org.apache.juddi.model.BindingTemplate>(0);
for (String key : getDetail.getBindingKey()) {
org.apache.juddi.model.BindingTemplate modelBindingTemplate = em.find(org.apache.juddi.model.BindingTemplate.class, key);
if (modelBindingTemplate != null)
existingList.add(modelBindingTemplate);
else
missingKeyBag.getBindingKey().add(key);
}
// Store deleted keys in the results
if (missingKeyBag.getBindingKey() != null && missingKeyBag.getBindingKey().size() > 0)
result.getKeyBag().add(missingKeyBag);
KeyBag resultsKeyBag = new KeyBag();
BindingDetail bindingDetail = new BindingDetail();
// Set the currentIndex to 0 or the value of the chunkData
int currentIndex = 0;
if (chunkData != null)
currentIndex = chunkData;
int returnedRowCount = 0;
while(currentIndex < existingList.size()) {
org.apache.juddi.model.BindingTemplate modelBindingTemplate = existingList.get(currentIndex);
if (startPointDate.after(modelBindingTemplate.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (endPointDate.before(modelBindingTemplate.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (modelSubscription.isBrief()) {
resultsKeyBag.getBindingKey().add(modelBindingTemplate.getEntityKey());
}
else {
org.uddi.api_v3.BindingTemplate apiBindingTemplate = new org.uddi.api_v3.BindingTemplate();
MappingModelToApi.mapBindingTemplate(modelBindingTemplate, apiBindingTemplate);
bindingDetail.getBindingTemplate().add(apiBindingTemplate);
returnedRowCount++;
}
// If the returned rows equals the max allowed, we can end the loop.
if (modelSubscription.getMaxEntities() != null) {
if (returnedRowCount == modelSubscription.getMaxEntities())
break;
}
currentIndex++;
}
// If the loop was broken prematurely (max row count hit) we set the chunk data to the next index to start with.
// A non-null value of chunk data will cause a chunk token to be generated.
if (currentIndex < (existingList.size() - 1))
chunkData = currentIndex + 1;
else
chunkData = null;
if (modelSubscription.isBrief())
result.getKeyBag().add(resultsKeyBag);
else
result.setBindingDetail(bindingDetail);
}
if (subscriptionFilter.getGetBusinessDetail() != null) {
GetBusinessDetail getDetail = subscriptionFilter.getGetBusinessDetail();
// Running through the key list here to determine the deleted keys and store the existing entities.
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
List<org.apache.juddi.model.BusinessEntity> existingList = new ArrayList<org.apache.juddi.model.BusinessEntity>(0);
for (String key : getDetail.getBusinessKey()) {
org.apache.juddi.model.BusinessEntity modelBusinessEntity = em.find(org.apache.juddi.model.BusinessEntity.class, key);
if (modelBusinessEntity != null)
existingList.add(modelBusinessEntity);
else
missingKeyBag.getBusinessKey().add(key);
}
// Store deleted keys in the results
if (missingKeyBag.getBusinessKey() != null && missingKeyBag.getBusinessKey().size() > 0)
result.getKeyBag().add(missingKeyBag);
KeyBag resultsKeyBag = new KeyBag();
BusinessDetail businessDetail = new BusinessDetail();
// Set the currentIndex to 0 or the value of the chunkData
int currentIndex = 0;
if (chunkData != null)
currentIndex = chunkData;
int returnedRowCount = 0;
while(currentIndex < existingList.size()) {
org.apache.juddi.model.BusinessEntity modelBusinessEntity = existingList.get(currentIndex);
if (startPointDate.after(modelBusinessEntity.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (endPointDate.before(modelBusinessEntity.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (modelSubscription.isBrief()) {
resultsKeyBag.getBusinessKey().add(modelBusinessEntity.getEntityKey());
}
else {
org.uddi.api_v3.BusinessEntity apiBusinessEntity = new org.uddi.api_v3.BusinessEntity();
MappingModelToApi.mapBusinessEntity(modelBusinessEntity, apiBusinessEntity);
businessDetail.getBusinessEntity().add(apiBusinessEntity);
returnedRowCount++;
}
// If the returned rows equals the max allowed, we can end the loop.
if (modelSubscription.getMaxEntities() != null) {
if (returnedRowCount == modelSubscription.getMaxEntities())
break;
}
currentIndex++;
}
// If the loop was broken prematurely (max row count hit) we set the chunk data to the next index to start with.
// A non-null value of chunk data will cause a chunk token to be generated.
if (currentIndex < (existingList.size() - 1))
chunkData = currentIndex + 1;
else
chunkData = null;
if (modelSubscription.isBrief())
result.getKeyBag().add(resultsKeyBag);
else
result.setBusinessDetail(businessDetail);
}
if (subscriptionFilter.getGetServiceDetail() != null) {
GetServiceDetail getDetail = subscriptionFilter.getGetServiceDetail();
// Running through the key list here to determine the deleted keys and store the existing entities.
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
List<org.apache.juddi.model.BusinessService> existingList = new ArrayList<org.apache.juddi.model.BusinessService>(0);
for (String key : getDetail.getServiceKey()) {
org.apache.juddi.model.BusinessService modelBusinessService = em.find(org.apache.juddi.model.BusinessService.class, key);
if (modelBusinessService != null)
existingList.add(modelBusinessService);
else
missingKeyBag.getBusinessKey().add(key);
}
// Store deleted keys in the results
if (missingKeyBag.getServiceKey() != null && missingKeyBag.getServiceKey().size() > 0)
result.getKeyBag().add(missingKeyBag);
KeyBag resultsKeyBag = new KeyBag();
ServiceDetail serviceDetail = new ServiceDetail();
// Set the currentIndex to 0 or the value of the chunkData
int currentIndex = 0;
if (chunkData != null)
currentIndex = chunkData;
int returnedRowCount = 0;
while(currentIndex < existingList.size()) {
org.apache.juddi.model.BusinessService modelBusinessService = existingList.get(currentIndex);
if (startPointDate.after(modelBusinessService.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (endPointDate.before(modelBusinessService.getModifiedIncludingChildren())) {
currentIndex++;
continue;
}
if (modelSubscription.isBrief()) {
resultsKeyBag.getServiceKey().add(modelBusinessService.getEntityKey());
}
else {
org.uddi.api_v3.BusinessService apiBusinessService = new org.uddi.api_v3.BusinessService();
MappingModelToApi.mapBusinessService(modelBusinessService, apiBusinessService);
serviceDetail.getBusinessService().add(apiBusinessService);
returnedRowCount++;
}
// If the returned rows equals the max allowed, we can end the loop.
if (modelSubscription.getMaxEntities() != null) {
if (returnedRowCount == modelSubscription.getMaxEntities())
break;
}
currentIndex++;
}
// If the loop was broken prematurely (max row count hit) we set the chunk data to the next index to start with.
// A non-null value of chunk data will cause a chunk token to be generated.
if (currentIndex < (existingList.size() - 1))
chunkData = currentIndex + 1;
else
chunkData = null;
if (modelSubscription.isBrief())
result.getKeyBag().add(resultsKeyBag);
else
result.setServiceDetail(serviceDetail);
}
if (subscriptionFilter.getGetTModelDetail() != null) {
GetTModelDetail getDetail = subscriptionFilter.getGetTModelDetail();
// Running through the key list here to determine the deleted keys and store the existing entities.
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
List<org.apache.juddi.model.Tmodel> existingList = new ArrayList<org.apache.juddi.model.Tmodel>(0);
for (String key : getDetail.getTModelKey()) {
org.apache.juddi.model.Tmodel modelTModel = em.find(org.apache.juddi.model.Tmodel.class, key);
if (modelTModel != null)
existingList.add(modelTModel);
else
missingKeyBag.getTModelKey().add(key);