SitePage.java 2.79 KB
/*
 * Copyright Codecrew Ry
 * 
 * All rights reserved.
 * 
 * This license applies to any software containing a notice placed by the 
 * copyright holder. Such software is herein referred to as the Software. 
 * This license covers modification, distribution and use of the Software. 
 * 
 * Any distribution and use in source and binary forms, with or without 
 * modification is not permitted without explicit written permission from the 
 * copyright owner. 
 * 
 * A non-exclusive royalty-free right is granted to the copyright owner of the 
 * Software to use, modify and distribute all modifications to the Software in 
 * future versions of the Software. 
 * 
 */
package fi.codecrew.moya.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.PrivateOwned;

@Entity
@Table(name = "site_pages", uniqueConstraints = @UniqueConstraint(columnNames = { SitePage.EVENT_ID_COLUMN, "name" }))
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;
    }

}