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.bo.ui;
17  
18  import javax.persistence.Column;
19  import javax.persistence.MappedSuperclass;
20  import javax.persistence.Transient;
21  import java.sql.Timestamp;
22  
23  /**
24   * This is a description of what this class does - shyu don't forget to fill this in. 
25   * 
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   *
28   */
29  @MappedSuperclass
30  public class KimDocumentBoActivatableToFromBase  extends KimDocumentBoBase {
31      private static final long serialVersionUID = 9042706897191231671L;
32  
33  	@Column(name="ACTV_FRM_DT")
34  	protected Timestamp activeFromDate;
35  	@Column(name="ACTV_TO_DT")
36  	protected Timestamp activeToDate;
37  
38  	//@Type(type="yes_no")
39  	@Column(name="ACTV_IND")
40      protected boolean active = true;
41  
42  	@Transient
43  	protected boolean edit;
44  
45  	public void setActive(boolean active) {
46  		this.active = active;
47  	}
48  
49  	/**
50  	 * @return the activeFromDate
51  	 */
52  	public Timestamp getActiveFromDate() {
53  		return this.activeFromDate;
54  	}
55  
56  	/**
57  	 * @param activeFromDate the activeFromDate to set
58  	 */
59  	public void setActiveFromDate(Timestamp activeFromDate) {
60  		this.activeFromDate = activeFromDate;
61  	}
62  
63  	/**
64  	 * @return the activeToDate
65  	 */
66  	public Timestamp getActiveToDate() {
67  		return this.activeToDate;
68  	}
69  
70  	/**
71  	 * @param activeToDate the activeToDate to set
72  	 */
73  	public void setActiveToDate(Timestamp activeToDate) {
74  		this.activeToDate = activeToDate;
75  	}
76  
77  	public boolean isActive() {
78  		long now = System.currentTimeMillis();		
79  		return (activeFromDate == null || now > activeFromDate.getTime()) && (activeToDate == null || now < activeToDate.getTime());
80  	}
81  
82  	/**
83  	 * @return the edit
84  	 */
85  	public boolean isEdit() {
86  		return this.edit;
87  	}
88  
89  	/**
90  	 * @param edit the edit to set
91  	 */
92  	public void setEdit(boolean edit) {
93  		this.edit = edit;
94  	}
95  }