1 64 65 package com.jcorporate.expresso.ext.dbobj.regobj; 66 67 import com.jcorporate.expresso.core.db.DBConnection; 68 import com.jcorporate.expresso.core.db.DBException; 69 import com.jcorporate.expresso.core.dbobj.RequestContext; 70 import com.jcorporate.expresso.core.dbobj.ValidValue; 71 import com.jcorporate.expresso.core.misc.DateTime; 72 import com.jcorporate.expresso.services.dbobj.RegistrationDBObject; 73 74 import java.util.Vector ; 75 76 83 public class Person extends RegistrationDBObject { 84 85 90 public Person() throws DBException { 91 super(); 92 } 93 94 95 101 public Person(DBConnection myConnection) throws DBException { 102 103 super(myConnection); 104 } 105 106 107 114 public Person(int uid) throws DBException { 115 super(uid); 116 } 117 118 125 public Person(RequestContext request) throws DBException { 126 super(request); 127 } 128 129 130 133 public void add() throws DBException { 134 setField("AddedOn", DateTime.getDateTimeForDB(this.getDataContext())); 135 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 136 137 138 super.add(); 139 140 141 } 142 143 144 149 public Vector getValidValues(String fieldName) throws DBException { 150 Vector myValues = new Vector (4); 151 if (fieldName.equals("Salutation")) { 152 myValues.addElement(new ValidValue("Mr.", "Mr.")); 153 myValues.addElement(new ValidValue("Mrs.", "Mrs.")); 154 myValues.addElement(new ValidValue("Ms.", "Ms.")); 155 myValues.addElement(new ValidValue("Miss", "Miss")); 156 myValues.addElement(new ValidValue("Master", "Master")); 157 return myValues; 158 } 159 return super.getValidValues(fieldName); 160 } 161 162 163 166 public void setupFields() throws DBException { 167 setTargetTable("SMPREGPR"); 168 setDescription("Your Name"); 169 setCharset("ISO-8859-1"); 170 171 172 addField("ExpUid", "int", 0, false, "Person ID Number"); 173 addField("Salutation", "char", 6, true, "Salutation"); 174 addField("FirstName", "varchar", 25, false, "First Name"); 175 addField("MiddleName", "varchar", 25, true, "Middle Name"); 176 addField("LastName", "varchar", 25, false, "Last Name"); 177 addField("BirthDate", "datetime", 0, true, "Birth Date"); 178 179 addField("AddedOn", "datetime", 0, true, "Added On"); 180 addField("UpdatedOn", "datetime", 0, true, "Updated On"); 181 setReadOnly("AddedOn"); 182 setReadOnly("UpdatedOn"); 183 184 185 setLookupObject("ExpUid", "com.jcorporate.expresso.security.dbobj.DefaultUserInfo"); 186 addKey("ExpUid"); 187 setMultiValued("Salutation"); 188 189 } 190 191 194 public void update() throws DBException { 195 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 196 super.update(); 197 198 } 199 } | Popular Tags |