Comment.java 1.7 KB
package fr.plil.sio.examen.api;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

/**
 * A comment is made by an reporter (i.e. an owner) on ANY animal 
 * (not only the ones he owns).
 * An reporter can have zero, one or more comments on any animal (i.e. it can
 * exists several comments from the same reporter on the same animal).
 * An animal can have zero, one or more comments by any reporter (i.e. it can
 * exists several comments from the same reporter on the same animal).
 * 
 * TODO: complete the classes in API to support comment serialization in the 
 * database.
 */
@Entity
public class Comment {
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    
    @ManyToOne(optional = false)
    private Owner reporter;
    
    @ManyToOne(optional = false)
    private Animal animal;
    
    @Column(nullable = false)
    private String message;
    
     public Long getId() {
        return id;
    }

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

    public Owner getReporter() {
        return this.reporter;
    }

    public void setReporter(Owner owner) {
        this.reporter = owner;
    }

    public Animal getAnimal() {
        return animal;
    }

    public void setAnimal(Animal animal) {
        this.animal = animal;
    }
    
    public String getMessage(){
        return this.message;
    }
    
    public void setMessage(String message){
        this.message = message;
    }
    
}