package com.eksad.masterdata.domain;

import com.eksad.ddms.common.util.object.EntityObject;
import com.eksad.masterdata.common.listEnum.WoState;
import com.eksad.masterdata.common.listEnum.WoStatus;
import jakarta.persistence.*;

import javax.validation.constraints.NotNull;
import java.util.Objects;

@Entity
@Table(name = "TRX_WO_MONITORING")
public class WorkOrderMonitoring implements EntityObject<WorkOrderMonitoring> {
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "trx_wo_monitoring_gen")
    @SequenceGenerator(name = "trx_wo_monitoring_gen", sequenceName = "trx_wo_monitoring_seq", allocationSize = 1)
    Long id;

    @Column(unique = true)
    @NotNull(message = "Work Order Monitoring ID cannot be null")
    String woMonitoringID;

    String woID;
    @Enumerated(EnumType.STRING)
    WoState woLastKnownState;
    @Enumerated(EnumType.STRING)
    WoStatus woLastKnownStatus;
    String noPolisi;
    Integer pitNumber;
    String unitCustomerID;
    String customerAtendeeID;
    String description;
    @Version
    Long version;
    @Column(name = "reqPayload", columnDefinition = "TEXT")
    String reqPayload;
    String reffNumber;

    @Embedded
    private CreationalSpecification woMonitoringCreational;

    public WorkOrderMonitoring() {
    }

    public WorkOrderMonitoring(Long id, String woMonitoringID, String woID, WoState woLastKnownState, WoStatus woLastKnownStatus, String noPolisi, Integer pitNumber, String unitCustomerID, String customerAtendeeID, String description, Long version, String reqPayload, String reffNumber) {
        this.id = id;
        this.woMonitoringID = woMonitoringID;
        this.woID = woID;
        this.woLastKnownState = woLastKnownState;
        this.woLastKnownStatus = woLastKnownStatus;
        this.noPolisi = noPolisi;
        this.pitNumber = pitNumber;
        this.unitCustomerID = unitCustomerID;
        this.customerAtendeeID = customerAtendeeID;
        this.description = description;
        this.version = version;
        this.reqPayload = reqPayload;
        this.reffNumber = reffNumber;
    }

    public Long getId() {
        return id;
    }

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

    public String getWoMonitoringID() {
        return woMonitoringID;
    }

    public void setWoMonitoringID(String woMonitoringID) {
        this.woMonitoringID = woMonitoringID;
    }

    public String getWoID() {
        return woID;
    }

    public void setWoID(String woID) {
        this.woID = woID;
    }

    public WoState getWoLastKnownState() {
        return woLastKnownState;
    }

    public void setWoLastKnownState(WoState woLastKnownState) {
        this.woLastKnownState = woLastKnownState;
    }

    public WoStatus getWoLastKnownStatus() {
        return woLastKnownStatus;
    }

    public void setWoLastKnownStatus(WoStatus woLastKnownStatus) {
        this.woLastKnownStatus = woLastKnownStatus;
    }

    public String getNoPolisi() {
        return noPolisi;
    }

    public void setNoPolisi(String noPolisi) {
        this.noPolisi = noPolisi;
    }

    public Integer getPitNumber() {
        return pitNumber;
    }

    public void setPitNumber(Integer pitNumber) {
        this.pitNumber = pitNumber;
    }

    public String getUnitCustomerID() {
        return unitCustomerID;
    }

    public void setUnitCustomerID(String unitCustomerID) {
        this.unitCustomerID = unitCustomerID;
    }

    public String getCustomerAtendeeID() {
        return customerAtendeeID;
    }

    public void setCustomerAtendeeID(String customerAtendeeID) {
        this.customerAtendeeID = customerAtendeeID;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public CreationalSpecification getWoMonitoringCreational() {
        return woMonitoringCreational;
    }

    public void setWoMonitoringCreational(CreationalSpecification woMonitoringCreational) {
        this.woMonitoringCreational = woMonitoringCreational;
    }

    public String getReqPayload() {
        return reqPayload;
    }

    public void setReqPayload(String reqPayload) {
        this.reqPayload = reqPayload;
    }

    public String getReffNumber() {
        return reffNumber;
    }

    public void setReffNumber(String reffNumber) {
        this.reffNumber = reffNumber;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 89 * hash + Objects.hashCode(this.woMonitoringID);
        hash = 89 * hash + Objects.hashCode(this.version);
        hash = 89 * hash + Objects.hashCode(this.woID);
        hash = 89 * hash + Objects.hashCode(this.woLastKnownState);
        hash = 89 * hash + Objects.hashCode(this.woLastKnownStatus);
        hash = 89 * hash + Objects.hashCode(this.noPolisi);
        hash = 89 * hash + Objects.hashCode(this.pitNumber);
        hash = 89 * hash + Objects.hashCode(this.unitCustomerID);
        hash = 89 * hash + Objects.hashCode(this.customerAtendeeID);
        hash = 89 * hash + Objects.hashCode(this.description);
        hash = 89 * hash + Objects.hashCode(this.woMonitoringCreational);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final WorkOrderMonitoring other = (WorkOrderMonitoring) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public boolean sameIdentityAs(WorkOrderMonitoring other) {
        return this.equals(other);
    }
}