1 package transactions.orders; 2 3 import dinamica.*; 4 5 18 public class SearchOrders extends GenericTransaction 19 { 20 21 25 public int service(Recordset inputs) throws Throwable 26 { 27 28 int rc = super.service(inputs); 30 31 Recordset filter = (Recordset)getSession().getAttribute("orders.filter"); 34 inputs.copyValues(filter); 35 36 37 38 String qBase = getResource("query-base.sql"); 40 41 String orderby = inputs.getString("orderby"); 45 String sortmode = inputs.getString("sortmode"); 46 qBase = StringUtil.replace(qBase,"${orderby}", orderby); 47 qBase = StringUtil.replace(qBase,"${sortmode}", sortmode); 48 49 StringBuffer qFilter = new StringBuffer (); 51 52 String [] params = { 55 "customerid", 56 "productid", 57 "dfrom", 58 "dto", 59 "total" 60 }; 61 62 for (int i=0;i<params.length;i++) 63 { 64 if (inputs.getValue(params[i])!=null) 65 qFilter.append(getResource("clause-" + params[i]+ ".sql")); 66 } 67 68 String where = qFilter.toString(); 70 71 String operator = inputs.getString("operator"); 75 where = StringUtil.replace(where,"${operator}", operator); 76 77 qBase = StringUtil.replace(qBase,"${filter}", where); 79 80 81 82 String sql = getSQL(qBase, inputs); 84 85 Db db = getDb(); 87 Recordset rs = db.get(sql); 88 89 if (rs.getRecordCount()>0) 91 { 92 getSession().setAttribute("orders.results", rs); 95 rc = 0; 96 } 97 else 98 { 99 rc = 1; 100 } 101 102 return rc; 103 104 } 105 106 } 107 | Popular Tags |