1 package org.tigris.scarab.om; 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.fulcrum.intake.Retrievable; 13 import org.apache.torque.TorqueException; 14 import org.apache.torque.om.BaseObject; 15 import org.apache.torque.om.ComboKey; 16 import org.apache.torque.om.DateKey; 17 import org.apache.torque.om.NumberKey; 18 import org.apache.torque.om.ObjectKey; 19 import org.apache.torque.om.SimpleKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.Persistent; 22 import org.apache.torque.util.Criteria; 23 import org.apache.torque.util.Transaction; 24 25 26 27 28 32 public abstract class BaseRIssueTypeOption extends BaseObject 33 implements org.apache.fulcrum.intake.Retrievable 34 { 35 36 private static final RIssueTypeOptionPeer peer = 37 new RIssueTypeOptionPeer(); 38 39 40 41 private Integer issueTypeId; 42 43 44 private Integer optionId; 45 46 47 private boolean active = true; 48 49 50 private boolean locked = false; 51 52 53 private int order = -1; 54 55 56 private int weight = -1; 57 58 59 64 public Integer getIssueTypeId() 65 { 66 return issueTypeId; 67 } 68 69 70 75 public void setIssueTypeId(Integer v) throws TorqueException 76 { 77 78 if (!ObjectUtils.equals(this.issueTypeId, v)) 79 { 80 this.issueTypeId = v; 81 setModified(true); 82 } 83 84 85 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) 86 { 87 aIssueType = null; 88 } 89 90 } 91 92 97 public Integer getOptionId() 98 { 99 return optionId; 100 } 101 102 103 108 public void setOptionId(Integer v) throws TorqueException 109 { 110 111 if (!ObjectUtils.equals(this.optionId, v)) 112 { 113 this.optionId = v; 114 setModified(true); 115 } 116 117 118 if (aAttributeOption != null && !ObjectUtils.equals(aAttributeOption.getOptionId(), v)) 119 { 120 aAttributeOption = null; 121 } 122 123 } 124 125 130 public boolean getActive() 131 { 132 return active; 133 } 134 135 136 141 public void setActive(boolean v) 142 { 143 144 if (this.active != v) 145 { 146 this.active = v; 147 setModified(true); 148 } 149 150 151 } 152 153 158 public boolean getLocked() 159 { 160 return locked; 161 } 162 163 164 169 public void setLocked(boolean v) 170 { 171 172 if (this.locked != v) 173 { 174 this.locked = v; 175 setModified(true); 176 } 177 178 179 } 180 181 186 public int getOrder() 187 { 188 return order; 189 } 190 191 192 197 public void setOrder(int v) 198 { 199 200 if (this.order != v) 201 { 202 this.order = v; 203 setModified(true); 204 } 205 206 207 } 208 209 214 public int getWeight() 215 { 216 return weight; 217 } 218 219 220 225 public void setWeight(int v) 226 { 227 228 if (this.weight != v) 229 { 230 this.weight = v; 231 setModified(true); 232 } 233 234 235 } 236 237 238 239 240 private AttributeOption aAttributeOption; 241 242 248 public void setAttributeOption(AttributeOption v) throws TorqueException 249 { 250 if (v == null) 251 { 252 setOptionId((Integer ) null); 253 } 254 else 255 { 256 setOptionId(v.getOptionId()); 257 } 258 aAttributeOption = v; 259 } 260 261 262 268 public AttributeOption getAttributeOption() throws TorqueException 269 { 270 if ( !ObjectUtils.equals(getOptionId(), null) ) 271 { 272 return AttributeOptionManager.getInstance(SimpleKey.keyFor(getOptionId())); 273 } 274 return aAttributeOption; 275 } 276 277 283 public void setAttributeOptionKey(ObjectKey key) throws TorqueException 284 { 285 286 setOptionId(new Integer (((NumberKey) key).intValue())); 287 } 288 289 290 291 private IssueType aIssueType; 292 293 299 public void setIssueType(IssueType v) throws TorqueException 300 { 301 if (v == null) 302 { 303 setIssueTypeId((Integer ) null); 304 } 305 else 306 { 307 setIssueTypeId(v.getIssueTypeId()); 308 } 309 aIssueType = v; 310 } 311 312 313 319 public IssueType getIssueType() throws TorqueException 320 { 321 if ( !ObjectUtils.equals(getIssueTypeId(), null) ) 322 { 323 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId())); 324 } 325 return aIssueType; 326 } 327 328 334 public void setIssueTypeKey(ObjectKey key) throws TorqueException 335 { 336 337 setIssueTypeId(new Integer (((NumberKey) key).intValue())); 338 } 339 340 341 private static List fieldNames = null; 342 343 348 public static synchronized List getFieldNames() 349 { 350 if (fieldNames == null) 351 { 352 fieldNames = new ArrayList (); 353 fieldNames.add("IssueTypeId"); 354 fieldNames.add("OptionId"); 355 fieldNames.add("Active"); 356 fieldNames.add("Locked"); 357 fieldNames.add("Order"); 358 fieldNames.add("Weight"); 359 fieldNames = Collections.unmodifiableList(fieldNames); 360 } 361 return fieldNames; 362 } 363 364 370 public Object getByName(String name) 371 { 372 if (name.equals("IssueTypeId")) 373 { 374 return getIssueTypeId(); 375 } 376 if (name.equals("OptionId")) 377 { 378 return getOptionId(); 379 } 380 if (name.equals("Active")) 381 { 382 return Boolean.valueOf(getActive()); 383 } 384 if (name.equals("Locked")) 385 { 386 return Boolean.valueOf(getLocked()); 387 } 388 if (name.equals("Order")) 389 { 390 return new Integer (getOrder()); 391 } 392 if (name.equals("Weight")) 393 { 394 return new Integer (getWeight()); 395 } 396 return null; 397 } 398 399 407 public Object getByPeerName(String name) 408 { 409 if (name.equals(RIssueTypeOptionPeer.ISSUE_TYPE_ID)) 410 { 411 return getIssueTypeId(); 412 } 413 if (name.equals(RIssueTypeOptionPeer.OPTION_ID)) 414 { 415 return getOptionId(); 416 } 417 if (name.equals(RIssueTypeOptionPeer.ACTIVE)) 418 { 419 return Boolean.valueOf(getActive()); 420 } 421 if (name.equals(RIssueTypeOptionPeer.LOCKED)) 422 { 423 return Boolean.valueOf(getLocked()); 424 } 425 if (name.equals(RIssueTypeOptionPeer.PREFERRED_ORDER)) 426 { 427 return new Integer (getOrder()); 428 } 429 if (name.equals(RIssueTypeOptionPeer.WEIGHT)) 430 { 431 return new Integer (getWeight()); 432 } 433 return null; 434 } 435 436 443 public Object getByPosition(int pos) 444 { 445 if (pos == 0) 446 { 447 return getIssueTypeId(); 448 } 449 if (pos == 1) 450 { 451 return getOptionId(); 452 } 453 if (pos == 2) 454 { 455 return Boolean.valueOf(getActive()); 456 } 457 if (pos == 3) 458 { 459 return Boolean.valueOf(getLocked()); 460 } 461 if (pos == 4) 462 { 463 return new Integer (getOrder()); 464 } 465 if (pos == 5) 466 { 467 return new Integer (getWeight()); 468 } 469 return null; 470 } 471 472 478 public void save() throws Exception 479 { 480 save(RIssueTypeOptionPeer.getMapBuilder() 481 .getDatabaseMap().getName()); 482 } 483 484 494 public void save(String dbName) throws TorqueException 495 { 496 Connection con = null; 497 try 498 { 499 con = Transaction.begin(dbName); 500 save(con); 501 Transaction.commit(con); 502 } 503 catch(TorqueException e) 504 { 505 Transaction.safeRollback(con); 506 throw e; 507 } 508 } 509 510 512 private boolean alreadyInSave = false; 513 523 public void save(Connection con) throws TorqueException 524 { 525 if (!alreadyInSave) 526 { 527 alreadyInSave = true; 528 529 530 531 if (isModified()) 533 { 534 if (isNew()) 535 { 536 RIssueTypeOptionPeer.doInsert((RIssueTypeOption)this, con); 537 setNew(false); 538 } 539 else 540 { 541 RIssueTypeOptionPeer.doUpdate((RIssueTypeOption)this, con); 542 } 543 544 if (isCacheOnSave()) 545 { 546 RIssueTypeOptionManager.putInstance(this); 547 } 548 } 549 550 alreadyInSave = false; 551 } 552 } 553 554 558 protected boolean isCacheOnSave() 559 { 560 return true; 561 } 562 563 564 565 private final SimpleKey[] pks = new SimpleKey[2]; 566 private final ComboKey comboPK = new ComboKey(pks); 567 568 573 public void setPrimaryKey(ObjectKey key) throws TorqueException 574 { 575 SimpleKey[] keys = (SimpleKey[]) key.getValue(); 576 SimpleKey tmpKey = null; 577 setIssueTypeId(new Integer (((NumberKey)keys[0]).intValue())); 578 setOptionId(new Integer (((NumberKey)keys[1]).intValue())); 579 } 580 581 587 public void setPrimaryKey( Integer issueTypeId, Integer optionId) 588 throws TorqueException 589 { 590 setIssueTypeId(issueTypeId); 591 setOptionId(optionId); 592 } 593 594 597 public void setPrimaryKey(String key) throws TorqueException 598 { 599 setPrimaryKey(new ComboKey(key)); 600 } 601 602 606 public ObjectKey getPrimaryKey() 607 { 608 pks[0] = SimpleKey.keyFor(getIssueTypeId()); 609 pks[1] = SimpleKey.keyFor(getOptionId()); 610 return comboPK; 611 } 612 613 617 public String getQueryKey() 618 { 619 if (getPrimaryKey() == null) 620 { 621 return ""; 622 } 623 else 624 { 625 return getPrimaryKey().toString(); 626 } 627 } 628 629 633 public void setQueryKey(String key) 634 throws TorqueException 635 { 636 setPrimaryKey(key); 637 } 638 639 645 public RIssueTypeOption copy() throws TorqueException 646 { 647 RIssueTypeOption copyObj = new RIssueTypeOption(); 648 copyObj.setIssueTypeId(issueTypeId); 649 copyObj.setOptionId(optionId); 650 copyObj.setActive(active); 651 copyObj.setLocked(locked); 652 copyObj.setOrder(order); 653 copyObj.setWeight(weight); 654 655 copyObj.setIssueTypeId((Integer )null); 656 copyObj.setOptionId((Integer )null); 657 658 return copyObj; 659 } 660 661 667 public RIssueTypeOptionPeer getPeer() 668 { 669 return peer; 670 } 671 672 public String toString() 673 { 674 StringBuffer str = new StringBuffer (); 675 str.append("RIssueTypeOption:\n"); 676 str.append("IssueTypeId = ") 677 .append(getIssueTypeId()) 678 .append("\n"); 679 str.append("OptionId = ") 680 .append(getOptionId()) 681 .append("\n"); 682 str.append("Active = ") 683 .append(getActive()) 684 .append("\n"); 685 str.append("Locked = ") 686 .append(getLocked()) 687 .append("\n"); 688 str.append("Order = ") 689 .append(getOrder()) 690 .append("\n"); 691 str.append("Weight = ") 692 .append(getWeight()) 693 .append("\n"); 694 return(str.toString()); 695 } 696 } 697 | Popular Tags |