package net.nhs.esb.transfer.model;

import java.text.SimpleDateFormat;
import java.util.GregorianCalendar;

import javax.persistence.Basic;
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.OneToOne;
import javax.persistence.PrePersist;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

@Entity
@Table(name="sites")
public class Site {
	
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @JsonProperty("id")
    private Long id;

    @Column(name="patient_id", unique=true, nullable=false)
    @JsonProperty("patientId")
    private Long patientId;
    
    @Column(name="site_to")
    @JsonProperty("siteTo")
    private String siteTo;
    
    @Column(name="site_from")
    @JsonProperty("siteFrom")
    private String siteFrom;
    
    @Column(name="time_stamp")
    @JsonProperty("timeStamp")
    private String timeStamp;
    
    @OneToOne
    @JoinColumn(name="transfer_detail_id")
    @JsonIgnore
    private TransferDetail transferDetail;
    
    @PrePersist
    public void setTimeStamp(){
    	SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
    	this.timeStamp = sdf.format(GregorianCalendar.getInstance().getTime());
    }
    
	public String getSiteTo() {
		return siteTo;
	}
	
	public void setSiteTo(String siteTo) {
		this.siteTo = siteTo;
	}
	
	public String getSiteFrom() {
		return siteFrom;
	}
	
	public void setSiteFrom(String siteFrom) {
		this.siteFrom = siteFrom;
	}

	public Long getId() {
		return id;
	}

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

	public Long getPatientId() {
		return patientId;
	}

	public void setPatientId(Long patientId) {
		this.patientId = patientId;
	}

	public TransferDetail getTransferDetail() {
		return transferDetail;
	}

	public void setTransferDetail(TransferDetail transferDetail) {
		this.transferDetail = transferDetail;
	}

	public String getTimeStamp() {
		return timeStamp;
	}

	public void setTimeStamp(String timeStamp) {
		this.timeStamp = timeStamp;
	}
}

@@ -100,16 +100,43 @@
 alendar;
+%0Aimport java.util.TimeZone;
 %0A%0Aimport
@@ -1296,21 +1296,18 @@
 Detail;%0A
-    
 %0A
+ 
     @Pre
@@ -1314,16 +1314,17 @@
 Persist%0A
+ 
     publ
@@ -1351,17 +1351,21 @@
 ()%7B%0A    
-%09
+     
 SimpleDa
@@ -1428,17 +1428,86 @@
 %22);%0A    
-%09
+     sdf.setTimeZone(TimeZone.getTimeZone(%22Europe/London%22));%0A         
 this.tim
@@ -1578,14 +1578,11 @@
     
+ 
 %7D%0A
-    
 %0A%09pu

Set a fixed timestamp.