Red Hat Application Migration Toolkit
package com.mpdmal.cloudental.entities;
import com.mpdmal.cloudental.entities.Medicalhistory;
import com.mpdmal.cloudental.entities.MedicalhistoryentryPK;
import com.mpdmal.cloudental.entities.base.DBEntity;
import com.mpdmal.cloudental.util.CloudentUtils;
import com.mpdmal.cloudental.util.exception.InvalidMedEntryAlertException;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Medicalhistoryentry extends DBEntity implements Serializable {
private static final long serialVersionUID = 1L;
@EmbeddedId
private MedicalhistoryentryPK id;
private Integer alert;
private String comments;
@ManyToOne(
cascade = {CascadeType.ALL}
)
@JoinColumn(
name = "id",
insertable = false,
updatable = false
)
private Medicalhistory medicalhistory;
public Integer getAlert() {
return this.alert;
}
public String getComments() {
return this.comments;
}
public MedicalhistoryentryPK getId() {
return this.id;
}
public Medicalhistory getMedicalhistory() {
return this.medicalhistory;
}
public void setMedicalhistory(Medicalhistory medicalhistory) {
this.medicalhistory = medicalhistory;
}
public void setId(MedicalhistoryentryPK id) {
this.id = id;
}
public void setComments(String comments) {
this.comments = comments;
}
public void setAlert(Integer alert) throws InvalidMedEntryAlertException {
if(CloudentUtils.isMedEntryAlertValid(alert.intValue())) {
this.alert = alert;
} else {
CloudentUtils.logError("Cannot set unknown medical history entry alert :" + alert);
throw new InvalidMedEntryAlertException(alert.intValue());
}
}
public String getXML() {
StringBuilder ans = new StringBuilder("<entry></entry>");
ans.insert(ans.indexOf("</entry"), "<added>" + this.id.getAdded() + "</added>");
ans.insert(ans.indexOf("</entry"), "<comments>" + this.comments + "</comments>");
ans.insert(ans.indexOf("</entry"), "<alert>" + CloudentUtils.findMedEntryAlertDescr(this.alert.intValue()) + "</alert>");
return ans.toString();
}
}