SitePage.java 2.33 KB
package fi.insomnia.bortal.model;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

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

@Entity
@Table(name = "site_pages", uniqueConstraints = @UniqueConstraint(columnNames = { SitePage.EVENT_ID_COLUMN, "name" }))
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class SitePage extends GenericEntity {

    private static final long serialVersionUID = -4333555423866132524L;

    public static final String EVENT_ID_COLUMN = "event_id";

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

    @Column(nullable = false)
    private String name;

    @ManyToOne()
    private SitePage parent;

    @ManyToMany()
    private List<Role> allowedRoles;

    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
    private List<SitePage> children;

    @PrivateOwned
    @OneToMany(mappedBy = "sitepage", cascade = CascadeType.ALL)
    private List<PageContent> contents;

    public LanEvent getEvent() {
        return event;
    }

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

    public String getName() {
        return name;
    }

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

    public SitePage getParent() {
        return parent;
    }

    public void setParent(SitePage parent) {
        this.parent = parent;
    }

    public List<SitePage> getChildren() {
        return children;
    }

    public void setChildren(List<SitePage> children) {
        this.children = children;
    }

    public List<PageContent> getContents() {
        return contents;
    }

    public void setContents(List<PageContent> contents) {
        this.contents = contents;
    }

    public List<Role> getAllowedRoles() {
        return allowedRoles;
    }

    public void setAllowedRoles(List<Role> allowedRoles) {
        this.allowedRoles = allowedRoles;
    }

}