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