1 package org.apache.jetspeed.om.dbregistry; 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 26 34 public abstract class BasePortletParameter extends BaseObject 35 { 36 37 private static final PortletParameterPeer peer = 38 new PortletParameterPeer(); 39 40 41 42 private long id; 43 44 45 private String name; 46 47 48 private String value="0"; 49 50 51 private String type; 52 53 54 private boolean hidden=false; 55 56 57 private String role; 58 59 60 private boolean cachedonvalue=true; 61 62 63 private boolean cachedonname=true; 64 65 66 private String title; 67 68 69 private String description; 70 71 72 private String image; 73 74 75 private long portletId; 76 77 78 private String securityRef; 79 80 81 85 public long getId() 86 { 87 return id; 88 } 89 90 91 94 public void setId(long v ) 95 { 96 97 if (this.id != v) 98 { 99 this.id = v; 100 setModified(true); 101 } 102 103 104 } 105 106 107 111 public String getName() 112 { 113 return name; 114 } 115 116 117 120 public void setName(String v ) 121 { 122 123 if (!ObjectUtils.equals(this.name, v)) 124 { 125 this.name = v; 126 setModified(true); 127 } 128 129 130 } 131 132 133 137 public String getValue() 138 { 139 return value; 140 } 141 142 143 146 public void setValue(String v ) 147 { 148 149 if (!ObjectUtils.equals(this.value, v)) 150 { 151 this.value = v; 152 setModified(true); 153 } 154 155 156 } 157 158 159 163 public String getType() 164 { 165 return type; 166 } 167 168 169 172 public void setType(String v ) 173 { 174 175 if (!ObjectUtils.equals(this.type, v)) 176 { 177 this.type = v; 178 setModified(true); 179 } 180 181 182 } 183 184 185 189 public boolean getHidden() 190 { 191 return hidden; 192 } 193 194 195 198 public void setHidden(boolean v ) 199 { 200 201 if (this.hidden != v) 202 { 203 this.hidden = v; 204 setModified(true); 205 } 206 207 208 } 209 210 211 215 public String getRole() 216 { 217 return role; 218 } 219 220 221 224 public void setRole(String v ) 225 { 226 227 if (!ObjectUtils.equals(this.role, v)) 228 { 229 this.role = v; 230 setModified(true); 231 } 232 233 234 } 235 236 237 241 public boolean getCachedonvalue() 242 { 243 return cachedonvalue; 244 } 245 246 247 250 public void setCachedonvalue(boolean v ) 251 { 252 253 if (this.cachedonvalue != v) 254 { 255 this.cachedonvalue = v; 256 setModified(true); 257 } 258 259 260 } 261 262 263 267 public boolean getCachedonname() 268 { 269 return cachedonname; 270 } 271 272 273 276 public void setCachedonname(boolean v ) 277 { 278 279 if (this.cachedonname != v) 280 { 281 this.cachedonname = v; 282 setModified(true); 283 } 284 285 286 } 287 288 289 293 public String getTitle() 294 { 295 return title; 296 } 297 298 299 302 public void setTitle(String v ) 303 { 304 305 if (!ObjectUtils.equals(this.title, v)) 306 { 307 this.title = v; 308 setModified(true); 309 } 310 311 312 } 313 314 315 319 public String getDescription() 320 { 321 return description; 322 } 323 324 325 328 public void setDescription(String v ) 329 { 330 331 if (!ObjectUtils.equals(this.description, v)) 332 { 333 this.description = v; 334 setModified(true); 335 } 336 337 338 } 339 340 341 345 public String getImage() 346 { 347 return image; 348 } 349 350 351 354 public void setImage(String v ) 355 { 356 357 if (!ObjectUtils.equals(this.image, v)) 358 { 359 this.image = v; 360 setModified(true); 361 } 362 363 364 } 365 366 367 371 public long getPortletId() 372 { 373 return portletId; 374 } 375 376 377 380 public void setPortletId(long v ) throws TorqueException 381 { 382 383 if (this.portletId != v) 384 { 385 this.portletId = v; 386 setModified(true); 387 } 388 389 390 if (aPortletDbEntry != null && !(aPortletDbEntry.getId() == v)) 391 { 392 aPortletDbEntry = null; 393 } 394 395 } 396 397 398 402 public String getSecurityRef() 403 { 404 return securityRef; 405 } 406 407 408 411 public void setSecurityRef(String v ) 412 { 413 414 if (!ObjectUtils.equals(this.securityRef, v)) 415 { 416 this.securityRef = v; 417 setModified(true); 418 } 419 420 421 } 422 423 424 425 426 427 private PortletDbEntry aPortletDbEntry; 428 429 434 public void setPortletDbEntry(PortletDbEntry v) throws TorqueException 435 { 436 if (v == null) 437 { 438 setPortletId(0); 439 } 440 else 441 { 442 setPortletId(v.getId()); 443 } 444 aPortletDbEntry = v; 445 } 446 447 448 public PortletDbEntry getPortletDbEntry() throws TorqueException 449 { 450 if ( getPortletId()>0 ) 451 { 452 return PortletDbEntryManager.getInstance(SimpleKey.keyFor(getPortletId())); 453 } 454 return aPortletDbEntry; 455 } 456 457 463 public void setPortletDbEntryKey(ObjectKey key) throws TorqueException 464 { 465 466 setPortletId(((NumberKey) key).longValue()); 467 } 468 469 470 471 private static List fieldNames = null; 472 473 476 public static synchronized List getFieldNames() 477 { 478 if (fieldNames == null) 479 { 480 fieldNames = new ArrayList (); 481 fieldNames.add("Id"); 482 fieldNames.add("Name"); 483 fieldNames.add("Value"); 484 fieldNames.add("Type"); 485 fieldNames.add("Hidden"); 486 fieldNames.add("Role"); 487 fieldNames.add("Cachedonvalue"); 488 fieldNames.add("Cachedonname"); 489 fieldNames.add("Title"); 490 fieldNames.add("Description"); 491 fieldNames.add("Image"); 492 fieldNames.add("PortletId"); 493 fieldNames.add("SecurityRef"); 494 fieldNames = Collections.unmodifiableList(fieldNames); 495 } 496 return fieldNames; 497 } 498 499 503 public Object getByName(String name) 504 { 505 if (name.equals("Id")) 506 { 507 return new Long (getId()); 508 } 509 if (name.equals("Name")) 510 { 511 return getName(); 512 } 513 if (name.equals("Value")) 514 { 515 return getValue(); 516 } 517 if (name.equals("Type")) 518 { 519 return getType(); 520 } 521 if (name.equals("Hidden")) 522 { 523 return new Boolean (getHidden()); 524 } 525 if (name.equals("Role")) 526 { 527 return getRole(); 528 } 529 if (name.equals("Cachedonvalue")) 530 { 531 return new Boolean (getCachedonvalue()); 532 } 533 if (name.equals("Cachedonname")) 534 { 535 return new Boolean (getCachedonname()); 536 } 537 if (name.equals("Title")) 538 { 539 return getTitle(); 540 } 541 if (name.equals("Description")) 542 { 543 return getDescription(); 544 } 545 if (name.equals("Image")) 546 { 547 return getImage(); 548 } 549 if (name.equals("PortletId")) 550 { 551 return new Long (getPortletId()); 552 } 553 if (name.equals("SecurityRef")) 554 { 555 return getSecurityRef(); 556 } 557 return null; 558 } 559 560 565 public Object getByPeerName(String name) 566 { 567 if (name.equals(PortletParameterPeer.ID )) 568 { 569 return new Long (getId()); 570 } 571 if (name.equals(PortletParameterPeer.NAME )) 572 { 573 return getName(); 574 } 575 if (name.equals(PortletParameterPeer.VALUE )) 576 { 577 return getValue(); 578 } 579 if (name.equals(PortletParameterPeer.TYPE )) 580 { 581 return getType(); 582 } 583 if (name.equals(PortletParameterPeer.HIDDEN )) 584 { 585 return new Boolean (getHidden()); 586 } 587 if (name.equals(PortletParameterPeer.ROLE )) 588 { 589 return getRole(); 590 } 591 if (name.equals(PortletParameterPeer.CACHEDONVALUE )) 592 { 593 return new Boolean (getCachedonvalue()); 594 } 595 if (name.equals(PortletParameterPeer.CACHEDONNAME )) 596 { 597 return new Boolean (getCachedonname()); 598 } 599 if (name.equals(PortletParameterPeer.TITLE )) 600 { 601 return getTitle(); 602 } 603 if (name.equals(PortletParameterPeer.DESCRIPTION )) 604 { 605 return getDescription(); 606 } 607 if (name.equals(PortletParameterPeer.IMAGE )) 608 { 609 return getImage(); 610 } 611 if (name.equals(PortletParameterPeer.PORTLET_ID )) 612 { 613 return new Long (getPortletId()); 614 } 615 if (name.equals(PortletParameterPeer.SECURITY )) 616 { 617 return getSecurityRef(); 618 } 619 return null; 620 } 621 622 626 public Object getByPosition(int pos) 627 { 628 if ( pos == 0 ) 629 { 630 return new Long (getId()); 631 } 632 if ( pos == 1 ) 633 { 634 return getName(); 635 } 636 if ( pos == 2 ) 637 { 638 return getValue(); 639 } 640 if ( pos == 3 ) 641 { 642 return getType(); 643 } 644 if ( pos == 4 ) 645 { 646 return new Boolean (getHidden()); 647 } 648 if ( pos == 5 ) 649 { 650 return getRole(); 651 } 652 if ( pos == 6 ) 653 { 654 return new Boolean (getCachedonvalue()); 655 } 656 if ( pos == 7 ) 657 { 658 return new Boolean (getCachedonname()); 659 } 660 if ( pos == 8 ) 661 { 662 return getTitle(); 663 } 664 if ( pos == 9 ) 665 { 666 return getDescription(); 667 } 668 if ( pos == 10 ) 669 { 670 return getImage(); 671 } 672 if ( pos == 11 ) 673 { 674 return new Long (getPortletId()); 675 } 676 if ( pos == 12 ) 677 { 678 return getSecurityRef(); 679 } 680 return null; 681 } 682 683 687 public void save() throws Exception 688 { 689 save(PortletParameterPeer.getMapBuilder() 690 .getDatabaseMap().getName()); 691 } 692 693 700 public void save(String dbName) throws TorqueException 701 { 702 Connection con = null; 703 try 704 { 705 con = Transaction.begin(dbName); 706 save(con); 707 Transaction.commit(con); 708 } 709 catch(TorqueException e) 710 { 711 Transaction.safeRollback(con); 712 throw e; 713 } 714 } 715 716 718 private boolean alreadyInSave = false; 719 726 public void save(Connection con) throws TorqueException 727 { 728 if (!alreadyInSave) 729 { 730 alreadyInSave = true; 731 732 733 734 if (isModified()) 736 { 737 if (isNew()) 738 { 739 PortletParameterPeer.doInsert((PortletParameter)this, con); 740 setNew(false); 741 } 742 else 743 { 744 PortletParameterPeer.doUpdate((PortletParameter)this, con); 745 } 746 747 if (isCacheOnSave()) 748 { 749 PortletParameterManager.putInstance(this); 750 } 751 } 752 753 alreadyInSave = false; 754 } 755 } 756 757 761 protected boolean isCacheOnSave() 762 { 763 return true; 764 } 765 766 767 772 public void setPrimaryKey(ObjectKey id) 773 { 774 setId(((NumberKey)id).longValue()); 775 } 776 777 780 public void setPrimaryKey(String key) 781 { 782 setId(Long.parseLong(key)); 783 } 784 785 786 790 public ObjectKey getPrimaryKey() 791 { 792 return SimpleKey.keyFor(getId()); 793 } 794 795 796 801 public PortletParameter copy() throws TorqueException 802 { 803 PortletParameter copyObj = new PortletParameter(); 804 copyObj.setId(id); 805 copyObj.setName(name); 806 copyObj.setValue(value); 807 copyObj.setType(type); 808 copyObj.setHidden(hidden); 809 copyObj.setRole(role); 810 copyObj.setCachedonvalue(cachedonvalue); 811 copyObj.setCachedonname(cachedonname); 812 copyObj.setTitle(title); 813 copyObj.setDescription(description); 814 copyObj.setImage(image); 815 copyObj.setPortletId(portletId); 816 copyObj.setSecurityRef(securityRef); 817 818 copyObj.setId(0); 819 820 return copyObj; 821 } 822 823 829 public PortletParameterPeer getPeer() 830 { 831 return peer; 832 } 833 } 834 | Popular Tags |