fb.setListHead(null);
fb.setMaxRows(null);
// Setting the start index to the chunkData
Holder<Integer> subscriptionStartIndex = new Holder<Integer>(chunkData);
BindingDetail bindingDetail = InquiryHelper.getBindingDetailFromKeys(fb, findQualifiers, em, currentMatchingKeys,
startPointDate, endPointDate, subscriptionStartIndex, modelSubscription.getMaxEntities());
// Upon exiting above function, if more results are to be had, the subscriptionStartIndex will contain the latest value (or null
// if no more results)
chunkData = subscriptionStartIndex.value;
result.setBindingDetail(bindingDetail);
}
}
if (subscriptionFilter.getFindBusiness() != null) {
//Get the current matching keys
List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
if (missingKeys != null && missingKeys.size() > 0) {
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
for (String key : missingKeys)
missingKeyBag.getBusinessKey().add(key);
result.getKeyBag().add(missingKeyBag);
}
// Re-setting the subscription matches to the new matching key collection
//modelSubscription.getSubscriptionMatches().clear();
//for (Object key : currentMatchingKeys) {
// SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
// modelSubscription.getSubscriptionMatches().add(subMatch);
//}
// Now, finding the necessary entities, within the coverage period limits
if (modelSubscription.isBrief()) {
KeyBag resultsKeyBag = new KeyBag();
for (String key : (List<String>)currentMatchingKeys)
resultsKeyBag.getBusinessKey().add(key);
result.getKeyBag().add(resultsKeyBag);
}
else {
FindBusiness fb = subscriptionFilter.getFindBusiness();
org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
findQualifiers.mapApiFindQualifiers(fb.getFindQualifiers());
// To do subscription "chunking", the listHead and maxRows are nulled which will set them to system default. User settings for
// these values don't make sense with the "chunking" feature.
fb.setListHead(null);
fb.setMaxRows(null);
// Setting the start index to the chunkData
Holder<Integer> subscriptionStartIndex = new Holder<Integer>(chunkData);
BusinessList businessList = InquiryHelper.getBusinessListFromKeys(fb, findQualifiers, em, currentMatchingKeys,
startPointDate, endPointDate, subscriptionStartIndex, modelSubscription.getMaxEntities());
// Upon exiting above function, if more results are to be had, the subscriptionStartIndex will contain the latest value (or null
// if no more results)
chunkData = subscriptionStartIndex.value;
result.setBusinessList(businessList);
}
}
if (subscriptionFilter.getFindService() != null) {
//Get the current matching keys
List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
if (logger.isDebugEnabled()) logger.debug("current matching keys=" + currentMatchingKeys);
List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
if (missingKeys != null && missingKeys.size() > 0) {
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
for (String key : missingKeys)
missingKeyBag.getServiceKey().add(key);
result.getKeyBag().add(missingKeyBag);
}
// Re-setting the subscription matches to the new matching key collection
//modelSubscription.getSubscriptionMatches().clear();
//for (Object key : currentMatchingKeys) {
// SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
// modelSubscription.getSubscriptionMatches().add(subMatch);
//}
// Now, finding the necessary entities, within the coverage period limits
if (modelSubscription.isBrief()) {
KeyBag resultsKeyBag = new KeyBag();
for (String key : (List<String>)currentMatchingKeys)
resultsKeyBag.getServiceKey().add(key);
result.getKeyBag().add(resultsKeyBag);
}
else {
FindService fs = subscriptionFilter.getFindService();
org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
findQualifiers.mapApiFindQualifiers(fs.getFindQualifiers());
// To do subscription "chunking", the listHead and maxRows are nulled which will set them to system default. User settings for
// these values don't make sense with the "chunking" feature.
fs.setListHead(null);
fs.setMaxRows(null);
// Setting the start index to the chunkData
Holder<Integer> subscriptionStartIndex = new Holder<Integer>(chunkData);
ServiceList serviceList = InquiryHelper.getServiceListFromKeys(fs, findQualifiers, em, currentMatchingKeys,
startPointDate, endPointDate, subscriptionStartIndex, modelSubscription.getMaxEntities());
if (serviceList.getServiceInfos()==null || serviceList.getServiceInfos().getServiceInfo().size()==0) {
serviceList=null;
}
// Upon exiting above function, if more results are to be had, the subscriptionStartIndex will contain the latest value (or null
// if no more results)
chunkData = subscriptionStartIndex.value;
result.setServiceList(serviceList);
}
}
if (subscriptionFilter.getFindTModel() != null) {
//Get the current matching keys
List<?> currentMatchingKeys = getSubscriptionMatches(subscriptionFilter, em);
List<String> missingKeys = getMissingKeys(currentMatchingKeys, modelSubscription.getSubscriptionMatches());
if (missingKeys != null && missingKeys.size() > 0) {
KeyBag missingKeyBag = new KeyBag();
missingKeyBag.setDeleted(true);
for (String key : missingKeys)
missingKeyBag.getTModelKey().add(key);
result.getKeyBag().add(missingKeyBag);
}
// Re-setting the subscription matches to the new matching key collection
//modelSubscription.getSubscriptionMatches().clear();
//for (Object key : currentMatchingKeys) {
// SubscriptionMatch subMatch = new SubscriptionMatch(modelSubscription, (String)key);
// modelSubscription.getSubscriptionMatches().add(subMatch);
//}
// Now, finding the necessary entities, within the coverage period limits
if (modelSubscription.isBrief()) {
KeyBag resultsKeyBag = new KeyBag();
for (String key : (List<String>)currentMatchingKeys)
resultsKeyBag.getTModelKey().add(key);
result.getKeyBag().add(resultsKeyBag);
}
else {
FindTModel ft = subscriptionFilter.getFindTModel();
org.apache.juddi.query.util.FindQualifiers findQualifiers = new org.apache.juddi.query.util.FindQualifiers();
findQualifiers.mapApiFindQualifiers(ft.getFindQualifiers());
// To do subscription "chunking", the listHead and maxRows are nulled which will set them to system default. User settings for
// these values don't make sense with the "chunking" feature.
ft.setListHead(null);
ft.setMaxRows(null);
// Setting the start index to the chunkData
Holder<Integer> subscriptionStartIndex = new Holder<Integer>(chunkData);
// If more results are to be had, chunkData will come out with a value and a new token will be generated below. Otherwise, it will
// be null and no token will be generated.
TModelList tmodelList = InquiryHelper.getTModelListFromKeys(ft, findQualifiers, em, currentMatchingKeys,
startPointDate, endPointDate, subscriptionStartIndex, modelSubscription.getMaxEntities());
// Upon exiting above function, if more results are to be had, the subscriptionStartIndex will contain the latest value (or null
// if no more results)
chunkData = subscriptionStartIndex.value;
result.setTModelList(tmodelList);
}
}
if (subscriptionFilter.getFindRelatedBusinesses() != null) {
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.