CompoEntry.java 4.42 KB
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package fi.insomnia.bortal.model;

import java.util.Calendar;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

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

/**
 * 
 */
@Entity
@Table(name = "compo_entries")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class CompoEntry extends GenericEntity {
    private static final long serialVersionUID = 2L;

    @JoinColumn(name = "compo_id", referencedColumnName = "id", nullable = false)
    @ManyToOne(optional = false)
    private Compo compo;

    @Column(name = "entry_created", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar created = Calendar.getInstance();

    @Column(name = "title", nullable = false)
    private String title;

    @Column(name = "author")
    private String author;

    @Lob
    @Column(name = "notes")
    private String notes;

    @Lob
    @Column(name = "screen_message")
    private String screenMessage;

    @Column(name = "sort")
    private Integer sort;

    @Column(name = "final_position")
    private Integer finalPosition;

    @JoinColumn(name = "current_file_id", referencedColumnName = CompoEntryFile.ID_COLUMN)
    @OneToOne
    private CompoEntryFile currentFile;

    @OneToMany(mappedBy = "compoEntry")
    private List<Vote> votes;

    @PrivateOwned
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", fetch = FetchType.LAZY)
    private List<CompoEntryFile> files;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "entry")
    private List<CompoEntryParticipant> participants;

    @JoinColumn(name = "creator_eventuser_id", referencedColumnName = EventUser.ID_COLUMN)
    @ManyToOne
    private EventUser creator;

    public CompoEntry() {
        super();
    }

    public Calendar getCreated() {
        return created;
    }

    public void setCreated(Calendar entryCreated) {
        this.created = entryCreated;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public String getScreenMessage() {
        return screenMessage;
    }

    public void setScreenMessage(String screenMessage) {
        this.screenMessage = screenMessage;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public List<Vote> getVotes() {
        return votes;
    }

    public void setVotes(List<Vote> voteList) {
        this.votes = voteList;
    }

    public List<CompoEntryFile> getFiles() {
        return files;
    }

    public void setFiles(List<CompoEntryFile> compoEntryFileList) {
        this.files = compoEntryFileList;
    }

    public List<CompoEntryParticipant> getParticipants() {
        return participants;
    }

    public void setParticipants(
            List<CompoEntryParticipant> compoEntryParticipantList) {
        this.participants = compoEntryParticipantList;
    }

    public Compo getCompo() {
        return compo;
    }

    public void setCompo(Compo composId) {
        this.compo = composId;
    }

    public EventUser getCreator() {
        return creator;
    }

    public void setCreator(EventUser creator) {
        this.creator = creator;
    }

    public void setFinalPosition(Integer finalPosition) {
        this.finalPosition = finalPosition;
    }

    public Integer getFinalPosition() {
        return finalPosition;
    }

    public void setCurrentFile(CompoEntryFile currentFile) {
        this.currentFile = currentFile;
    }

    public CompoEntryFile getCurrentFile() {
        return currentFile;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

}