Coverage Report - org.melati.poem.generated.SettingTableBase
 
Classes in this File Line Coverage Branch Coverage Complexity
SettingTableBase
70%
19/27
0%
0/2
1.022
SettingTableBase$1
66%
10/15
N/A
1.022
SettingTableBase$2
53%
8/15
N/A
1.022
SettingTableBase$3
38%
5/13
N/A
1.022
 
 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.Column;
 8  
 import org.melati.poem.Database;
 9  
 import org.melati.poem.DefinitionSource;
 10  
 import org.melati.poem.Field;
 11  
 import org.melati.poem.JdbcPersistent;
 12  
 import org.melati.poem.Persistent;
 13  
 import org.melati.poem.PoemDatabaseTables;
 14  
 import org.melati.poem.PoemException;
 15  
 import org.melati.poem.Searchability;
 16  
 import org.melati.poem.Setting;
 17  
 import org.melati.poem.StringPoemType;
 18  
 import org.melati.poem.TroidPoemType;
 19  
 import org.melati.poem.ValidationPoemException;
 20  
 import org.melati.poem.ValueInfoTable;
 21  
 
 22  
 
 23  
 /**
 24  
  * Melati POEM generated base class for <code>Table</code> <code>setting</code>.
 25  
  *
 26  
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 27  
  */
 28  
 
 29  
 public class SettingTableBase<T extends Setting> extends ValueInfoTable<T> {
 30  
 
 31  64
   private Column<Integer> col_id = null;
 32  64
   private Column<String> col_name = null;
 33  64
   private Column<String> col_value = 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 SettingTableBase(
 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 ((Setting)g).getId();
 77  
           }
 78  
 
 79  
           public void setCooked(Persistent g, Object cooked)
 80  
               throws AccessPoemException, ValidationPoemException {
 81  0
             ((Setting)g).setId((Integer)cooked);
 82  0
           }
 83  
 
 84  
           public Field<Integer> asField(Persistent g) {
 85  2
             return ((Setting)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 int defaultDisplayOrder() {
 97  40
             return 0;
 98  
           }
 99  
 
 100  
           public String defaultDescription() {
 101  40
             return "The Table Row Object ID";
 102  
           }
 103  
 
 104  
           public Object getRaw_unsafe(Persistent g)
 105  
               throws AccessPoemException {
 106  48
             return ((Setting)g).getId_unsafe();
 107  
           }
 108  
 
 109  
           public void setRaw_unsafe(Persistent g, Object raw)
 110  
               throws AccessPoemException {
 111  48
             ((Setting)g).setId_unsafe((Integer)raw);
 112  48
           }
 113  
 
 114  
           public Object getRaw(Persistent g)
 115  
               throws AccessPoemException {
 116  2
             return ((Setting)g).getId();
 117  
           }
 118  
 
 119  
           public void setRaw(Persistent g, Object raw)
 120  
               throws AccessPoemException {
 121  0
             ((Setting)g).setId((Integer)raw);
 122  0
           }
 123  
         });
 124  
 
 125  41
     defineColumn(col_name =
 126  
         new Column<String>(this, "name",
 127  
                    new StringPoemType(false, 200),
 128  41
                    DefinitionSource.dsd) { 
 129  
           public Object getCooked(Persistent g)
 130  
               throws AccessPoemException, PoemException {
 131  0
             return ((Setting)g).getName();
 132  
           }
 133  
 
 134  
           public void setCooked(Persistent g, Object cooked)
 135  
               throws AccessPoemException, ValidationPoemException {
 136  0
             ((Setting)g).setName((String)cooked);
 137  0
           }
 138  
 
 139  
           public Field<String> asField(Persistent g) {
 140  2
             return ((Setting)g).getNameField();
 141  
           }
 142  
 
 143  
           public Searchability defaultSearchability() {
 144  80
             return Searchability.primary;
 145  
           }
 146  
 
 147  
           public int defaultDisplayOrder() {
 148  40
             return 1;
 149  
           }
 150  
 
 151  
           public String defaultDescription() {
 152  40
             return "A code name for this setting";
 153  
           }
 154  
 
 155  
           public boolean defaultUnique() {
 156  40
             return true;
 157  
           }
 158  
 
 159  
           public Object getRaw_unsafe(Persistent g)
 160  
               throws AccessPoemException {
 161  66
             return ((Setting)g).getName_unsafe();
 162  
           }
 163  
 
 164  
           public void setRaw_unsafe(Persistent g, Object raw)
 165  
               throws AccessPoemException {
 166  0
             ((Setting)g).setName_unsafe((String)raw);
 167  0
           }
 168  
 
 169  
           public Object getRaw(Persistent g)
 170  
               throws AccessPoemException {
 171  2
             return ((Setting)g).getName();
 172  
           }
 173  
 
 174  
           public void setRaw(Persistent g, Object raw)
 175  
               throws AccessPoemException {
 176  0
             ((Setting)g).setName((String)raw);
 177  0
           }
 178  
         });
 179  
 
 180  41
     defineColumn(col_value =
 181  
         new Column<String>(this, "value",
 182  
                    new StringPoemType(true, -1),
 183  41
                    DefinitionSource.dsd) { 
 184  
           public Object getCooked(Persistent g)
 185  
               throws AccessPoemException, PoemException {
 186  0
             return ((Setting)g).getValue();
 187  
           }
 188  
 
 189  
           public void setCooked(Persistent g, Object cooked)
 190  
               throws AccessPoemException, ValidationPoemException {
 191  0
             ((Setting)g).setValue((String)cooked);
 192  0
           }
 193  
 
 194  
           public Field<String> asField(Persistent g) {
 195  2
             return ((Setting)g).getValueField();
 196  
           }
 197  
 
 198  
           public int defaultDisplayOrder() {
 199  40
             return 150;
 200  
           }
 201  
 
 202  
           public String defaultDescription() {
 203  40
             return "The value of this setting";
 204  
           }
 205  
 
 206  
           public Object getRaw_unsafe(Persistent g)
 207  
               throws AccessPoemException {
 208  48
             return ((Setting)g).getValue_unsafe();
 209  
           }
 210  
 
 211  
           public void setRaw_unsafe(Persistent g, Object raw)
 212  
               throws AccessPoemException {
 213  0
             ((Setting)g).setValue_unsafe((String)raw);
 214  0
           }
 215  
 
 216  
           public Object getRaw(Persistent g)
 217  
               throws AccessPoemException {
 218  0
             return ((Setting)g).getValue();
 219  
           }
 220  
 
 221  
           public void setRaw(Persistent g, Object raw)
 222  
               throws AccessPoemException {
 223  0
             ((Setting)g).setValue((String)raw);
 224  0
           }
 225  
         });
 226  41
   }
 227  
 
 228  
 
 229  
  /**
 230  
   * Retrieves the <code>Id</code> <code>Column</code> for this 
 231  
   * <code>setting</code> <code>Table</code>.
 232  
   * 
 233  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 234  
   * @return the id <code>Column</code>
 235  
   */
 236  
   public final Column<Integer> getIdColumn() {
 237  2
     return col_id;
 238  
   }
 239  
 
 240  
 
 241  
  /**
 242  
   * Retrieves the <code>Name</code> <code>Column</code> for this 
 243  
   * <code>setting</code> <code>Table</code>.
 244  
   * 
 245  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 246  
   * @return the name <code>Column</code>
 247  
   */
 248  
   public final Column<String> getNameColumn() {
 249  67
     return col_name;
 250  
   }
 251  
 
 252  
 
 253  
  /**
 254  
   * Retrieves the <code>Value</code> <code>Column</code> for this 
 255  
   * <code>setting</code> <code>Table</code>.
 256  
   * 
 257  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 258  
   * @return the value <code>Column</code>
 259  
   */
 260  
   public final Column<String> getValueColumn() {
 261  35
     return col_value;
 262  
   }
 263  
 
 264  
 
 265  
  /**
 266  
   * Retrieve the <code>Setting</code> as a <code>Setting</code>.
 267  
   *
 268  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 269  
   * @param troid a Table Row Object ID
 270  
   * @return the <code>Persistent</code> identified by the <code>troid</code>
 271  
   */
 272  
   public Setting getSettingObject(Integer troid) {
 273  0
     return (Setting)getObject(troid);
 274  
   }
 275  
 
 276  
 
 277  
  /**
 278  
   * Retrieve the <code>Setting</code> 
 279  
   * as a <code>Setting</code>.
 280  
   *
 281  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 282  
   * @param troid a Table Row Object ID
 283  
   * @return the <code>Persistent</code> identified   */
 284  
   public Setting getSettingObject(int troid) {
 285  0
     return (Setting)getObject(troid);
 286  
   }
 287  
 
 288  
   protected JdbcPersistent _newPersistent() {
 289  18
     return new Setting();
 290  
   }
 291  
   public String defaultDescription() {
 292  40
     return "A configurable Setting for the application, where a Setting can be of any object type";
 293  
   }
 294  
 
 295  
   public boolean defaultRememberAllTroids() {
 296  40
     return true;
 297  
   }
 298  
 
 299  
   public Integer defaultCacheLimit() {
 300  40
     return new Integer(999999999);
 301  
   }
 302  
 
 303  
   public String defaultCategory() {
 304  40
     return "System";
 305  
   }
 306  
 
 307  
   public int defaultDisplayOrder() {
 308  40
     return 3040;
 309  
   }
 310  
 
 311  
   /**
 312  
    * @return a newly created or existing Setting
 313  
    **/
 314  
   public Setting ensure(String name) {
 315  0
     Setting p = (Setting)getNameColumn().firstWhereEq(name);
 316  0
     if (p == null) {
 317  0
       p = (Setting)newPersistent();
 318  0
       p.setName(name);
 319  
     }
 320  0
     return (Setting)getNameColumn().ensure(p);
 321  
   }
 322  
 }
 323