Coverage Report - org.kuali.rice.krad.bo.InactivatableFromToImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
InactivatableFromToImpl
0%
0/18
0%
0/10
1.4
 
 1  
 /*
 2  
  * Copyright 2007-2008 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.krad.bo;
 17  
 
 18  
 import java.sql.Timestamp;
 19  
 
 20  
 import javax.persistence.Column;
 21  
 import javax.persistence.MappedSuperclass;
 22  
 import javax.persistence.Transient;
 23  
 
 24  
 /**
 25  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 26  
  */
 27  
 @MappedSuperclass
 28  0
 public abstract class InactivatableFromToImpl extends PersistableBusinessObjectBase implements InactivateableFromTo {
 29  
 
 30  
         private static final long serialVersionUID = 1L;
 31  
 
 32  
         @Column(name = "ACTV_FRM_DT")
 33  
         protected Timestamp activeFromDate;
 34  
         @Column(name = "ACTV_TO_DT")
 35  
         protected Timestamp activeToDate;
 36  
         @Transient
 37  
         protected Timestamp activeAsOfDate;
 38  
         @Transient
 39  
         protected boolean current;
 40  
 
 41  
         /**
 42  
          * Returns active if the {@link #getActiveAsOfDate()} (current time used if not set) is between
 43  
          * the from and to dates. Null dates are considered to indicate an open range.
 44  
          */
 45  
         public boolean isActive() {
 46  0
                 long asOfDate = System.currentTimeMillis();
 47  0
                 if (activeAsOfDate != null) {
 48  0
                         asOfDate = activeAsOfDate.getTime();
 49  
                 }
 50  
 
 51  0
                 return (activeFromDate == null || asOfDate >= activeFromDate.getTime())
 52  
                                 && (activeToDate == null || asOfDate < activeToDate.getTime());
 53  
         }
 54  
         
 55  
         public void setActive(boolean active) {
 56  
                 // do nothing
 57  0
         }
 58  
 
 59  
         public void setActiveFromDate(Timestamp from) {
 60  0
                 this.activeFromDate = from;
 61  0
         }
 62  
 
 63  
         public void setActiveToDate(Timestamp to) {
 64  0
                 this.activeToDate = to;
 65  0
         }
 66  
 
 67  
         public Timestamp getActiveFromDate() {
 68  0
                 return this.activeFromDate;
 69  
         }
 70  
 
 71  
         public Timestamp getActiveToDate() {
 72  0
                 return this.activeToDate;
 73  
         }
 74  
 
 75  
         public Timestamp getActiveAsOfDate() {
 76  0
                 return this.activeAsOfDate;
 77  
         }
 78  
 
 79  
         public void setActiveAsOfDate(Timestamp activeAsOfDate) {
 80  0
                 this.activeAsOfDate = activeAsOfDate;
 81  0
         }
 82  
 
 83  
         public boolean isCurrent() {
 84  0
                 return this.current;
 85  
         }
 86  
 
 87  
         public void setCurrent(boolean current) {
 88  0
                 this.current = current;
 89  0
         }
 90  
 }