1 2 38 39 40 package jspPhoneBook.data; 41 42 import com.lutris.appserver.server.sql.*; 43 import java.sql.*; 44 import java.math.*; 45 import java.io.Serializable ; 46 import com.lutris.dods.builder.generator.dataobject.*; 47 import com.lutris.dods.builder.generator.query.*; 48 import org.enhydra.dods.cache.Condition; 49 50 51 62 public class PersonDataStruct extends CoreDataStruct implements Cloneable , Serializable { 63 64 68 public boolean readOnly = false; 69 70 74 protected boolean isEmpty = true; 75 76 79 private String databaseName = null; 80 81 private byte[] copyByteArray( byte[] source ) { 82 byte[] dest = new byte[ source.length ]; 83 System.arraycopy( source, 0, dest, 0, source.length ); 84 return dest; 85 } 86 87 91 protected int getVersion () { 92 return get_Version(); 93 } 94 95 98 protected int get_Version () { 99 return super.get_Version(); 100 } 101 102 106 protected void setVersion (int v) { 107 set_Version(v); 108 } 109 110 113 protected void set_Version (int v) { 114 super.set_Version(v); 115 } 116 117 121 public ObjectId getOId() { 122 return get_OId(); 123 } 124 125 129 public ObjectId get_OId() { 130 return super.get_OId(); 131 } 132 133 137 protected void setOId(ObjectId oId) { 138 set_OId(oId); 139 } 140 141 145 protected void set_OId(ObjectId oId) { 146 super.set_OId(oId); 147 } 148 149 150 151 158 public String get_Handle() 159 throws DatabaseManagerException { 160 String ret = null; 161 if ( null == get_OId() ) 162 throw new DatabaseManagerException( "ID not set " ); 163 ret = get_OId().toString(); 164 return ret; 165 } 166 167 168 176 public String get_CacheHandle()throws DatabaseManagerException { 177 String ret = get_Database() + "." + get_Handle(); 178 return ret; 179 } 180 181 182 183 186 public void set_Database(String dbName) { 187 if (null != databaseName) 188 throw new Error ("Whatta hack you are doing! Multiple db setting not allowed."); 189 databaseName = dbName; 190 } 191 192 193 196 public String get_Database() { 197 return databaseName; 198 } 199 200 201 private String firstName = null; 202 203 204 205 210 211 static public final int COLUMN_FIRSTNAME = 0; 212 213 214 215 216 217 222 223 public void setFirstName(String _firstName) { 224 225 if (readOnly) 226 227 throw new Error ("This should never happen! setFirstName on " 228 229 + this +" is being called although readOnly is true"); 230 231 233 firstName = _firstName; 234 235 237 } 238 239 240 241 246 247 public String getFirstName() { 248 249 return firstName; 250 251 } 252 253 254 255 private String lastName = null; 256 257 258 259 264 265 static public final int COLUMN_LASTNAME = 1; 266 267 268 269 270 271 276 277 public void setLastName(String _lastName) { 278 279 if (readOnly) 280 281 throw new Error ("This should never happen! setLastName on " 282 283 + this +" is being called although readOnly is true"); 284 285 287 lastName = _lastName; 288 289 291 } 292 293 294 295 300 301 public String getLastName() { 302 303 return lastName; 304 305 } 306 307 308 309 private String phoneNumber = null; 310 311 312 313 318 319 static public final int COLUMN_PHONENUMBER = 2; 320 321 322 323 324 325 330 331 public void setPhoneNumber(String _phoneNumber) { 332 333 if (readOnly) 334 335 throw new Error ("This should never happen! setPhoneNumber on " 336 337 + this +" is being called although readOnly is true"); 338 339 341 phoneNumber = _phoneNumber; 342 343 345 } 346 347 348 349 354 355 public String getPhoneNumber() { 356 357 return phoneNumber; 358 359 } 360 361 362 365 static public final int COLUMN_OID = 3; 366 367 375 public boolean compareCond(Condition cond) { 376 try { 377 switch (cond.getColumnIndex()) { 378 case COLUMN_FIRSTNAME: 379 380 return QueryBuilder.compare(getFirstName(),cond.getValue(),cond.getOperator()); 381 382 383 384 case COLUMN_LASTNAME: 385 386 return QueryBuilder.compare(getLastName(),cond.getValue(),cond.getOperator()); 387 388 389 390 case COLUMN_PHONENUMBER: 391 392 return QueryBuilder.compare(getPhoneNumber(),cond.getValue(),cond.getOperator()); 393 394 395 396 397 case COLUMN_OID: 398 return QueryBuilder.compare(get_CacheHandle(),cond.getValue(),cond.getOperator()); 399 } 400 } catch (Exception e) { 401 System.out.println("************************** compareCond catck blok"); 402 } 403 return false; 404 } 405 406 416 public PersonDataStruct duplicate() 417 throws DatabaseManagerException, ObjectIdException { 418 PersonDataStruct ret = new PersonDataStruct (); 419 if (!isEmpty) { 420 ret.firstName = GenericDO.copyString(firstName); 421 422 ret.lastName = GenericDO.copyString(lastName); 423 424 ret.phoneNumber = GenericDO.copyString(phoneNumber); 425 426 427 } 428 ret.set_OId(get_OId()); 429 ret.set_Version(get_Version()); 430 ret.databaseName=get_Database(); 431 ret.isEmpty = isEmpty; 432 return ret; 433 } 434 } 435 | Popular Tags |