package com.agilex.healthcare.schedulingmanager.datalayer.appointment;

import com.agilex.healthcare.schedulingmanager.datalayer.PersistenceObject;
import com.agilex.healthcare.schedulingmanager.datalayer.Transformable;
import com.agilex.healthcare.schedulingmanager.domain.SMAppointmentRequestMessage;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

@Entity
@Table(name = AppointmentRequestMessagePo.TABLE_NAME)
@XStreamAlias("SMAppointmentRequestMessage")
public class AppointmentRequestMessagePo extends PersistenceObject implements Transformable<SMAppointmentRequestMessage> {
	private static final long serialVersionUID = 200834375889390334L;

    public static final String TABLE_NAME = "APPOINTMENT_REQUEST_MESSAGE";

	//<column name="APPOINTMENT_REQUEST_ID" type="varchar(32)"/>
	private String  appointmentRequestId;

	//<column name="SENDER_ID" type="varchar(255)"/>
	private String senderId;

	//<column name="MESSAGE_TEXT" type="varchar(255)"/>
	private String messageText;

	//<column name="MESSAGE_DATE_TIME" type="datetime"/>
	private Date messageDateTime;

	public AppointmentRequestMessagePo() {
	}
	
	public AppointmentRequestMessagePo(SMAppointmentRequestMessage dto) {
		setAppointmentRequestId(dto.getAppointmentRequestId());
		setMessageDateTime(dto.getMessageDateTime());
		setSenderId(dto.getSenderId());
		setMessageText(dto.getMessageText());
	}
	
	@Id
	@GeneratedValue(generator="appointment_request_message_id_generator")
	@GenericGenerator(name="appointment_request_message_id_generator", strategy = "uuid")
	@Column(name = "ID")
	public String getId() {
		return super.getId();
	}

	public void setId(String id) {
		super.setId(id);
	}

	@Column(name = "APPOINTMENT_REQUEST_ID")
	public String getAppointmentRequestId() {
		return appointmentRequestId;
	}

	public void setAppointmentRequestId(String appointmentRequestId) {
		this.appointmentRequestId = appointmentRequestId;
	}

	@Column(name = "SENDER_ID")
	public String getSenderId() {
		return senderId;
	}

	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}

	@Column(name = "MESSAGE_TEXT")
	public String getMessageText() {
		return messageText;
	}

	public void setMessageText(String messageText) {
		this.messageText = messageText;
	}

	@Column(name = "MESSAGE_DATE_TIME")
	public Date getMessageDateTime() {
		return messageDateTime;
	}

	public void setMessageDateTime(Date messageDateTime) {
		this.messageDateTime = messageDateTime;
	}

	@Override
	public SMAppointmentRequestMessage create() {
		SMAppointmentRequestMessage dto = new SMAppointmentRequestMessage();

		dto.setAppointmentRequestId(getAppointmentRequestId());
		dto.setMessageDateTime(getMessageDateTime());
		dto.setSenderId(getSenderId());
		dto.setMessageText(getMessageText());
        dto.getDataIdentifier().setUniqueId(getId());
				
		return dto;
	}

}
