Red Hat Application Migration Toolkit
package com.mpdmal.cloudental.entities;
import com.mpdmal.cloudental.entities.Medicalhistoryentry;
import com.mpdmal.cloudental.entities.Patient;
import com.mpdmal.cloudental.entities.base.DBEntity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
@Entity
public class Medicalhistory extends DBEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@OneToOne
@JoinColumn(
name = "id"
)
private Patient patient;
@Column(
nullable = true,
length = 1024
)
private String comments;
@OneToMany(
cascade = {CascadeType.ALL},
mappedBy = "medicalhistory"
)
private Collection entries;
public Integer getId() {
return this.patient.getId();
}
public String getComments() {
return this.comments;
}
public Patient getPatient() {
return this.patient;
}
public Collection getEntries() {
return this.entries;
}
public void addMedicalEntry(Medicalhistoryentry entry) {
if(this.entries == null) {
this.entries = new ArrayList();
}
this.entries.add(entry);
}
public void setEntries(Set entries) {
if(entries != null) {
entries.clear();
}
Iterator var2 = entries.iterator();
while(var2.hasNext()) {
Medicalhistoryentry medicalhistoryentry = (Medicalhistoryentry)var2.next();
this.addMedicalEntry(medicalhistoryentry);
}
}
public void deleteMedicalEntry(Medicalhistoryentry entry) {
if(this.entries.contains(entry)) {
this.entries.remove(entry);
}
}
public void setPatient(Patient patient) {
this.patient = patient;
}
public void setComments(String comments) {
this.comments = comments;
}
public String getXML() {
StringBuilder ans = new StringBuilder("<medhistory></medhistory>");
ans.insert(ans.indexOf("</medhistory"), "<comments>" + this.comments + "</comments>");
Collection entries = this.getEntries();
Iterator var3 = entries.iterator();
while(var3.hasNext()) {
Medicalhistoryentry entry = (Medicalhistoryentry)var3.next();
ans.insert(ans.indexOf("</medhistory"), entry.getXML());
}
return ans.toString();
}
}