Compo.java 4.64 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.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

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

/**
 * Competition to be held at the event.
 */
@Entity
@Table(name = "compos")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class Compo extends GenericEntity {
    private static final long serialVersionUID = 2L;

    /**
     * Name of the competition.
     */
    @Column(name = "compo_name", nullable = false)
    private String name;

    public static final String EVENT_ID_COLUMN = "event_id";

    @ManyToOne()
    @JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
    private LanEvent event;

    /**
     * Start time of the competition Submitting entries should be disabled after
     * this time.
     */
    @Column(name = "compo_start")
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar startTime;

    /**
     * When the voting should start
     * 
     * @see {@link #holdVoting}
     */
    @Column(name = "vote_start")
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar voteStart;

    @Column(name = "vote_end")
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar voteEnd;

    @Column(name = "submit_start")
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar submitStart;

    @Column(name = "submit_end")
    @Temporal(TemporalType.TIMESTAMP)
    private Calendar submitEnd;

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

    @Column(name = "max_participant_count")
    private int maxParticipantCount;

    /**
     * If ( for some unimaginable reason ) compo is delayed hold voting can be
     * used to postpone the start of the voting from the time specified in
     * {@link #voteStart}
     */
    @Column(name = "hold_voting", nullable = false)
    private boolean holdVoting = true;

    /**
     * Entries submitted to participate this compo.
     */
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compo")
    private List<CompoEntry> compoEntries;

    public Compo(String compoName, boolean holdVoting) {
        this();

        this.name = compoName;
        this.holdVoting = holdVoting;
    }

    public Compo() {
        super();
    }

    public String getName() {
        return name;
    }

    public void setName(String compoName) {
        this.name = compoName;
    }

    public Calendar getStartTime() {
        return startTime;
    }

    public void setStartTime(Calendar compoStart) {
        this.startTime = compoStart;
    }

    public Calendar getVoteStart() {
        return voteStart;
    }

    public void setVoteStart(Calendar voteStart) {
        this.voteStart = voteStart;
    }

    public Calendar getVoteEnd() {
        return voteEnd;
    }

    public void setVoteEnd(Calendar voteEnd) {
        this.voteEnd = voteEnd;
    }

    public Calendar getSubmitStart() {
        return submitStart;
    }

    public void setSubmitStart(Calendar submitStart) {
        this.submitStart = submitStart;
    }

    public Calendar getSubmitEnd() {
        return submitEnd;
    }

    public void setSubmitEnd(Calendar submitEnd) {
        this.submitEnd = submitEnd;
    }

    public boolean getHoldVoting() {
        return holdVoting;
    }

    public void setHoldVoting(boolean holdVoting) {
        this.holdVoting = holdVoting;
    }

    public List<CompoEntry> getCompoEntries() {
        return compoEntries;
    }

    public void setCompoEntries(List<CompoEntry> compoEntryList) {
        this.compoEntries = compoEntryList;
    }

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

    public String getDescription() {
        return description;
    }

    /**
     * @return the maxParticipantCount
     */
    public int getMaxParticipantCount() {
        return maxParticipantCount;
    }

    /**
     * @param maxParticipantCount
     *            the maxParticipantCount to set
     */
    public void setMaxParticipantCount(int maxParticipantCount) {
        this.maxParticipantCount = maxParticipantCount;
    }

    public LanEvent getEvent() {
        return event;
    }

    public void setEvent(LanEvent event) {
        this.event = event;
    }
}