Information

0
Story Points

Technologies

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

import com.mpdmal.cloudental.entities.Dentist;
import com.mpdmal.cloudental.entities.PostitPK;
import com.mpdmal.cloudental.entities.base.DBEntity;
import com.mpdmal.cloudental.util.CloudentUtils;
import com.mpdmal.cloudental.util.exception.InvalidPostitAlertException;
import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

@Entity
public class Postit extends DBEntity implements Serializable {
   private static final long serialVersionUID = 1L;
   @EmbeddedId
   private PostitPK id;
   @NotNull
   private Integer alert;
   @NotNull
   private String post;
   @ManyToOne
   @JoinColumn(
      name = "id",
      insertable = false,
      updatable = false
   )
   private Dentist dentist;

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

   public Integer getAlert() {
      return this.alert;
   }

   public String getPost() {
      return this.post;
   }

   public Dentist getDentist() {
      return this.dentist;
   }

   public String getAlertDescr() {
      return CloudentUtils.findPostitAlertDescr(this.alert.intValue());
   }

   public void setPost(String post) {
      this.post = post;
   }

   public void setAlert(Integer alert) throws InvalidPostitAlertException {
      if(CloudentUtils.isPostitAlertValid(alert.intValue())) {
         this.alert = alert;
      } else {
         CloudentUtils.logError("Cannot set unkown postit alert:" + alert);
         throw new InvalidPostitAlertException(alert.intValue());
      }
   }

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

   public void setDentist(Dentist dentist) {
      this.dentist = dentist;
   }

   public String getXML() {
      StringBuilder ans = new StringBuilder("<postit></postit>");
      ans.insert(ans.indexOf("</postit"), "<post>" + this.post + "</post>");
      ans.insert(ans.indexOf("</postit"), "<created>" + this.id.getPostdate() + "</created>");
      ans.insert(ans.indexOf("</postit"), "<alert>" + CloudentUtils.findPostitAlertDescr(this.alert.intValue()) + "</alert>");
      return ans.toString();
   }
}
Page generated: Oct 19, 2017 2:35:22 PM