Revision 4812
Added by daigle about 15 years ago
QueryGroup.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
import edu.ucsb.nceas.dbadapter.*; |
33 | 33 |
import edu.ucsb.nceas.metacat.util.MetacatUtil; |
34 |
import edu.ucsb.nceas.metacat.util.SystemUtil; |
|
35 |
import edu.ucsb.nceas.metacat.util.UtilException; |
|
34 | 36 |
|
35 | 37 |
import java.io.*; |
36 | 38 |
import java.util.Hashtable; |
... | ... | |
329 | 331 |
{ |
330 | 332 |
//System.out.println("new term is not null branch in handle new query term"); |
331 | 333 |
//we only handle union operator now. |
332 |
if (operator != null && operator.equalsIgnoreCase(UNION) && |
|
333 |
MetacatUtil.pathsForIndexing.contains(newTerm.getPathExpression())) |
|
334 |
{ |
|
335 |
//System.out.println("in only union branch in handle new query term"); |
|
336 |
for (int i=0; i<queryTermsInPathIndex.size(); i++) |
|
337 |
{ |
|
338 |
QueryTerm term = (QueryTerm)queryTermsInPathIndex.elementAt(i); |
|
339 |
if (term != null && term.hasSameSearchValue(newTerm)) |
|
340 |
{ |
|
341 |
//System.out.println("1Move a query term and add a new query term into search value in handle new query term"); |
|
342 |
// find a target which has same search value |
|
343 |
Vector newSameValueVector = new Vector(); |
|
344 |
newSameValueVector.add(term); |
|
345 |
newSameValueVector.addElement(newTerm); |
|
346 |
queryTermsWithSameValue.add(newSameValueVector); |
|
347 |
queryTermsInPathIndex.remove(i); |
|
348 |
return; |
|
349 |
} |
|
350 |
} |
|
351 |
// no same search value was found in queryTerms. |
|
352 |
// then we need search queryTermsWithSameValue |
|
353 |
for (int i=0; i<queryTermsWithSameValue.size(); i++) |
|
354 |
{ |
|
355 |
Vector sameValueVec = (Vector)queryTermsWithSameValue.elementAt(i); |
|
356 |
// we only compare the first query term |
|
357 |
QueryTerm term = (QueryTerm)sameValueVec.elementAt(0); |
|
358 |
if (term != null && term.hasSameSearchValue(newTerm)) |
|
359 |
{ |
|
360 |
//System.out.println("2add a new query term into search value in handle new query term"); |
|
361 |
sameValueVec.add(newTerm); |
|
362 |
return; |
|
363 |
} |
|
364 |
} |
|
365 |
//nothing found, but the search path is still in xml_path_index, |
|
366 |
// save it into queryTermsInPathIndex vector |
|
367 |
queryTermsInPathIndex.add(newTerm); |
|
368 |
return; |
|
369 |
} |
|
334 |
try { |
|
335 |
if (operator != null |
|
336 |
&& operator.equalsIgnoreCase(UNION) |
|
337 |
&& SystemUtil.getPathsForIndexing().contains( |
|
338 |
newTerm.getPathExpression())) { |
|
339 |
// System.out.println("in only union branch in handle new |
|
340 |
// query term"); |
|
341 |
for (int i = 0; i < queryTermsInPathIndex.size(); i++) { |
|
342 |
QueryTerm term = (QueryTerm) queryTermsInPathIndex.elementAt(i); |
|
343 |
if (term != null && term.hasSameSearchValue(newTerm)) { |
|
344 |
// System.out.println("1Move a query term and add a |
|
345 |
// new query term into search value in handle new |
|
346 |
// query term"); |
|
347 |
// find a target which has same search value |
|
348 |
Vector newSameValueVector = new Vector(); |
|
349 |
newSameValueVector.add(term); |
|
350 |
newSameValueVector.addElement(newTerm); |
|
351 |
queryTermsWithSameValue.add(newSameValueVector); |
|
352 |
queryTermsInPathIndex.remove(i); |
|
353 |
return; |
|
354 |
} |
|
355 |
} |
|
356 |
// no same search value was found in queryTerms. |
|
357 |
// then we need search queryTermsWithSameValue |
|
358 |
for (int i = 0; i < queryTermsWithSameValue.size(); i++) { |
|
359 |
Vector sameValueVec = (Vector) queryTermsWithSameValue |
|
360 |
.elementAt(i); |
|
361 |
// we only compare the first query term |
|
362 |
QueryTerm term = (QueryTerm) sameValueVec.elementAt(0); |
|
363 |
if (term != null && term.hasSameSearchValue(newTerm)) { |
|
364 |
// System.out.println("2add a new query term into |
|
365 |
// search value in handle new query term"); |
|
366 |
sameValueVec.add(newTerm); |
|
367 |
return; |
|
368 |
} |
|
369 |
} |
|
370 |
// nothing found, but the search path is still in |
|
371 |
// xml_path_index, |
|
372 |
// save it into queryTermsInPathIndex vector |
|
373 |
queryTermsInPathIndex.add(newTerm); |
|
374 |
return; |
|
375 |
} |
|
376 |
} catch (UtilException ue) { |
|
377 |
logMetacat.warn("Could not get index paths: " + ue.getMessage()); |
|
378 |
} |
|
370 | 379 |
|
371 | 380 |
// add this newTerm to queryTerms since we couldn't find it in xml_path_index |
372 | 381 |
queryTerms.add(newTerm); |
Also available in: Unified diff
Format indexPaths in metacat.properties. Remove from build.properties and build.xml. Move indexPath list getter from MetacatUtil to SystemUtil.