Red Hat Application Migration Toolkit
package com.mpdmal.cloudental.entities; import com.mpdmal.cloudental.entities.Activity; import com.mpdmal.cloudental.entities.Toothhistory; import com.mpdmal.cloudental.entities.base.DBEntity; import java.io.Serializable; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.Iterator; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.validation.constraints.NotNull; @Entity public class Visit extends DBEntity implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue( strategy = GenerationType.IDENTITY ) private Integer id; @NotNull private String comments; @NotNull private int color; @NotNull private String title; @NotNull @Temporal(TemporalType.TIMESTAMP) private Date visitdate; @Temporal(TemporalType.TIMESTAMP) private Date enddate; @ManyToOne( fetch = FetchType.LAZY ) @JoinColumn( name = "activityid" ) private Activity activity; @OneToMany( cascade = {CascadeType.ALL}, mappedBy = "visit", fetch = FetchType.LAZY ) private Collection toothhistory; @NotNull private BigDecimal deposit; public Date getVisitdate() { return this.visitdate; } public Date getEnddate() { return this.enddate; } public String getComments() { return this.comments; } public Integer getId() { return this.id; } public Activity getActivity() { return this.activity; } public Collection getToothhistory() { return this.toothhistory; } public BigDecimal getDeposit() { return this.deposit; } public String getTitle() { return this.title; } public Integer getColor() { return Integer.valueOf(this.color); } public void setToothhistory(Collection toothhistory) { this.toothhistory = toothhistory; } public void setActivity(Activity activity) { this.activity = activity; } public void setComments(String comments) { this.comments = comments; } public void setEnddate(Date enddate) { this.enddate = enddate; } public void setVisitdate(Date visitdate) { this.visitdate = visitdate; } public void setId(Integer id) { this.id = id; } public void setDeposit(BigDecimal deposit) { this.deposit = deposit; } public void setTitle(String title) { this.title = title; } public void setColor(Integer color) { this.color = color.intValue(); } public String getXML() { StringBuilder ans = new StringBuilder("<visit></visit>"); ans.insert(ans.indexOf("</visit"), "<start>" + this.visitdate + "</start>"); ans.insert(ans.indexOf("</visit"), "<end>" + this.enddate + "</end>"); ans.insert(ans.indexOf("</visit"), "<title>" + this.title + "</title>"); ans.insert(ans.indexOf("</visit"), "<color>" + this.color + "</color>"); ans.insert(ans.indexOf("</visit"), "<comments>" + this.comments + "</comments>"); ans.insert(ans.indexOf("</visit"), "<ToothOperations>"); Iterator var2 = this.toothhistory.iterator(); while(var2.hasNext()) { Toothhistory history = (Toothhistory)var2.next(); ans.insert(ans.indexOf("</visit"), history.getXML()); } ans.insert(ans.indexOf("</visit"), "</ToothOperations>"); return ans.toString(); } public String toString() { String ans = this.title + " [" + this.activity.getPatienthistory().getPatient().getSurname() + "]\n "; SimpleDateFormat dftime = new SimpleDateFormat("hh:mm a"); SimpleDateFormat dfdate = new SimpleDateFormat("d/MMM"); Calendar c = Calendar.getInstance(); c.setTime(this.visitdate); int startday = c.get(5); String starttime = dftime.format(this.visitdate); String startdate = dfdate.format(this.visitdate); c.setTime(this.enddate); int endday = c.get(5); String endtime = dftime.format(this.enddate); String enddatestr = dfdate.format(this.enddate); return startday == endday?ans + startdate + " " + starttime + " - " + endtime:ans + startdate + " " + starttime + " - " + enddatestr + " " + endtime; } }