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.krad.bo;
17  
18  import org.joda.time.DateTime;
19  import org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils;
20  
21  import javax.persistence.Column;
22  import javax.persistence.MappedSuperclass;
23  import javax.persistence.Transient;
24  import java.sql.Timestamp;
25  
26  /**
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   */
29  @MappedSuperclass
30  public abstract class InactivatableFromToImpl extends PersistableBusinessObjectBase implements InactivatableFromTo {
31  
32  	private static final long serialVersionUID = 1L;
33  
34  	@Column(name = "ACTV_FRM_DT")
35  	protected Timestamp activeFromDate;
36  	@Column(name = "ACTV_TO_DT")
37  	protected Timestamp activeToDate;
38  	@Transient
39  	protected Timestamp activeAsOfDate;
40  	@Transient
41  	protected boolean current;
42  
43  	/**
44  	 * Returns active if the {@link #getActiveAsOfDate()} (current time used if not set) is between
45  	 * the from and to dates. Null dates are considered to indicate an open range.
46  	 */
47  	public boolean isActive() {
48          return InactivatableFromToUtils.isActive(new DateTime(activeFromDate), new DateTime(activeToDate), new DateTime(activeAsOfDate));
49  	}
50  	
51  	public void setActive(boolean active) {
52  		// do nothing
53  	}
54  
55  	public void setActiveFromDate(Timestamp from) {
56  		this.activeFromDate = from;
57  	}
58  
59  	public void setActiveToDate(Timestamp to) {
60  		this.activeToDate = to;
61  	}
62  
63  	public Timestamp getActiveFromDate() {
64  		return this.activeFromDate;
65  	}
66  
67  	public Timestamp getActiveToDate() {
68  		return this.activeToDate;
69  	}
70  
71  	public Timestamp getActiveAsOfDate() {
72  		return this.activeAsOfDate;
73  	}
74  
75  	public void setActiveAsOfDate(Timestamp activeAsOfDate) {
76  		this.activeAsOfDate = activeAsOfDate;
77  	}
78  
79  	public boolean isCurrent() {
80  		return this.current;
81  	}
82  
83  	public void setCurrent(boolean current) {
84  		this.current = current;
85  	}
86  }