juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfa...@apache.org
Subject svn commit: r727243 - in /webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi: api/impl/ model/ query/
Date Wed, 17 Dec 2008 01:53:32 GMT
Author: jfaath
Date: Tue Dec 16 17:53:32 2008
New Revision: 727243

URL: http://svn.apache.org/viewvc?rev=727243&view=rev
Log:
JUDDI-159:  adding searching by categories.  This does not complete this issue - searching
by category groups must still be done.

Added:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java
  (with props)
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
  (with props)
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
  (with props)
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java
  (with props)
Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingCategoryBag.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessCategoryBag.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/OperationalInfo.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/ServiceCategoryBag.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/TmodelCategoryBag.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCategoryQuery.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByTModelKeyQuery.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByIdentifierQuery.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByTModelKeyQuery.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/api/impl/UDDIInquiryImpl.java
Tue Dec 16 17:53:32 2008
@@ -28,13 +28,17 @@
 import org.apache.juddi.query.FetchBusinessEntitiesQuery;
 import org.apache.juddi.query.FetchBusinessServicesQuery;
 import org.apache.juddi.query.FetchTModelsQuery;
+import org.apache.juddi.query.FindBindingByCategoryQuery;
 import org.apache.juddi.query.FindBindingByTModelKeyQuery;
+import org.apache.juddi.query.FindBusinessByCategoryQuery;
 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.FindServiceByCategoryQuery;
 import org.apache.juddi.query.FindServiceByNameQuery;
 import org.apache.juddi.query.FindServiceByTModelKeyQuery;
+import org.apache.juddi.query.FindTModelByCategoryQuery;
 import org.apache.juddi.query.FindTModelByIdentifierQuery;
 import org.apache.juddi.query.FindTModelByNameQuery;
 import org.apache.juddi.query.PersistenceManager;
@@ -100,7 +104,7 @@
 		doFindTModelEmbeddedSearch(em, body.getFindQualifiers(), body.getFindTModel(), body.getTModelBag());
 		
 		keysFound = FindBindingByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(),
body.getServiceKey(), keysFound);
-		//keysFound = FindBindingByCategoryQuery.select(em, findQualifiers, tmodelKeys, body.getServiceKey(),
keysFound);
+		keysFound = FindBindingByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
body.getServiceKey(), keysFound);
 
 		BindingDetail result = new BindingDetail();
 		ListDescription listDesc = new ListDescription();
@@ -171,7 +175,7 @@
 		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);
+		keysFound = FindBusinessByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
keysFound);
 		keysFound = FindBusinessByNameQuery.select(em, findQualifiers, body.getName(), keysFound);
 
 		BusinessList result = new BusinessList();
@@ -322,7 +326,7 @@
 		
 		List<?> keysFound = null;
 		FindServiceByTModelKeyQuery.select(em, findQualifiers, body.getTModelBag(), body.getBusinessKey(),
keysFound);
-		//keysFound = FindServiceByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
body.getBusinessKey, keysFound);
+		keysFound = FindServiceByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
body.getBusinessKey(), keysFound);
 		keysFound = FindServiceByNameQuery.select(em, findQualifiers, body.getName(), body.getBusinessKey(),
keysFound);
 
 		ServiceList result = new ServiceList();
@@ -366,7 +370,7 @@
 
 		List<?> keysFound = null;
 		keysFound = FindTModelByIdentifierQuery.select(em, findQualifiers, body.getIdentifierBag(),
keysFound);
-		//keysFound = FindTModelByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
keysFound);
+		keysFound = FindTModelByCategoryQuery.select(em, findQualifiers, body.getCategoryBag(),
keysFound);
 		keysFound = FindTModelByNameQuery.select(em, findQualifiers, body.getName(), keysFound);
 
 		TModelList result = new TModelList();

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingCategoryBag.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingCategoryBag.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingCategoryBag.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingCategoryBag.java
Tue Dec 16 17:53:32 2008
@@ -41,7 +41,7 @@
 	} 
 	
 	@OneToOne(optional=false, fetch = FetchType.LAZY)
-    @JoinColumn(name = "binding_template_id")
+    @JoinColumn(name = "entity_key")
 	public BindingTemplate getBindingTemplate() {
 		return bindingTemplate;
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessCategoryBag.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessCategoryBag.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessCategoryBag.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessCategoryBag.java
Tue Dec 16 17:53:32 2008
@@ -41,7 +41,7 @@
 	}
 	
 	@OneToOne(optional=false, fetch = FetchType.LAZY)
