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 BaseIssueTemplateInfo extends BaseObject 33 implements org.apache.fulcrum.intake.Retrievable 34 { 35 36 private static final IssueTemplateInfoPeer peer = 37 new IssueTemplateInfoPeer(); 38 39 40 41 private Long issueId; 42 43 44 private String name; 45 46 47 private String description; 48 49 50 private boolean approved = false; 51 52 53 private Integer scopeId; 54 55 56 61 public Long getIssueId() 62 { 63 return issueId; 64 } 65 66 67 72 public void setIssueId(Long v) throws TorqueException 73 { 74 75 if (!ObjectUtils.equals(this.issueId, v)) 76 { 77 this.issueId = v; 78 setModified(true); 79 } 80 81 82 if (aIssue != null && !ObjectUtils.equals(aIssue.getIssueId(), v)) 83 { 84 aIssue = null; 85 } 86 87 } 88 89 94 public String getName() 95 { 96 return name; 97 } 98 99 100 105 public void setName(String v) 106 { 107 108 if (!ObjectUtils.equals(this.name, v)) 109 { 110 this.name = v; 111 setModified(true); 112 } 113 114 115 } 116 117 122 public String getDescription() 123 { 124 return description; 125 } 126 127 128 133 public void setDescription(String v) 134 { 135 136 if (!ObjectUtils.equals(this.description, v)) 137 { 138 this.description = v; 139 setModified(true); 140 } 141 142 143 } 144 145 150 public boolean getApproved() 151 { 152 return approved; 153 } 154 155 156 161 public void setApproved(boolean v) 162 { 163 164 if (this.approved != v) 165 { 166 this.approved = v; 167 setModified(true); 168 } 169 170 171 } 172 173 178 public Integer getScopeId() 179 { 180 return scopeId; 181 } 182 183 184 189 public void setScopeId(Integer v) throws TorqueException 190 { 191 192 if (!ObjectUtils.equals(this.scopeId, v)) 193 { 194 this.scopeId = v; 195 setModified(true); 196 } 197 198 199 if (aScope != null && !ObjectUtils.equals(aScope.getScopeId(), v)) 200 { 201 aScope = null; 202 } 203 204 } 205 206 207 208 209 private Issue aIssue; 210 211 217 public void setIssue(Issue v) throws TorqueException 218 { 219 if (v == null) 220 { 221 setIssueId((Long ) null); 222 } 223 else 224 { 225 setIssueId(v.getIssueId()); 226 } 227 aIssue = v; 228 } 229 230 231 237 public Issue getIssue() throws TorqueException 238 { 239 if ( !ObjectUtils.equals(getIssueId(), null) ) 240 { 241 return IssueManager.getInstance(SimpleKey.keyFor(getIssueId())); 242 } 243 return aIssue; 244 } 245 246 252 public void setIssueKey(ObjectKey key) throws TorqueException 253 { 254 255 setIssueId(new Long (((NumberKey) key).longValue())); 256 } 257 258 259 260 private Scope aScope; 261 262 268 public void setScope(Scope v) throws TorqueException 269 { 270 if (v == null) 271 { 272 setScopeId((Integer ) null); 273 } 274 else 275 { 276 setScopeId(v.getScopeId()); 277 } 278 aScope = v; 279 } 280 281 282 288 public Scope getScope() throws TorqueException 289 { 290 if ( !ObjectUtils.equals(getScopeId(), null) ) 291 { 292 return ScopeManager.getInstance(SimpleKey.keyFor(getScopeId())); 293 } 294 return aScope; 295 } 296 297 303 public void setScopeKey(ObjectKey key) throws TorqueException 304 { 305 306 setScopeId(new Integer (((NumberKey) key).intValue())); 307 } 308 309 310 private static List fieldNames = null; 311 312 317 public static synchronized List getFieldNames() 318 { 319 if (fieldNames == null) 320 { 321 fieldNames = new ArrayList (); 322 fieldNames.add("IssueId"); 323 fieldNames.add("Name"); 324 fieldNames.add("Description"); 325 fieldNames.add("Approved"); 326 fieldNames.add("ScopeId"); 327 fieldNames = Collections.unmodifiableList(fieldNames); 328 } 329 return fieldNames; 330 } 331 332 338 public Object getByName(String name) 339 { 340 if (name.equals("IssueId")) 341 { 342 return getIssueId(); 343 } 344 if (name.equals("Name")) 345 { 346 return getName(); 347 } 348 if (name.equals("Description")) 349 { 350 return getDescription(); 351 } 352 if (name.equals("Approved")) 353 { 354 return Boolean.valueOf(getApproved()); 355 } 356 if (name.equals("ScopeId")) 357 { 358 return getScopeId(); 359 } 360 return null; 361 } 362 363 371 public Object getByPeerName(String name) 372 { 373 if (name.equals(IssueTemplateInfoPeer.ISSUE_ID)) 374 { 375 return getIssueId(); 376 } 377 if (name.equals(IssueTemplateInfoPeer.NAME)) 378 { 379 return getName(); 380 } 381 if (name.equals(IssueTemplateInfoPeer.DESCRIPTION)) 382 { 383 return getDescription(); 384 } 385 if (name.equals(IssueTemplateInfoPeer.APPROVED)) 386 { 387 return Boolean.valueOf(getApproved()); 388 } 389 if (name.equals(IssueTemplateInfoPeer.SCOPE_ID)) 390 { 391 return getScopeId(); 392 } 393 return null; 394 } 395 396 403 public Object getByPosition(int pos) 404 { 405 if (pos == 0) 406 { 407 return getIssueId(); 408 } 409 if (pos == 1) 410 { 411 return getName(); 412 } 413 if (pos == 2) 414 { 415 return getDescription(); 416 } 417 if (pos == 3) 418 { 419 return Boolean.valueOf(getApproved()); 420 } 421 if (pos == 4) 422 { 423 return getScopeId(); 424 } 425 return null; 426 } 427 428 434 public void save() throws Exception 435 { 436 save(IssueTemplateInfoPeer.getMapBuilder() 437 .getDatabaseMap().getName()); 438 } 439 440 450 public void save(String dbName) throws TorqueException 451 { 452 Connection con = null; 453 try 454 { 455 con = Transaction.begin(dbName); 456 save(con); 457 Transaction.commit(con); 458 } 459 catch(TorqueException e) 460 { 461 Transaction.safeRollback(con); 462 throw e; 463 } 464 } 465 466 468 private boolean alreadyInSave = false; 469 479 public void save(Connection con) throws TorqueException 480 { 481 if (!alreadyInSave) 482 { 483 alreadyInSave = true; 484 485 486 487 if (isModified()) 489 { 490 if (isNew()) 491 { 492 IssueTemplateInfoPeer.doInsert((IssueTemplateInfo)this, con); 493 setNew(false); 494 } 495 else 496 { 497 IssueTemplateInfoPeer.doUpdate((IssueTemplateInfo)this, con); 498 } 499 500 if (isCacheOnSave()) 501 { 502 IssueTemplateInfoManager.putInstance(this); 503 } 504 } 505 506 alreadyInSave = false; 507 } 508 } 509 510 514 protected boolean isCacheOnSave() 515 { 516 return true; 517 } 518 519 520 525 public void setPrimaryKey(ObjectKey issueId) 526 throws TorqueException { 527 setIssueId(new Long (((NumberKey)issueId).longValue())); 528 } 529 530 535 public void setPrimaryKey(String key) throws TorqueException 536 { 537 setIssueId(new Long (key)); 538 } 539 540 541 545 public ObjectKey getPrimaryKey() 546 { 547 return SimpleKey.keyFor(getIssueId()); 548 } 549 550 554 public String getQueryKey() 555 { 556 if (getPrimaryKey() == null) 557 { 558 return ""; 559 } 560 else 561 { 562 return getPrimaryKey().toString(); 563 } 564 } 565 566 570 public void setQueryKey(String key) 571 throws TorqueException 572 { 573 setPrimaryKey(key); 574 } 575 576 582 public IssueTemplateInfo copy() throws TorqueException 583 { 584 IssueTemplateInfo copyObj = new IssueTemplateInfo(); 585 copyObj.setIssueId(issueId); 586 copyObj.setName(name); 587 copyObj.setDescription(description); 588 copyObj.setApproved(approved); 589 copyObj.setScopeId(scopeId); 590 591 copyObj.setIssueId((Long )null); 592 593 return copyObj; 594 } 595 596 602 public IssueTemplateInfoPeer getPeer() 603 { 604 return peer; 605 } 606 607 public String toString() 608 { 609 StringBuffer str = new StringBuffer (); 610 str.append("IssueTemplateInfo:\n"); 611 str.append("IssueId = ") 612 .append(getIssueId()) 613 .append("\n"); 614 str.append("Name = ") 615 .append(getName()) 616 .append("\n"); 617 str.append("Description = ") 618 .append(getDescription()) 619 .append("\n"); 620 str.append("Approved = ") 621 .append(getApproved()) 622 .append("\n"); 623 str.append("ScopeId = ") 624 .append(getScopeId()) 625 .append("\n"); 626 return(str.toString()); 627 } 628 } 629 | Popular Tags |