View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.impl.common.history;
17  
18  import org.joda.time.DateTime;
19  import org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils;
20  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
21  
22  import javax.persistence.Column;
23  import java.sql.Timestamp;
24  
25  
26  public abstract class AbstractHistoryBo<T extends PersistableBusinessObjectBase> extends PersistableBusinessObjectBase {
27      protected T bo;
28      //private static final long serialVersionUID = -7272085876524380076L;
29      @Column(name = "ACTV_FRM_DT")
30      private Timestamp activeFromDateValue;
31      @Column(name = "ACTV_TO_DT")
32      private Timestamp activeToDateValue;
33  
34      public boolean isActive(Timestamp activeAsOfDate) {
35          return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), new DateTime(
36                  activeAsOfDate.getTime()));
37      }
38  
39      public boolean isActive(DateTime activeAsOfDate) {
40          return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), activeAsOfDate);
41      }
42  
43      public boolean isActive() {
44          return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), null);
45      }
46  
47      public DateTime getActiveFromDate() {
48          return this.activeFromDateValue == null ? null : new DateTime(this.activeFromDateValue.getTime());
49      }
50  
51      public DateTime getActiveToDate() {
52          return this.activeToDateValue == null ? null : new DateTime(this.activeToDateValue.getTime());
53      }
54  
55      public Timestamp getActiveFromDateValue() {
56          return activeFromDateValue;
57      }
58  
59      public void setActiveFromDateValue(Timestamp activeFromDateValue) {
60          this.activeFromDateValue = activeFromDateValue;
61      }
62  
63      public Timestamp getActiveToDateValue() {
64          return activeToDateValue;
65      }
66  
67      public void setActiveToDateValue(Timestamp activeToDateValue) {
68          this.activeToDateValue = activeToDateValue;
69      }
70  
71      public T getBo() {
72          return bo;
73      }
74  
75      public void setBo(T bo) {
76          this.bo = bo;
77      }
78  }