-    @JoinColumn(name = "business_entity_id")
+    @JoinColumn(name = "entity_key")
 	public BusinessEntity getBusinessEntity() {
 		return businessEntity;
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/OperationalInfo.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/OperationalInfo.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/OperationalInfo.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/OperationalInfo.java
Tue Dec 16 17:53:32 2008
@@ -90,7 +90,7 @@
 		this.modifiedIncludingChildren = modifiedIncludingChildren;
 	}
 
-	@Column(name = "key_id", nullable = false, length = 255)
+	@Column(name = "node_id", nullable = false, length = 255)
 	public String getNodeId() {
 		return nodeId;
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/ServiceCategoryBag.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/ServiceCategoryBag.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/ServiceCategoryBag.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/ServiceCategoryBag.java
Tue Dec 16 17:53:32 2008
@@ -41,7 +41,7 @@
 	}
 	
 	@OneToOne(optional=false, fetch = FetchType.LAZY)
-    @JoinColumn(name = "business_service_id")
+    @JoinColumn(name = "entity_key")
 	public BusinessService getBusinessService() {
 		return businessService;
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/TmodelCategoryBag.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/TmodelCategoryBag.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/TmodelCategoryBag.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/TmodelCategoryBag.java
Tue Dec 16 17:53:32 2008
@@ -39,7 +39,7 @@
 	}
 	
 	@OneToOne(optional=false, fetch = FetchType.LAZY)
-    @JoinColumn(name = "tmodel_id")
+    @JoinColumn(name = "entity_key")
 	public Tmodel getTmodel() {
 		return tmodel;
 	}

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/EntityQuery.java
Tue Dec 16 17:53:32 2008
@@ -41,11 +41,12 @@
 	public static final int DEFAULT_MAXROWS = 100;
 	public static final int DEFAULT_MAXINCLAUSE = 1000;
 	
