package no.kdrs.grouse.model;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;

/**
 * Created by tsodring on 9/8/17.
 */

@Entity
@Table(name = "projects")
@XmlRootElement
public class Project {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "project_id", nullable = false, updatable = false)
    private Long id;

    /**
     * Acts as a secondary key for a row of information. project_number
     * is what you search on. Normally automatically set to a UUID
     */
    @Column(name = "project_number")
    private String projectNumber;

    /**
     * Assignable descriptive name to the project e.g
     * 'Eksempel kommune nytt sak/arkiv system 2017'
     */
    @Column(name = "project_name")
    private String projectName;

    /**
     * Name of the requirements document
     */
    @Column(name = "file_name")
    private String fileName;


    @JsonIgnore
    @OneToMany(mappedBy = "referenceProject", fetch = FetchType.LAZY)
    private List<ProjectRequirement> referenceProjectRequirement;

    @JsonIgnore
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "username",
            referencedColumnName = "username")
    private GrouseUser referenceUser;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Long getId() {
        return id;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getProjectNumber() {
        return projectNumber;
    }

    public void setProjectNumber(String projectNumber) {
        this.projectNumber = projectNumber;
    }

    public List<ProjectRequirement> getReferenceProjectRequirement() {
        return referenceProjectRequirement;
    }

    public void setReferenceProjectRequirement(List<ProjectRequirement> referenceProjectRequirement) {
        this.referenceProjectRequirement = referenceProjectRequirement;
    }

    public GrouseUser getReferenceUser() {
        return referenceUser;
    }

    public void setReferenceUser(GrouseUser referenceUser) {
        this.referenceUser = referenceUser;
    }

    @Override
    public String toString() {
        return "Project{" +
                "id=" + id +
                ", projectNumber='" + projectNumber + '\'' +
                ", projectName='" + projectName + '\'' +
                ", fileName='" + fileName + '\'' +
                '}';
    }
}

@@ -154,16 +154,39 @@
 lement;%0A
+import java.util.Date;%0A
 import j
@@ -1065,159 +1065,764 @@
 e;%0A%0A
-%0A    @JsonIgnore%0A    @OneToMany(mappedBy = %22referenceProject%22, fetch = FetchType.LAZY)%0A    private List%3CProjectRequirement%3E referenceProjectRequirement
+    /**%0A     * The date the project was created%0A     */%0A    @Column(name = %22created_date%22)%0A    @Temporal(TemporalType.TIMESTAMP)%0A    private Date createdDate;%0A%0A    /**%0A     * Name of the organisation%0A     */%0A    @Column(name = %22organisation_name%22)%0A    private String organisationName;%0A%0A    /**%0A     * The date the project was accessed%0A     */%0A    @Column(name = %22accessed_date%22)%0A    @Temporal(TemporalType.TIMESTAMP)%0A    private Date accessedDate;%0A%0A    @JsonIgnore%0A    @OneToMany(mappedBy = %22referenceProject%22, fetch = FetchType.LAZY)%0A    private List%3CProjectRequirement%3E referenceProjectRequirement;%0A%0A    @JsonIgnore%0A    @OneToMany(mappedBy = %22referenceProject%22, fetch = FetchType.LAZY)%0A    private List%3CProjectFunctionality%3E referenceProjectFunctionality
 ;%0A%0A 
@@ -2299,32 +2299,234 @@
 ectName;%0A    %7D%0A%0A
+    public String getOrganisationName() %7B%0A        return organisationName;%0A    %7D%0A%0A    public void setOrganisationName(String organisationName) %7B%0A        this.organisationName = organisationName;%0A    %7D%0A%0A
     public Strin
@@ -2839,32 +2839,374 @@
 tNumber;%0A    %7D%0A%0A
+    public Date getCreatedDate() %7B%0A        return createdDate;%0A    %7D%0A%0A    public void setCreatedDate(Date createdDate) %7B%0A        this.createdDate = createdDate;%0A    %7D%0A%0A    public Date getAccessedDate() %7B%0A        return accessedDate;%0A    %7D%0A%0A    public void setAccessedDate(Date accessedDate) %7B%0A        this.accessedDate = accessedDate;%0A    %7D%0A%0A
     public List%3C
@@ -3681,24 +3681,357 @@
 ser;%0A    %7D%0A%0A
+    public List%3CProjectFunctionality%3E getReferenceProjectFunctionality() %7B%0A        return referenceProjectFunctionality;%0A    %7D%0A%0A    public void setReferenceProjectFunctionality(%0A            List%3CProjectFunctionality%3E referenceProjectFunctionality) %7B%0A        this.referenceProjectFunctionality = referenceProjectFunctionality;%0A    %7D%0A%0A
     @Overrid

Add additional values