ContactCategoryTableBase.java

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

package org.melati.example.contacts.generated;


import org.melati.example.contacts.Category;
import org.melati.example.contacts.Contact;
import org.melati.example.contacts.ContactCategory;
import org.melati.example.contacts.ContactsDatabaseTables;
import org.melati.example.contacts.ContactsTable;
import org.melati.poem.AccessPoemException;
import org.melati.poem.Column;
import org.melati.poem.Database;
import org.melati.poem.DefinitionSource;
import org.melati.poem.DisplayLevel;
import org.melati.poem.Field;
import org.melati.poem.JdbcPersistent;
import org.melati.poem.Persistent;
import org.melati.poem.PoemException;
import org.melati.poem.ReferencePoemType;
import org.melati.poem.Searchability;
import org.melati.poem.StandardIntegrityFix;
import org.melati.poem.TroidPoemType;
import org.melati.poem.ValidationPoemException;


/**
 * Melati POEM generated base class for <code>Table</code> <code>ContactCategory</code>.
 *
 * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 */

public class ContactCategoryTableBase<T extends ContactCategory> extends ContactsTable<T> {

  private Column<Integer> col_id = null;
  private Column<Integer> col_category = null;
  private Column<Integer> col_contact = null;

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

  public ContactCategoryTableBase(
      Database database, String name,
      DefinitionSource definitionSource) throws PoemException {
    super(database, name, definitionSource);
  }


 /**
  * Get the database tables.
  *
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
  * @return the database tables
  */
  public ContactsDatabaseTables getContactsDatabaseTables() {
    return (ContactsDatabaseTables)getDatabase();
  }


 /**
  * Initialise this table by defining its columns.
  *
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
  */
  public void init() throws PoemException {
    super.init();
    defineColumn(col_id =
        new Column<Integer>(this, "id",
                   new TroidPoemType(),
                   DefinitionSource.dsd) { 
          public Object getCooked(Persistent g)
              throws AccessPoemException, PoemException {
            return ((ContactCategory)g).getId();
          }

          public void setCooked(Persistent g, Object cooked)
              throws AccessPoemException, ValidationPoemException {
            ((ContactCategory)g).setId((Integer)cooked);
          }

          public Field<Integer> asField(Persistent g) {
            return ((ContactCategory)g).getIdField();
          }

          public boolean defaultUserEditable() {
            return false;
          }

          public boolean defaultUserCreateable() {
            return false;
          }

          public DisplayLevel defaultDisplayLevel() {
            return DisplayLevel.record;
          }

          public Searchability defaultSearchability() {
            return Searchability.no;
          }

          public int defaultDisplayOrder() {
            return 0;
          }

          public Object getRaw_unsafe(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getId_unsafe();
          }

          public void setRaw_unsafe(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setId_unsafe((Integer)raw);
          }

          public Object getRaw(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getId();
          }

          public void setRaw(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setId((Integer)raw);
          }
        });

    defineColumn(col_category =
        new Column<Integer>(this, "category",
                   new ReferencePoemType(getContactsDatabaseTables().
                                             getCategoryTable(), false),
                   DefinitionSource.dsd) { 
          public Object getCooked(Persistent g)
              throws AccessPoemException, PoemException {
            return ((ContactCategory)g).getCategory();
          }

          public void setCooked(Persistent g, Object cooked)
              throws AccessPoemException, ValidationPoemException {
            ((ContactCategory)g).setCategory((Category)cooked);
          }

          public Field<Integer> asField(Persistent g) {
            return ((ContactCategory)g).getCategoryField();
          }

          public DisplayLevel defaultDisplayLevel() {
            return DisplayLevel.primary;
          }

          public Searchability defaultSearchability() {
            return Searchability.primary;
          }

          public Integer defaultDisplayOrderPriority() {
            return new Integer(0);
          }

          public int defaultDisplayOrder() {
            return 1;
          }

          public String defaultDescription() {
            return "Category";
          }

          public Object getRaw_unsafe(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getCategory_unsafe();
          }

          public void setRaw_unsafe(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setCategory_unsafe((Integer)raw);
          }

          public Object getRaw(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getCategoryTroid();
          }

          public void setRaw(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setCategoryTroid((Integer)raw);
          }

          public StandardIntegrityFix defaultIntegrityFix() {
            return StandardIntegrityFix.delete;
          }
        });

    defineColumn(col_contact =
        new Column<Integer>(this, "contact",
                   new ReferencePoemType(getContactsDatabaseTables().
                                             getContactTable(), false),
                   DefinitionSource.dsd) { 
          public Object getCooked(Persistent g)
              throws AccessPoemException, PoemException {
            return ((ContactCategory)g).getContact();
          }

          public void setCooked(Persistent g, Object cooked)
              throws AccessPoemException, ValidationPoemException {
            ((ContactCategory)g).setContact((Contact)cooked);
          }

          public Field<Integer> asField(Persistent g) {
            return ((ContactCategory)g).getContactField();
          }

          public DisplayLevel defaultDisplayLevel() {
            return DisplayLevel.summary;
          }

          public Searchability defaultSearchability() {
            return Searchability.yes;
          }

          public Integer defaultDisplayOrderPriority() {
            return new Integer(1);
          }

          public int defaultDisplayOrder() {
            return 2;
          }

          public String defaultDescription() {
            return "Contact";
          }

          public Object getRaw_unsafe(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getContact_unsafe();
          }

          public void setRaw_unsafe(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setContact_unsafe((Integer)raw);
          }

          public Object getRaw(Persistent g)
              throws AccessPoemException {
            return ((ContactCategory)g).getContactTroid();
          }

          public void setRaw(Persistent g, Object raw)
              throws AccessPoemException {
            ((ContactCategory)g).setContactTroid((Integer)raw);
          }

          public StandardIntegrityFix defaultIntegrityFix() {
            return StandardIntegrityFix.delete;
          }
        });
  }


