package at.ac.tuwien.inso.entity;

import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

@Entity
public class Grade {

    @Id
    @GeneratedValue
    private Long id;

    @ManyToOne
    private Course course;

    @ManyToOne
    private Lecturer lecturer;

    @ManyToOne
    private Student student;

    @Embedded
    private Mark mark;

    public Grade() {

    }

    public Grade(Course course, Lecturer lecturer, Student student, Mark mark) {
        this.course = course;
        this.lecturer = lecturer;
        this.student = student;
        this.mark = mark;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public Lecturer getLecturer() {
        return lecturer;
    }

    public void setLecturer(Lecturer lecturer) {
        this.lecturer = lecturer;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    public Mark getMark() {
        return mark;
    }

    public void setMark(Mark mark) {
        this.mark = mark;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Grade grade = (Grade) o;

        if (id != null) {
            if (!id.equals(grade.id)) return false;
        } else {
            if (grade.id != null) {
                return false;
            }
        }
        if (!course.equals(grade.course)) return false;
        if (!lecturer.equals(grade.lecturer)) return false;
        if (!student.equals(grade.student)) return false;
        return mark.equals(grade.mark);

    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = course != null ? 31 * result + course.hashCode() : 0;
        result = lecturer != null ? 31 * result + lecturer.hashCode() : 0;
        result = student != null ? 31 * result + student.hashCode() : 0;
        result = mark != null ? 31 * result + mark.hashCode() : 0;
        return result;
    }

    @Override
    public String toString() {
        return "Grade{" +
                "id=" + id +
                ", course=" + course +
                ", lecturer=" + lecturer +
                ", student=" + student +
                ", mark=" + mark +
                '}';
    }
}

@@ -28,16 +28,40 @@
 ntity;%0A%0A
+import java.util.UUID;%0A%0A
 import j
@@ -480,16 +480,99 @@
  mark;%0A%0A
+    private String urlIdentifier = UUID.randomUUID().toString().replace(%22-%22, %22%22);%0A%0A
     publ
@@ -1484,32 +1484,216 @@
  = mark;%0A    %7D%0A%0A
+    public String getUrlIdentifier() %7B%0A        return urlIdentifier;%0A    %7D%0A%0A    public void setUrlIdentifier(String urlIdentifier) %7B%0A        this.urlIdentifier = urlIdentifier;%0A    %7D%0A%0A
     @Override%0A  
@@ -1750,16 +1750,28 @@
 is == o)
+%0A           
  return 
@@ -1828,16 +1828,28 @@
 Class())
+%0A           
  return 
@@ -1953,16 +1953,32 @@
 ade.id))
+%0A               
  return 
@@ -2132,16 +2132,28 @@
 course))
+%0A           
  return 
@@ -2204,16 +2204,28 @@
 cturer))
+%0A           
  return 
@@ -2274,16 +2274,110 @@
 tudent))
+%0A            return false;%0A        if (!urlIdentifier.equals(grade.urlIdentifier))%0A           
  return 
@@ -2804,32 +2804,117 @@
 hashCode() : 0;%0A
+        result = urlIdentifier != null ? 31 * result + urlIdentifier.hashCode() : 0;%0A
         return r
@@ -3185,16 +3185,69 @@
  mark +%0A
+                %22, urlIdentifier=%22 + urlIdentifier +%0A
         

Add urlIdentifier field with a UUID