001/**
002 * Copyright 2005-2014 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.Timestamp;
019
020import javax.persistence.Column;
021import javax.persistence.Convert;
022import javax.persistence.Embeddable;
023import javax.persistence.MappedSuperclass;
024
025import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
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 KimDocumentBoActivatableToFromEditableBase  extends KimDocumentBoBase {
035
036    private static final long serialVersionUID = 9042706897191231673L;
037
038    @Column(name="ACTV_IND")
039        @Convert(converter=BooleanYNConverter.class)
040    protected boolean active = true;
041        
042        @Column(name="EDIT_FLAG")
043        @Convert(converter=BooleanYNConverter.class)
044    protected boolean edit;
045
046        
047        @Column(name="ACTV_FRM_DT")
048        protected Timestamp activeFromDate;
049        @Column(name="ACTV_TO_DT")
050        protected Timestamp activeToDate;
051
052        public boolean isActive() {
053                long now = System.currentTimeMillis();          
054                return (activeFromDate == null || now > activeFromDate.getTime()) && (activeToDate == null || now < activeToDate.getTime());
055        }
056
057        public void setActive(boolean active) {
058                this.active = active;
059        }
060
061        public boolean isEdit() {
062                return this.edit;
063        }
064
065        public void setEdit(boolean edit) {
066                this.edit = edit;
067        }
068
069        /**
070         * @return the activeFromDate
071         */
072        public Timestamp getActiveFromDate() {
073                return this.activeFromDate;
074        }
075
076        /**
077         * @param activeFromDate the activeFromDate to set
078         */
079        public void setActiveFromDate(Timestamp activeFromDate) {
080                this.activeFromDate = activeFromDate;
081        }
082
083        /**
084         * @return the activeToDate
085         */
086        public Timestamp getActiveToDate() {
087                return this.activeToDate;
088        }
089
090        /**
091         * @param activeToDate the activeToDate to set
092         */
093        public void setActiveToDate(Timestamp activeToDate) {
094                this.activeToDate = activeToDate;
095        }
096
097}