You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by tc...@apache.org on 2011/05/19 02:31:18 UTC

svn commit: r1124478 - in /juddi/trunk: juddi-core/src/main/java/org/apache/juddi/api/impl/ juddi-core/src/main/java/org/apache/juddi/query/ uddi-tck-base/src/main/resources/uddi_data/tompublisher/ uddi-tck/src/test/java/org/apache/juddi/v3/tck/

Author: tcunning
Date: Thu May 19 00:31:17 2011
New Revision: 1124478

URL: http://svn.apache.org/viewvc?rev=1124478&view=rev
Log:
JUDDI-456
Added query classes for FindServiceByCombinedCategoryQuery and 
FindBusinessByCategoryquery, added tests for both the find_business and the
find_service instance, and added calls to both within InquiryHelper.

Added:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business2.xml
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business3.xml
    juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business4.xml
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java
Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java?rev=1124478&r1=1124477&r2=1124478&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/InquiryHelper.java Thu May 19 00:31:17 2011
@@ -35,12 +35,14 @@ import org.apache.juddi.query.FindBindin
 import org.apache.juddi.query.FindBindingByTModelKeyQuery;
 import org.apache.juddi.query.FindBusinessByCategoryGroupQuery;
 import org.apache.juddi.query.FindBusinessByCategoryQuery;
+import org.apache.juddi.query.FindBusinessByCombinedCategoryQuery;
 import org.apache.juddi.query.FindBusinessByDiscoveryURLQuery;
 import org.apache.juddi.query.FindBusinessByIdentifierQuery;
 import org.apache.juddi.query.FindBusinessByNameQuery;
 import org.apache.juddi.query.FindBusinessByTModelKeyQuery;
 import org.apache.juddi.query.FindServiceByCategoryGroupQuery;
 import org.apache.juddi.query.FindServiceByCategoryQuery;
+import org.apache.juddi.query.FindServiceByCombinedCategoryQuery;
 import org.apache.juddi.query.FindServiceByNameQuery;
 import org.apache.juddi.query.FindServiceByTModelKeyQuery;
 import org.apache.juddi.query.FindTModelByCategoryGroupQuery;
@@ -65,7 +67,7 @@ import org.uddi.api_v3.TModelBag;
 import org.uddi.api_v3.TModelList;
 import org.uddi.v3_service.DispositionReportFaultMessage;
 
