/*
* COMSAT
* Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 3.0
* as published by the Free Software Foundation.
*/
/*
* Based on the corresponding class in Spring Boot Samples.
* Copyright the original author(s).
* Released under the ASF 2.0 license.
*/
package comsat.sample.data.jpa.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.springframework.util.Assert;
@Entity
public class Review implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@ManyToOne(optional = false)
private Hotel hotel;
@Column(nullable = false, name = "idx")
private int index;
@Column(nullable = false)
@Enumerated(EnumType.ORDINAL)
private Rating rating;
@Column(nullable = false)
@Temporal(TemporalType.DATE)
private Date checkInDate;
@Column(nullable = false)
@Enumerated(EnumType.ORDINAL)
private TripType tripType;
@Column(nullable = false)
private String title;
@Column(nullable = false, length = 5000)
private String details;
protected Review() {
}
public Review(Hotel hotel, int index, ReviewDetails details) {
Assert.notNull(hotel, "Hotel must not be null");
Assert.notNull(details, "Details must not be null");
this.hotel = hotel;
this.index = index;
this.rating = details.getRating();
this.checkInDate = details.getCheckInDate();
this.tripType = details.getTripType();
this.title = details.getTitle();
this.details = details.getDetails();
}
public Hotel getHotel() {
return this.hotel;
}
public int getIndex() {
return this.index;
}
public Rating getRating() {
return this.rating;
}
public void setRating(Rating rating) {
this.rating = rating;
}
public Date getCheckInDate() {
return this.checkInDate;
}
public void setCheckInDate(Date checkInDate) {
this.checkInDate = checkInDate;
}
public TripType getTripType() {
return this.tripType;
}
public void setTripType(TripType tripType) {
this.tripType = tripType;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDetails() {
return this.details;
}
public void setDetails(String details) {
this.details = details;
}
}