Coverage Report - org.melati.poem.generated.CapabilityTableBase
 
Classes in this File Line Coverage Branch Coverage Complexity
CapabilityTableBase
65%
15/23
0%
0/2
1.026
CapabilityTableBase$1
56%
9/16
N/A
1.026
CapabilityTableBase$2
88%
15/17
N/A
1.026
 
 1  
 // Do not edit this file!  It was generated by Melati POEM's DSD preprocessor.
 2  
 
 3  
 package org.melati.poem.generated;
 4  
 
 5  
 
 6  
 import org.melati.poem.AccessPoemException;
 7  
 import org.melati.poem.Capability;
 8  
 import org.melati.poem.Column;
 9  
 import org.melati.poem.Database;
 10  
 import org.melati.poem.DefinitionSource;
 11  
 import org.melati.poem.DisplayLevel;
 12  
 import org.melati.poem.Field;
 13  
 import org.melati.poem.JdbcPersistent;
 14  
 import org.melati.poem.Persistent;
 15  
 import org.melati.poem.PoemDatabaseTables;
 16  
 import org.melati.poem.PoemException;
 17  
 import org.melati.poem.PoemTable;
 18  
 import org.melati.poem.Searchability;
 19  
 import org.melati.poem.StringPoemType;
 20  
 import org.melati.poem.TroidPoemType;
 21  
 import org.melati.poem.ValidationPoemException;
 22  
 
 23  
 
 24  
 /**
 25  
  * Melati POEM generated base class for <code>Table</code> <code>capability</code>.
 26  
  *
 27  
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 28  
  */
 29  
 
 30  
 public class CapabilityTableBase<T extends Capability> extends PoemTable<T> {
 31  
 
 32  64
   private Column<Integer> col_id = null;
 33  64
   private Column<String> col_name = null;
 34  
 
 35  
  /**
 36  
   * Constructor. 
 37  
   * 
 38  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 39  
   * @param database          the POEM database we are using
 40  
   * @param name              the name of this <code>Table</code>
 41  
   * @param definitionSource  which definition is being used
 42  
   * @throws PoemException    if anything goes wrong
 43  
   */
 44  
 
 45  
   public CapabilityTableBase(
 46  
       Database database, String name,
 47  
       DefinitionSource definitionSource) throws PoemException {
 48  64
     super(database, name, definitionSource);
 49  64
   }
 50  
 
 51  
 
 52  
  /**
 53  
   * Get the database tables.
 54  
   *
 55  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 56  
   * @return the database tables
 57  
   */
 58  
   public PoemDatabaseTables getPoemDatabaseTables() {
 59  0
     return (PoemDatabaseTables)getDatabase();
 60  
   }
 61  
 
 62  
 
 63  
  /**
 64  
   * Initialise this table by defining its columns.
 65  
   *
 66  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 67  
   */
 68  
   public void init() throws PoemException {
 69  41
     super.init();
 70  41
     defineColumn(col_id =
 71  
         new Column<Integer>(this, "id",
 72  
                    new TroidPoemType(),
 73  41
                    DefinitionSource.dsd) { 
 74  
           public Object getCooked(Persistent g)
 75  
               throws AccessPoemException, PoemException {
 76  0
             return ((Capability)g).getId();
 77  
           }
 78  
 
 79  
           public void setCooked(Persistent g, Object cooked)
 80  
               throws AccessPoemException, ValidationPoemException {
 81  0
             ((Capability)g).setId((Integer)cooked);
 82  0
           }
 83  
 
 84  
           public Field<Integer> asField(Persistent g) {
 85  0
             return ((Capability)g).getIdField();
 86  
           }
 87  
 
 88  
           public boolean defaultUserEditable() {
 89  40
             return false;
 90  
           }
 91  
 
 92  
           public boolean defaultUserCreateable() {
 93  40
             return false;
 94  
           }
 95  
 
 96  
           public DisplayLevel defaultDisplayLevel() {
 97  80
             return DisplayLevel.detail;
 98  
           }
 99  
 
 100  
           public int defaultDisplayOrder() {
 101  40
             return 0;
 102  
           }
 103  
 
 104  
           public String defaultDescription() {
 105  40
             return "The Table Row Object ID";
 106  
           }
 107  
 
 108  
           public Object getRaw_unsafe(Persistent g)
 109  
               throws AccessPoemException {
 110  239
             return ((Capability)g).getId_unsafe();
 111  
           }
 112  
 
 113  
           public void setRaw_unsafe(Persistent g, Object raw)
 114  
               throws AccessPoemException {
 115  555
             ((Capability)g).setId_unsafe((Integer)raw);
 116  555
           }
 117  
 
 118  
           public Object getRaw(Persistent g)
 119  
               throws AccessPoemException {
 120  0
             return ((Capability)g).getId();
 121  
           }
 122  
 
 123  
           public void setRaw(Persistent g, Object raw)
 124  
               throws AccessPoemException {
 125  0
             ((Capability)g).setId((Integer)raw);
 126  0
           }
 127  
         });
 128  
 
 129  41
     defineColumn(col_name =
 130  
         new Column<String>(this, "name",
 131  
                    new StringPoemType(false, 60),
 132  41
                    DefinitionSource.dsd) { 
 133  
           public Object getCooked(Persistent g)
 134  
               throws AccessPoemException, PoemException {
 135  2
             return ((Capability)g).getName();
 136  
           }
 137  
 
 138  
           public void setCooked(Persistent g, Object cooked)
 139  
               throws AccessPoemException, ValidationPoemException {
 140  2
             ((Capability)g).setName((String)cooked);
 141  2
           }
 142  
 
 143  
           public Field<String> asField(Persistent g) {
 144  2
             return ((Capability)g).getNameField();
 145  
           }
 146  
 
 147  
           public DisplayLevel defaultDisplayLevel() {
 148  80
             return DisplayLevel.primary;
 149  
           }
 150  
 
 151  
           public Searchability defaultSearchability() {
 152  80
             return Searchability.primary;
 153  
           }
 154  
 
 155  
           public Integer defaultDisplayOrderPriority() {
 156  40
             return new Integer(0);
 157  
           }
 158  
 
 159  
           public int defaultDisplayOrder() {
 160  40
             return 1;
 161  
           }
 162  
 
 163  
           public String defaultDescription() {
 164  40
             return "A human-readable name for the Capability";
 165  
           }
 166  
 
 167  
           public boolean defaultUnique() {
 168  40
             return true;
 169  
           }
 170  
 
 171  
           public Object getRaw_unsafe(Persistent g)
 172  
               throws AccessPoemException {
 173  350
             return ((Capability)g).getName_unsafe();
 174  
           }
 175  
 
 176  
           public void setRaw_unsafe(Persistent g, Object raw)
 177  
               throws AccessPoemException {
 178  211
             ((Capability)g).setName_unsafe((String)raw);
 179  211
           }
 180  
 
 181  
           public Object getRaw(Persistent g)
 182  
               throws AccessPoemException {
 183  17
             return ((Capability)g).getName();
 184  
           }
 185  
 
 186  
           public void setRaw(Persistent g, Object raw)
 187  
               throws AccessPoemException {
 188  0
             ((Capability)g).setName((String)raw);
 189  0
           }
 190  
         });
 191  41
   }
 192  
 
 193  
 
 194  
  /**
 195  
   * Retrieves the <code>Id</code> <code>Column</code> for this 
 196  
   * <code>capability</code> <code>Table</code>.
 197  
   * 
 198  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 199  
   * @return the id <code>Column</code>
 200  
   */
 201  
   public final Column<Integer> getIdColumn() {
 202  0
     return col_id;
 203  
   }
 204  
 
 205  
 
 206  
  /**
 207  
   * Retrieves the <code>Name</code> <code>Column</code> for this 
 208  
   * <code>capability</code> <code>Table</code>.
 209  
   * 
 210  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 211  
   * @return the name <code>Column</code>
 212  
   */
 213  
   public final Column<String> getNameColumn() {
 214  565
     return col_name;
 215  
   }
 216  
 
 217  
 
 218  
  /**
 219  
   * Retrieve the <code>Capability</code> as a <code>Capability</code>.
 220  
   *
 221  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 222  
   * @param troid a Table Row Object ID
 223  
   * @return the <code>Persistent</code> identified by the <code>troid</code>
 224  
   */
 225  
   public Capability getCapabilityObject(Integer troid) {
 226  628
     return (Capability)getObject(troid);
 227  
   }
 228  
 
 229  
 
 230  
  /**
 231  
   * Retrieve the <code>Capability</code> 
 232  
   * as a <code>Capability</code>.
 233  
   *
 234  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 235  
   * @param troid a Table Row Object ID
 236  
   * @return the <code>Persistent</code> identified   */
 237  
   public Capability getCapabilityObject(int troid) {
 238  0
     return (Capability)getObject(troid);
 239  
   }
 240  
 
 241  
   protected JdbcPersistent _newPersistent() {
 242  218
     return new Capability();
 243  
   }
 244  
   public String defaultDescription() {
 245  40
     return "A Capability which Users can be required to possess before accessing data";
 246  
   }
 247  
 
 248  
   public boolean defaultRememberAllTroids() {
 249  40
     return true;
 250  
   }
 251  
 
 252  
   public String defaultCategory() {
 253  40
     return "User";
 254  
   }
 255  
 
 256  
   public int defaultDisplayOrder() {
 257  40
     return 2030;
 258  
   }
 259  
 
 260  
   /**
 261  
    * @return a newly created or existing Capability
 262  
    **/
 263  
   public Capability ensure(String name) {
 264  0
     Capability p = (Capability)getNameColumn().firstWhereEq(name);
 265  0
     if (p == null) {
 266  0
       p = (Capability)newPersistent();
 267  0
       p.setName(name);
 268  
     }
 269  0
     return (Capability)getNameColumn().ensure(p);
 270  
   }
 271  
 }
 272