package com.clinichelper.Entity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.UUID;

/**
 * Created by eva_c on 9/25/2016.
 */
@Entity
@Table(name="equipments")
public class Equipment implements Serializable{
    @Id
    private String equipmentId;
    @NotNull
    private String equipmentName;
    @NotNull
    private String equipmentUse;
    private String equipmentDescription;
    @ManyToMany
    private Clinic clinic;

    // Constructores
    public  Equipment(){

    }

    public Equipment(Clinic clinic, String equipmentName, String equipmentUse, String equipmentDescription) {
        this.setEquipmentId(clinic.getClinicPrefix() + "-E-" + UUID.randomUUID().toString().split("-")[0].toUpperCase());
        this.setEquipmentName(equipmentName.toUpperCase());
        this.setEquipmentUse(equipmentUse);
        this.setEquipmentDescription(equipmentDescription);
        this.clinic = clinic;
    }

    //Getters and Setters
    public String getEquipmentId() {
        return equipmentId;
    }

    public void setEquipmentId(String equipmentId) {
        this.equipmentId = equipmentId;
    }

    public String getEquipmentName() {
        return equipmentName;
    }

    public void setEquipmentName(String equipmentName) {
        this.equipmentName = equipmentName;
    }

    public String getEquipmentUse() {
        return equipmentUse;
    }

    public void setEquipmentUse(String equipmentUse) {
        this.equipmentUse = equipmentUse;
    }

    public String getEquipmentDescription() {
        return equipmentDescription;
    }

    public void setEquipmentDescription(String equipmentDescription) {
        this.equipmentDescription = equipmentDescription;
    }
}

@@ -447,24 +447,62 @@
 escription;%0A
+    private Integer equipmentInStock;%0A
     @ManyToM
@@ -505,16 +505,16 @@
 yToMany%0A
-
     priv
@@ -685,32 +685,58 @@
 pmentDescription
+, Integer equipmentInStock
 ) %7B%0A        this
@@ -1039,16 +1039,68 @@
 clinic;%0A
+        this.setEquipmentInStock(equipmentInStock);%0A
     %7D%0A%0A 
@@ -1815,24 +1815,24 @@
 cription) %7B%0A
-
         this
@@ -1882,11 +1882,215 @@
 n;%0A    %7D
+%0A%0A    public Integer getEquipmentInStock() %7B%0A        return equipmentInStock;%0A    %7D%0A%0A    public void setEquipmentInStock(Integer equipmentInStock) %7B%0A        this.equipmentInStock = equipmentInStock;%0A    %7D
 %0A%7D%0A

Refactor Equipment Entity