Coverage Report - org.paneris.jammyjoes.controller.ProductSearch
 
Classes in this File Line Coverage Branch Coverage Complexity
ProductSearch
0%
0/16
N/A
1
 
 1  
 package org.paneris.jammyjoes.controller;
 2  
 
 3  
 import java.util.Vector;
 4  
 
 5  
 import org.melati.poem.util.EnumUtils;
 6  
 import org.melati.poem.util.PagedEnumeration;
 7  
 import org.melati.util.StringUtils;
 8  
 import org.paneris.jammyjoes.model.JammyjoesDatabase;
 9  
 
 10  
 /**
 11  
  * @author Tim
 12  
  *
 13  
  * To change this generated comment edit the template variable "typecomment":
 14  
  * Window>Preferences>Java>Templates.
 15  
  * To enable and disable the creation of type comments go to
 16  
  * Window>Preferences>Java>Code Generation.
 17  
  */
 18  
 public class ProductSearch {
 19  
   
 20  
   private JammyjoesDatabase db;
 21  
   private int maxHits;
 22  
   private Logger logger;
 23  
   
 24  0
   public ProductSearch(JammyjoesDatabase db, int maxHits, Logger logger) {
 25  0
     this.db = db;
 26  0
     this.maxHits = maxHits;
 27  0
     this.logger = logger;
 28  0
   }
 29  
 
 30  
   public PagedEnumeration doSearch(SearchCriteria criteria) {
 31  0
     Vector where = new Vector();
 32  0
     criteria.constrain(where);
 33  0
     where.add(q("retailpriceincvat") + " IS NOT NULL");
 34  0
     String whereClause = EnumUtils.concatenated(" AND ", where.elements());
 35  0
     logger.logWhereClause(whereClause);
 36  0
     PagedEnumeration results = db.getProductTable().unFiltetredSelection(whereClause, criteria.order(), false, 0, maxHits);
 37  0
     logger.logHits(results.getTotalCount());
 38  0
     return results;
 39  
   }
 40  
 
 41  
   public String q(String name) {
 42  0
     StringBuffer b = new StringBuffer();
 43  0
     StringUtils.appendQuoted(b, name, '"');
 44  0
     return b.toString();
 45  
   }
 46  
 
 47  
 }