View Javadoc

1   package org.paneris.jammyjoes.model;
2   
3   import org.melati.poem.Database;
4   import org.melati.poem.DefinitionSource;
5   import org.melati.poem.PoemException;
6   import org.melati.poem.SQLPoemException;
7   import org.melati.poem.util.PagedEnumeration;
8   import org.paneris.jammyjoes.model.generated.ProductTableBase;
9   
10  public class ProductTable extends ProductTableBase {
11  
12    public ProductTable(Database database, String name, DefinitionSource definitionSource)
13      throws PoemException {
14      super(database, name, definitionSource);
15    }
16    
17    public PagedEnumeration selection(
18      String whereClause,
19      String orderByClause,
20      boolean includeDeleted,
21      int pageStart,
22      int pageSize)
23      throws SQLPoemException {
24      if (whereClause == null)
25        whereClause = "";
26      if (whereClause.indexOf("\"status\"") < 0 && whereClause.indexOf("\"id\"") < 0) {
27        if (!whereClause.equals(""))
28          whereClause += " AND ";
29        whereClause += "((\"status\" != "
30          + getJammyjoesDatabaseTables().getProductStatusTable().getDiscontinued().getTroid();
31        whereClause += " AND ";
32        whereClause += "\"status\" != "
33          + getJammyjoesDatabaseTables().getProductStatusTable().getNotStocked().getTroid();
34        whereClause += ") OR \"stocklevel\" > 0)";
35      }
36      return super.selection(whereClause, orderByClause, includeDeleted, pageStart, pageSize);
37    }
38  
39    public PagedEnumeration unFiltetredSelection(String whereClause, String orderByClause, boolean includeDeleted, int pageStart, int pageSize) {
40      return super.selection(whereClause, orderByClause, includeDeleted, pageStart, pageSize);
41    }
42    
43  }