Subversion Repositories SmartDukaan

Rev

Rev 31764 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/**
 * 
 */
package com.spice.profitmandi.dao.entity.cs;

import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author govind
 *
 */
@Entity
@Table(name = "cs.position")
@NamedQueries({
        @NamedQuery(name = "Position.Auth_User_Partner_Maping", query = "select new com.spice.profitmandi.dao.model.AuthUserPartnerMapModel( "
                + "  p.authUserId, pp.fofoId )  from Position p" +
                " JOIN PartnerPosition pp ON pp.positionId = p.id" +
                "                  JOIN Region r ON pp.regionId = r.id" +
                "                  JOIN PartnerRegion pr ON pr.regionId = pp.regionId" +
                "                  JOIN FofoStore fs ON fs.id = pp.fofoId" +
                "         where p.authUserId = :authId and fs.active= true and p.categoryId = :categoryId")
})
public class Position {

    @Id
    @Column(name = "id", unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;

    @Column(name = "auth_user_id")
    private int authUserId;

    @Column(name = "category_id")
    private int categoryId;

    @Column(name = "region_id")
    private int regionId;

    @Column(name = "escalation_type")
    @Enumerated(EnumType.STRING)
    private EscalationType escalationType;

    @Convert(converter = LocalDateTimeAttributeConverter.class)
    @Column(name = "create_timestamp")
    private LocalDateTime createTimestamp;


    @Column(name = "ticket_assignee")
    private boolean ticketAssignee;


    public boolean isTicketAssignee() {
        return ticketAssignee;
    }

    public void setTicketAssignee(boolean ticketAssignee) {
        this.ticketAssignee = ticketAssignee;
    }

    public int getId() {
        return id;
    }

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

    public int getAuthUserId() {
        return authUserId;
    }

    public void setAuthUserId(int authUserId) {
        this.authUserId = authUserId;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public EscalationType getEscalationType() {
        return escalationType;
    }

    public void setEscalationType(EscalationType escalationType) {
        this.escalationType = escalationType;
    }

    public int getRegionId() {
        return regionId;
    }

    public void setRegionId(int regionId) {
        this.regionId = regionId;
    }

    public LocalDateTime getCreateTimestamp() {
        return createTimestamp;
    }

    public void setCreateTimestamp(LocalDateTime createTimestamp) {
        this.createTimestamp = createTimestamp;
    }

    public String getFormattedCreateTimestamp() {
        if (createTimestamp == null) {
            return null;
        }
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
        return createTimestamp.format(formatter);
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + authUserId;
        result = prime * result + categoryId;
        result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
        result = prime * result + ((escalationType == null) ? 0 : escalationType.hashCode());
        result = prime * result + id;
        result = prime * result + regionId;
        result = prime * result + (ticketAssignee ? 1231 : 1237);
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        Position other = (Position) obj;
        if (authUserId != other.authUserId) return false;
        if (categoryId != other.categoryId) return false;
        if (createTimestamp == null) {
            if (other.createTimestamp != null) return false;
        } else if (!createTimestamp.equals(other.createTimestamp)) return false;
        if (escalationType != other.escalationType) return false;
        if (id != other.id) return false;
        if (regionId != other.regionId) return false;
        if (ticketAssignee != other.ticketAssignee) return false;
        return true;
    }

    @Override
    public String toString() {
        return "Position [id=" + id + ", authUserId=" + authUserId + ", categoryId=" + categoryId + ", regionId=" + regionId + ", escalationType=" + escalationType + ", createTimestamp=" + createTimestamp + ", ticketAssignee=" + ticketAssignee + "]";
    }


}