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 Contact 85 extends RegistrationDBObject { 86 87 92 public Contact() 93 throws DBException { 94 super(); 95 } 96 97 103 public Contact(DBConnection myConnection) 104 throws DBException { 105 super(myConnection); 106 } 107 108 115 public Contact(RequestContext request) 116 throws DBException { 117 super(request); 118 } 119 120 127 public Contact(int uid) 128 throws DBException { 129 super(uid); 130 } 131 132 135 public void add() 136 throws DBException { 137 setField("AddedOn", DateTime.getDateTimeForDB(this.getDataContext())); 138 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 139 super.add(); 140 } 141 142 143 148 public Vector getValidValues(String fieldName) 149 throws DBException { 150 Vector myValues = new Vector (4); 151 152 if (fieldName.equals(FLD_TYPE)) { 153 myValues.addElement(new ValidValue("Secondary Email", 154 "Secondary Email")); 155 myValues.addElement(new ValidValue("Web URL", "Web URL")); 156 myValues.addElement(new ValidValue("Instant Messenger", 157 "Instant Messenger")); 158 myValues.addElement(new ValidValue("IIRC", "IIRC")); 159 myValues.addElement(new ValidValue("Other", "Other")); 160 161 return myValues; 162 } 163 164 return super.getValidValues(fieldName); 165 } 166 167 171 public void setupFields() 172 throws DBException { 173 setTargetTable("SMPREGCT"); 174 setDescription("Ways of Contacting You"); 175 setCharset("ISO-8859-1"); 176 177 178 addField("ContactID", "auto-inc", 0, false, "Contact ID"); 179 addField("ExpUid", "int", 0, false, "Person ID Number"); 180 addField(FLD_TYPE, "varchar", 20, false, "Type"); 181 addField("Contact", "varchar", 20, false, "Address/URL/Number/etc."); 182 addField("Instructions", "text", 0, true, "Contact When/How"); 183 addField("AddedOn", "datetime", 0, true, "Added On"); 184 addField("UpdatedOn", "datetime", 0, true, "Updated On"); 185 setReadOnly("AddedOn"); 186 setReadOnly("UpdatedOn"); 187 188 189 setReadOnly("ContactID"); 190 addKey("ContactID"); 191 setLookupObject("ExpUid", 192 "com.jcorporate.expresso.security.dbobj.DefaultUserInfo"); 193 addKey("ExpUid"); 194 setMultiValued(FLD_TYPE); 195 } 196 197 200 public static final String FLD_TYPE = "ContactType"; 201 202 205 public void update() 206 throws DBException { 207 setField("UpdatedOn", DateTime.getDateTimeForDB(this.getDataContext())); 208 super.update(); 209 } 210 211 212 } 213 214 | Popular Tags |