CapabilityTableBase.java

  1. // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.

  2. package org.melati.poem.generated;


  3. import org.melati.poem.AccessPoemException;
  4. import org.melati.poem.Capability;
  5. import org.melati.poem.Column;
  6. import org.melati.poem.Database;
  7. import org.melati.poem.DefinitionSource;
  8. import org.melati.poem.DisplayLevel;
  9. import org.melati.poem.Field;
  10. import org.melati.poem.JdbcPersistent;
  11. import org.melati.poem.Persistent;
  12. import org.melati.poem.PoemDatabaseTables;
  13. import org.melati.poem.PoemException;
  14. import org.melati.poem.PoemTable;
  15. import org.melati.poem.Searchability;
  16. import org.melati.poem.StringPoemType;
  17. import org.melati.poem.TroidPoemType;
  18. import org.melati.poem.ValidationPoemException;


  19. /**
  20.  * Melati POEM generated base class for <code>Table</code> <code>capability</code>.
  21.  *
  22.  * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  23.  */

  24. public class CapabilityTableBase<T extends Capability> extends PoemTable<T> {

  25.   private Column<Integer> col_id = null;
  26.   private Column<String> col_name = null;

  27.  /**
  28.   * Constructor.
  29.   *
  30.   * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  31.   * @param database          the POEM database we are using
  32.   * @param name              the name of this <code>Table</code>
  33.   * @param definitionSource  which definition is being used
  34.   * @throws PoemException    if anything goes wrong
  35.   */

  36.   public CapabilityTableBase(
  37.       Database database, String name,
  38.       DefinitionSource definitionSource) throws PoemException {
  39.     super(database, name, definitionSource);
  40.   }


  41.  /**
  42.   * Get the database tables.
  43.   *
  44.   * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  45.   * @return the database tables
  46.   */
  47.   public PoemDatabaseTables getPoemDatabaseTables() {
  48.     return (PoemDatabaseTables)getDatabase();
  49.   }


  50.  /**
  51.   * Initialise this table by defining its columns.
  52.   *
  53.   * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  54.   */
  55.   public void init() throws PoemException {
  56.     super.init();
  57.     defineColumn(col_id =
  58.         new Column<Integer>(this, "id",
  59.                    new TroidPoemType(),
  60.                    DefinitionSource.dsd) {
  61.           public Object getCooked(Persistent g)
  62.               throws AccessPoemException, PoemException {
  63.             return ((Capability)g).getId();
  64.           }

  65.           public void setCooked(Persistent g, Object cooked)
  66.               throws AccessPoemException, ValidationPoemException {
  67.             ((Capability)g).setId((Integer)cooked);
  68.           }

  69.           public Field<Integer> asField(Persistent g) {
  70.             return ((Capability)g).getIdField();
  71.           }

  72.           public boolean defaultUserEditable() {
  73.             return false;
  74.           }

  75.           public boolean defaultUserCreateable() {
  76.             return false;
  77.           }

  78.           public DisplayLevel defaultDisplayLevel() {
  79.             return DisplayLevel.detail;
  80.           }

  81.           public int defaultDisplayOrder() {
  82.             return 0;
  83.           }

  84.           public String defaultDescription() {
  85.             return "The Table Row Object ID";
  86.           }

  87.           public Object getRaw_unsafe(Persistent g)
  88.               throws AccessPoemException {
  89.             return ((Capability)g).getId_unsafe();
  90.           }

  91.           public void setRaw_unsafe(Persistent g, Object raw)
  92.               throws AccessPoemException {
  93.             ((Capability)g).setId_unsafe((Integer)raw);
  94.           }

  95.           public Object getRaw(Persistent g)
  96.               throws AccessPoemException {
  97.             return ((Capability)g).getId();
  98.           }

  99.           public void setRaw(Persistent g, Object raw)
  100.               throws AccessPoemException {
  101.             ((Capability)g).setId((Integer)raw);
  102.           }
  103.         });

  104.     defineColumn(col_name =
  105.         new Column<String>(this, "name",
  106.                    new StringPoemType(false, 60),
  107.                    DefinitionSource.dsd) {
  108.           public Object getCooked(Persistent g)
  109.               throws AccessPoemException, PoemException {
  110.             return ((Capability)g).getName();
  111.           }

  112.           public void setCooked(Persistent g, Object cooked)
  113.               throws AccessPoemException, ValidationPoemException {
  114.             ((Capability)g).setName((String)cooked);
  115.           }

  116.           public Field<String> asField(Persistent g) {
  117.             return ((Capability)g).getNameField();
  118.           }

  119.           public DisplayLevel defaultDisplayLevel() {
  120.             return DisplayLevel.primary;
  121.           }

  122.           public Searchability defaultSearchability() {
  123.             return Searchability.primary;
  124.           }

  125.           public Integer defaultDisplayOrderPriority() {
  126.             return new Integer(0);
  127.           }

  128.           public int defaultDisplayOrder() {
  129.             return 1;
  130.           }

  131.           public String defaultDescription() {
  132.             return "A human-readable name for the Capability";
  133.           }

  134.           public boolean defaultUnique() {
  135.             return true;
  136.           }

  137.           public Object getRaw_unsafe(Persistent g)
  138.               throws AccessPoemException {
  139.             return ((Capability)g).getName_unsafe();
  140.           }

  141.           public void setRaw_unsafe(Persistent g, Object raw)
  142.               throws AccessPoemException {
  143.             ((Capability)g).setName_unsafe((String)raw);
  144.           }

  145.           public Object getRaw(Persistent g)
  146.               throws AccessPoemException {
  147.             return ((Capability)g).getName();
  148.           }

  149.           public void setRaw(Persistent g, Object raw)
  150.               throws AccessPoemException {
  151.             ((Capability)g).setName((String)raw);
  152.           }
  153.         });
  154.   }


  155.  /**
  156.   * Retrieves the <code>Id</code> <code>Column</code> for this
  157.   * <code>capability</code> <code>Table</code>.
  158.   *
  159.   * see org.melati.poem.prepro.FieldDef#generateColAccessor
  160.   * @return the id <code>Column</code>
  161.   */
  162.   public final Column<Integer> getIdColumn() {
  163.     return col_id;
  164.   }


  165.  /**
  166.   * Retrieves the <code>Name</code> <code>Column</code> for this
  167.   * <code>capability</code> <code>Table</code>.
  168.   *
  169.   * see org.melati.poem.prepro.FieldDef#generateColAccessor
  170.   * @return the name <code>Column</code>
  171.   */
  172.   public final Column<String> getNameColumn() {
  173.     return col_name;
  174.   }


  175.  /**
  176.   * Retrieve the <code>Capability</code> as a <code>Capability</code>.
  177.   *
  178.   * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  179.   * @param troid a Table Row Object ID
  180.   * @return the <code>Persistent</code> identified by the <code>troid</code>
  181.   */
  182.   public Capability getCapabilityObject(Integer troid) {
  183.     return (Capability)getObject(troid);
  184.   }


  185.  /**
  186.   * Retrieve the <code>Capability</code>
  187.   * as a <code>Capability</code>.
  188.   *
  189.   * See org.melati.poem.prepro.TableDef#generateTableBaseJava
  190.   * @param troid a Table Row Object ID
  191.   * @return the <code>Persistent</code> identified   */
  192.   public Capability getCapabilityObject(int troid) {
  193.     return (Capability)getObject(troid);
  194.   }

  195.   protected JdbcPersistent _newPersistent() {
  196.     return new Capability();
  197.   }
  198.   public String defaultDescription() {
  199.     return "A Capability which Users can be required to possess before accessing data";
  200.   }

  201.   public boolean defaultRememberAllTroids() {
  202.     return true;
  203.   }

  204.   public String defaultCategory() {
  205.     return "User";
  206.   }

  207.   public int defaultDisplayOrder() {
  208.     return 2030;
  209.   }

  210.   /**
  211.    * @return a newly created or existing Capability
  212.    **/
  213.   public Capability ensure(String name) {
  214.     Capability p = (Capability)getNameColumn().firstWhereEq(name);
  215.     if (p == null) {
  216.       p = (Capability)newPersistent();
  217.       p.setName(name);
  218.     }
  219.     return (Capability)getNameColumn().ensure(p);
  220.   }
  221. }