Form.java

/*
 * +====================================================================+
 * |         Copyright (C) 2015 Rochester Institute of Technology,      |
 * |            103 Lomb Memorial Drive, Rochester, NY - 14623          |
 * |                        All Rights Reserved.                        |
 * +====================================================================+
 *   FILENAME
 *    Form.java
 *
 *   AUTHOR
 *    @author mhickson
 *
 * =====================================================================
 */

package edu.rit.coopeval.model;

import javax.persistence.*;
import java.util.Collection;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonView;
import edu.rit.coopeval.comparators.FormQuestionComparator;
import edu.rit.coopeval.viewmodel.JsonViewer;
import org.hibernate.annotations.SortComparator;

@Entity
@Table(name = "FORM")
public class Form extends AuditableEntity {

    @Id
    @Column(name = "FORMID", nullable = false, insertable = true, updatable = true, precision = 0)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "formId_seq")
    @SequenceGenerator(name = "formId_seq", sequenceName = "SEQ_Form_formId", allocationSize = 1)
    @JsonView(JsonViewer.Summary.class)
    private long formId;

    @Column(name = "NAME", nullable = true, insertable = true, updatable = true, length = 64)
    @JsonView(JsonViewer.Summary.class)
    private String name;

    @Column(name = "ISSTUDENTFORM")
    @JsonView(JsonViewer.Summary.class)
    private String isStudentForm;

    @OneToMany(mappedBy = "formByStudentFormId")
    private Collection<DepartmentTermForm> departmentTermFormsByFormByStudentFormId;

    @OneToMany(mappedBy = "formByEmployerFormId")
    private Collection<DepartmentTermForm> departmentTermFormsByFormByEmployerFormId;

    @OneToMany(mappedBy = "formByFormId")
    @SortComparator(FormQuestionComparator.class)
    private Set<FormQuestion> formQuestionsByFormId;

    public long getFormId() {
        return formId;
    }

    public void setFormId(long formId) {
        this.formId = formId;
    }

    public String getName() {
        return name;
    }

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

    public String getIsStudentForm() {
        return isStudentForm;
    }

    public void setIsStudentForm(String isStudentForm) {
        this.isStudentForm = isStudentForm;
    }

    public Set<FormQuestion> getFormQuestionsByFormId() {
        return formQuestionsByFormId;
    }

    public void setFormQuestionsByFormId(Set<FormQuestion> formQuestionsByFormId) {
        this.formQuestionsByFormId = formQuestionsByFormId;
    }

    public Collection<DepartmentTermForm> getDepartmentTermFormsByFormByStudentFormId() {
        return departmentTermFormsByFormByStudentFormId;
    }

    public void setDepartmentTermFormsByFormByStudentFormId(
            Collection<DepartmentTermForm> departmentTermFormsByFormByStudentFormId) {
        this.departmentTermFormsByFormByStudentFormId = departmentTermFormsByFormByStudentFormId;
    }

    public Collection<DepartmentTermForm> getDepartmentTermFormsByFormByEmployerFormId() {
        return departmentTermFormsByFormByEmployerFormId;
    }

    public void setDepartmentTermFormsByFormByEmployerFormId(
            Collection<DepartmentTermForm> departmentTermFormsByFormByEmployerFormId) {
        this.departmentTermFormsByFormByEmployerFormId = departmentTermFormsByFormByEmployerFormId;
    }
}