This project has retired. For details please refer to its Attic page.
FindQualifiers 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.util;
19  
20  import java.util.List;
21  
22  import org.apache.juddi.v3.error.ErrorMessage;
23  import org.apache.juddi.v3.error.UnsupportedException;
24  import org.uddi.v3_service.DispositionReportFaultMessage;
25  
26  /**
27   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
28   */
29  public class FindQualifiers {
30  
31  	public static final String AND_ALL_KEYS = "andAllKeys";
32  	public static final String AND_ALL_KEYS_TMODEL = "uddi:uddi.org:findqualifier:andallkeys";
33  
34  	public static final String APPROXIMATE_MATCH = "approximateMatch";
35  	public static final String APPROXIMATE_MATCH_TMODEL = "uddi:uddi.org:findqualifier:approximatematch";
36  
37  	public static final String BINARY_SORT = "binarySort";
38  	public static final String BINARY_SORT_TMODEL = "uddi:uddi.org:sortorder:binarysort";
39  
40  	public static final String BINDING_SUBSET = "bindingSubset";
41  	public static final String BINDING_SUBSET_TMODEL = "uddi:uddi.org:findqualifier:bindingsubset";
42  
43  	public static final String CASE_INSENSITIVE_SORT = "caseInsensitiveSort";
44  	public static final String CASE_INSENSITIVE_SORT_TMODEL = "uddi:uddi.org:findqualifier:caseinsensitivesort";
45  
46  	public static final String CASE_INSENSITIVE_MATCH = "caseInsensitiveMatch";
47  	public static final String CASE_INSENSITIVE_MATCH_TMODEL = "uddi:uddi.org:findqualifier:caseinsensitivematch";
48  
49  	public static final String CASE_SENSITIVE_SORT = "caseSensitiveSort";
50  	public static final String CASE_SENSITIVE_SORT_TMODEL = "uddi:uddi.org:findqualifier:casesensitivesort";
51  
52  	public static final String CASE_SENSITIVE_MATCH = "caseSensitiveMatch";
53  	public static final String CASE_SENSITIVE_MATCH_TMODEL = "uddi:uddi.org:findqualifier:casesensitivematch";
54  
55  	public static final String COMBINE_CATEGORY_BAGS = "combineCategoryBags";
56  	public static final String COMBINE_CATEGORY_BAGS_TMODEL = "uddi:uddi.org:findqualifier:combinecategorybags";
57  
58  	public static final String DIACRITIC_INSENSITIVE_MATCH = "diacriticInsensitiveMatch";
59  	public static final String DIACRITIC_INSENSITIVE_MATCH_TMODEL = "uddi:uddi.org:findqualifier:diacriticsinsensitivematch";
60  
61  	public static final String DIACRITIC_SENSITIVE_MATCH = "diacriticSensitiveMatch";
62  	public static final String DIACRITIC_SENSITIVE_MATCH_TMODEL = "uddi:uddi.org:findqualifier:diacriticssensitivematch";
63  
64  	public static final String EXACT_MATCH = "exactMatch";
65  	public static final String EXACT_MATCH_TMODEL = "uddi:uddi.org:findqualifier:exactmatch";
66  
67  	public static final String SIGNATURE_PRESENT = "signaturePresent";
68  	public static final String SIGNATURE_PRESENT_TMODEL = "uddi:uddi.org:findqualifier:signaturepresent";
69  
70  	public static final String OR_ALL_KEYS = "orAllKeys";
71  	public static final String OR_ALL_KEYS_TMODEL = "uddi:uddi.org:findqualifier:orallkeys";
72  
73  	public static final String OR_LIKE_KEYS = "orLikeKeys";
74  	public static final String OR_LIKE_KEYS_TMODEL = "uddi:uddi.org:findqualifier:orlikekeys";
75  
76  	public static final String SERVICE_SUBSET = "serviceSubset";
77  	public static final String SERVICE_SUBSET_TMODEL = "uddi:uddi.org:findqualifier:servicesubset";
78  
79  	public static final String SORT_BY_NAME_ASC = "sortByNameAsc";
80  	public static final String SORT_BY_NAME_ASC_TMODEL = "uddi:uddi.org:findqualifier:sortbynameasc";
81  
82  	public static final String SORT_BY_NAME_DESC = "sortByNameDesc";
83  	public static final String SORT_BY_NAME_DESC_TMODEL = "uddi:uddi.org:findqualifier:sortbynamedesc";
84  
85  	public static final String SORT_BY_DATE_ASC = "sortByDateAsc";
86  	public static final String SORT_BY_DATE_ASC_TMODEL = "uddi:uddi.org:findqualifier:sortbydateasc";
87  	
88  	public static final String SORT_BY_DATE_DESC = "sortByDateDesc";
89  	public static final String SORT_BY_DATE_DESC_TMODEL = "uddi:uddi.org:findqualifier:sortbydatedesc";
90  
91  	public static final String SUPPRESS_PROJECTED_SERVICES = "suppressProjectedServices";
92  	public static final String SUPPRESS_PROJECTED_SERVICES_TMODEL = "uddi:uddi.org:findqualifier:suppressprojectedservices";
93  
94  	public static final String UTS_10 = "UTS-10";
95  	public static final String UTS_10_TMODEL = "uddi:uddi.org:sortorder:uts-10";
96  	
97  	private boolean andAllKeys = false;
98  	private boolean approximateMatch = false;
99  	private boolean binarySort = false;
100 	private boolean bindingSubset = false;
101 	private boolean caseInsensitiveSort = false;
102 	private boolean caseInsensitiveMatch = false;
103 	private boolean caseSensitiveSort = false;
104 	private boolean caseSensitiveMatch = false;
105 	private boolean combineCategoryBags = false;
106 	private boolean diacriticInsensitiveMatch = false;
107 	private boolean diacriticSensitiveMatch = false;
108 	private boolean exactMatch = false;
109 	private boolean signaturePresent = false;
110 	private boolean orAllKeys = false;
111 	private boolean orLikeKeys = false;
112 	private boolean serviceSubset = false;
113 	private boolean sortByNameAsc = false;
114 	private boolean sortByNameDesc = false;
115 	private boolean sortByDateAsc = false;
116 	private boolean sortByDateDesc = false;
117 	private boolean suppressProjectedServices = false;
118 	private boolean uts10 = false;
119 
120 	public FindQualifiers() {
121 		// These are the defaults as defined by the UDDI specification.
122 		this.setExactMatch(true);
123 		this.setCaseSensitiveMatch(true);
124 		this.setCaseSensitiveSort(true);
125 		this.setDiacriticSensitiveMatch(true);
126 		
127 	}
128 
129 	public void mapApiFindQualifiers(org.uddi.api_v3.FindQualifiers apiFindQualifiers) 
130 			throws DispositionReportFaultMessage {
131 		if (apiFindQualifiers == null)
132 			return;
133 		
134 		List<String> fqList = apiFindQualifiers.getFindQualifier();
135 		if (fqList != null) {
136 			for (String fq : fqList) {
137 				if (fq.equalsIgnoreCase(AND_ALL_KEYS) || fq.equalsIgnoreCase(AND_ALL_KEYS_TMODEL))
138 					this.setAndAllKeys(true);
139 				else if (fq.equalsIgnoreCase(APPROXIMATE_MATCH) || fq.equalsIgnoreCase(APPROXIMATE_MATCH_TMODEL))
140 					this.setApproximateMatch(true);
141 				else if (fq.equalsIgnoreCase(BINARY_SORT) || fq.equalsIgnoreCase(BINARY_SORT_TMODEL))
142 					this.setBinarySort(true);
143 				else if (fq.equalsIgnoreCase(BINDING_SUBSET) || fq.equalsIgnoreCase(BINDING_SUBSET_TMODEL))
144 					this.setBindingSubset(true);
145 				else if (fq.equalsIgnoreCase(CASE_INSENSITIVE_SORT) || fq.equalsIgnoreCase(CASE_INSENSITIVE_SORT_TMODEL))
146 					this.setCaseInsensitiveSort(true);
147 				else if (fq.equalsIgnoreCase(CASE_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(CASE_INSENSITIVE_MATCH_TMODEL))
148 					this.setCaseInsensitiveMatch(true);
149 				else if (fq.equalsIgnoreCase(CASE_SENSITIVE_SORT) || fq.equalsIgnoreCase(CASE_SENSITIVE_SORT_TMODEL))
150 					this.setCaseSensitiveSort(true);
151 				else if (fq.equalsIgnoreCase(CASE_SENSITIVE_MATCH) || fq.equalsIgnoreCase(CASE_SENSITIVE_MATCH_TMODEL))
152 					this.setCaseSensitiveMatch(true);
153 				else if (fq.equalsIgnoreCase(COMBINE_CATEGORY_BAGS) || fq.equalsIgnoreCase(COMBINE_CATEGORY_BAGS_TMODEL))
154 					this.setCombineCategoryBags(true);
155 				else if (fq.equalsIgnoreCase(DIACRITIC_INSENSITIVE_MATCH) || fq.equalsIgnoreCase(DIACRITIC_INSENSITIVE_MATCH_TMODEL))
156 					this.setDiacriticInsensitiveMatch(true);
157 				else if (fq.equalsIgnoreCase(DIACRITIC_SENSITIVE_MATCH) || fq.equalsIgnoreCase(DIACRITIC_SENSITIVE_MATCH_TMODEL))
158 					this.setDiacriticSensitiveMatch(true);
159 				else if (fq.equalsIgnoreCase(EXACT_MATCH) || fq.equalsIgnoreCase(EXACT_MATCH_TMODEL))
160 					this.setExactMatch(true);
161 				else if (fq.equalsIgnoreCase(SIGNATURE_PRESENT) || fq.equalsIgnoreCase(SIGNATURE_PRESENT_TMODEL))
162 					this.setSignaturePresent(true);
163 				else if (fq.equalsIgnoreCase(OR_ALL_KEYS) || fq.equalsIgnoreCase(OR_ALL_KEYS_TMODEL))
164 					this.setOrAllKeys(true);
165 				else if (fq.equalsIgnoreCase(OR_LIKE_KEYS) || fq.equalsIgnoreCase(OR_LIKE_KEYS_TMODEL))
166 					this.setOrLikeKeys(true);
167 				else if (fq.equalsIgnoreCase(SERVICE_SUBSET) || fq.equalsIgnoreCase(SERVICE_SUBSET_TMODEL))
168 					this.setServiceSubset(true);
169 				else if (fq.equalsIgnoreCase(SORT_BY_NAME_ASC) || fq.equalsIgnoreCase(SORT_BY_NAME_ASC_TMODEL))
170 					this.setSortByNameAsc(true);
171 				else if (fq.equalsIgnoreCase(SORT_BY_NAME_DESC) || fq.equalsIgnoreCase(SORT_BY_NAME_DESC_TMODEL))
172 					this.setSortByNameDesc(true);
173 				else if (fq.equalsIgnoreCase(SORT_BY_DATE_ASC) || fq.equalsIgnoreCase(SORT_BY_DATE_ASC_TMODEL))
174 					this.setSortByDateAsc(true);
175 				else if (fq.equalsIgnoreCase(SORT_BY_DATE_DESC) || fq.equalsIgnoreCase(SORT_BY_DATE_DESC_TMODEL))
176 					this.setSortByDateDesc(true);
177 				else if (fq.equalsIgnoreCase(SUPPRESS_PROJECTED_SERVICES) || fq.equalsIgnoreCase(SUPPRESS_PROJECTED_SERVICES_TMODEL))
178 					this.setSuppressProjectedServices(true);
179 				else if (fq.equalsIgnoreCase(UTS_10) || fq.equalsIgnoreCase(UTS_10_TMODEL))
180 					this.setUts10(true);
181 				else 
182 					throw new UnsupportedException(new ErrorMessage("errors.Unsupported.findQualifier", fq));
183 			}
184 		}
185 	}
186 	
187 	public boolean isAndAllKeys() {
188 		return andAllKeys;
189 	}
190 	public void setAndAllKeys(boolean andAllKeys) {
191 		this.andAllKeys = andAllKeys;
192 		this.orAllKeys = !andAllKeys;
193 		this.orLikeKeys = !andAllKeys;
194 	}
195 
196 	public boolean isApproximateMatch() {
197 		return approximateMatch;
198 	}
199 	public void setApproximateMatch(boolean approximateMatch) {
200 		this.approximateMatch = approximateMatch;
201 		this.exactMatch = !approximateMatch;
202 	}
203 
204 	public boolean isBinarySort() {
205 		return binarySort;
206 	}
207 	public void setBinarySort(boolean binarySort) {
208 		this.binarySort = binarySort;
209 		this.uts10 = !binarySort;
210 	}
211 
212 	public boolean isBindingSubset() {
213 		return bindingSubset;
214 	}
215 	public void setBindingSubset(boolean bindingSubset) {
216 		this.bindingSubset = bindingSubset;
217 		this.combineCategoryBags = !bindingSubset;
218 		this.bindingSubset = !bindingSubset;
219 	}
220 
221 	public boolean isCaseInsensitiveSort() {
222 		return caseInsensitiveSort;
223 	}
224 	public void setCaseInsensitiveSort(boolean caseInsensitiveSort) {
225 		this.caseInsensitiveSort = caseInsensitiveSort;
226 		this.caseSensitiveSort = !caseInsensitiveSort;
227 	}
228 
229 	public boolean isCaseInsensitiveMatch() {
230 		return caseInsensitiveMatch;
231 	}
232 	public void setCaseInsensitiveMatch(boolean caseInsensitiveMatch) {
233 		this.caseInsensitiveMatch = caseInsensitiveMatch;
234 		this.caseSensitiveMatch = !caseInsensitiveMatch;
235 		this.exactMatch = !caseInsensitiveMatch;
236 	}
237 
238 	public boolean isCaseSensitiveSort() {
239 		return caseSensitiveSort;
240 	}
241 	public void setCaseSensitiveSort(boolean caseSensitiveSort) {
242 		this.caseSensitiveSort = caseSensitiveSort;
243 		this.caseInsensitiveSort = !caseSensitiveSort;
244 	}
245 
246 	public boolean isCaseSensitiveMatch() {
247 		return caseSensitiveMatch;
248 	}
249 	public void setCaseSensitiveMatch(boolean caseSensitiveMatch) {
250 		this.caseSensitiveMatch = caseSensitiveMatch;
251 		this.caseInsensitiveMatch = !caseSensitiveMatch;
252 	}
253 	
254 	public boolean isCombineCategoryBags() {
255 		return combineCategoryBags;
256 	}
257 	public void setCombineCategoryBags(boolean combineCategoryBags) {
258 		this.combineCategoryBags = combineCategoryBags;
259 		this.serviceSubset = !combineCategoryBags;
260 		this.bindingSubset = !combineCategoryBags;
261 	}
262 
263 	public boolean isDiacriticInsensitiveMatch() {
264 		return diacriticInsensitiveMatch;
265 	}
266 	public void setDiacriticInsensitiveMatch(boolean diacriticInsensitiveMatch) {
267 		this.diacriticInsensitiveMatch = diacriticInsensitiveMatch;
268 		this.diacriticSensitiveMatch = !diacriticInsensitiveMatch;
269 	}
270 
271 	public boolean isDiacriticSensitiveMatch() {
272 		return diacriticSensitiveMatch;
273 	}
274 	public void setDiacriticSensitiveMatch(boolean diacriticSensitiveMatch) {
275 		this.diacriticSensitiveMatch = diacriticSensitiveMatch;
276 		this.diacriticInsensitiveMatch = !diacriticSensitiveMatch;
277 	}
278 
279 	public boolean isExactMatch() {
280 		return exactMatch;
281 	}
282 	public void setExactMatch(boolean exactMatch) {
283 		this.exactMatch = exactMatch;
284 		this.approximateMatch = !exactMatch;
285 		this.caseInsensitiveMatch = !exactMatch;
286 	}
287 
288 	public boolean isSignaturePresent() {
289 		return signaturePresent;
290 	}
291 	public void setSignaturePresent(boolean signaturePresent) {
292 		this.signaturePresent = signaturePresent;
293 	}
294 
295 	public boolean isOrAllKeys() {
296 		return orAllKeys;
297 	}
298 	public void setOrAllKeys(boolean orAllKeys) {
299 		this.orAllKeys = orAllKeys;
300 		this.andAllKeys = !orAllKeys;
301 		this.orLikeKeys = !orAllKeys;
302 	}
303 
304 	public boolean isOrLikeKeys() {
305 		return orLikeKeys;
306 	}
307 	public void setOrLikeKeys(boolean orLikeKeys) {
308 		this.orLikeKeys = orLikeKeys;
309 		this.andAllKeys = !orLikeKeys;
310 		this.orAllKeys = !orLikeKeys;
311 	}
312 
313 	public boolean isServiceSubset() {
314 		return serviceSubset;
315 	}
316 	public void setServiceSubset(boolean serviceSubset) {
317 		this.serviceSubset = serviceSubset;
318 		this.combineCategoryBags = !serviceSubset;
319 		this.bindingSubset = !serviceSubset;
320 	}
321 
322 	public boolean isSortByNameAsc() {
323 		return sortByNameAsc;
324 	}
325 	public void setSortByNameAsc(boolean sortByNameAsc) {
326 		this.sortByNameAsc = sortByNameAsc;
327 		this.sortByNameDesc = !sortByNameAsc;
328 	}
329 
330 	public boolean isSortByNameDesc() {
331 		return sortByNameDesc;
332 	}
333 	public void setSortByNameDesc(boolean sortByNameDesc) {
334 		this.sortByNameDesc = sortByNameDesc;
335 		this.sortByNameAsc = !sortByNameDesc;
336 	}
337 
338 	public boolean isSortByDateAsc() {
339 		return sortByDateAsc;
340 	}
341 	public void setSortByDateAsc(boolean sortByDateAsc) {
342 		this.sortByDateAsc = sortByDateAsc;
343 		this.sortByDateDesc = !sortByDateAsc;
344 	}
345 
346 	public boolean isSortByDateDesc() {
347 		return sortByDateDesc;
348 	}
349 	public void setSortByDateDesc(boolean sortByDateDesc) {
350 		this.sortByDateDesc = sortByDateDesc;
351 		this.sortByDateAsc = !sortByDateDesc;
352 	}
353 
354 	public boolean isSuppressProjectedServices() {
355 		return suppressProjectedServices;
356 	}
357 	public void setSuppressProjectedServices(boolean suppressProjectedServices) {
358 		this.suppressProjectedServices = suppressProjectedServices;
359 	}
360 
361 	public boolean isUts10() {
362 		return uts10;
363 	}
364 	public void setUts10(boolean uts10) {
365 		this.uts10 = uts10;
366 		this.binarySort = !uts10;
367 	}
368 	
369 	
370 }