Information

0
Story Points

Technologies

Decompiled Java File
package com.mpdmal.cloudental.entities;

import com.mpdmal.cloudental.entities.Discount;
import com.mpdmal.cloudental.entities.Patient;
import com.mpdmal.cloudental.entities.Postit;
import com.mpdmal.cloudental.entities.PricelistItem;
import com.mpdmal.cloudental.entities.base.DBEntity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotEmpty;

@Entity
@Table(
   name = "dentist"
)
public class Dentist extends DBEntity implements Serializable {
   private static final long serialVersionUID = 1L;
   @Id
   @GeneratedValue(
      strategy = GenerationType.IDENTITY
   )
   @Column(
      unique = true
   )
   private Integer id;
   @NotNull
   @NotEmpty
   @Column(
      length = 80
   )
   private String name;
   @NotNull
   @NotEmpty
   @Column(
      length = 16
   )
   private String password;
   @NotNull
   @NotEmpty
   @Column(
      length = 80
   )
   private String surname;
   @NotNull
   @NotEmpty
   @Column(
      unique = true,
      length = 16
   )
   private String username;
   @OneToMany(
      cascade = {CascadeType.ALL},
      mappedBy = "dentist",
      fetch = FetchType.LAZY
   )
   private Collection discounts;
   @OneToMany(
      cascade = {CascadeType.ALL},
      mappedBy = "dentist",
      fetch = FetchType.LAZY
   )
   private Collection postits;
   @OneToMany(
      cascade = {CascadeType.ALL},
      mappedBy = "dentist",
      fetch = FetchType.LAZY
   )
   private Collection priceables;
   @OneToMany(
      cascade = {CascadeType.ALL},
      mappedBy = "dentist",
      fetch = FetchType.EAGER
   )
   private Collection patients;
   @OneToMany(
      cascade = {CascadeType.ALL},
      mappedBy = "dentist",
      fetch = FetchType.LAZY
   )
   private Collection prescriptions;
   public static final String DENTIST_NODE = "<dentist>";
   public static final String DENTIST_ENDNODE = "</dentist>";
   public static final String DENTIST_NAMENODE = "<name>";
   public static final String DENTIST_NAMEENDNODE = "</name>";
   public static final String DENTIST_SURNAMENODE = "<surname>";
   public static final String DENTIST_SURNAMEENDNODE = "</surname>";
   public static final String DENTIST_USERNAMENODE = "<username>";
   public static final String DENTIST_USERNAMEENDNODE = "</username>";
   public static final String DENTIST_PASSWORDNODE = "<password>";
   public static final String DENTIST_PASSWORDENDNODE = "</password>";
   public static final String DENTIST_IDNODE = "<id>";
   public static final String DENTIST_IDENDNODE = "</id>";

   public String getUIFriendlyString() {
      return this.getName() + " " + this.getSurname() + " (" + this.getUsername() + ")";
   }

   public Integer getId() {
      return this.id;
   }

   public String getSurname() {
      return this.surname;
   }

   public String getUsername() {
      return this.username;
   }

   public String getPassword() {
      return this.password;
   }

   public String getName() {
      return this.name;
   }

   public Collection getPrescriptions() {
      return this.prescriptions;
   }

   public void setPrescriptions(Collection prescriptions) {
      this.prescriptions = prescriptions;
   }

   public void setId(Integer id) {
      this.id = id;
   }

   public void setName(String name) {
      this.name = name;
   }

   public void setSurname(String name) {
      this.surname = name;
   }

   public void setUsername(String name) {
      this.username = name;
   }

   public void setPassword(String password) {
      this.password = password;
   }

   public Collection getPatientList() {
      return this.patients;
   }

   public void setPatients(Collection patients) {
      if(patients != null) {
         patients.clear();
      }

      Iterator var2 = patients.iterator();

      while(var2.hasNext()) {
         Patient patient = (Patient)var2.next();
         this.addPatient(patient);
      }

   }

   public void addPatient(Patient p) {
      if(this.patients == null) {
         this.patients = new ArrayList();
      }

      this.patients.add(p);
   }

   public void removePatient(Patient p) {
      if(this.patients.contains(p)) {
         this.patients.remove(p);
      }

   }

   public Collection getPriceList() {
      return this.priceables;
   }

