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 77 84 public class Phone 85 extends RegistrationDBObject { 86 public static final String FLD_TYPE = "PhoneType"; 87 public static final String FLD_NUMBER = "PhoneNum"; 88 89 90 95 public Phone() 96 throws DBException { 97 super(); 98 } 99 100 106 public Phone(DBConnection myConnection) 107 throws DBException { 108 super(myConnection); 109 } 110 111 118 public Phone(int uid) 119 throws DBException { 120 super(uid); 121 } 122 123 130 public Phone(RequestContext request) 131 throws DBException { 132 super(request); 133 } 134 135 138 public void add() 139 throws DBException { 140 setField("AddedOn", DateTime.getDateTimeForDB(this.getDataContext())); 141 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 142 super.add(); 143 } 144 145 146 151 public Vector getValidValues(String fieldName) 152 throws DBException { 153 Vector myValues = new Vector (4); 154 155 if (fieldName.equals(FLD_TYPE)) { 156 myValues.addElement(new ValidValue("Primary Voice", 157 "Primary Voice")); 158 myValues.addElement(new ValidValue("Secondary Voice", 159 "Secondary Voice")); 160 myValues.addElement(new ValidValue("Mobile", "Mobile")); 161 myValues.addElement(new ValidValue("Pager", "Pager")); 162 myValues.addElement(new ValidValue("Other", "Other")); 163 164 return myValues; 165 } 166 167 return super.getValidValues(fieldName); 168 } 169 170 174 public void setupFields() 175 throws DBException { 176 setTargetTable("SMPREGPH"); 177 setDescription("Phone Number(s)"); 178 setCharset("ISO-8859-1"); 179 180 181 addField("PhoneID", "auto-inc", 0, false, "Phone ID"); 182 addField("ExpUid", "int", 0, false, "Person ID Number"); 183 addField(FLD_TYPE, "varchar", 20, false, "Type"); 184 addField("CountryCode", "char", 3, false, "Country Code"); 185 addField("AreaCode", "char", 3, false, "Area/City Code"); 186 addField(FLD_NUMBER, "char", 10, false, "Phone Number"); 187 addField("AddedOn", "datetime", 0, true, "Added On"); 188 addField("UpdatedOn", "datetime", 0, true, "Updated On"); 189 setReadOnly("AddedOn"); 190 setReadOnly("UpdatedOn"); 191 192 193 setReadOnly("PhoneID"); 194 addKey("PhoneID"); 195 setLookupObject("ExpUid", 196 "com.jcorporate.expresso.security.dbobj.DefaultUserInfo"); 197 addKey("ExpUid"); 198 setMultiValued(FLD_TYPE); 199 } 200 201 204 public void update() 205 throws DBException { 206 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 207 super.update(); 208 } 209 210 211 } 212 213 | Popular Tags |