1 package org.paneris.melati.site.model; 2 3 import org.paneris.melati.site.model.generated.LinkTypeTableBase; 4 import org.melati.poem.DefinitionSource; 5 import org.melati.poem.Database; 6 import org.melati.poem.PoemException; 7 8 /** 9 * Melati POEM generated, programmer modifiable stub 10 * for a <code>LinkTypeTable</code> object. 11 * <p> 12 * Description: 13 * Types of media output. 14 * </p> 15 * 16 * 17 * <table> 18 * <tr><th colspan='3'> 19 * Field summary for SQL table <code>LinkType</code> 20 * </th></tr> 21 * <tr><th>Name</th><th>Type</th><th>Description</th></tr> 22 * <tr><td> id </td><td> Integer </td><td> </td></tr> 23 * <tr><td> name </td><td> String </td><td> The category's name </td></tr> 24 * <tr><td> description </td><td> String </td><td> The a description of the 25 * link type </td></tr> 26 * </table> 27 * 28 * @generator org.melati.poem.prepro.TableDef#generateTableMainJava 29 */ 30 public class LinkTypeTable extends LinkTypeTableBase { 31 32 /** 33 * Constructor. 34 * 35 * @generator org.melati.poem.prepro.TableDef#generateTableMainJava 36 * @param database the POEM database we are using 37 * @param name the name of this <code>Table</code> 38 * @param definitionSource which definition is being used 39 * @throws PoemException if anything goes wrong 40 */ 41 public LinkTypeTable( 42 Database database, String name, 43 DefinitionSource definitionSource) throws PoemException { 44 super(database, name, definitionSource); 45 } 46 47 // programmer's domain-specific code here 48 49 /** 50 * @return existing or newly minted LinkType 51 */ 52 public LinkType ensure(String name, String description) { 53 LinkType p = (LinkType)getNameColumn().firstWhereEq(name); 54 if (p == null) { 55 p = (LinkType)newPersistent(); 56 p.setName(name); 57 p.setDescription(description); 58 p.makePersistent(); 59 } 60 return p; 61 } 62 63 }