occur = BooleanClause.Occur.MUST_NOT;
booleanQuery.add(new WildcardQuery(new Term(((BooleanQueryCriteria) queryCriteria)
.getTerms().get(0).getElementName(), "*")), BooleanClause.Occur.SHOULD);
break;
default:
throw new CatalogException("Invalid BooleanQueryCriteria opertor ["
+ ((BooleanQueryCriteria) queryCriteria).getOperator() + "]");
}
for (QueryCriteria qc : ((BooleanQueryCriteria) queryCriteria).getTerms())
booleanQuery.add(this.getQuery(qc), occur);
return booleanQuery;
} else if (queryCriteria instanceof TermQueryCriteria) {
String val = ((TermQueryCriteria) queryCriteria).getValue();
return new TermQuery(new Term(queryCriteria.getElementName(), val));
} else if (queryCriteria instanceof RangeQueryCriteria) {
String startVal = ((RangeQueryCriteria) queryCriteria).getStartValue();
String endVal = ((RangeQueryCriteria) queryCriteria).getEndValue();
boolean inclusive = ((RangeQueryCriteria) queryCriteria).getInclusive();
Term startTerm = null, endTerm = null;
if (!startVal.equals("")) {
startTerm = new Term(queryCriteria.getElementName(), startVal);
}
if (!endVal.equals("")) {
endTerm = new Term(queryCriteria.getElementName(), endVal);
}
return new RangeQuery(startTerm, endTerm, inclusive);
}else {
throw new CatalogException("Invalid QueryCriteria ["
+ queryCriteria.getClass().getCanonicalName() + "]");
}
}