1 package org.apache.jetspeed.om.dbpsml; 2 3 4 import java.math.BigDecimal ; 5 import java.sql.Connection ; 6 import java.util.ArrayList ; 7 import java.util.Collections ; 8 import java.util.Date ; 9 import java.util.List ; 10 11 import org.apache.commons.lang.ObjectUtils; 12 import org.apache.torque.TorqueException; 13 import org.apache.torque.om.BaseObject; 14 import org.apache.torque.om.ComboKey; 15 import org.apache.torque.om.DateKey; 16 import org.apache.torque.om.NumberKey; 17 import org.apache.torque.om.ObjectKey; 18 import org.apache.torque.om.SimpleKey; 19 import org.apache.torque.om.StringKey; 20 import org.apache.torque.om.Persistent; 21 import org.apache.torque.util.Criteria; 22 import org.apache.torque.util.Transaction; 23 24 25 33 public abstract class BaseJetspeedUserProfile extends BaseObject 34 { 35 36 private static final JetspeedUserProfilePeer peer = 37 new JetspeedUserProfilePeer(); 38 39 40 41 private int psmlId; 42 43 44 private String userName; 45 46 47 private String mediaType; 48 49 50 private String language; 51 52 53 private String country; 54 55 56 private String page; 57 58 59 private byte[] profile; 60 61 62 66 public int getPsmlId() 67 { 68 return psmlId; 69 } 70 71 72 75 public void setPsmlId(int v ) 76 { 77 78 if (this.psmlId != v) 79 { 80 this.psmlId = v; 81 setModified(true); 82 } 83 84 85 } 86 87 88 92 public String getUserName() 93 { 94 return userName; 95 } 96 97 98 101 public void setUserName(String v ) 102 { 103 104 if (!ObjectUtils.equals(this.userName, v)) 105 { 106 this.userName = v; 107 setModified(true); 108 } 109 110 111 } 112 113 114 118 public String getMediaType() 119 { 120 return mediaType; 121 } 122 123 124 127 public void setMediaType(String v ) 128 { 129 130 if (!ObjectUtils.equals(this.mediaType, v)) 131 { 132 this.mediaType = v; 133 setModified(true); 134 } 135 136 137 } 138 139 140 144 public String getLanguage() 145 { 146 return language; 147 } 148 149 150 153 public void setLanguage(String v ) 154 { 155 156 if (!ObjectUtils.equals(this.language, v)) 157 { 158 this.language = v; 159 setModified(true); 160 } 161 162 163 } 164 165 166 170 public String getCountry() 171 { 172 return country; 173 } 174 175 176 179 public void setCountry(String v ) 180 { 181 182 if (!ObjectUtils.equals(this.country, v)) 183 { 184 this.country = v; 185 setModified(true); 186 } 187 188 189 } 190 191 192 196 public String getPage() 197 { 198 return page; 199 } 200 201 202 205 public void setPage(String v ) 206 { 207 208 if (!ObjectUtils.equals(this.page, v)) 209 { 210 this.page = v; 211 setModified(true); 212 } 213 214 215 } 216 217 218 222 public byte[] getProfile() 223 { 224 return profile; 225 } 226 227 228 231 public void setProfile(byte[] v ) 232 { 233 234 if (!ObjectUtils.equals(this.profile, v)) 235 { 236 this.profile = v; 237 setModified(true); 238 } 239 240 241 } 242 243 244 245 246 private static List fieldNames = null; 247 248 251 public static synchronized List getFieldNames() 252 { 253 if (fieldNames == null) 254 { 255 fieldNames = new ArrayList (); 256 fieldNames.add("PsmlId"); 257 fieldNames.add("UserName"); 258 fieldNames.add("MediaType"); 259 fieldNames.add("Language"); 260 fieldNames.add("Country"); 261 fieldNames.add("Page"); 262 fieldNames.add("Profile"); 263 fieldNames = Collections.unmodifiableList(fieldNames); 264 } 265 return fieldNames; 266 } 267 268 272 public Object getByName(String name) 273 { 274 if (name.equals("PsmlId")) 275 { 276 return new Integer (getPsmlId()); 277 } 278 if (name.equals("UserName")) 279 { 280 return getUserName(); 281 } 282 if (name.equals("MediaType")) 283 { 284 return getMediaType(); 285 } 286 if (name.equals("Language")) 287 { 288 return getLanguage(); 289 } 290 if (name.equals("Country")) 291 { 292 return getCountry(); 293 } 294 if (name.equals("Page")) 295 { 296 return getPage(); 297 } 298 if (name.equals("Profile")) 299 { 300 return getProfile(); 301 } 302 return null; 303 } 304 305 310 public Object getByPeerName(String name) 311 { 312 if (name.equals(JetspeedUserProfilePeer.PSML_ID )) 313 { 314 return new Integer (getPsmlId()); 315 } 316 if (name.equals(JetspeedUserProfilePeer.USER_NAME )) 317 { 318 return getUserName(); 319 } 320 if (name.equals(JetspeedUserProfilePeer.MEDIA_TYPE )) 321 { 322 return getMediaType(); 323 } 324 if (name.equals(JetspeedUserProfilePeer.LANGUAGE )) 325 { 326 return getLanguage(); 327 } 328 if (name.equals(JetspeedUserProfilePeer.COUNTRY )) 329 { 330 return getCountry(); 331 } 332 if (name.equals(JetspeedUserProfilePeer.PAGE )) 333 { 334 return getPage(); 335 } 336 if (name.equals(JetspeedUserProfilePeer.PROFILE )) 337 { 338 return getProfile(); 339 } 340 return null; 341 } 342 343 347 public Object getByPosition(int pos) 348 { 349 if ( pos == 0 ) 350 { 351 return new Integer (getPsmlId()); 352 } 353 if ( pos == 1 ) 354 { 355 return getUserName(); 356 } 357 if ( pos == 2 ) 358 { 359 return getMediaType(); 360 } 361 if ( pos == 3 ) 362 { 363 return getLanguage(); 364 } 365 if ( pos == 4 ) 366 { 367 return getCountry(); 368 } 369 if ( pos == 5 ) 370 { 371 return getPage(); 372 } 373 if ( pos == 6 ) 374 { 375 return getProfile(); 376 } 377 return null; 378 } 379 380 384 public void save() throws Exception 385 { 386 save(JetspeedUserProfilePeer.getMapBuilder() 387 .getDatabaseMap().getName()); 388 } 389 390 397 public void save(String dbName) throws TorqueException 398 { 399 Connection con = null; 400 try 401 { 402 con = Transaction.begin(dbName); 403 save(con); 404 Transaction.commit(con); 405 } 406 catch(TorqueException e) 407 { 408 Transaction.safeRollback(con); 409 throw e; 410 } 411 } 412 413 415 private boolean alreadyInSave = false; 416 423 public void save(Connection con) throws TorqueException 424 { 425 if (!alreadyInSave) 426 { 427 alreadyInSave = true; 428 429 430 431 if (isModified()) 433 { 434 if (isNew()) 435 { 436 JetspeedUserProfilePeer.doInsert((JetspeedUserProfile)this, con); 437 setNew(false); 438 } 439 else 440 { 441 JetspeedUserProfilePeer.doUpdate((JetspeedUserProfile)this, con); 442 } 443 444 if (isCacheOnSave()) 445 { 446 JetspeedUserProfileManager.putInstance(this); 447 } 448 } 449 450 alreadyInSave = false; 451 } 452 } 453 454 458 protected boolean isCacheOnSave() 459 { 460 return true; 461 } 462 463 464 469 public void setPrimaryKey(ObjectKey psmlId) 470 { 471 setPsmlId(((NumberKey)psmlId).intValue()); 472 } 473 474 477 public void setPrimaryKey(String key) 478 { 479 setPsmlId(Integer.parseInt(key)); 480 } 481 482 483 487 public ObjectKey getPrimaryKey() 488 { 489 return SimpleKey.keyFor(getPsmlId()); 490 } 491 492 493 498 public JetspeedUserProfile copy() throws TorqueException 499 { 500 JetspeedUserProfile copyObj = new JetspeedUserProfile(); 501 copyObj.setPsmlId(psmlId); 502 copyObj.setUserName(userName); 503 copyObj.setMediaType(mediaType); 504 copyObj.setLanguage(language); 505 copyObj.setCountry(country); 506 copyObj.setPage(page); 507 copyObj.setProfile(profile); 508 509 copyObj.setPsmlId(0); 510 511 return copyObj; 512 } 513 514 520 public JetspeedUserProfilePeer getPeer() 521 { 522 return peer; 523 } 524 } 525 | Popular Tags |