view backend/src/main/java/org/dive4elements/river/model/TimeInterval.java @ 9055:df5c5614e9a7

New pseudo datetime for year-only values (31.12. instead of 15.6.)
author mschaefer
date Fri, 04 May 2018 14:03:47 +0200
parents 4c3ccf2b0304
children df6f1b5806f6
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

package org.dive4elements.river.model;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "time_intervals")
public class TimeInterval
implements   Serializable
{
    /**
     * Pseudo-date for Date values where only the year field is significant
     * (in Flys 3.2.1 June-15 12:00 had been used)
     */
    public final static Calendar YEAR_ONLY_DATE;
    static {
        YEAR_ONLY_DATE = Calendar.getInstance();
        YEAR_ONLY_DATE.clear();
        YEAR_ONLY_DATE.set(0, Calendar.DECEMBER, 31, 3, 5, 6);
    }

    private Integer id;
    private Date    startTime;
    private Date    stopTime;

    public TimeInterval() {
    }

    public TimeInterval(final Date startTime, final Date stopTime) {
        this.startTime = startTime;
        this.stopTime  = stopTime;
    }

    @Id
    @SequenceGenerator(
            name           = "SEQUENCE_TIME_INTERVALS_ID_SEQ",
            sequenceName   = "TIME_INTERVALS_ID_SEQ",
            allocationSize = 1)
    @GeneratedValue(
            strategy  = GenerationType.SEQUENCE,
            generator = "SEQUENCE_TIME_INTERVALS_ID_SEQ")
    @Column(name = "id")
    public Integer getId() {
        return this.id;
    }

    public void setId(final Integer id) {
        this.id = id;
    }

    @Column(name = "start_time") // FIXME: type mapping needed?
    public Date getStartTime() {
        return this.startTime;
    }

    public void setStartTime(final Date startTime) {
        this.startTime = startTime;
    }

    @Column(name = "stop_time") // FIXME: type mapping needed?
    public Date getStopTime() {
        return this.stopTime;
    }

    public void setStopTime(final Date stopTime) {
        this.stopTime = stopTime;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org