-/**
+/**Co
  * Used to factor out inquiry functionality as it is used in more than one spot.
  * 
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
@@ -190,7 +192,12 @@ public class InquiryHelper {
 		keysFound = FindBusinessByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(), keysFound);
 		keysFound = FindBusinessByIdentifierQuery.select(em, findQualifiers, body.getIdentifierBag(), keysFound);
 		keysFound = FindBusinessByDiscoveryURLQuery.select(em, findQualifiers, body.getDiscoveryURLs(), keysFound);
-		keysFound = FindBusinessByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), keysFound);
+                if (findQualifiers.isCombineCategoryBags()) {
+                    keysFound = FindBusinessByCombinedCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), keysFound);
+                } else {
+                    keysFound = FindBusinessByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), keysFound);
+                }
+
 		keysFound = FindBusinessByCategoryGroupQuery.select(em, findQualifiers, body.getCategoryBag(), keysFound);
 		keysFound = FindBusinessByNameQuery.select(em, findQualifiers, body.getName(), keysFound);
 		
@@ -299,7 +306,11 @@ public class InquiryHelper {
 		
 		
 		keysFound = FindServiceByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(), body.getBusinessKey(), keysFound);
-		keysFound = FindServiceByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);
+                if (findQualifiers.isCombineCategoryBags()) {
+		    keysFound = FindServiceByCombinedCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);
+		} else {
+			keysFound = FindServiceByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);
+		}
 		keysFound = FindServiceByCategoryGroupQuery.select(em, findQualifiers, body.getCategoryBag(), body.getBusinessKey(), keysFound);
 		keysFound = FindServiceByNameQuery.select(em, findQualifiers, body.getName(), body.getBusinessKey(), keysFound);
 		

Added: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java (added)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCombinedCategoryQuery.java Thu May 19 00:31:17 2011
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.juddi.query;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.juddi.query.util.FindQualifiers;
+import org.uddi.api_v3.CategoryBag;
+
+/**
+ * Returns the list of business keys possessing the keyedReferenceGroups in the passed category bag.
+ * Output is restricted by list of business keys passed in.  If null, all business entities are searched.
+ * Output is produced by building the appropriate JPA query based on input and find qualifiers.
+ * 
+ * From specification:
+ * "combineCategoryBags:  this may only be used in the find_business and find_service calls.  In the case of 
+ * find_business, this qualifier makes the categoryBag entries for the full businessEntity element behave as though all 
+ * categoryBag elements found at the businessEntity level and in all contained or referenced businessService elements 
+ * and bindingTemplate elements were combined.  Searching for a category will yield a positive match on a registered 
+ * business if any of the categoryBag elements contained within the full businessEntity element (including the 
+ * categoryBag elements within contained or referenced businessService elements or bindingTemplate elements) 
+ * contains the filter criteria.  In the case of find_service, this qualifier makes the categoryBag entries 
+ * for the full businessService element behave as though all categoryBag elements found at the businessService level 
+ * and in all contained or referenced elements in the bindingTemplate elements were combined.  Searching for a category 
+ * will yield a positive match on a registered service if any of the categoryBag elements contained within the 
+ * full businessService element (including the categoryBag elements within contained or referenced bindingTemplate 
+ * elements) contains the filter criteria. This find qualifier does not cause the keyedReferences in categoryBags 
+ * to be combined with the keyedReferences in keyedReferenceGroups in categoryBags when performing the comparison.  
+ * The keyedReferences are combined with each other, and the keyedReferenceGroups are combined with each other."
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class FindBusinessByCombinedCategoryQuery {
+        
+        private static final String ENTITY_NAME_CHILD = "BusinessCategoryBag";
+        private static final String ENTITY_NAME_CHILD2  = "ServiceCategoryBag";
+
+        private static FindEntityByCombinedCategoryQuery findQuery;
+        
+        static {
+            findQuery = new FindEntityByCombinedCategoryQuery(BusinessEntityQuery.ENTITY_NAME, 
+                            BusinessEntityQuery.ENTITY_ALIAS, 
+                            BusinessEntityQuery.KEY_NAME, 
+                            BusinessEntityQuery.ENTITY_FIELD, 
+                            ENTITY_NAME_CHILD,
+                            ENTITY_NAME_CHILD2);
+        }
+        
+        public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn) {
+                return findQuery.select(em, fq, categoryBag, keysIn);
+        }
+}

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java?rev=1124478&r1=1124477&r2=1124478&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java (original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java Thu May 19 00:31:17 2011
@@ -57,13 +57,13 @@ public class FindEntityByCategoryQuery e
 	private static final String ALIAS_KEYEDREFERENCE = buildAlias(ENTITY_KEYEDREFERENCE);
 	private static final String FIELD_CATEGORYBAG = "categoryBag";
 	
-	private String entityName;
-	private String entityAlias;
-	private String keyName;
-	private String entityField;
-	private String entityNameChild;
-	private String entityAliasChild;
-	private String selectSQL;
+	protected String entityName;
+	protected String entityAlias;
+	protected String keyName;
+	protected String entityField;
+	protected String entityNameChild;
+	protected String entityAliasChild;
+	protected String selectSQL;
 
 	public FindEntityByCategoryQuery(String entityName, String entityAlias, String keyName, String entityField, String entityNameChild) {
 		this.entityName = entityName;

Added: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java (added)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCombinedCategoryQuery.java Thu May 19 00:31:17 2011
@@ -0,0 +1,393 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.juddi.query;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.config.Constants;
+import org.apache.juddi.query.util.DynamicQuery;
+import org.apache.juddi.query.util.FindQualifiers;
+import org.apache.juddi.query.util.KeyedRefTModelComparator;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.KeyedReference;
+
+/**
+ * Returns the list of "entity" keys possessing the keyedReferences passed in or the level below.
+ * For findBusiness queries, this means keyedReferences on the businessEntity and service levels,
+ * and for findService queries this means keyedReferences on the service and serviceBinding level.
+ * 
+ * Output is restricted by list of "entity" keys passed in.  If null, all entities are searched.
+ * Output is produced by building the appropriate JPA query based on input and find qualifiers.
+ * 
+ * From the spec : 
+ * 
+ *  * From specification:
+ * "combineCategoryBags:  this may only be used in the find_business and find_service calls.  In the case of 
+ * find_business, this qualifier makes the categoryBag entries for the full businessEntity element behave as though all 
+ * categoryBag elements found at the businessEntity level and in all contained or referenced businessService elements 
+ * and bindingTemplate elements were combined.  Searching for a category will yield a positive match on a registered 
+ * business if any of the categoryBag elements contained within the full businessEntity element (including the 
+ * categoryBag elements within contained or referenced businessService elements or bindingTemplate elements) 
+ * contains the filter criteria.  In the case of find_service, this qualifier makes the categoryBag entries 
+ * for the full businessService element behave as though all categoryBag elements found at the businessService level 
+ * and in all contained or referenced elements in the bindingTemplate elements were combined.  Searching for a category 
+ * will yield a positive match on a registered service if any of the categoryBag elements contained within the 
+ * full businessService element (including the categoryBag elements within contained or referenced bindingTemplate 
+ * elements) contains the filter criteria. This find qualifier does not cause the keyedReferences in categoryBags 
+ * to be combined with the keyedReferences in keyedReferenceGroups in categoryBags when performing the comparison.  
+ * The keyedReferences are combined with each other, and the keyedReferenceGroups are combined with each other."
+ * 
+ * 
+ * NOTES:
+ * 1) Categories are grouped with a logical AND by default.
+ * 2) Concerning when the categories are AND'd together - the only way this can be done with a single query was to create a self-join for 
+ *    each category.  If there are a lot of categories, the performance could suffer.
+ *    TODO:  Test performance with multiple AND'd categories.  If too slow, look to process this query in multiple steps.
+ * 3) The "orLikeKeys" qualifier complicates matters.  The "like" keys are OR'd together and these groups of "like" keys are AND'd together.
+ *    As with "andAllKeys", self-joins are created but only one for each group of "like" keys.  If none of the keyedReferences passed are alike then this
+ *    will reduce to an "andAllKeys" query.  If all are alike, then this will query will exhibit the behavior of OR'ing all keys.
+ * 
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:kstam@apache.org">Kurt Stam</a>
+ */
+public class FindEntityByCombinedCategoryQuery extends FindEntityByCategoryQuery {
+	
+	@SuppressWarnings("unused")
+	private static Log log = LogFactory.getLog(FindEntityByCombinedCategoryQuery.class);
+
+	private static final String ENTITY_KEYEDREFERENCE = "KeyedReference";
+	private static final String ALIAS_KEYEDREFERENCE = buildAlias(ENTITY_KEYEDREFERENCE);
+	private static final String FIELD_CATEGORYBAG = "categoryBag";
+	
+	private String joinClause;
+	private String currentAlias;
+	
+	protected String entityNameChild2;
+	protected String entityAliasChild2;
+
+	public FindEntityByCombinedCategoryQuery(String entityName, String entityAlias, String keyName, String entityField, String entityNameChild) {
+		super(entityName, entityAlias, keyName, entityField, entityNameChild);
+	}
+	
+	public FindEntityByCombinedCategoryQuery(String entityName, String entityAlias, String keyName, String entityField, String entityNameChild,
+			String entityNameChild2) {
+		super(entityName, entityAlias, keyName, entityField, entityNameChild);
+		
+		this.entityNameChild2 = entityNameChild2;
+		this.entityAliasChild2 = buildAlias(entityNameChild2);
+		
+		selectSQL = "";
+	}
+	
+	public String getEntityNameChild2() {
+		return entityNameChild2;
+	}
+	
+	public String getEntityAliasChild2() {
+		return entityAliasChild2;
+	}
+		
+	public List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<?> keysIn, DynamicQuery.Parameter... restrictions) {
+	        StringBuffer queryOne = new StringBuffer(200);
+                StringBuffer queryTwo = new StringBuffer(200);
+	    
+                // If keysIn is not null and empty, then search is over.
+		if ((keysIn != null) && (keysIn.size() == 0))
+			return keysIn;
+		
+		if (categoryBag == null)
+			return keysIn;
+		
+		List<KeyedReference> categories = categoryBag.getKeyedReference();
+		if (categories == null || categories.size() == 0)
+			return keysIn;
+		
+		queryOne.append("select " + entityAlias + "." + keyName + ", " + entityAliasChild + ".id "
+	                    + "from " + entityName + " " + entityAlias + ", " + entityNameChild + " " + entityAliasChild + " ");
+		
+		ArrayList<List> aggregatedResultsOne = new ArrayList<List>();
+                ArrayList<List> aggregatedResultsTwo = new ArrayList<List>();
+
+		for (KeyedReference elem : categories) {
+		    List<KeyedReference> keyedRefs = new ArrayList<KeyedReference>(0);
+
+		    if (elem instanceof KeyedReference)
+			keyedRefs.add((KeyedReference)elem);
+	            DynamicQuery dynamicQry = new DynamicQuery(queryOne.toString());
+	            currentAlias = entityAliasChild;
+	            joinClause = entityAlias + "." + keyName + " = "
+	                + entityAliasChild + "." + entityField + "." + keyName + " ";
+	            appendConditions(dynamicQry, fq, keyedRefs);
+	            if (restrictions != null && restrictions.length > 0)
+	                dynamicQry.AND().pad().appendGroupedAnd(restrictions);
+
+	            if (keyedRefs.size() != 0) {
+	                List list = getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);
+	                aggregatedResultsOne.addAll(list);
+	            }
+		}		
+
+	        queryTwo.append("select  " + entityAlias + "." + keyName + ", " + entityAliasChild2 + ".id "
+	                + "from " + entityName + " " + entityAlias + ", " + entityNameChild + " " + entityAliasChild + ", "
+	                + entityNameChild2 + " " + entityAliasChild2 + " ");
+
+                for (KeyedReference elem : categories) {
+                    List<KeyedReference> keyedRefs = new ArrayList<KeyedReference>(0);
+
+                    if (elem instanceof KeyedReference)
+                        keyedRefs.add((KeyedReference)elem);
+                    DynamicQuery dynamicQry = new DynamicQuery(queryTwo.toString());
+                    currentAlias = entityAliasChild2;
+                    
+                    if (BusinessEntityQuery.ENTITY_NAME.equals(entityName)) {
+                        joinClause = entityAlias + ".id" + " = "
+                        + entityAliasChild + "." + entityField + ".id" + " and "
+                        + entityAliasChild + "." + entityField + ".id" + " = "
+                        + entityAliasChild2 + ".businessService.businessEntity.id";
+                    } else {
+                        joinClause = entityAlias + ".id" + " = "
+                            + entityAliasChild + "." + entityField + ".id" + " and "
+                            + entityAliasChild + "." + entityField + ".id" + " = "
+                            + entityAliasChild2 + ".bindingTemplate.businessService.id";
+                    }
+
+                    appendConditions(dynamicQry, fq, keyedRefs);
+                    if (restrictions != null && restrictions.length > 0)
+                        dynamicQry.AND().pad().appendGroupedAnd(restrictions);
+
+                    if (keyedRefs.size() != 0) {
+                        List list = getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);
+                        aggregatedResultsTwo.addAll(list);
+                    }
+                }               
+
+                ArrayList results = new ArrayList();
+                if (BusinessServiceQuery.ENTITY_NAME.equals(entityName)) {
+                    ArrayList idsOne = new ArrayList();
+                    ArrayList idsTwo = new ArrayList();
+                    
+                    for (Iterator i = aggregatedResultsOne.iterator(); i.hasNext();) {
+                        Object[] l = (Object[]) i.next();
+                        String id = (String) l[0];
+                        idsOne.add(id);
+                    }
+                    for (Iterator i = aggregatedResultsTwo.iterator(); i.hasNext();) {
+                        Object[] l = (Object[]) i.next();
+                        String id = (String) l[0];
+                        idsTwo.add(id);
+                    }
+                    
+                    results.addAll(idsOne);
+                    results.retainAll(idsTwo);
+                } else if (BusinessEntityQuery.ENTITY_NAME.equals(entityName)) {
+                    ArrayList idsOne = new ArrayList();
+                    ArrayList idsTwo = new ArrayList();
+
+                    for (Iterator i = aggregatedResultsOne.iterator(); i.hasNext();) {
+                        Object[] l = (Object[]) i.next();
+                        String id = (String) l[0];
+                        idsOne.add(id);                        
+                    }
+                    for (Iterator i = aggregatedResultsTwo.iterator(); i.hasNext();) {
+                        Object[] l = (Object[]) i.next();
+                        String id = (String) l[0];
+                        idsTwo.add(id);
+                    }
+                    
+                    results.addAll(idsOne);
+                    results.retainAll(idsTwo);                    
+                }
+                		
+		return results;
+	}
+	
+	
+	/*
+	 * Appends the conditions to the query based on the keyedReference list.  With the default or when "orAllKeys" is passed, the keyedReferences are autonomous and are
+	 * all AND'd or OR'd respectively.  However, "orLikeKeys" requires special treatment.  The goal is to create the conditions in this format:
+	 * 
+	 * (likeKey1 = X or likeKey1 = Y) and (likeKey2 = A or likeKey2 = B or likeKey2 = C) 
+	 * 
+	 * ie. the "like" KeyedReferences are OR'd and the groups of "like" KeyedReferences are AND'd with each other.
+	 */
+	public void appendConditions(DynamicQuery qry, FindQualifiers fq, List<KeyedReference> keyedRefs) {
+		
+		// Append the necessary tables (two will always be added connecting the entity to its category table and then the category table to the keyed references).
+		appendJoinTables(qry, fq, keyedRefs);
+		qry.AND().pad().openParen().pad();
+		
+		String predicate = DynamicQuery.PREDICATE_EQUALS;
+		if (fq.isApproximateMatch()) {
+			predicate = DynamicQuery.PREDICATE_LIKE;
+		}
+		
+		// Sorting the collection by tModel Key
+		Collections.sort(keyedRefs, new KeyedRefTModelComparator());
+
+		String prevTModelKey = null;
+		int count = 0;
+		int tblCount = -1;
+		for(KeyedReference keyedRef : keyedRefs) {
+			String tmodelKey = keyedRef.getTModelKey();
+			String keyValue = keyedRef.getKeyValue();
+			String keyName = keyedRef.getKeyName();
+			
+			if (fq.isApproximateMatch()) {
+				// JUDDI-235: wildcards are provided by user (only commenting in case a new interpretation arises)
+				//keyValue = keyValue.endsWith(DynamicQuery.WILDCARD)?keyValue:keyValue + DynamicQuery.WILDCARD;
+				//keyName = keyName.endsWith(DynamicQuery.WILDCARD)?keyName:keyName + DynamicQuery.WILDCARD;
+			}
+
+			// Either opening up (and AND'ing) a new "group" of like keys or simply appending an "or".  If this is not "orLikeKeys", then just need to increment
+			// the table count.
+			if (fq.isOrLikeKeys()) {
+				if (count == 0) {
+					qry.openParen().pad();
+					tblCount++;
+				}
+				else {
+					if (!tmodelKey.equals(prevTModelKey)) {
+						qry.closeParen().pad().AND().pad().openParen().pad();
+						tblCount++;
+					}
+					else
+						qry.OR().pad();
+				}
+			}
+			else
+				tblCount++;
+			
+			String keyValueTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".keyValue";
+			String keyNameTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".keyName";
+			String tmodelKeyTerm = (fq.isOrAllKeys()?ALIAS_KEYEDREFERENCE + "0":ALIAS_KEYEDREFERENCE + tblCount) + ".tmodelKeyRef";
+			if (fq.isCaseInsensitiveMatch()) {
+				keyValueTerm = "upper(" + keyValueTerm + ")";
+				keyValue = keyValue.toUpperCase();
+				
+				keyNameTerm = "upper(" + keyNameTerm + ")";
+				keyName = keyName.toUpperCase();
+			}
+			
+			
+			// According to specification, if the "general keyword" tmodel is used, then the keyName must be part of the query.
+			if (Constants.GENERAL_KEYWORD_TMODEL.equalsIgnoreCase(tmodelKey)) {
+				qry.appendGroupedAnd(new DynamicQuery.Parameter(tmodelKeyTerm, tmodelKey, DynamicQuery.PREDICATE_EQUALS),
+									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate),
+									 new DynamicQuery.Parameter(keyNameTerm, keyName, predicate));
+			}
+			else {
+				qry.appendGroupedAnd(new DynamicQuery.Parameter(tmodelKeyTerm, tmodelKey, DynamicQuery.PREDICATE_EQUALS),
+									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate));
+				
+			}
+			
+			if (count + 1 < keyedRefs.size()) {
+				if (fq.isOrAllKeys())
+					qry.OR().pad();
+				else if (fq.isOrLikeKeys()) {
+				}
+				else
+					qry.AND().pad();
+			}
+			
+			// The "orLikeKeys" will always leave an unclosed parenthesis.  This will close it.
+			if (fq.isOrLikeKeys() && (count + 1 == keyedRefs.size()))
+				qry.closeParen().pad();
+
+			prevTModelKey = tmodelKey;
+			count++;
+		}
+		qry.closeParen().pad();
+		
+	}
+
+	
+	
+	/*
+	 * Appends the necessary join table for the child entity and additional tables for when keys are AND'd.  When "orLikeKeys" is used, 
+	 * we only need an extra table for each distinct tmodelKey.
+	 */
+	public void appendJoinTables(DynamicQuery qry, FindQualifiers fq, List<KeyedReference> keyedRefs) {
+		
+		if (keyedRefs != null & keyedRefs.size() > 0) {
+			// Sorting the collection by tModel Key
+			Collections.sort(keyedRefs, new KeyedRefTModelComparator());
+
+			StringBuffer thetaJoins = new StringBuffer(200);
+			int tblCount = 0;
+			int count = 0;
+			String curTModelKey = null;
+			String prevTModelKey = null;
+			for(KeyedReference kr : keyedRefs) {
+				curTModelKey = kr.getTModelKey();
+				if (count != 0) {
+					if (!fq.isOrAllKeys()) {
+						if (fq.isOrLikeKeys() && curTModelKey.equals(prevTModelKey)) {
+							// Do nothing
+						}
+						else {
+							tblCount++;
+							qry.comma().pad().append(ENTITY_KEYEDREFERENCE + " " + ALIAS_KEYEDREFERENCE + tblCount).pad();
+							thetaJoins.append(ALIAS_KEYEDREFERENCE + (tblCount - 1) + "." + FIELD_CATEGORYBAG + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
+					//		thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
+						}
+					}
+
+				}
+				else {
+					qry.comma().pad().append(ENTITY_KEYEDREFERENCE + " " + ALIAS_KEYEDREFERENCE + tblCount).pad();
+					//thetaJoins.append(" ( ");
+                                        thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
+					thetaJoins.append(currentAlias + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
+					//thetaJoins.append(DynamicQuery.OPERATOR_OR + " ");
+					//thetaJoins.append(entityAliasChild2 + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "." + FIELD_CATEGORYBAG + ".id ");
+					///thetaJoins.append(" ) ");
+					thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
+					
+				}
+				prevTModelKey = curTModelKey;
+				count++;
+			}
+			
+			qry.WHERE().pad().openParen().pad();
+			
+                        qry.append(joinClause).pad();
+
+			
+			// Appending the middling entity-specific category table condition
+			//qry.append(entityAlias + "." + keyName + " = " + entityAliasChild + "." + entityField + "." + KEY_NAME).pad();
+//			qry.AND().pad();
+
+			String thetaJoinsStr = thetaJoins.toString();
+			if (thetaJoinsStr.endsWith(DynamicQuery.OPERATOR_AND + " "))
+				thetaJoinsStr = thetaJoinsStr.substring(0, thetaJoinsStr.length() - (DynamicQuery.OPERATOR_AND + " ").length());
+			qry.append(thetaJoinsStr);
+
+			qry.closeParen().pad();
+		}
+	}
+	
+}

Added: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java (added)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCombinedCategoryQuery.java Thu May 19 00:31:17 2011
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2001-2008 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.juddi.query;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+
+import org.apache.juddi.query.util.DynamicQuery;
+import org.apache.juddi.query.util.FindQualifiers;
+import org.uddi.api_v3.CategoryBag;
+
+/**
+ * Returns the list of service keys possessing the keyedReferences in the passed category bag.
+ * Output is restricted by list of service keys passed in.  If null, all business services are searched.
+ * Output is produced by building the appropriate JPA query based on input and find qualifiers.
+ * 
+ * From specification:
+ * From specification:
+ * "combineCategoryBags:  this may only be used in the find_business and find_service calls.  In the case of 
+ * find_business, this qualifier makes the categoryBag entries for the full businessEntity element behave as though all 
+ * categoryBag elements found at the businessEntity level and in all contained or referenced businessService elements 
+ * and bindingTemplate elements were combined.  Searching for a category will yield a positive match on a registered 
+ * business if any of the categoryBag elements contained within the full businessEntity element (including the 
+ * categoryBag elements within contained or referenced businessService elements or bindingTemplate elements) 
+ * contains the filter criteria.  In the case of find_service, this qualifier makes the categoryBag entries 
+ * for the full businessService element behave as though all categoryBag elements found at the businessService level 
+ * and in all contained or referenced elements in the bindingTemplate elements were combined.  Searching for a category 
+ * will yield a positive match on a registered service if any of the categoryBag elements contained within the 
+ * full businessService element (including the categoryBag elements within contained or referenced bindingTemplate 
+ * elements) contains the filter criteria. This find qualifier does not cause the keyedReferences in categoryBags 
+ * to be combined with the keyedReferences in keyedReferenceGroups in categoryBags when performing the comparison.  
+ * The keyedReferences are combined with each other, and the keyedReferenceGroups are combined with each other."
+ * 
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:kstam@apache.org">Kurt Stam</a>
+ */
+public class FindServiceByCombinedCategoryQuery {
+	
+	private static final String ENTITY_NAME_CHILD  = "ServiceCategoryBag";
+	private static final String ENTITY_NAME_CHILD2 = "BindingCategoryBag";
+	
+	private static FindEntityByCombinedCategoryQuery findQuery;
+	
+	static {
+		findQuery = new FindEntityByCombinedCategoryQuery(BusinessServiceQuery.ENTITY_NAME, 
+				BusinessServiceQuery.ENTITY_ALIAS, 
+				BusinessServiceQuery.KEY_NAME, 
+				BusinessServiceQuery.ENTITY_FIELD, 
+				ENTITY_NAME_CHILD,
+				ENTITY_NAME_CHILD2);
+	}
+	
+	public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, String parentKey, List<?> keysIn) {
+		if (parentKey != null && parentKey.length() > 0) {
+			DynamicQuery.Parameter param = new DynamicQuery.Parameter(BusinessServiceQuery.ENTITY_ALIAS + "." + BusinessServiceQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS); 
+			return findQuery.select(em, fq, categoryBag, keysIn, param);
+		}
+		else
+			return findQuery.select(em, fq, categoryBag, keysIn);
+	}
+	
+//	select service.entity_key, scb.id from juddiv3.j3_business_service service 
+//	join juddiv3.j3_service_category_bag scb on service.entity_key = scb.entity_key, 
+//	juddiv3.j3_keyed_reference kr0, juddiv3.j3_keyed_reference kr1 
+//	where (kr0.category_bag_id=scb.id and kr0.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel01' and kr0.key_value='value-z') or (kr1.category_bag_id=scb.id and
+//	kr1.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel02' and kr1.key_value='value-x') group by  service.entity_key, scb.id UNION
+//	select service.entity_key, bcb.id from juddiv3.j3_business_service service join juddiv3.j3_binding_template bt on service.entity_key = bt.service_key join
+//	juddiv3.j3_binding_category_bag bcb on bt.entity_key = bcb.entity_key,
+//	juddiv3.j3_keyed_reference kr0, juddiv3.j3_keyed_reference kr1 
+//	where (kr0.category_bag_id=bcb.id and kr0.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel01' and kr0.key_value='value-z') or (kr1.category_bag_id=bcb.id and
+//	kr1.tmodel_key_ref='uddi:uddi.joepublisher.com:tmodel02' and kr1.key_value='value-x') group by  service.entity_key, bcb.id ;
+}

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business1.xml Thu May 19 00:31:17 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.tompublisher.com:businesstest01"> 
+        <name>businesstest01</name> 
+        <businessServices> 
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest01"> 
+                <name>servicetest01</name> 
+                <bindingTemplates> 
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest01"> 
+                        <accessPoint>http://genericaccesspoint.com</accessPoint> 
+                        <categoryBag> 
+                            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-y"/> 
+                        </categoryBag> 
+                    </bindingTemplate> 
+                </bindingTemplates> 
+                <categoryBag> 
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/> 
+                </categoryBag> 
+            </businessService> 
+        </businessServices> 
+</businessEntity> 
+
+

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business2.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business2.xml?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business2.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business2.xml Thu May 19 00:31:17 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.tompublisher.com:businesstest02"> 
+        <name>businesstest02</name> 
+        <businessServices> 
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest02"> 
+                <name>servicetest02</name> 
+                <bindingTemplates> 
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest02"> 
+                        <accessPoint>http://genericaccesspoint.com</accessPoint> 
+                        <categoryBag> 
+                            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-z"/> 
+                        </categoryBag> 
+                    </bindingTemplate> 
+                </bindingTemplates> 
+                <categoryBag> 
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/> 
+                </categoryBag> 
+            </businessService> 
+        </businessServices> 
+</businessEntity> 
+
+

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business3.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business3.xml?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business3.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business3.xml Thu May 19 00:31:17 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.tompublisher.com:businesstest03"> 
+        <name>businesstest03</name> 
+        <businessServices> 
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest03"> 
+                <name>servicetest03</name> 
+                <bindingTemplates> 
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest03"> 
+                        <accessPoint>http://genericaccesspoint.com</accessPoint> 
+                    </bindingTemplate> 
+                </bindingTemplates> 
+                <categoryBag>
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-y"/>
+                </categoryBag>
+            </businessService> 
+        </businessServices> 
+        <categoryBag>
+            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/>
+        </categoryBag>
+</businessEntity> 
+
+

