<commit_before>package net.nhs.esb.transfer.model;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
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 javax.persistence.Transient;

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")
    @JsonIgnore
    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");
        sdf.setTimeZone(TimeZone.getTimeZone("Europe/London"));
        timeStamp = sdf.format(GregorianCalendar.getInstance().getTime());
    }

    @Transient
    @JsonProperty("timeStamp")
    public Date getJsonTimestamp() {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            sdf.setTimeZone(TimeZone.getTimeZone("Europe/London"));
            return sdf.parse(timeStamp);
        } catch (ParseException ignore) {
            return null;
        }
    }


    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;
    }
}
<commit_msg>Fixed problem where transfer of care timestamps could be set to null<commit_after>package net.nhs.esb.transfer.model;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
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 javax.persistence.Transient;

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")
    @JsonIgnore
    private String timestamp;

    @OneToOne
    @JoinColumn(name = "transfer_detail_id")
    @JsonIgnore
    private TransferDetail transferDetail;

    @PrePersist
    public void setTimeStamp() {
        formatTimestamp(Calendar.getInstance().getTime());
    }

    private void formatTimestamp(Date timestamp) {
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        sdf.setTimeZone(TimeZone.getTimeZone("Europe/London"));
        this.timestamp = sdf.format(timestamp);
    }

    @Transient
    @JsonProperty("timeStamp")
    public Date getJsonTimestamp() {

        if (timestamp == null) {
            return null;
        }

        try {
            SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
            sdf.setTimeZone(TimeZone.getTimeZone("Europe/London"));
            return sdf.parse(timestamp);
        } catch (ParseException ignore) {
            return null;
        }
    }

    @Transient
    @JsonProperty("timeStamp")
    public void setJsonTimestamp(Date timestamp) {
        formatTimestamp(timestamp);
    }

    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;
    }
}

{'fraction_non_alphanumeric': 0.09862058030759474, 'fraction_numerical': 0.0, 'mean_word_length': 3.038412291933419, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4819379', 'n_tokens_mistral': 1870, 'n_tokens_neox': 1816, 'n_words': 398}