LogEntry.java 2.18 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fi.insomnia.bortal.model;

import static javax.persistence.TemporalType.TIMESTAMP;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

import org.eclipse.persistence.annotations.OptimisticLocking;
import org.eclipse.persistence.annotations.OptimisticLockingType;

/**
 * 
 */
@Entity
@Table(name = "event_log")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class LogEntry extends GenericEntity {

    private static final long serialVersionUID = 1L;

    @ManyToOne
    private LanEvent parentEvent;

    @Column(name = "event_time", nullable = false)
    @Temporal(TIMESTAMP)
    private Calendar time = Calendar.getInstance();

    @Lob
    @Column(name = "event_description")
    private String description;

    @JoinColumn(name = "event_log_type_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private LogEntryType type;

    @JoinColumn(name = "user_id", referencedColumnName = "id")
    @ManyToOne
    private User user;

    public LogEntry() {
    }

    public LogEntry(Calendar eventTime) {
        this.time = eventTime;
    }

    public Calendar getTime() {
        return time;
    }

    public void setTime(Calendar eventTime) {
        this.time = eventTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String eventDescription) {
        this.description = eventDescription;
    }

    public LogEntryType getType() {
        return type;
    }

    public void setType(LogEntryType eventLogTypesId) {
        this.type = eventLogTypesId;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User usersId) {
        this.user = usersId;
    }

    public void setParentEvent(LanEvent parentEvent) {
        this.parentEvent = parentEvent;
    }

    public LanEvent getParentEvent() {
        return parentEvent;
    }
}