001/**
002 * Copyright 2005-2016 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.kim.bo.ui;
017
018import java.sql.Date;
019import java.sql.Timestamp;
020
021import javax.persistence.Column;
022import javax.persistence.MappedSuperclass;
023import javax.persistence.Transient;
024
025import org.hibernate.annotations.Type;
026
027/**
028 * This is a description of what this class does - shyu don't forget to fill this in. 
029 * 
030 * @author Kuali Rice Team (rice.collab@kuali.org)
031 *
032 */
033@MappedSuperclass
034public class KimDocumentBoActivatableToFromBase  extends KimDocumentBoBase {
035    private static final long serialVersionUID = 9042706897191231671L;
036
037        @Column(name="ACTV_FRM_DT")
038        protected Timestamp activeFromDate;
039        @Column(name="ACTV_TO_DT")
040        protected Timestamp activeToDate;
041
042        @Type(type="yes_no")
043        @Column(name="ACTV_IND")
044    protected boolean active = true;
045
046        @Transient
047        protected boolean edit;
048
049        public void setActive(boolean active) {
050                this.active = active;
051        }
052
053        /**
054         * @return the activeFromDate
055         */
056        public Timestamp getActiveFromDate() {
057                return this.activeFromDate;
058        }
059
060        /**
061         * @param activeFromDate the activeFromDate to set
062         */
063        public void setActiveFromDate(Timestamp activeFromDate) {
064                this.activeFromDate = activeFromDate;
065        }
066
067        /**
068         * @return the activeToDate
069         */
070        public Timestamp getActiveToDate() {
071                return this.activeToDate;
072        }
073
074        /**
075         * @param activeToDate the activeToDate to set
076         */
077        public void setActiveToDate(Timestamp activeToDate) {
078                this.activeToDate = activeToDate;
079        }
080
081        public boolean isActive() {
082                long now = System.currentTimeMillis();          
083                return (activeFromDate == null || now > activeFromDate.getTime()) && (activeToDate == null || now < activeToDate.getTime());
084        }
085
086        /**
087         * @return the edit
088         */
089        public boolean isEdit() {
090                return this.edit;
091        }
092
093        /**
094         * @param edit the edit to set
095         */
096        public void setEdit(boolean edit) {
097                this.edit = edit;
098        }
099}