001package org.apache.turbine.services.schedule; 002 003import java.io.Serializable; 004import java.sql.Connection; 005import java.text.SimpleDateFormat; 006import java.util.ArrayList; 007import java.util.Collections; 008import java.util.Date; 009import java.util.GregorianCalendar; 010import java.util.List; 011 012import org.apache.torque.TorqueException; 013import org.apache.torque.map.TableMap; 014import org.apache.torque.om.ComboKey; 015import org.apache.torque.om.DateKey; 016import org.apache.torque.om.NumberKey; 017import org.apache.torque.om.ObjectKey; 018import org.apache.torque.om.SimpleKey; 019import org.apache.torque.om.StringKey; 020import org.apache.torque.om.BooleanKey; 021import org.apache.torque.om.Persistent; 022import org.apache.torque.criteria.Criteria; 023import org.apache.torque.util.Transaction; 024import org.apache.commons.lang.ObjectUtils; 025 026 027/** 028 * This class was autogenerated by Torque on: 029 * 030 * [Mon Dec 21 20:40:21 CET 2015] 031 * 032 * You should not use this class directly. It should not even be 033 * extended; all references should be to JobEntryTorque 034 */ 035public abstract class BaseJobEntryTorque extends org.apache.turbine.services.schedule.AbstractJobEntry 036 implements Persistent, Serializable 037{ 038 /** Serial version */ 039 private static final long serialVersionUID = 1450726821044L; 040 041 042 043 /** Defines the jobId field. */ 044 private int jobId = 0; 045 046 /** Defines the second field. */ 047 private int second = -1; 048 049 /** Defines the minute field. */ 050 private int minute = -1; 051 052 /** Defines the hour field. */ 053 private int hour = -1; 054 055 /** Defines the weekDay field. */ 056 private int weekDay = -1; 057 058 /** Defines the dayOfMonth field. */ 059 private int dayOfMonth = -1; 060 061 /** Defines the task field. */ 062 private String task = null; 063 064 /** Defines the email field. */ 065 private String email = null; 066 067 /** Defines the property field. */ 068 private byte[] property = null; 069 070 /** Whether this object was modified after loading or after last save. */ 071 private boolean modified = true; 072 073 /** 074 * Whether this object was loaded from the database or already saved 075 * (false) or whether it is not yet in the database(true). 076 */ 077 private boolean isNew = true; 078 079 /** Flag which indicates whether this object is currently saving. */ 080 private boolean saving = false; 081 082 /** 083 * Flag which indicates whether this object is currently loaded 084 * from the database. 085 */ 086 private boolean loading = false; 087 088 /** 089 * Flag which indicates whether this object was deleted from the database. 090 * Note that this flags does not always display the current database state, 091 * there is no magical connection between this flag and the database. 092 */ 093 private boolean deleted = false; 094 095 096 097 098 099 /** 100 * Get the value of jobId. 101 * 102 * @return int 103 */ 104 public int getJobId() 105 { 106 107 return jobId; 108 } 109 110 /** 111 * Set the value of jobId. 112 * 113 * @param v new value 114 */ 115 public void setJobId(int v) 116 { 117 if (this.jobId != v) 118 { 119 setModified(true); 120 } 121 122 this.jobId = v; 123 124 125 } 126 127 /** 128 * Get the value of second. 129 * 130 * @return int 131 */ 132 public int getSecond() 133 { 134 135 return second; 136 } 137 138 /** 139 * Set the value of second. 140 * 141 * @param v new value 142 */ 143 public void setSecond(int v) 144 { 145 if (this.second != v) 146 { 147 setModified(true); 148 } 149 150 this.second = v; 151 152 153 } 154 155 /** 156 * Get the value of minute. 157 * 158 * @return int 159 */ 160 public int getMinute() 161 { 162 163 return minute; 164 } 165 166 /** 167 * Set the value of minute. 168 * 169 * @param v new value 170 */ 171 public void setMinute(int v) 172 { 173 if (this.minute != v) 174 { 175 setModified(true); 176 } 177 178 this.minute = v; 179 180 181 } 182 183 /** 184 * Get the value of hour. 185 * 186 * @return int 187 */ 188 public int getHour() 189 { 190 191 return hour; 192 } 193 194 /** 195 * Set the value of hour. 196 * 197 * @param v new value 198 */ 199 public void setHour(int v) 200 { 201 if (this.hour != v) 202 { 203 setModified(true); 204 } 205 206 this.hour = v; 207 208 209 } 210 211 /** 212 * Get the value of weekDay. 213 * 214 * @return int 215 */ 216 public int getWeekDay() 217 { 218 219 return weekDay; 220 } 221 222 /** 223 * Set the value of weekDay. 224 * 225 * @param v new value 226 */ 227 public void setWeekDay(int v) 228 { 229 if (this.weekDay != v) 230 { 231 setModified(true); 232 } 233 234 this.weekDay = v; 235 236 237 } 238 239 /** 240 * Get the value of dayOfMonth. 241 * 242 * @return int 243 */ 244 public int getDayOfMonth() 245 { 246 247 return dayOfMonth; 248 } 249 250 /** 251 * Set the value of dayOfMonth. 252 * 253 * @param v new value 254 */ 255 public void setDayOfMonth(int v) 256 { 257 if (this.dayOfMonth != v) 258 { 259 setModified(true); 260 } 261 262 this.dayOfMonth = v; 263 264 265 } 266 267 /** 268 * Get the value of task. 269 * 270 * @return String 271 */ 272 public String getTask() 273 { 274 275 return task; 276 } 277 278 /** 279 * Set the value of task. 280 * 281 * @param v new value 282 */ 283 public void setTask(String v) 284 { 285 if (!ObjectUtils.equals(this.task, v)) 286 { 287 setModified(true); 288 } 289 290 this.task = v; 291 292 293 } 294 295 /** 296 * Get the value of email. 297 * 298 * @return String 299 */ 300 public String getEmail() 301 { 302 303 return email; 304 } 305 306 /** 307 * Set the value of email. 308 * 309 * @param v new value 310 */ 311 public void setEmail(String v) 312 { 313 if (!ObjectUtils.equals(this.email, v)) 314 { 315 setModified(true); 316 } 317 318 this.email = v; 319 320 321 } 322 323 /** 324 * Get the value of property. 325 * 326 * @return byte[] 327 */ 328 public byte[] getProperty() 329 { 330 331 return property; 332 } 333 334 /** 335 * Set the value of property. 336 * 337 * @param v new value 338 */ 339 public void setProperty(byte[] v) 340 { 341 if (!ObjectUtils.equals(this.property, v)) 342 { 343 setModified(true); 344 } 345 346 this.property = v; 347 348 349 } 350 351 352 /** 353 * Returns whether the object has ever been saved. This will 354 * be false, if the object was retrieved from storage or was created 355 * and then saved. 356 * 357 * @return true, if the object has never been persisted. 358 */ 359 public boolean isNew() 360 { 361 return isNew; 362 } 363 364 /** 365 * Sets whether the object has ever been saved. 366 * 367 * @param isNew true if the object has never been saved, false otherwise. 368 */ 369 public void setNew(boolean isNew) 370 { 371 this.isNew = isNew; 372 } 373 374 /** 375 * Returns whether the object has been modified. 376 * 377 * @return True if the object has been modified. 378 */ 379 public boolean isModified() 380 { 381 return modified; 382 } 383 384 /** 385 * Sets whether the object has been modified. 386 * 387 * @param modified true if the object has been modified, false otherwise. 388 */ 389 public void setModified(boolean modified) 390 { 391 this.modified = modified; 392 } 393 394 /** 395 * Sets the modified state for the object to be false. 396 */ 397 public void resetModified() 398 { 399 modified = false; 400 } 401 402 403 /** 404 * Returns whether this object is currently saving. 405 * 406 * @return true if this object is currently saving, false otherwise. 407 */ 408 public boolean isSaving() 409 { 410 return saving; 411 } 412 413 /** 414 * Sets whether this object is currently saving. 415 * 416 * @param saving true if this object is currently saving, false otherwise. 417 */ 418 public void setSaving(boolean saving) 419 { 420 this.saving = saving; 421 } 422 423 424 /** 425 * Returns whether this object is currently being loaded from the database. 426 * 427 * @return true if this object is currently loading, false otherwise. 428 */ 429 public boolean isLoading() 430 { 431 return loading; 432 } 433 434 /** 435 * Sets whether this object is currently being loaded from the database. 436 * 437 * @param loading true if this object is currently loading, false otherwise. 438 */ 439 public void setLoading(boolean loading) 440 { 441 this.loading = loading; 442 } 443 444 445 /** 446 * Returns whether this object was deleted from the database. 447 * Note that this getter does not automatically reflect database state, 448 * it will be set to true by Torque if doDelete() was called with this 449 * object. Bulk deletes and deletes via primary key do not change 450 * this flag. Also, if doDelete() was called on an object which does 451 * not exist in the database, the deleted flag is set to true even if 452 * it was not deleted. 453 * 454 * @return true if this object was deleted, false otherwise. 455 */ 456 public boolean isDeleted() 457 { 458 return deleted; 459 } 460 461 /** 462 * Sets whether this object was deleted from the database. 463 * 464 * @param deleted true if this object was deleted, false otherwise. 465 */ 466 public void setDeleted(boolean deleted) 467 { 468 this.deleted = deleted; 469 } 470 471 472 473 474 475 476 477 478 /** 479 * Stores an object in the database. If the object is new, 480 * it is inserted; otherwise an update is performed. 481 * 482 * @param toSave the object to be saved, not null. 483 * 484 * @throws TorqueException if an error occurs during saving. 485 */ 486 public void save() throws TorqueException 487 { 488 save(JobEntryTorquePeer.DATABASE_NAME); 489 } 490 491 /** 492 * Stores an object in the database. If the object is new, 493 * it is inserted; otherwise an update is performed. 494 * 495 * @param toSave the object to be saved, not null. 496 * @param dbName the name of the database to which the object 497 * should be saved. 498 * 499 * @throws TorqueException if an error occurs during saving. 500 */ 501 public void save(String dbName) 502 throws TorqueException 503 { 504 Connection con = null; 505 try 506 { 507 con = Transaction.begin(dbName); 508 save(con); 509 Transaction.commit(con); 510 } 511 catch(TorqueException e) 512 { 513 Transaction.safeRollback(con); 514 throw e; 515 } 516 } 517 518 /** 519 * Stores an object in the database. If the object is new, 520 * it is inserted; otherwise an update is performed. This method 521 * is meant to be used as part of a transaction, otherwise use 522 * the save() method and the connection details will be handled 523 * internally. 524 * 525 * @param toSave the object to be saved, not null. 526 * @param con the connection to use for saving the object, not null. 527 * 528 * @throws TorqueException if an error occurs during saving. 529 */ 530 public void save(Connection con) 531 throws TorqueException 532 { 533 if (isSaving()) 534 { 535 return; 536 } 537 try 538 { 539 setSaving(true); 540 // If this object has been modified, then save it to the database. 541 if (isModified()) 542 { 543 if (isNew()) 544 { 545 JobEntryTorquePeer.doInsert((JobEntryTorque) this, con); 546 setNew(false); 547 } 548 else 549 { 550 JobEntryTorquePeer.doUpdate((JobEntryTorque) this, con); 551 } 552 } 553 554 } 555 finally 556 { 557 setSaving(false); 558 } 559 } 560 561 562 563 564 /** 565 * Set the PrimaryKey using ObjectKey. 566 * 567 * @param key jobId ObjectKey 568 */ 569 public void setPrimaryKey(ObjectKey key) 570 571 { 572 setJobId(((NumberKey) key).intValue()); 573 } 574 575 /** 576 * Set the PrimaryKey using a String. 577 * 578 * @param key 579 */ 580 public void setPrimaryKey(String key) 581 { 582 setJobId(Integer.parseInt(key)); 583 } 584 585 586 /** 587 * returns an id that differentiates this object from others 588 * of its class. 589 */ 590 public ObjectKey getPrimaryKey() 591 { 592 return SimpleKey.keyFor(getJobId()); 593 } 594 595 596 597 /** 598 * Makes a copy of this object. 599 * It creates a new object filling in the simple attributes. 600 * It then fills all the association collections and sets the 601 * related objects to isNew=true. 602 */ 603 public JobEntryTorque copy() throws TorqueException 604 { 605 return copy(true); 606 } 607 608 /** 609 * Makes a copy of this object using a connection. 610 * It creates a new object filling in the simple attributes. 611 * It then fills all the association collections and sets the 612 * related objects to isNew=true. 613 * 614 * @param con the database connection to read associated objects. 615 */ 616 public JobEntryTorque copy(Connection con) throws TorqueException 617 { 618 return copy(true, con); 619 } 620 621 /** 622 * Makes a copy of this object. 623 * It creates a new object filling in the simple attributes. 624 * If the parameter deepcopy is true, it then fills all the 625 * association collections and sets the related objects to 626 * isNew=true. 627 * 628 * @param deepcopy whether to copy the associated objects. 629 */ 630 public JobEntryTorque copy(boolean deepcopy) throws TorqueException 631 { 632 JobEntryTorque jobEntryTorque = new JobEntryTorque(); 633 634 return copyInto(jobEntryTorque, deepcopy); 635 } 636 637 /** 638 * Makes a copy of this object using connection. 639 * It creates a new object filling in the simple attributes. 640 * If the parameter deepcopy is true, it then fills all the 641 * association collections and sets the related objects to 642 * isNew=true. 643 * 644 * @param deepcopy whether to copy the associated objects. 645 * @param con the database connection to read associated objects. 646 */ 647 public JobEntryTorque copy(boolean deepcopy, Connection con) throws TorqueException 648 { 649 JobEntryTorque jobEntryTorque = new JobEntryTorque(); 650 651 return copyInto(jobEntryTorque, deepcopy, con); 652 } 653 654 /** 655 * Fills the copyObj with the contents of this object. 656 * The associated objects are also copied and treated as new objects. 657 * 658 * @param copyObj the object to fill. 659 */ 660 public JobEntryTorque copyInto(JobEntryTorque copyObj) throws TorqueException 661 { 662 return copyInto(copyObj, true); 663 } 664 665 /** 666 * Fills the copyObj with the contents of this object using connection. 667 * The associated objects are also copied and treated as new objects. 668 * 669 * @param copyObj the object to fill. 670 * @param con the database connection to read associated objects. 671 */ 672 public JobEntryTorque copyInto(JobEntryTorque copyObj, Connection con) throws TorqueException 673 { 674 return copyInto(copyObj, true, con); 675 } 676 677 /** 678 * Fills the copyObj with the contents of this object. 679 * If deepcopy is true, The associated objects are also copied 680 * and treated as new objects. 681 * 682 * @param copyObj the object to fill. 683 * @param deepcopy whether the associated objects should be copied. 684 */ 685 protected JobEntryTorque copyInto(JobEntryTorque copyObj, boolean deepcopy) throws TorqueException 686 { 687 copyObj.setJobId(0); 688 copyObj.setSecond(second); 689 copyObj.setMinute(minute); 690 copyObj.setHour(hour); 691 copyObj.setWeekDay(weekDay); 692 copyObj.setDayOfMonth(dayOfMonth); 693 copyObj.setTask(task); 694 copyObj.setEmail(email); 695 copyObj.setProperty(property); 696 697 if (deepcopy) 698 { 699 } 700 return copyObj; 701 } 702 703 704 /** 705 * Fills the copyObj with the contents of this object using connection. 706 * If deepcopy is true, The associated objects are also copied 707 * and treated as new objects. 708 * 709 * @param copyObj the object to fill. 710 * @param deepcopy whether the associated objects should be copied. 711 * @param con the database connection to read associated objects. 712 */ 713 public JobEntryTorque copyInto(JobEntryTorque copyObj, boolean deepcopy, Connection con) throws TorqueException 714 { 715 copyObj.setJobId(0); 716 copyObj.setSecond(second); 717 copyObj.setMinute(minute); 718 copyObj.setHour(hour); 719 copyObj.setWeekDay(weekDay); 720 copyObj.setDayOfMonth(dayOfMonth); 721 copyObj.setTask(task); 722 copyObj.setEmail(email); 723 copyObj.setProperty(property); 724 725 if (deepcopy) 726 { 727 } 728 return copyObj; 729 } 730 731 /** The Peer class */ 732 private static final org.apache.turbine.services.schedule.JobEntryTorquePeer peer 733 = new org.apache.turbine.services.schedule.JobEntryTorquePeer(); 734 735 /** 736 * returns a peer instance associated with this om. Since Peer classes 737 * are not to have any instance attributes, this method returns the 738 * same instance for all member of this class. The method could therefore 739 * be static, but this would prevent one from overriding the behavior. 740 */ 741 public org.apache.turbine.services.schedule.JobEntryTorquePeer getPeer() 742 { 743 return peer; 744 } 745 746 /** 747 * Retrieves the TableMap object related to this Table data without 748 * compiler warnings of using getPeer().getTableMap(). 749 * 750 * @return The associated TableMap object. 751 */ 752 public TableMap getTableMap() throws TorqueException 753 { 754 return org.apache.turbine.services.schedule.JobEntryTorquePeer.getTableMap(); 755 } 756 757 758 759 public String toString() 760 { 761 StringBuffer str = new StringBuffer(); 762 str.append("JobEntryTorque:\n"); 763 str.append("jobId = ") 764 .append(getJobId()) 765 .append("\n"); 766 str.append("second = ") 767 .append(getSecond()) 768 .append("\n"); 769 str.append("minute = ") 770 .append(getMinute()) 771 .append("\n"); 772 str.append("hour = ") 773 .append(getHour()) 774 .append("\n"); 775 str.append("weekDay = ") 776 .append(getWeekDay()) 777 .append("\n"); 778 str.append("dayOfMonth = ") 779 .append(getDayOfMonth()) 780 .append("\n"); 781 str.append("task = ") 782 .append(getTask()) 783 .append("\n"); 784 str.append("email = ") 785 .append(getEmail()) 786 .append("\n"); 787 str.append("property = ") 788 .append("<binary>") 789 .append("\n"); 790 return(str.toString()); 791 } 792 793 /** 794 * Compares the primary key of this instance with the key of another. 795 * 796 * @param toCompare The object to compare to. 797 * @return Whether the primary keys are equal and the object have the 798 * same class. 799 */ 800 public boolean equals(Object toCompare) 801 { 802 if (toCompare == null) 803 { 804 return false; 805 } 806 if (this == toCompare) 807 { 808 return true; 809 } 810 if (!getClass().equals(toCompare.getClass())) 811 { 812 return false; 813 } 814 JobEntryTorque other = (JobEntryTorque) toCompare; 815 if (getPrimaryKey() == null || other.getPrimaryKey() == null) 816 { 817 return false; 818 } 819 return getPrimaryKey().equals(other.getPrimaryKey()); 820 } 821 822 /** 823 * If the primary key is not <code>null</code>, return the hashcode of the 824 * primary key. Otherwise calls <code>Object.hashCode()</code>. 825 * 826 * @return an <code>int</code> value 827 */ 828 public int hashCode() 829 { 830 ObjectKey ok = getPrimaryKey(); 831 if (ok == null) 832 { 833 return super.hashCode(); 834 } 835 836 return ok.hashCode(); 837 } 838 839 840 841 /** 842 * Compares the content of this object to another object 843 * 844 * @param toCompare The object to compare to. 845 * @return true if all of the columns in the other object have 846 * the same value as the objects in this class. 847 */ 848 public boolean valueEquals(JobEntryTorque toCompare) 849 { 850 if (toCompare == null) 851 { 852 return false; 853 } 854 if (this == toCompare) 855 { 856 return true; 857 } 858 if (this.jobId != toCompare.getJobId()) 859 { 860 return false; 861 } 862 if (this.second != toCompare.getSecond()) 863 { 864 return false; 865 } 866 if (this.minute != toCompare.getMinute()) 867 { 868 return false; 869 } 870 if (this.hour != toCompare.getHour()) 871 { 872 return false; 873 } 874 if (this.weekDay != toCompare.getWeekDay()) 875 { 876 return false; 877 } 878 if (this.dayOfMonth != toCompare.getDayOfMonth()) 879 { 880 return false; 881 } 882 if (!ObjectUtils.equals(this.task, toCompare.getTask())) 883 { 884 return false; 885 } 886 if (!ObjectUtils.equals(this.email, toCompare.getEmail())) 887 { 888 return false; 889 } 890 if (!ObjectUtils.equals(this.property, toCompare.getProperty())) 891 { 892 return false; 893 } 894 return true; 895 } 896 897 898 899}