Added: juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business4.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business4.xml?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business4.xml (added)
+++ juddi/trunk/uddi-tck-base/src/main/resources/uddi_data/tompublisher/juddi456-business4.xml Thu May 19 00:31:17 2011
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Copyright 2001-2009 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */ -->
+
+<businessEntity xmlns="urn:uddi-org:api_v3" xmlns:xml="http://www.w3.org/XML/1998/namespace" businessKey="uddi:uddi.tompublisher.com:businesstest04"> 
+        <name>businesstest04</name> 
+        <businessServices> 
+            <businessService serviceKey="uddi:uddi.tompublisher.com:servicetest04"> 
+                <name>servicetest04</name> 
+                <bindingTemplates> 
+                    <bindingTemplate bindingKey="uddi:uddi.tompublisher.com:bindingtest04"> 
+                        <accessPoint>http://genericaccesspoint.com</accessPoint> 
+                    </bindingTemplate> 
+                </bindingTemplates> 
+                <categoryBag>
+                    <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest01" keyValue="value-z"/>
+                </categoryBag>
+            </businessService> 
+        </businessServices> 
+        <categoryBag>
+            <keyedReference tModelKey="uddi:uddi.tompublisher.com:tmodeltest02" keyValue="value-x"/>
+        </categoryBag>
+</businessEntity> 
+
+