   public void setPricelist(Collection pc) {
      if(this.priceables != null) {
         this.priceables.clear();
      }

      Iterator var2 = this.priceables.iterator();

      while(var2.hasNext()) {
         PricelistItem item = (PricelistItem)var2.next();
         this.addPricelistItem(item);
      }

   }

   public void addPricelistItem(PricelistItem item) {
      if(this.priceables == null) {
         this.priceables = new ArrayList();
      }

      this.priceables.add(item);
   }

   public void removePricelistItem(PricelistItem item) {
      if(this.priceables.contains(item)) {
         this.priceables.remove(item);
      }

   }

   public Collection getDiscounts() {
      return this.discounts;
   }

   public void setDiscounts(Collection ds) {
      if(this.discounts != null) {
         this.discounts.clear();
      }

      Iterator var2 = this.discounts.iterator();

      while(var2.hasNext()) {
         Discount discount = (Discount)var2.next();
         this.addDiscount(discount);
      }

   }

   public void addDiscount(Discount ds) {
      if(this.discounts == null) {
         this.discounts = new ArrayList();
      }

      this.discounts.add(ds);
   }

   public void removeDiscount(Discount d) {
      if(this.discounts.contains(d)) {
         this.discounts.remove(d);
      }

   }

   public Collection getNotes() {
      return this.postits;
   }

   public void setNotes(Collection notes) {
      if(this.postits != null) {
         this.postits.clear();
      }

      Iterator var2 = notes.iterator();

      while(var2.hasNext()) {
         Postit postit = (Postit)var2.next();
         this.addNote(postit);
      }

   }

   public void addNote(Postit note) {
      if(this.postits == null) {
         this.postits = new ArrayList();
      }

      note.setDentist(this);
      this.getNotes().add(note);
   }

   public void removeNote(Postit note) {
      if(this.getNotes().contains(note)) {
         this.postits.remove(note);
      }

   }

   public String getBASICXML() {
      StringBuilder ans = new StringBuilder("<dentist></dentist>");
      ans.insert(ans.indexOf("</dentist>"), "<id>" + this.getId() + "</id>");
      ans.insert(ans.indexOf("</dentist>"), "<name>" + this.name + "</name>");
      ans.insert(ans.indexOf("</dentist>"), "<surname>" + this.surname + "</surname>");
      ans.insert(ans.indexOf("</dentist>"), "<username>" + this.username + "</username>");
      ans.insert(ans.indexOf("</dentist>"), "<password>" + this.password + "</password>");
      return ans.toString();
   }

   public String getXML() {
      StringBuilder ans = new StringBuilder(this.getBASICXML());
      ans.insert(ans.indexOf("</dentist>"), "<pinboard>");
      Iterator var2;
      if(this.postits != null) {
         var2 = this.postits.iterator();

         while(var2.hasNext()) {
            Postit patient = (Postit)var2.next();
            ans.insert(ans.indexOf("</dentist>"), patient.getXML());
         }
      }

      ans.insert(ans.indexOf("</dentist>"), "</pinboard>");
      ans.insert(ans.indexOf("</dentist>"), "<pricelist>");
      if(this.priceables != null) {
         var2 = this.priceables.iterator();

         while(var2.hasNext()) {
            PricelistItem patient1 = (PricelistItem)var2.next();
            ans.insert(ans.indexOf("</dentist>"), patient1.getXML());
         }
      }

      ans.insert(ans.indexOf("</dentist>"), "</pricelist>");
      ans.insert(ans.indexOf("</dentist>"), "<discounts>");
      if(this.discounts != null) {
         var2 = this.discounts.iterator();

         while(var2.hasNext()) {
            Discount patient2 = (Discount)var2.next();
            ans.insert(ans.indexOf("</dentist>"), patient2.getXML());
         }
      }

      ans.insert(ans.indexOf("</dentist>"), "</discounts>");
      ans.insert(ans.indexOf("</dentist>"), "<patientlist>");
      if(this.patients != null) {
         var2 = this.patients.iterator();

         while(var2.hasNext()) {
            Patient patient3 = (Patient)var2.next();
            ans.insert(ans.indexOf("</dentist>"), patient3.getXML());
         }
      }

      ans.insert(ans.indexOf("</dentist>"), "</patientlist>");
      return ans.toString();
   }
}
Page generated: Oct 19, 2017 2:34:23 PM