View Javadoc
1   /**
2    * Copyright 2005-2016 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.active;
17  
18  import java.sql.Timestamp;
19  
20  import javax.persistence.Column;
21  import javax.persistence.MappedSuperclass;
22  
23  import org.joda.time.DateTime;
24  import org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils;
25  import org.kuali.rice.krad.bo.DataObjectBase;
26  
27  @MappedSuperclass
28  public abstract class ActiveFromToBo extends DataObjectBase {
29      private static final long serialVersionUID = -7272085876524380076L;
30      @Column(name = "ACTV_FRM_DT")
31      private Timestamp activeFromDateValue;
32      @Column(name = "ACTV_TO_DT")
33      private Timestamp activeToDateValue;
34  
35      public boolean isActive(Timestamp activeAsOfDate) {
36          return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), new DateTime(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  }