Added: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java (added)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_120_CombineCategoryBagsFindServiceIntegrationTest.java Thu May 19 00:31:17 2011
@@ -0,0 +1,177 @@
+package org.apache.juddi.v3.tck;
+
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.config.UDDIClerkManager;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BusinessInfo;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.ServiceInfo;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModelBag;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ * Test to verify JUDDI-456
+ * 
+ * Test does a find_service with the combinedCategoryBags findQualifier set, expects
+ * back one service with a serviceKey of uddi:uddi.tompublisher.com:servicetest02.
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class UDDI_120_CombineCategoryBagsFindServiceIntegrationTest 
+{
+    final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
+    final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
+    final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
+
+    final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
+    final static String TOM_PUBLISHER_TMODEL01_KEY      = "uddi:uddi.tompublisher.com:tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL01_NAME 	= "tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL02_KEY      = "uddi:uddi.tompublisher.com:tmodeltest02";
+
+    final static String TOM_BUSINESS1_XML       = "uddi_data/tompublisher/juddi456-business1.xml";
+    final static String TOM_BUSINESS2_XML       = "uddi_data/tompublisher/juddi456-business2.xml";
+    final static String TOM_BUSINESS1_KEY        = "uddi:uddi.tompublisher.com:businesstest01";
+    final static String TOM_BUSINESS2_KEY        = "uddi:uddi.tompublisher.com:businesstest02";
+
+    final static String SERVICE_KEY = "uddi:uddi.tompublisher.com:servicetest02";
+    
+    final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
+    
+    private static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
+	
+	protected static TckTModel tckTModel               = null;
+	protected static TckTModel tckTModel01             = null;
+	protected static TckTModel tckTModel02             = null;	
+	
+	protected static TckBusiness tckBusiness1          = null;
+	protected static TckBusiness tckBusiness2          = null;
+	protected static String authInfoJoe                = null;
+	
+	private static UDDIInquiryPortType inquiry = null;
+	private static UDDIClerkManager manager;
+
+	@AfterClass
+	public static void stopManager() throws ConfigurationException {
+		manager.stop();
+	}
+	
+	@BeforeClass
+	public static void startManager() throws ConfigurationException {
+		manager  = new UDDIClerkManager();
+		manager.start();
+		
+		logger.debug("Getting auth tokens..");
+		try {
+			 Transport transport = manager.getTransport();
+        	 UDDISecurityPortType security = transport.getUDDISecurityService();
+        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
+        	 Assert.assertNotNull(authInfoJoe);
+        	 UDDIPublicationPortType publication = transport.getUDDIPublishService();
+        	 inquiry = transport.getUDDIInquiryService();
+        	 
+        	 tckTModel  = new TckTModel(publication, inquiry);
+        	 tckTModel01 = new TckTModel(publication, inquiry);
+        	 tckTModel02 = new TckTModel(publication, inquiry);
+        	 tckBusiness1 = new TckBusiness(publication, inquiry);
+        	 tckBusiness2 = new TckBusiness(publication, inquiry); 
+	     } catch (Exception e) {
+	    	 logger.error(e.getMessage(), e);
+				Assert.fail("Could not obtain authInfo token.");
+	     } 
+	}
+	
+	@Test
+	public void tompublisher() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel01.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel02.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness1.saveBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+			tckBusiness2.saveBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			try {
+				int size = 0;
+				ServiceList sl = null;
+
+				FindService fs = new FindService();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add("combineCategoryBags");
+				fs.setFindQualifiers(fqs);
+
+	                        KeyedReference keyRef1 = new KeyedReference();
+	                        keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+	                        keyRef1.setKeyValue("value-z");
+	                        
+	                        KeyedReference keyRef2 = new KeyedReference();
+	                        keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				keyRef2.setKeyValue("value-x");
+				
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				cb.getKeyedReference().add(keyRef2);
+				fs.setCategoryBag(cb);
+				
+				sl = inquiry.findService(fs);
+				if (sl.getServiceInfos() == null) {
+                                    Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+                                            + "found " + size);
+				}
+				size = sl.getServiceInfos().getServiceInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				} else {
+				        List<ServiceInfo> siList = sl.getServiceInfos().getServiceInfo();
+					String serviceKey = siList.get(0).getServiceKey();
+					if (!SERVICE_KEY.equals(serviceKey)) {
+					    Assert.fail("Should have found service key " + SERVICE_KEY
+					            + " but found [" + serviceKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+                        tckBusiness1.deleteBusinesses(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY, 1);
+                        tckBusiness2.deleteBusinesses(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY, 1);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel01.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel02.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+		}
+	}
+	
+}

