001    /**
002     * Copyright 2005-2012 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     */
016    package org.kuali.rice.kim.bo.ui;
017    
018    import java.sql.Date;
019    import java.sql.Timestamp;
020    
021    import javax.persistence.AttributeOverride;
022    import javax.persistence.AttributeOverrides;
023    import javax.persistence.Column;
024    import javax.persistence.MappedSuperclass;
025    
026    import org.hibernate.annotations.Type;
027    
028    /**
029     * This is a description of what this class does - shyu don't forget to fill this in. 
030     * 
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     *
033     */
034    @MappedSuperclass
035    @AttributeOverrides({
036            @AttributeOverride(name="edit",column=@Column(name="EDIT_FLAG"))
037    })
038    public class KimDocumentBoActivatableToFromEditableBase  extends KimDocumentBoBase {
039        private static final long serialVersionUID = 9042706897191231673L;
040            @Type(type="yes_no")
041            @Column(name="ACTV_IND")
042        protected boolean active = true;
043            
044            @Type(type="yes_no")
045            @Column(name="EDIT_FLAG")
046        protected boolean edit;
047    
048            
049            @Column(name="ACTV_FRM_DT")
050            protected Timestamp activeFromDate;
051            @Column(name="ACTV_TO_DT")
052            protected Timestamp activeToDate;
053    
054            public boolean isActive() {
055                    long now = System.currentTimeMillis();          
056                    return (activeFromDate == null || now > activeFromDate.getTime()) && (activeToDate == null || now < activeToDate.getTime());
057            }
058    
059            public void setActive(boolean active) {
060                    this.active = active;
061            }
062    
063            public boolean isEdit() {
064                    return this.edit;
065            }
066    
067            public void setEdit(boolean edit) {
068                    this.edit = edit;
069            }
070    
071            /**
072             * @return the activeFromDate
073             */
074            public Timestamp getActiveFromDate() {
075                    return this.activeFromDate;
076            }
077    
078            /**
079             * @param activeFromDate the activeFromDate to set
080             */
081            public void setActiveFromDate(Timestamp activeFromDate) {
082                    this.activeFromDate = activeFromDate;
083            }
084    
085            /**
086             * @return the activeToDate
087             */
088            public Timestamp getActiveToDate() {
089                    return this.activeToDate;
090            }
091    
092            /**
093             * @param activeToDate the activeToDate to set
094             */
095            public void setActiveToDate(Timestamp activeToDate) {
096                    this.activeToDate = activeToDate;
097            }
098    
099    }