This project has retired. For details please refer to its Attic page.
FindBusinessByNameQuery xref
View Javadoc
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  import javax.persistence.EntityManager;
22  
23  import org.apache.juddi.query.util.FindQualifiers;
24  import org.uddi.api_v3.Name;
25  
26  /**
27   * Returns the list of business keys possessing the Names in the passed Name list.
28   * Output is restricted by list of business keys passed in.  If null, all businesses are searched.
29   * Output is produced by building the appropriate JPA query based on input and find qualifiers.
30   *
31   * From specification:
32   * "This optional collection of string values represents one or more names potentially qualified with xml:lang attributes. 
33   * Since "exactMatch" is the default behavior, the value supplied for the name argument must be an exact match.  If the "approximateMatch" 
34   * findQualifier is used together with an appropriate wildcard character in the name, then any businessEntity matching this name with 
35   * wildcards and the other criteria will be referenced in the results.  For more on wildcard matching, see Section 5.1.6 About Wildcards.   
36   * The businessList returned contains businessInfo structures for businesses whose name matches the value(s) passed 
37   * (lexical-order match i.e., leftmost in left-to-right languages).  If multiple name values are passed, the match occurs on a 
38   * logical OR basis. Each name MAY be marked with an xml:lang adornment.  If a language markup is specified, the search results report a 
39   * match only on those entries that match both the name value and language criteria. The match on language is a leftmost case-insensitive 
40   * comparison of the characters supplied. This allows one to find all businesses whose name begins with an "A" and are expressed in any 
41   * dialect of French, for example.  Values which can be passed in the language criteria adornment MUST obey the rules governing the 
42   * xml:lang data type as defined in Section 3.3.2.3 name."
43   *  
44   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
45   */
46  public class FindBusinessByNameQuery {
47  
48  	public static final String ENTITY_NAME_CHILD = "BusinessName";
49  	
50  	private final static FindEntityByNamesQuery findQuery;
51  	
52  	static {
53  		findQuery = new FindEntityByNamesQuery(BusinessEntityQuery.ENTITY_NAME, 
54  											   BusinessEntityQuery.ENTITY_ALIAS, 
55  											   BusinessEntityQuery.KEY_NAME, 
56  											   BusinessEntityQuery.ENTITY_FIELD, 
57  											   ENTITY_NAME_CHILD,
58  											   BusinessEntityQuery.SIGNATURE_PRESENT);
59  	}
60  
61  	public static List<Object> select(EntityManager em, FindQualifiers fq, List<Name> names, List<Object> keysIn) {
62  		return findQuery.select(em, fq, names, keysIn);
63  	}
64  	
65  }