Added: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java?rev=1124478&view=auto
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java (added)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest.java Thu May 19 00:31:17 2011
@@ -0,0 +1,174 @@
+package org.apache.juddi.v3.tck;
+
+/*
+ * Copyright 2001-2009 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.config.UDDIClerkManager;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.uddi.api_v3.BusinessInfo;
+import org.uddi.api_v3.BusinessList;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.FindBusiness;
+import org.uddi.api_v3.FindQualifiers;
+import org.uddi.api_v3.FindService;
+import org.uddi.api_v3.KeyedReference;
+import org.uddi.api_v3.ServiceInfo;
+import org.uddi.api_v3.ServiceList;
+import org.uddi.api_v3.TModelBag;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+
+/**
+ * Test to verify JUDDI-456, does a findBusiness query with combineCategoryBags findQualifier.
+ * 
+ * Expected result is one returned businessEntity with a businessKey of uddi:uddi.tompublisher.com:businesstest04
+ * 
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ */
+public class UDDI_130_CombineCategoryBagsFindBusinessIntegrationTest 
+{
+    final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
+    final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
+    final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
+
+    final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
+    final static String TOM_PUBLISHER_TMODEL01_KEY      = "uddi:uddi.tompublisher.com:tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL01_NAME 	= "tmodeltest01";
+    final static String TOM_PUBLISHER_TMODEL02_KEY      = "uddi:uddi.tompublisher.com:tmodeltest02";
+
+    final static String TOM_BUSINESS1_XML       = "uddi_data/tompublisher/juddi456-business3.xml";
+    final static String TOM_BUSINESS2_XML       = "uddi_data/tompublisher/juddi456-business4.xml";
+    
+    final static String TOM_BUSINESS1_KEY        = "uddi:uddi.tompublisher.com:businesstest03";
+    final static String TOM_BUSINESS2_KEY        = "uddi:uddi.tompublisher.com:businesstest04";
+
+    final static String BUSINESS_KEY = "uddi:uddi.tompublisher.com:businesstest04";
+        
+    private static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
+	
+	protected static TckTModel tckTModel               = null;
+	protected static TckTModel tckTModel01             = null;
+	protected static TckTModel tckTModel02             = null;	
+	
+	protected static TckBusiness tckBusiness1          = null;
+	protected static TckBusiness tckBusiness2          = null;
+	protected static String authInfoJoe                = null;
+	
+	private static UDDIInquiryPortType inquiry = null;
+	private static UDDIClerkManager manager;
+
+	@AfterClass
+	public static void stopManager() throws ConfigurationException {
+		manager.stop();
+	}
+	
+	@BeforeClass
+	public static void startManager() throws ConfigurationException {
+		manager  = new UDDIClerkManager();
+		manager.start();
+		
+		logger.debug("Getting auth tokens..");
+		try {
+			 Transport transport = manager.getTransport();
+        	 UDDISecurityPortType security = transport.getUDDISecurityService();
+        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
+        	 Assert.assertNotNull(authInfoJoe);
+        	 UDDIPublicationPortType publication = transport.getUDDIPublishService();
+        	 inquiry = transport.getUDDIInquiryService();
+        	 
+        	 tckTModel  = new TckTModel(publication, inquiry);
+        	 tckTModel01 = new TckTModel(publication, inquiry);
+        	 tckTModel02 = new TckTModel(publication, inquiry);
+        	 tckBusiness1 = new TckBusiness(publication, inquiry);
+        	 tckBusiness2 = new TckBusiness(publication, inquiry); 
+	     } catch (Exception e) {
+	    	 logger.error(e.getMessage(), e);
+				Assert.fail("Could not obtain authInfo token.");
+	     } 
+	}
+	
+	@Test
+	public void tompublisher() {
+		try {
+			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel01.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel02.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+			
+			tckBusiness1.saveBusiness(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY);
+			tckBusiness2.saveBusiness(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY);
+			try {
+				int size = 0;
+				BusinessList bl = null;
+
+				FindBusiness fb = new FindBusiness();
+				FindQualifiers fqs = new FindQualifiers();
+				fqs.getFindQualifier().add("combineCategoryBags");
+				fb.setFindQualifiers(fqs);
+
+	                        KeyedReference keyRef1 = new KeyedReference();
+	                        keyRef1.setTModelKey(TOM_PUBLISHER_TMODEL01_KEY);
+	                        keyRef1.setKeyValue("value-z");
+	                        
+	                        KeyedReference keyRef2 = new KeyedReference();
+	                        keyRef2.setTModelKey(TOM_PUBLISHER_TMODEL02_KEY);
+				keyRef2.setKeyValue("value-x");
+				
+				CategoryBag cb = new CategoryBag();
+				cb.getKeyedReference().add(keyRef1);
+				cb.getKeyedReference().add(keyRef2);
+				fb.setCategoryBag(cb);
+				
+				bl = inquiry.findBusiness(fb);
+				if (bl.getBusinessInfos() == null) {
+                                    Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+                                            + "found " + size);
+				}
+				size = bl.getBusinessInfos().getBusinessInfo().size();
+				if (size != 1) {
+					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+							+ "found " + size);
+				} else {
+				        List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
+					String businessKey = biList.get(0).getBusinessKey();
+					if (!BUSINESS_KEY.equals(businessKey)) {
+					    Assert.fail("Should have found business key " + BUSINESS_KEY
+					            + " but found [" + businessKey + "]");
+					}
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				Assert.fail(e.getMessage());
+			}
+		} finally {
+                        tckBusiness1.deleteBusiness(authInfoJoe, TOM_BUSINESS1_XML, TOM_BUSINESS1_KEY);
+                        tckBusiness2.deleteBusiness(authInfoJoe, TOM_BUSINESS2_XML, TOM_BUSINESS2_KEY);
+			
+			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+			tckTModel01.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+			tckTModel02.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+		}
+	}	
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org