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.impl.common.active;
017
018import java.sql.Timestamp;
019
020import javax.persistence.Column;
021import javax.persistence.MappedSuperclass;
022
023import org.joda.time.DateTime;
024import org.kuali.rice.core.api.mo.common.active.InactivatableFromToUtils;
025import org.kuali.rice.krad.bo.DataObjectBase;
026
027@MappedSuperclass
028public abstract class ActiveFromToBo extends DataObjectBase {
029    private static final long serialVersionUID = -7272085876524380076L;
030    @Column(name = "ACTV_FRM_DT")
031    private Timestamp activeFromDateValue;
032    @Column(name = "ACTV_TO_DT")
033    private Timestamp activeToDateValue;
034
035    public boolean isActive(Timestamp activeAsOfDate) {
036        return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), new DateTime(activeAsOfDate.getTime()));
037    }
038
039    public boolean isActive(DateTime activeAsOfDate) {
040        return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), activeAsOfDate);
041    }
042
043    public boolean isActive() {
044        return InactivatableFromToUtils.isActive(getActiveFromDate(), getActiveToDate(), null);
045    }
046
047    public DateTime getActiveFromDate() {
048        return this.activeFromDateValue == null ? null : new DateTime(this.activeFromDateValue.getTime());
049    }
050
051    public DateTime getActiveToDate() {
052        return this.activeToDateValue == null ? null : new DateTime(this.activeToDateValue.getTime());
053    }
054
055    public Timestamp getActiveFromDateValue() {
056        return activeFromDateValue;
057    }
058
059    public void setActiveFromDateValue(Timestamp activeFromDateValue) {
060        this.activeFromDateValue = activeFromDateValue;
061    }
062
063    public Timestamp getActiveToDateValue() {
064        return activeToDateValue;
065    }
066
067    public void setActiveToDateValue(Timestamp activeToDateValue) {
068        this.activeToDateValue = activeToDateValue;
069    }
070}