/*
 * Arrebol Consultancy copyright.
 * 
 * This code belongs to Arrebol Consultancy
 * its use, redistribution or modification are prohibited 
 * without written authorization from Arrebol Consultancy.
 */
package com.arrebol.apc.model.views;

import com.arrebol.apc.model.enums.ActionStatus;
import com.arrebol.apc.model.enums.ActiveStatus;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.Immutable;

/**
 *
 * @author Carlos Janitzio Zavala Lopez <janitzio.zavala@arrebol.com.mx>
 */
@Entity
@Immutable
@Table(name = "APC_TRANSFER_VIEW")
public class TransferView implements Serializable {

    @Id
    @Column(name = "id", length = 36)
    private String id;

    @Id
    @Column(name = "id_office", length = 36)
    private String idOffice;

    @Column(name = "full_name_transmitter", length = 103)
    private String fullNameTransmitter;

    @Column(name = "transmitter_routes")
    private String transmitterRoutes;

    @Column(name = "full_name_receiver", length = 103)
    private String fullNameReceiver;

    @Column(name = "receiver_routes")
    private String receiverRoutes;

    @Column(name = "amount_to_transfer")
    private BigDecimal amountToTransfer;

    @Enumerated(EnumType.STRING)
    @Column(name = "action_status")
    private ActionStatus actionStatus;

    @Column(name = "str_action_status", length = 9)
    private String strActionStatus;

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "created_on", length = 19)
    private Date createdOn;

    @Column(name = "str_created_on", length = 22)
    private String strCreatedOn;

    @Column(name = "style_class", length = 7)
    private String styleClass;

    public TransferView() {
    }

    public String getId() {
        return id;
    }

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

    public String getIdOffice() {
        return idOffice;
    }

    public void setIdOffice(String idOffice) {
        this.idOffice = idOffice;
    }

    public String getFullNameTransmitter() {
        return fullNameTransmitter;
    }

    public void setFullNameTransmitter(String fullNameTransmitter) {
        this.fullNameTransmitter = fullNameTransmitter;
    }

    public String getTransmitterRoutes() {
        return transmitterRoutes;
    }

    public void setTransmitterRoutes(String transmitterRoutes) {
        this.transmitterRoutes = transmitterRoutes;
    }

    public String getFullNameReceiver() {
        return fullNameReceiver;
    }

    public void setFullNameReceiver(String fullNameReceiver) {
        this.fullNameReceiver = fullNameReceiver;
    }

    public String getReceiverRoutes() {
        return receiverRoutes;
    }

    public void setReceiverRoutes(String receiverRoutes) {
        this.receiverRoutes = receiverRoutes;
    }

    public BigDecimal getAmountToTransfer() {
        return amountToTransfer;
    }

    public void setAmountToTransfer(BigDecimal amountToTransfer) {
        this.amountToTransfer = amountToTransfer;
    }

    public ActionStatus getActionStatus() {
        return actionStatus;
    }

    public void setActionStatus(ActionStatus actionStatus) {
        this.actionStatus = actionStatus;
    }

    public String getStrActionStatus() {
        return strActionStatus;
    }

    public void setStrActionStatus(String strActionStatus) {
        this.strActionStatus = strActionStatus;
    }

    public Date getCreatedOn() {
        return createdOn;
    }

    public void setCreatedOn(Date createdOn) {
        this.createdOn = createdOn;
    }

    public String getStrCreatedOn() {
        return strCreatedOn;
    }

    public void setStrCreatedOn(String strCreatedOn) {
        this.strCreatedOn = strCreatedOn;
    }

    public String getStyleClass() {
        return styleClass;
    }

    public void setStyleClass(String styleClass) {
        this.styleClass = styleClass;
    }

    public boolean getActive() {
        return null == getStyleClass();
    }

    public boolean getAction(Date lastStableSmallBox) {
        Date date = createdOn;
        boolean action = true;
        try {
            SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");

            String dateStr = dt1.format(date);
            date = dt1.parse(dateStr);

            action = date.after(lastStableSmallBox);
        } catch (Exception ex) {
        }
        return action;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 79 * hash + Objects.hashCode(this.id);
        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 TransferView other = (TransferView) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

}
