Coverage Report - org.paneris.rimauresq.model.SettingTable
 
Classes in this File Line Coverage Branch Coverage Complexity
SettingTable
89%
8/9
50%
2/4
1.2
SettingTable$1
93%
14/15
N/A
1.2
 
 1  
 package org.paneris.rimauresq.model;
 2  
 
 3  
 import org.paneris.rimauresq.model.generated.SettingTableBase;
 4  
 import org.melati.poem.DefinitionSource;
 5  
 import org.melati.poem.Database;
 6  
 import org.melati.poem.PoemException;
 7  
 import org.melati.poem.PoemTask;
 8  
 import org.melati.poem.PoemThread;
 9  
 
 10  
 /**
 11  
  * Melati POEM generated, programmer modifiable stub 
 12  
  * for a <code>SettingTable</code> object.
 13  
  *
 14  
  * 
 15  
  * <table> 
 16  
  * <tr><th colspan='3'>
 17  
  * Field summary for SQL table <code>Setting</code>
 18  
  * </th></tr>
 19  
  * <tr><th>Name</th><th>Type</th><th>Description</th></tr>
 20  
  * </table> 
 21  
  * 
 22  
  * @generator  org.melati.poem.prepro.TableDef#generateTableMainJava 
 23  
  */
 24  
 public class SettingTable extends SettingTableBase {
 25  
 
 26  
  /**
 27  
   * Constructor.
 28  
   * 
 29  
   * @generator org.melati.poem.prepro.TableDef#generateTableMainJava 
 30  
   * @param database          the POEM database we are using
 31  
   * @param name              the name of this <code>Table</code>
 32  
   * @param definitionSource  which definition is being used
 33  
   * @throws PoemException    if anything goes wrong
 34  
   */
 35  
   public SettingTable(
 36  
       Database database, String name,
 37  
       DefinitionSource definitionSource) throws PoemException {
 38  4
     super(database, name, definitionSource);
 39  4
   }
 40  
 
 41  
   // programmer's domain-specific code here
 42  
   public void postInitialise() {
 43  4
       super.postInitialise();
 44  4
       PoemThread.withAccessToken(
 45  
           getDatabase().getUserTable().administratorUser(),
 46  
           new PoemTask() {
 47  
             public void run() {
 48  4
                 String installationDir = "/dist/rimauresq";
 49  4
                 ensure("CVSRoot",installationDir,"CVS Root", 
 50  
                        "The directory into which system was checked out from CVS");
 51  4
                 ensure("SMTPServer","127.0.0.1","SMTP server", 
 52  
                        "The SMTP server for outgoing mail");
 53  
                 // FIXME duplicated in BoardTable
 54  4
                 ensure("BoardsAttachmentsPath", installationDir + "/www/attachments",
 55  
                        "Boards attachments Path",
 56  
                        "A directory which will contain one directory " +
 57  
                        "for each board (named after the board) in which " +
 58  
                        "to store attachments for this board " + 
 59  
                        "(e.g. /usr/httpd/testapp/board_attachments)");
 60  
                 // FIXME duplicated in BoardTable
 61  4
                 ensure("BoardsAttachmentsURL", "/attachments",
 62  
                        "Boards attachments URL",
 63  
                        "A URL to the directory defined by " + 
 64  
                        "BoardsAttachmentsPath" +
 65  
                        "(e.g. http://www.testapp.co.uk/board_attachments)");
 66  4
                 ensure("BoardsEmailDomain", "wvm.paneris.net", 
 67  
                        "localhost",
 68  
                        "The domain which receives mail for this database. " +
 69  
                        "Note that this must be the same as that defined in " + 
 70  
                        "smtpServer.properties " +
 71  
                        "(or equivalent, if you set a different name when " +
 72  
                        "starting SMTPServerServlet) "+ 
 73  
                        "(e.g. boards.testapp.co.uk)");
 74  4
                 ensure("BoardsEmailTemplates", "org/paneris/wvm/boards/emailtemplates", 
 75  
                        "Boards email templates",
 76  
                        "The directory containing the templates for " +
 77  
                        "sending out email. " +
 78  
                        "This is relative to WM's TemplatePath " +
 79  
                        "(e.g. testapp/boards/emailtemplates)");
 80  4
                 ensure("BoardsSystemURL","/db/board",
 81  
                        "Boards system URL",
 82  
                        "The URL to the BoardAdmin handler for this database " +
 83  
                        " (e.g. http://www.testapp.co.uk/testapp/"+
 84  
                        "org.paneris.melati.boards.BoardAdmin)");
 85  4
                 ensure("BoardsStylesheetURL","/styles/boards.css",
 86  
                        "Stylesheet URL",
 87  
                        "A URL to a stylesheet for all board pages");
 88  4
               ensure("LogicalDatabase","rimauresq",
 89  
                      "Logical database", 
 90  
                      "The name of the database " + 
 91  
                      "(note this must agree with the entry in " + 
 92  
                      "org.melati.LogicalDatabase.properties) eg testdb");
 93  4
               ensure("UploadURL","/fs",
 94  
                      "Upload URL", 
 95  
                      "Base reference for uploaded files ");
 96  4
               ensure("UploadDir", installationDir + "/www/fs",
 97  
                      "Upload Directory", 
 98  
                      "Where in the files system to write uploaded files ");
 99  
 
 100  4
             }
 101  
 
 102  4
             public String toString() {
 103  0
               return "Creating default settings";
 104  
             }
 105  
       }
 106  
       );
 107  4
     }
 108  
 
 109  
 
 110  
    /**
 111  
     * Ensure that <code>Setting</code>s have a value, as 
 112  
     * <code>org.paneris.melati.boards.meodel.SettingTable.ensure</code>
 113  
     * creates them with empty values.
 114  
     */
 115  
     public org.melati.poem.Setting ensure(String name, String value,
 116  
                           String displayname, String description) {
 117  100
       org.melati.poem.Setting p = super.ensure(name, value, displayname, 
 118  
                                                description);
 119  100
       if (p.getValue() == null || p.getValue().equals("")) {
 120  0
         p.setValue(value);
 121  
       }
 122  100
       return p;
 123  
     }
 124  
     
 125  
 }
 126