Coverage Report - org.melati.poem.generated.UserTableBase
 
Classes in this File Line Coverage Branch Coverage Complexity
UserTableBase
67%
21/31
0%
0/2
1.016
UserTableBase$1
62%
10/16
N/A
1.016
UserTableBase$2
100%
18/18
N/A
1.016
UserTableBase$3
80%
12/15
N/A
1.016
UserTableBase$4
81%
13/16
N/A
1.016
 
 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.DisplayLevel;
 11  
 import org.melati.poem.Field;
 12  
 import org.melati.poem.JdbcPersistent;
 13  
 import org.melati.poem.PasswordPoemType;
 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.User;
 22  
 import org.melati.poem.ValidationPoemException;
 23  
 
 24  
 
 25  
 /**
 26  
  * Melati POEM generated base class for <code>Table</code> <code>user</code>.
 27  
  *
 28  
  * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 29  
  */
 30  
 
 31  
 public class UserTableBase<T extends User> extends PoemTable<T> {
 32  
 
 33  64
   private Column<Integer> col_id = null;
 34  64
   private Column<String> col_name = null;
 35  64
   private Column<String> col_login = null;
 36  64
   private Column<String> col_password = null;
 37  
 
 38  
  /**
 39  
   * Constructor. 
 40  
   * 
 41  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 42  
   * @param database          the POEM database we are using
 43  
   * @param name              the name of this <code>Table</code>
 44  
   * @param definitionSource  which definition is being used
 45  
   * @throws PoemException    if anything goes wrong
 46  
   */
 47  
 
 48  
   public UserTableBase(
 49  
       Database database, String name,
 50  
       DefinitionSource definitionSource) throws PoemException {
 51  64
     super(database, name, definitionSource);
 52  64
   }
 53  
 
 54  
 
 55  
  /**
 56  
   * Get the database tables.
 57  
   *
 58  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 59  
   * @return the database tables
 60  
   */
 61  
   public PoemDatabaseTables getPoemDatabaseTables() {
 62  0
     return (PoemDatabaseTables)getDatabase();
 63  
   }
 64  
 
 65  
 
 66  
  /**
 67  
   * Initialise this table by defining its columns.
 68  
   *
 69  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 70  
   */
 71  
   public void init() throws PoemException {
 72  41
     super.init();
 73  41
     defineColumn(col_id =
 74  
         new Column<Integer>(this, "id",
 75  
                    new TroidPoemType(),
 76  41
                    DefinitionSource.dsd) { 
 77  
           public Object getCooked(Persistent g)
 78  
               throws AccessPoemException, PoemException {
 79  0
             return ((User)g).getId();
 80  
           }
 81  
 
 82  
           public void setCooked(Persistent g, Object cooked)
 83  
               throws AccessPoemException, ValidationPoemException {
 84  0
             ((User)g).setId((Integer)cooked);
 85  0
           }
 86  
 
 87  
           public Field<Integer> asField(Persistent g) {
 88  0
             return ((User)g).getIdField();
 89  
           }
 90  
 
 91  
           public boolean defaultUserEditable() {
 92  40
             return false;
 93  
           }
 94  
 
 95  
           public boolean defaultUserCreateable() {
 96  40
             return false;
 97  
           }
 98  
 
 99  
           public DisplayLevel defaultDisplayLevel() {
 100  80
             return DisplayLevel.detail;
 101  
           }
 102  
 
 103  
           public int defaultDisplayOrder() {
 104  40
             return 10;
 105  
           }
 106  
 
 107  
           public String defaultDescription() {
 108  40
             return "The Table Row Object ID";
 109  
           }
 110  
 
 111  
           public Object getRaw_unsafe(Persistent g)
 112  
               throws AccessPoemException {
 113  163
             return ((User)g).getId_unsafe();
 114  
           }
 115  
 
 116  
           public void setRaw_unsafe(Persistent g, Object raw)
 117  
               throws AccessPoemException {
 118  257
             ((User)g).setId_unsafe((Integer)raw);
 119  257
           }
 120  
 
 121  
           public Object getRaw(Persistent g)
 122  
               throws AccessPoemException {
 123  4
             return ((User)g).getId();
 124  
           }
 125  
 
 126  
           public void setRaw(Persistent g, Object raw)
 127  
               throws AccessPoemException {
 128  0
             ((User)g).setId((Integer)raw);
 129  0
           }
 130  
         });
 131  
 
 132  41
     defineColumn(col_name =
 133  
         new Column<String>(this, "name",
 134  
                    new StringPoemType(false, 60),
 135  41
                    DefinitionSource.dsd) { 
 136  
           public Object getCooked(Persistent g)
 137  
               throws AccessPoemException, PoemException {
 138  19
             return ((User)g).getName();
 139  
           }
 140  
 
 141  
           public void setCooked(Persistent g, Object cooked)
 142  
               throws AccessPoemException, ValidationPoemException {
 143  6
             ((User)g).setName((String)cooked);
 144  6
           }
 145  
 
 146  
           public Field<String> asField(Persistent g) {
 147  13
             return ((User)g).getNameField();
 148  
           }
 149  
 
 150  
           public DisplayLevel defaultDisplayLevel() {
 151  80
             return DisplayLevel.primary;
 152  
           }
 153  
 
 154  
           public Searchability defaultSearchability() {
 155  80
             return Searchability.primary;
 156  
           }
 157  
 
 158  
           public Integer defaultDisplayOrderPriority() {
 159  40
             return new Integer(0);
 160  
           }
 161  
 
 162  
           public String defaultDisplayName() {
 163  40
             return "Full name";
 164  
           }
 165  
 
 166  
           public int defaultDisplayOrder() {
 167  40
             return 20;
 168  
           }
 169  
 
 170  
           public String defaultDescription() {
 171  40
             return "The user's real name";
 172  
           }
 173  
 
 174  
           public boolean defaultIndexed() {
 175  40
             return true;
 176  
           }
 177  
 
 178  
           public Object getRaw_unsafe(Persistent g)
 179  
               throws AccessPoemException {
 180  164
             return ((User)g).getName_unsafe();
 181  
           }
 182  
 
 183  
           public void setRaw_unsafe(Persistent g, Object raw)
 184  
               throws AccessPoemException {
 185  57
             ((User)g).setName_unsafe((String)raw);
 186  57
           }
 187  
 
 188  
           public Object getRaw(Persistent g)
 189  
               throws AccessPoemException {
 190  31
             return ((User)g).getName();
 191  
           }
 192  
 
 193  
           public void setRaw(Persistent g, Object raw)
 194  
               throws AccessPoemException {
 195  10
             ((User)g).setName((String)raw);
 196  10
           }
 197  
         });
 198  
 
 199  41
     defineColumn(col_login =
 200  
         new Column<String>(this, "login",
 201  
                    new StringPoemType(false, 255),
 202  41
                    DefinitionSource.dsd) { 
 203  
           public Object getCooked(Persistent g)
 204  
               throws AccessPoemException, PoemException {
 205  0
             return ((User)g).getLogin();
 206  
           }
 207  
 
 208  
           public void setCooked(Persistent g, Object cooked)
 209  
               throws AccessPoemException, ValidationPoemException {
 210  2
             ((User)g).setLogin((String)cooked);
 211  2
           }
 212  
 
 213  
           public Field<String> asField(Persistent g) {
 214  8
             return ((User)g).getLoginField();
 215  
           }
 216  
 
 217  
           public int defaultDisplayOrder() {
 218  40
             return 30;
 219  
           }
 220  
 
 221  
           public String defaultDescription() {
 222  40
             return "The user's login name";
 223  
           }
 224  
 
 225  
           public boolean defaultUnique() {
 226  40
             return true;
 227  
           }
 228  
 
 229  
           public int defaultWidth() {
 230  40
             return 20;
 231  
           }
 232  
 
 233  
           public Object getRaw_unsafe(Persistent g)
 234  
               throws AccessPoemException {
 235  245
             return ((User)g).getLogin_unsafe();
 236  
           }
 237  
 
 238  
           public void setRaw_unsafe(Persistent g, Object raw)
 239  
               throws AccessPoemException {
 240  57
             ((User)g).setLogin_unsafe((String)raw);
 241  57
           }
 242  
 
 243  
           public Object getRaw(Persistent g)
 244  
               throws AccessPoemException {
 245  8
             return ((User)g).getLogin();
 246  
           }
 247  
 
 248  
           public void setRaw(Persistent g, Object raw)
 249  
               throws AccessPoemException {
 250  0
             ((User)g).setLogin((String)raw);
 251  0
           }
 252  
         });
 253  
 
 254  41
     defineColumn(col_password =
 255  
         new Column<String>(this, "password",
 256  
                    new PasswordPoemType(false, 20),
 257  41
                    DefinitionSource.dsd) { 
 258  
           public Object getCooked(Persistent g)
 259  
               throws AccessPoemException, PoemException {
 260  0
             return ((User)g).getPassword();
 261  
           }
 262  
 
 263  
           public void setCooked(Persistent g, Object cooked)
 264  
               throws AccessPoemException, ValidationPoemException {
 265  2
             ((User)g).setPassword((String)cooked);
 266  2
           }
 267  
 
 268  
           public Field<String> asField(Persistent g) {
 269  8
             return ((User)g).getPasswordField();
 270  
           }
 271  
 
 272  
           public DisplayLevel defaultDisplayLevel() {
 273  80
             return DisplayLevel.record;
 274  
           }
 275  
 
 276  
           public Searchability defaultSearchability() {
 277  80
             return Searchability.no;
 278  
           }
 279  
 
 280  
           public int defaultDisplayOrder() {
 281  40
             return 40;
 282  
           }
 283  
 
 284  
           public String defaultDescription() {
 285  40
             return "The user's password";
 286  
           }
 287  
 
 288  
           public int defaultWidth() {
 289  40
             return 10;
 290  
           }
 291  
 
 292  
           public Object getRaw_unsafe(Persistent g)
 293  
               throws AccessPoemException {
 294  163
             return ((User)g).getPassword_unsafe();
 295  
           }
 296  
 
 297  
           public void setRaw_unsafe(Persistent g, Object raw)
 298  
               throws AccessPoemException {
 299  57
             ((User)g).setPassword_unsafe((String)raw);
 300  57
           }
 301  
 
 302  
           public Object getRaw(Persistent g)
 303  
               throws AccessPoemException {
 304  9
             return ((User)g).getPassword();
 305  
           }
 306  
 
 307  
           public void setRaw(Persistent g, Object raw)
 308  
               throws AccessPoemException {
 309  0
             ((User)g).setPassword((String)raw);
 310  0
           }
 311  
         });
 312  41
   }
 313  
 
 314  
 
 315  
  /**
 316  
   * Retrieves the <code>Id</code> <code>Column</code> for this 
 317  
   * <code>user</code> <code>Table</code>.
 318  
   * 
 319  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 320  
   * @return the id <code>Column</code>
 321  
   */
 322  
   public final Column<Integer> getIdColumn() {
 323  1
     return col_id;
 324  
   }
 325  
 
 326  
 
 327  
  /**
 328  
   * Retrieves the <code>Name</code> <code>Column</code> for this 
 329  
   * <code>user</code> <code>Table</code>.
 330  
   * 
 331  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 332  
   * @return the name <code>Column</code>
 333  
   */
 334  
   public final Column<String> getNameColumn() {
 335  98
     return col_name;
 336  
   }
 337  
 
 338  
 
 339  
  /**
 340  
   * Retrieves the <code>Login</code> <code>Column</code> for this 
 341  
   * <code>user</code> <code>Table</code>.
 342  
   * 
 343  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 344  
   * @return the login <code>Column</code>
 345  
   */
 346  
   public final Column<String> getLoginColumn() {
 347  289
     return col_login;
 348  
   }
 349  
 
 350  
 
 351  
  /**
 352  
   * Retrieves the <code>Password</code> <code>Column</code> for this 
 353  
   * <code>user</code> <code>Table</code>.
 354  
   * 
 355  
   * see org.melati.poem.prepro.FieldDef#generateColAccessor 
 356  
   * @return the password <code>Column</code>
 357  
   */
 358  
   public final Column<String> getPasswordColumn() {
 359  33
     return col_password;
 360  
   }
 361  
 
 362  
 
 363  
  /**
 364  
   * Retrieve the <code>User</code> as a <code>User</code>.
 365  
   *
 366  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 367  
   * @param troid a Table Row Object ID
 368  
   * @return the <code>Persistent</code> identified by the <code>troid</code>
 369  
   */
 370  
   public User getUserObject(Integer troid) {
 371  0
     return (User)getObject(troid);
 372  
   }
 373  
 
 374  
 
 375  
  /**
 376  
   * Retrieve the <code>User</code> 
 377  
   * as a <code>User</code>.
 378  
   *
 379  
   * See org.melati.poem.prepro.TableDef#generateTableBaseJava 
 380  
   * @param troid a Table Row Object ID
 381  
   * @return the <code>Persistent</code> identified   */
 382  
   public User getUserObject(int troid) {
 383  0
     return (User)getObject(troid);
 384  
   }
 385  
 
 386  
   protected JdbcPersistent _newPersistent() {
 387  102
     return new User();
 388  
   }
 389  
   public String defaultDescription() {
 390  19
     return "A registered User of the database";
 391  
   }
 392  
 
 393  
   public boolean defaultRememberAllTroids() {
 394  40
     return true;
 395  
   }
 396  
 
 397  
   public String defaultCategory() {
 398  19
     return "User";
 399  
   }
 400  
 
 401  
   public int defaultDisplayOrder() {
 402  19
     return 2010;
 403  
   }
 404  
 
 405  
   /**
 406  
    * @return a newly created or existing User
 407  
    **/
 408  
   public User ensure(String name, String login, String password) {
 409  0
     User p = (User)getLoginColumn().firstWhereEq(login);
 410  0
     if (p == null) {
 411  0
       p = (User)newPersistent();
 412  0
       p.setName(name);
 413  0
       p.setLogin(login);
 414  0
       p.setPassword(password);
 415  
     }
 416  0
     return (User)getLoginColumn().ensure(p);
 417  
   }
 418  
 }
 419