View Javadoc

1   /*
2    * Copyright 2007-2009 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.kns.dto;
17  
18  import java.util.Date;
19  
20  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
21  
22  import org.kuali.rice.core.jaxb.SqlDateAdapter;
23  
24  public class InactiveableInfo {
25  	private static final long serialVersionUID = 1L;
26  
27  	protected Date activeFromDate;
28  	protected Date activeToDate;
29  	protected Date activeAsOfDate;
30  
31  	/**
32  	 * Returns active if the {@link #getActiveAsOfDate()} (current time used if not set) is between
33  	 * the from and to dates. Null dates are considered to indicate an open range.
34  	 */
35  	public boolean isActive() {
36  		long asOfDate = System.currentTimeMillis();
37  		if (activeAsOfDate != null) {
38  			asOfDate = activeAsOfDate.getTime();
39  		}
40  
41  		return (activeFromDate == null || asOfDate > activeFromDate.getTime())
42  				&& (activeToDate == null || asOfDate < activeToDate.getTime());
43  	}
44  
45  	public void setActive(boolean active) {
46  		// do nothing
47  	}
48  
49  	public void setActiveFromDate(Date from) {
50  		this.activeFromDate = from;
51  	}
52  
53  	public void setActiveToDate(Date to) {
54  		this.activeToDate = to;
55  	}
56  
57  	public void setActiveAsOfDate(Date activeAsOfDate) {
58  		this.activeAsOfDate = activeAsOfDate;
59  	}
60  
61  	public Date getActiveFromDate() {
62  		return this.activeFromDate;
63  	}
64  
65  	public Date getActiveToDate() {
66  		return this.activeToDate;
67  	}
68  	
69  	public Date getActiveAsOfDate() {
70  		return this.activeAsOfDate;
71  	}
72  
73  }