1 /* 2 * Copyright 2001-2008 The Apache Software Foundation. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 package org.apache.juddi.query; 19 20 import java.util.List; 21 22 import javax.persistence.EntityManager; 23 24 import org.apache.juddi.query.util.FindQualifiers; 25 import org.uddi.api_v3.CategoryBag; 26 27 /** 28 * Returns the list of business keys possessing the keyedReferenceGroups in the passed category bag. 29 * Output is restricted by list of business keys passed in. If null, all business entities are searched. 30 * Output is produced by building the appropriate JPA query based on input and find qualifiers. 31 * 32 * From specification: 33 * "combineCategoryBags: this may only be used in the find_business and find_service calls. In the case of 34 * find_business, this qualifier makes the categoryBag entries for the full businessEntity element behave as though all 35 * categoryBag elements found at the businessEntity level and in all contained or referenced businessService elements 36 * and bindingTemplate elements were combined. Searching for a category will yield a positive match on a registered 37 * business if any of the categoryBag elements contained within the full businessEntity element (including the 38 * categoryBag elements within contained or referenced businessService elements or bindingTemplate elements) 39 * contains the filter criteria. In the case of find_service, this qualifier makes the categoryBag entries 40 * for the full businessService element behave as though all categoryBag elements found at the businessService level 41 * and in all contained or referenced elements in the bindingTemplate elements were combined. Searching for a category 42 * will yield a positive match on a registered service if any of the categoryBag elements contained within the 43 * full businessService element (including the categoryBag elements within contained or referenced bindingTemplate 44 * elements) contains the filter criteria. This find qualifier does not cause the keyedReferences in categoryBags 45 * to be combined with the keyedReferences in keyedReferenceGroups in categoryBags when performing the comparison. 46 * The keyedReferences are combined with each other, and the keyedReferenceGroups are combined with each other." 47 * 48 * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a> 49 */ 50 public class FindBusinessByCombinedCategoryQuery { 51 52 private static final String ENTITY_NAME_CHILD = "BusinessCategoryBag"; 53 private static final String ENTITY_FIELD2 = "businessService." + BusinessEntityQuery.ENTITY_FIELD; 54 private static final String ENTITY_NAME_CHILD2 = "ServiceCategoryBag"; 55 private static final String ENTITY_FIELD3 = "bindingTemplate.businessService." + BusinessEntityQuery.ENTITY_FIELD; 56 private static final String ENTITY_NAME_CHILD3 = "BindingCategoryBag"; 57 58 59 private static FindEntityByCombinedCategoryQuery findQuery; 60 61 static { 62 findQuery = new FindEntityByCombinedCategoryQuery(BusinessEntityQuery.ENTITY_NAME, 63 BusinessEntityQuery.ENTITY_ALIAS, 64 BusinessEntityQuery.KEY_NAME, 65 BusinessEntityQuery.ENTITY_FIELD, 66 ENTITY_NAME_CHILD, 67 ENTITY_FIELD2, 68 ENTITY_NAME_CHILD2, 69 ENTITY_FIELD3, 70 ENTITY_NAME_CHILD3, 71 BusinessEntityQuery.SIGNATURE_PRESENT); 72 } 73 74 public static List<Object> select(EntityManager em, FindQualifiers fq, CategoryBag categoryBag, List<Object> keysIn) { 75 return findQuery.select(em, fq, categoryBag, keysIn); 76 } 77 }