+	// TODO:  make this alias creator a little more unique
 	public static String buildAlias(String entityName) {
 		if (entityName == null || entityName.length() == 0)
 			return "x";
 		
-		return entityName.substring(0, entityName.length() - 3);
+		return entityName.substring(0, entityName.length() - 3) + "_";
 	}
 	
 	/*

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java?rev=727243&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java
Tue Dec 16 17:53:32 2008
@@ -0,0 +1,62 @@
+/*
+ * 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 binding keys possessing the keyedReferences in the passed category
bag.
+ * Output is restricted by list of binding keys passed in.  If null, all binding templates
are searched.
+ * Output is produced by building the appropriate JPA query based on input and find qualifiers.
+ * 
+ * From specification:
+ * "This optional argument is a list of category references in the form of keyedReference
elements and keyedReferenceGroup
+ *  structures.  When used, the returned bindingDetail for this API will contain elements
matching all of the categories 
+ *  passed (logical AND by default).   Specifying the appropriate findQualifiers can override
this behavior."
+ * 
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class FindBindingByCategoryQuery {
+	
+	private static final String ENTITY_NAME_CHILD = "BindingCategoryBag";
+	
+	private static FindEntityByCategoryQuery findQuery;
+	
+	static {
+		findQuery = new FindEntityByCategoryQuery(BindingTemplateQuery.ENTITY_NAME, 
+												  BindingTemplateQuery.ENTITY_ALIAS, 
+												  BindingTemplateQuery.KEY_NAME, 
+												  BindingTemplateQuery.ENTITY_FIELD, 
+												  ENTITY_NAME_CHILD);
+	}
+	
+	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(BindingTemplateQuery.ENTITY_ALIAS
+ "." + BindingTemplateQuery.KEY_NAME_PARENT, parentKey, DynamicQuery.PREDICATE_EQUALS); 
+			return findQuery.select(em, fq, categoryBag, keysIn, param);
+		}
+		else
+			return findQuery.select(em, fq, categoryBag, keysIn);
+	}
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBindingByCategoryQuery.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCategoryQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCategoryQuery.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCategoryQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByCategoryQuery.java
Tue Dec 16 17:53:32 2008
@@ -18,125 +18,39 @@
 package org.apache.juddi.query;
 
 import java.util.List;
+
 import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import javax.xml.bind.JAXBElement;
 
-import org.apache.juddi.config.Constants;
-import org.apache.juddi.query.util.DynamicQuery;
 import org.apache.juddi.query.util.FindQualifiers;
 import org.uddi.api_v3.CategoryBag;
-import org.uddi.api_v3.KeyedReference;
-import org.uddi.api_v3.KeyedReferenceGroup;
 
 /**
+ * Returns the list of business keys possessing the keyedReferences 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:
+ * "This is a list of category references in the form of keyedReference elements and keyedReferenceGroup

+ * structures.  The returned businessList contains businessInfo elements matching all of
the categories 
+ * passed (logical AND by default).   Specifying the appropriate findQualifiers can override
this behavior."
+ * 
  * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
  */
 public class FindBusinessByCategoryQuery {
 	
-	private static String selectSQL;
+	private static final String ENTITY_NAME_CHILD = "BusinessCategoryBag";
 	
-	static {
-		StringBuffer sql = new StringBuffer(200);
-		sql.append("select bc.id.businessKey from BusinessCategory bc ");
-		selectSQL = sql.toString();
-	}
-
-	public static List<?> select(FindQualifiers fq, CategoryBag categories, List<Object>
keysIn, EntityManager em) {
-		// If keysIn is not null and empty, then search is over.
-		if ((keysIn != null) && (keysIn.size() == 0))
-			return keysIn;
-		
-		if (categories == null)
-			return keysIn;
-		
-		List<JAXBElement<?>> catElems = categories.getContent();
-		if (catElems == null || catElems.size() == 0)
-			return keysIn;
-		
-		DynamicQuery dynamicQry = new DynamicQuery(selectSQL);
-		appendConditions(dynamicQry, fq, catElems, keysIn);
-		
-		System.out.println(dynamicQry);
-		
-		Query qry = dynamicQry.buildJPAQuery(em);
-		List<?> result = qry.getResultList();
-		
-		return result;
-	}
+	private static FindEntityByCategoryQuery findQuery;
 	
-	public static void appendConditions(DynamicQuery qry, FindQualifiers fq, List<JAXBElement<?>>
catElems, List<Object> keysIn) {
-		String predicate = DynamicQuery.PREDICATE_EQUALS;
-		if (fq.isApproximateMatch()) {
-			predicate = DynamicQuery.PREDICATE_LIKE;
-		}
-		
-		int count = 0;
-		qry.WHERE().pad().openParen().pad();
-		for(JAXBElement<?> elem : catElems) {
-			String tmodelKey = null;
-			String keyValue = null;
-			String keyName = null;
-			
-			if (elem != null && elem.getValue() instanceof KeyedReference) {
-				KeyedReference kr = (KeyedReference)elem.getValue();
-				tmodelKey = kr.getTModelKey();
-				keyValue = kr.getKeyValue();
-				keyName = kr.getKeyName();
-			}
-			else if (elem != null && elem.getValue() instanceof KeyedReferenceGroup) {
-				
-			}
-			
-			if (fq.isApproximateMatch()) {
-				keyValue = keyValue.endsWith(DynamicQuery.WILDCARD)?keyValue:keyValue + DynamicQuery.WILDCARD;
-				keyName = keyName.endsWith(DynamicQuery.WILDCARD)?keyName:keyName + DynamicQuery.WILDCARD;
-			}
-
-			String keyValueTerm = "bc.keyValue";
-			String keyNameTerm = "bc.keyName";
-			if (fq.isCaseInsensitiveMatch()) {
-				keyValueTerm = "upper(bc.keyValue)";
-				keyValue = keyValue.toUpperCase();
-				
-				keyNameTerm = "upper(bc.keyName)";
-				keyName = keyName.toUpperCase();
-			}
-			
-			if (Constants.GENERAL_KEYWORD_TMODEL.equalsIgnoreCase(tmodelKey)) {
-				qry.appendGroupedAnd(new DynamicQuery.Parameter("bc.tmodelKeyRef", tmodelKey, DynamicQuery.PREDICATE_EQUALS),
-									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate),
-									 new DynamicQuery.Parameter(keyNameTerm, keyName, predicate));
-			}
-			else {
-				qry.appendGroupedAnd(new DynamicQuery.Parameter("bc.tmodelKeyRef", tmodelKey, DynamicQuery.PREDICATE_EQUALS),
-									 new DynamicQuery.Parameter(keyValueTerm, keyValue, predicate));
-				
-			}
-			
-			if (count + 1 < catElems.size()) {
-				if (fq.isOrAllKeys())
-					qry.OR().pad();
-				else
-					qry.AND().pad();
-			}
-			
-			count++;
-		}
-		qry.closeParen().pad();
-		
-		qry.appendInListWithAnd("bc.id.businessKey", keysIn);
+	static {
+		findQuery = new FindEntityByCategoryQuery(BusinessEntityQuery.ENTITY_NAME, 
+												  BusinessEntityQuery.ENTITY_ALIAS, 
+												  BusinessEntityQuery.KEY_NAME, 
+												  BusinessEntityQuery.ENTITY_FIELD, 
+												  ENTITY_NAME_CHILD);
 	}
 	
-	public static void appendGrouping(DynamicQuery qry, FindQualifiers fq, int elemCount) {
-		qry.GROUPBY().pad().append("bc.id.businessKey").pad();
-		
-		// By default, all the "keys" switches in find qualifiers are turned off.  The default
behavior for categories is to "AND" the keyed references.
-		if (fq.isOrAllKeys()) {
-			// do nothing
-		}
-		else
-			qry.HAVING().pad().append("count(bc.id.businessKey >=" + elemCount).pad();
-		
+	public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag,
List<?> keysIn) {
+		return findQuery.select(em, fq, categoryBag, keysIn);
 	}
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByTModelKeyQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByTModelKeyQuery.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByTModelKeyQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindBusinessByTModelKeyQuery.java
Tue Dec 16 17:53:32 2008
@@ -130,21 +130,21 @@
 					if (!fq.isOrAllKeys()) {
 						tblCount++;
 						qry.comma().pad().append(ENTITY_NAME_CHILD + " " + entityAliasChild + tblCount).pad();
-						thetaJoins.append(entityAliasChild + (tblCount - 1) + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
+						thetaJoins.append(entityAliasChild + (tblCount - 1) + "." + BindingTemplateQuery.ENTITY_FIELD
+ "." + BindingTemplateQuery.KEY_NAME + " = " + entityAliasChild + tblCount + "." + BindingTemplateQuery.ENTITY_FIELD
+ "." + BindingTemplateQuery.KEY_NAME + " ");
 						thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
 					}
 				}
 				else {
 					qry.comma().pad().append(ENTITY_NAME_CHILD + " " + entityAliasChild + tblCount).pad();
-					thetaJoins.append(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
+					thetaJoins.append(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + BindingTemplateQuery.ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
 					thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
 				}
 			}
 			
 			qry.WHERE().pad().openParen().pad();
 			
-			qry.append(ENTITY_ALIAS + "." + KEY_NAME + " = " + BusinessServiceQuery.ENTITY_ALIAS +
".businessEntity." + KEY_NAME).pad();
-			qry.AND().pad().append(BusinessServiceQuery.ENTITY_ALIAS + "." + BusinessServiceQuery.KEY_NAME
+ " = " + BindingTemplateQuery.ENTITY_ALIAS + ".businessService." + BusinessServiceQuery.KEY_NAME).pad();
+			qry.append(ENTITY_ALIAS + "." + KEY_NAME + " = " + BusinessServiceQuery.ENTITY_ALIAS +
"." + ENTITY_FIELD + "." + KEY_NAME).pad();
+			qry.AND().pad().append(BusinessServiceQuery.ENTITY_ALIAS + "." + BusinessServiceQuery.KEY_NAME
+ " = " + BindingTemplateQuery.ENTITY_ALIAS + "." + BusinessServiceQuery.ENTITY_FIELD + "."
+ BusinessServiceQuery.KEY_NAME).pad();
 			qry.AND().pad();
 			
 			String thetaJoinsStr = thetaJoins.toString();

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java?rev=727243&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
Tue Dec 16 17:53:32 2008
@@ -0,0 +1,291 @@
+/*
+ * 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.List;
+import java.util.Collections;
+import javax.persistence.EntityManager;
+import javax.xml.bind.JAXBElement;
+
+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.apache.log4j.Logger;
+import org.uddi.api_v3.CategoryBag;
+import org.uddi.api_v3.KeyedReference;
+
+/**
+ * Returns the list of "entity" keys possessing the keyedReferences in the passed category
bag.
+ * 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.
+ * 
+ * NOTES:
+ * 1) Identifiers 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>
+ */
+public class FindEntityByCategoryQuery extends EntityQuery {
+	
+	private Logger log = Logger.getLogger(FindEntityByCategoryQuery.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 entityName;
+	private String entityAlias;
+	private String keyName;
+	private String entityField;
+	private String entityNameChild;
+	private String entityAliasChild;
+	private String selectSQL;
+
+	public FindEntityByCategoryQuery(String entityName, String entityAlias, String keyName,
String entityField, String entityNameChild) {
+		this.entityName = entityName;
+		this.entityAlias = entityAlias;
+		this.keyName = keyName;
+		this.entityField = entityField;
+		this.entityNameChild = entityNameChild;
+		this.entityAliasChild = buildAlias(entityNameChild);
+		
+		StringBuffer sql = new StringBuffer(200);
+		sql.append("select distinct " + entityAlias + "." + keyName + " from " + entityName + "
" + entityAlias + " , " + entityNameChild + " " + entityAliasChild + " ");
+		selectSQL = sql.toString();
+	}
+	
+	public String getEntityName() {
+		return entityName;
+	}
+
+	public String getEntityAlias() {
+		return entityAlias;
+	}
+
+	public String getKeyName() {
+		return keyName;
+	}
+
+	public String getEntityField() {
+		return entityField;
+	}
+
+	public String getEntityNameChild() {
+		return entityNameChild;
+	}
+	
+	public String getEntityAliasChild() {
+		return entityAliasChild;
+	}
+	
+	public String getSelectSQL() {
+		return selectSQL;
+	}
+
+	
+	public List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag,
List<?> keysIn, DynamicQuery.Parameter... restrictions) {
+		// 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<JAXBElement<?>> categories = categoryBag.getContent();
+		if (categories == null || categories.size() == 0)
+			return keysIn;
+		
+		List<KeyedReference> keyedRefs = new ArrayList<KeyedReference>(0);
+		for (JAXBElement<?> elem : categories) {
+			if (elem.getValue() instanceof KeyedReference)
+				keyedRefs.add((KeyedReference)elem.getValue());
+		}
+		if (keyedRefs.size() == 0)
+			return keysIn;		
+		
+		DynamicQuery dynamicQry = new DynamicQuery(selectSQL);
+		appendConditions(dynamicQry, fq, keyedRefs);
+		if (restrictions != null && restrictions.length > 0)
+			dynamicQry.AND().pad().appendGroupedAnd(restrictions);
+
+		return getQueryResult(em, dynamicQry, keysIn, entityAlias + "." + keyName);
+	}
+	
+	
+	/*
+	 * 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()) {
+				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(entityAliasChild + ".id = " + ALIAS_KEYEDREFERENCE + tblCount + "."
+ FIELD_CATEGORYBAG + ".id ");
+					thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
+				}
+				prevTModelKey = curTModelKey;
+				count++;
+			}
+			
+			qry.WHERE().pad().openParen().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();
+		}
+	}
+	
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByCategoryQuery.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByIdentifierQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByIdentifierQuery.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByIdentifierQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindEntityByIdentifierQuery.java
Tue Dec 16 17:53:32 2008
@@ -174,14 +174,14 @@
 			else
 				tblCount++;
 			
-			String keyValueTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAlias
+ "0") + ".keyValue";
-			String keyNameTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAlias
+ "0") + ".keyName";
-			String tmodelKeyTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAlias
+ "0") + ".tmodelKeyRef";
+			String keyValueTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAliasChild
+ "0") + ".keyValue";
+			String keyNameTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAliasChild
+ "0") + ".keyName";
+			String tmodelKeyTerm = (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAliasChild
+ "0") + ".tmodelKeyRef";
 			if (fq.isCaseInsensitiveMatch()) {
-				keyValueTerm = "upper(" + (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAlias
+ "0") + ".keyValue)";
+				keyValueTerm = "upper(" + keyValueTerm + ")";
 				keyValue = keyValue.toUpperCase();
 				
-				keyNameTerm = "upper(" + (fq.isAndAllKeys()||fq.isOrLikeKeys()?entityAliasChild + tblCount:entityAlias
+ "0") + ".keyName)";
+				keyNameTerm = "upper(" + keyNameTerm + ")";
 				keyName = keyName.toUpperCase();
 			}
 			

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java?rev=727243&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
Tue Dec 16 17:53:32 2008
@@ -0,0 +1,61 @@
+/*
+ * 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:
+ * "This is a list of category references.  The returned serviceList contains serviceInfo
structures matching all of 
+ * the categories passed (logical AND by default).   Specifying the appropriate findQualifiers
can override this behavior."
+ * 
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class FindServiceByCategoryQuery {
+	
+	private static final String ENTITY_NAME_CHILD = "ServiceCategoryBag";
+	
+	private static FindEntityByCategoryQuery findQuery;
+	
+	static {
+		findQuery = new FindEntityByCategoryQuery(BusinessServiceQuery.ENTITY_NAME, 
+												  BusinessServiceQuery.ENTITY_ALIAS, 
+												  BusinessServiceQuery.KEY_NAME, 
+												  BusinessServiceQuery.ENTITY_FIELD, 
+												  ENTITY_NAME_CHILD);
+	}
+	
+	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);
+	}
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByCategoryQuery.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByTModelKeyQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByTModelKeyQuery.java?rev=727243&r1=727242&r2=727243&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByTModelKeyQuery.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindServiceByTModelKeyQuery.java
Tue Dec 16 17:53:32 2008
@@ -131,20 +131,20 @@
 					if (!fq.isOrAllKeys()) {
 						tblCount++;
 						qry.comma().pad().append(ENTITY_NAME_CHILD + " " + entityAliasChild + tblCount).pad();
-						thetaJoins.append(entityAliasChild + (tblCount - 1) + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
+						thetaJoins.append(entityAliasChild + (tblCount - 1) + "." + BindingTemplateQuery.ENTITY_FIELD
+ "." + BindingTemplateQuery.KEY_NAME + " = " + entityAliasChild + tblCount + "." + BindingTemplateQuery.ENTITY_FIELD
+ "." + BindingTemplateQuery.KEY_NAME + " ");
 						thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
 					}
 				}
 				else {
 					qry.comma().pad().append(ENTITY_NAME_CHILD + " " + entityAliasChild + tblCount).pad();
-					thetaJoins.append(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
+					thetaJoins.append(BindingTemplateQuery.ENTITY_ALIAS + "." + BindingTemplateQuery.KEY_NAME
+ " = " + entityAliasChild + tblCount + "." + BindingTemplateQuery.ENTITY_FIELD + "." + BindingTemplateQuery.KEY_NAME
+ " ");
 					thetaJoins.append(DynamicQuery.OPERATOR_AND + " ");
 				}
 			}
 			
 			qry.WHERE().pad().openParen().pad();
 			
-			qry.append(ENTITY_ALIAS + "." + KEY_NAME + " = " + BindingTemplateQuery.ENTITY_ALIAS +
".businessService." + KEY_NAME).pad();
+			qry.append(ENTITY_ALIAS + "." + KEY_NAME + " = " + BindingTemplateQuery.ENTITY_ALIAS +
"." + ENTITY_FIELD + "." + KEY_NAME).pad();
 			qry.AND().pad();
 		
 			String thetaJoinsStr = thetaJoins.toString();

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java?rev=727243&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java
Tue Dec 16 17:53:32 2008
@@ -0,0 +1,56 @@
+/*
+ * 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 tModel keys possessing the keyedReferences in the passed category
bag.
+ * Output is restricted by list of tModel keys passed in.  If null, all tModels are searched.
+ * Output is produced by building the appropriate JPA query based on input and find qualifiers.
+ * 
+ * From specification:
+ * "This is a list of category references.  The returned tModelList contains tModelInfo elements
whose 
+ * associated tModels match all of the categories passed (logical AND by default).   Specifying
the 
+ * appropriate findQualifiers can override this behavior."
+ * 
+ * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
+ */
+public class FindTModelByCategoryQuery {
+	
+	private static final String ENTITY_NAME_CHILD = "TmodelCategoryBag";
+	
+	private static FindEntityByCategoryQuery findQuery;
+	
+	static {
+		findQuery = new FindEntityByCategoryQuery(TModelQuery.ENTITY_NAME, 
+												  TModelQuery.ENTITY_ALIAS, 
+												  TModelQuery.KEY_NAME, 
+												  TModelQuery.ENTITY_FIELD, 
+												  ENTITY_NAME_CHILD);
+	}
+	
+	public static List<?> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag,
List<?> keysIn) {
+		return findQuery.select(em, fq, categoryBag, keysIn);
+	}
+}

Propchange: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/query/FindTModelByCategoryQuery.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



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


Mime
View raw message