}
public Vector<Hashtable<String, Object>> complexQuery(
Hashtable<String, Object> complexQueryHash) throws CatalogException {
try {
ComplexQuery complexQuery = XmlRpcStructFactory
.getComplexQueryFromXmlRpc(complexQueryHash);
// get ProductTypes
List<ProductType> productTypes = null;
if (complexQuery.getReducedProductTypeNames() == null) {
productTypes = this.repositoryManager.getProductTypes();
} else {
productTypes = new Vector<ProductType>();
for (String productTypeName : complexQuery
.getReducedProductTypeNames())
productTypes.add(this.repositoryManager
.getProductTypeByName(productTypeName));
}
// get Metadata
List<QueryResult> queryResults = new LinkedList<QueryResult>();
for (ProductType productType : productTypes) {
List<String> productIds = catalog.query(this.getCatalogQuery(
complexQuery, productType), productType);
for (String productId : productIds) {
Product product = catalog.getProductById(productId);
product.setProductType(productType);
QueryResult qr = new QueryResult(product, this
.getReducedMetadata(product, complexQuery
.getReducedMetadata()));
qr.setToStringFormat(complexQuery
.getToStringResultFormat());
queryResults.add(qr);
}
}
LOG.log(Level.INFO, "Query returned " + queryResults.size()
+ " results");
// filter query results
if (complexQuery.getQueryFilter() != null) {
queryResults = applyFilterToResults(queryResults, complexQuery
.getQueryFilter());
LOG.log(Level.INFO, "Filter returned " + queryResults.size()
+ " results");
}
// sort query results
if (complexQuery.getSortByMetKey() != null)
queryResults = sortQueryResultList(queryResults, complexQuery
.getSortByMetKey());
return XmlRpcStructFactory.getXmlRpcQueryResults(queryResults);
} catch (Exception e) {
e.printStackTrace();