package vu.org.ombudsman; import org.hibernate.validator.NotNull; import org.trails.descriptor.annotation.PropertyDescriptor; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.SequenceGenerator; import javax.persistence.Id; import javax.persistence.Column; import javax.persistence.Table; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.JoinColumn; import javax.persistence.CascadeType; import java.io.Serializable; import java.util.Date; import java.util.List; import java.util.ArrayList; /** * This class models the complaint entity. Each of its * instances are persisted into a database via the hibernate * relational persistance mapping framework. * * It is the main entity of this tiny database. It records * each case or complaints. A complaint can have 0 or many * letters associated with it which are modelled as * a List attribute of type Letter. This is a slight improvement * from the old DB where users had to enter manually the * case # of the complaint associated with the letters. * * @author Ghislain Hachey * @version 1.0 */ @Entity @SequenceGenerator(name = "SEQ_GEN", sequenceName = "complaint_sequence", allocationSize = 1) @Table(name="complaint") public class Complaint { private Long id = 1L; private Investigator investigator; private String team; private Cif cifPreparedBy; private Lawyer lawyerPreparedBy; private String complainantName; private String against; private String code; private Date complaintReceived; private Date complaintRegistered; private String address; private String phoneNumber; private ComplainantType complainantType; private ComplaintMethod complaintMethod; private ComplaintType complaintType; private ComplaintCategory complaintCategory; private Province province; private String shortName; private String complaintName; private Boolean jurisdiction; private OutsetFileDisposition outsetFileDisposition; private Boolean referred; private Boolean closed; private Boolean adviceGiven; private ClosingReason closingReason; private Boolean mediation; private Date dateCaseClosed; private String remarks; private String archiveBox; private List letters = new ArrayList(); @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN") @PropertyDescriptor(displayName = "Case #", index = 0, hidden = false, searchable = true) @Column(name = "complaint_id") public Long getId() { return id; } public void setId(Long newId) { this.id = newId; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "investigator_id") @PropertyDescriptor(index = 1, searchable = false, summary = false) public Investigator getInvestigator() { return investigator; } public void setInvestigator(Investigator newInvestigator) { this.investigator = newInvestigator; } @PropertyDescriptor(index = 2, searchable = false, summary = false) public String getTeam() { return team; } public void setTeam(String newTeam) { this.team = newTeam; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "cif_id") @PropertyDescriptor(index = 3, displayName = "CIF prepared by", searchable = false, summary = false) public Cif getCifPreparedBy() { return cifPreparedBy; } public void setCifPreparedBy(Cif newCifPreparedBy) { this.cifPreparedBy = newCifPreparedBy; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "lawyer_id") @PropertyDescriptor(index = 4, displayName = "LA prepared by", searchable = false, summary = false) public Lawyer getLawyerPreparedBy() { return lawyerPreparedBy; } public void setLawyerPreparedBy(Lawyer newLawyerPreparedBy) { this.lawyerPreparedBy = newLawyerPreparedBy; } @PropertyDescriptor(index = 5, displayName = "Name of complainant") @Column(name = "complainant_name") public String getComplainantName() { return complainantName; } public void setComplainantName(String newComplainantName) { this.complainantName = newComplainantName; } @PropertyDescriptor(index = 6, summary = false) public String getAgainst() { return against; } public void setAgainst(String newAgainst) { this.against = newAgainst; } @PropertyDescriptor(index = 7, displayName = "CODE") public String getCode() { return code; } public void setCode(String newCode) { this.code = newCode; } @PropertyDescriptor(index = 8, displayName = "Date complaint received", summary = false) @Column(name = "complaint_received") public Date getComplaintReceived() { return complaintReceived; } public void setComplaintReceived(Date newComplaintReceived) { this.complaintReceived = newComplaintReceived; } @PropertyDescriptor(index = 9, displayName = "Date complaint registered") @Column(name = "complaint_registered") public Date getComplaintRegistered() { return complaintRegistered; } public void setComplaintRegistered(Date newComplaintRegistered) { this.complaintRegistered = newComplaintRegistered; } @PropertyDescriptor(index = 10, searchable = false, summary = false) public String getAddress() { return address; } public void setAddress(String newAddress) { this.address = newAddress; } @PropertyDescriptor(index = 11, displayName = "Phone #", summary = false) @Column(name = "phone_number") public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String newPhoneNumber) { this.phoneNumber = newPhoneNumber; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "complainant_type_id") @PropertyDescriptor(index = 12, displayName = "Type of complainant", searchable = false, summary = false) public ComplainantType getComplainantType() { return complainantType; } public void setComplainantType (ComplainantType newComplainantType) { this.complainantType = newComplainantType; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "complaint_method_id") @PropertyDescriptor(index = 13, displayName = "Method of complaint", searchable = false, summary = false) public ComplaintMethod getComplaintMethod() { return complaintMethod; } public void setComplaintMethod(ComplaintMethod newComplaintMethod) { this.complaintMethod = newComplaintMethod; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "complaint_type_id") @PropertyDescriptor(index = 14, displayName = "Type of complaint", searchable = false, summary = false) public ComplaintType getComplaintType() { return complaintType; } public void setComplaintType(ComplaintType newComplaintType) { this.complaintType = newComplaintType; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "complaint_category_id") @PropertyDescriptor(index = 15, displayName = "Category of complaint", searchable = false, summary = false) public ComplaintCategory getComplaintCategory() { return complaintCategory; } public void setComplaintCategory(ComplaintCategory newComplaintCategory) { this.complaintCategory = newComplaintCategory; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "province_id") @PropertyDescriptor(index = 16, searchable = false, summary = false) public Province getProvince() { return province; } public void setProvince(Province newProvince) { this.province = newProvince; } @PropertyDescriptor(index = 17, searchable = false) @Column(name = "short_name") public String getShortName() { return shortName; } public void setShortName(String newShortName) { this.shortName = newShortName; } @PropertyDescriptor(index = 18, displayName = "Name of complaint", searchable = false, summary = false) @Column(name = "complaint_name") public String getComplaintName() { return complaintName; } public void setComplaintName(String newComplaintName) { this.complaintName = newComplaintName; } @PropertyDescriptor(index = 19, summary = false) public Boolean getJurisdiction() { return jurisdiction; } public void setJurisdiction(Boolean newJurisdiction) { this.jurisdiction = newJurisdiction; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "outset_file_disposition_id") @PropertyDescriptor(index = 20, displayName = "File disposition at outset", searchable = false, summary = false) public OutsetFileDisposition getOutsetFileDisposition() { return outsetFileDisposition; } public void setOutsetFileDisposition(OutsetFileDisposition newOutsetFileDisposition) { this.outsetFileDisposition = newOutsetFileDisposition; } @PropertyDescriptor(index = 21, searchable = false, summary = false) public Boolean getReferred() { return referred; } public void setReferred(Boolean newReferred) { this.referred = newReferred; } @PropertyDescriptor(index = 22, searchable = false, summary = false) public Boolean getClosed() { return closed; } public void setClosed(Boolean newClosed) { this.closed = newClosed; } @PropertyDescriptor(index = 23, searchable = false, summary = false) @Column(name = "advice_given") public Boolean getAdviceGiven() { return adviceGiven; } public void setAdviceGiven(Boolean newAdviceGiven) { this.adviceGiven = newAdviceGiven; } @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name = "closing_reason_id") @PropertyDescriptor(index = 24, searchable = false, summary = false) public ClosingReason getClosingReason() { return closingReason; } public void setClosingReason(ClosingReason newClosingReason) { this.closingReason = newClosingReason; } @PropertyDescriptor(index = 25, searchable = false, summary = false) public Boolean getMediation() { return mediation; } public void setMediation(Boolean newMediation) { this.mediation = newMediation; } @PropertyDescriptor(index = 26, displayName = "Date case closed", searchable = false, summary = false) @Column(name = "date_case_closed") public Date getDateCaseClosed() { return dateCaseClosed; } public void setDateCaseClosed(Date newDateCaseClosed) { this.dateCaseClosed = newDateCaseClosed; } @PropertyDescriptor(index = 27, searchable = false, summary = false) public String getRemarks() { return remarks; } public void setRemarks(String newRemarks) { this.remarks = newRemarks; } @PropertyDescriptor(index = 28, searchable = false, summary = false) @Column(name = "archive_box") public String getArchiveBox() { return archiveBox; } public void setArchiveBox(String newArchiveBox) { this.archiveBox = newArchiveBox; } @PropertyDescriptor(index = 29, searchable = false, summary = false) @OneToMany(mappedBy = "complaint") public List getLetters() { return letters; } public void setLetters(List newLetters) { this.letters = newLetters; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Complaint that = (Complaint) o; return getId() != null ? getId().equals(that.getId()) : that.getId() == null; } public int hashCode() { return (getId() != null ? getId().hashCode() : 0); } public String toString() { return "Name of Complainant: " + getComplainantName() + "\n" + "Complaint against: " + getAgainst(); } }