 /**
  * Retrieves the <code>Id</code> <code>Column</code> for this 
  * <code>ContactCategory</code> <code>Table</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateColAccessor 
  * @return the id <code>Column</code>
  */
  public final Column<Integer> getIdColumn() {
    return col_id;
  }


 /**
  * Retrieves the <code>Category</code> <code>Column</code> for this 
  * <code>ContactCategory</code> <code>Table</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateColAccessor 
  * @return the category <code>Column</code>
  */
  public final Column<Integer> getCategoryColumn() {
    return col_category;
  }


 /**
  * Retrieves the <code>Contact</code> <code>Column</code> for this 
  * <code>ContactCategory</code> <code>Table</code>.
  * 
  * see org.melati.poem.prepro.FieldDef#generateColAccessor 
  * @return the contact <code>Column</code>
  */
  public final Column<Integer> getContactColumn() {
    return col_contact;
  }


 /**
  * Retrieve the <code>ContactCategory</code> as a <code>ContactCategory</code>.
  *
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
  * @param troid a Table Row Object ID
  * @return the <code>Persistent</code> identified by the <code>troid</code>
  */
  public ContactCategory getContactCategoryObject(Integer troid) {
    return (ContactCategory)getObject(troid);
  }


 /**
  * Retrieve the <code>ContactCategory</code> 
  * as a <code>ContactCategory</code>.
  *
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
  * @param troid a Table Row Object ID
  * @return the <code>Persistent</code> identified   */
  public ContactCategory getContactCategoryObject(int troid) {
    return (ContactCategory)getObject(troid);
  }

  protected JdbcPersistent _newPersistent() {
    return new ContactCategory();
  }
  public String defaultDescription() {
    return "Contacts Categories";
  }

  public String defaultCategory() {
    return "Data";
  }

  public int defaultDisplayOrder() {
    return 10;
  }
}