Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.user;

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

/**
 * One lifecycle instance of a partner agenda. At most one OPEN row per
 * (fofoId, agendaType) — enforced by the DB unique key uq_one_open on the
 * generated open_marker column (1 while OPEN, NULL when CLOSED).
 * AUTO instances open/close only via the nightly rule cron; MANUAL instances
 * are opened from the Assign Visit modal and closed by the visiting team.
 */
@Entity
@NamedQueries({
        @NamedQuery(
                name = "AgendaInstance.selectOpenByFofoId",
                query = "SELECT a FROM AgendaInstance a WHERE a.fofoId = :fofoId AND a.status = 'OPEN' ORDER BY a.openedOn ASC"),
        @NamedQuery(
                name = "AgendaInstance.selectOpenByFofoIdAndType",
                query = "SELECT a FROM AgendaInstance a WHERE a.fofoId = :fofoId AND a.agendaType = :agendaType AND a.status = 'OPEN'"),
        @NamedQuery(
                name = "AgendaInstance.selectOpenByFofoIds",
                query = "SELECT a FROM AgendaInstance a WHERE a.fofoId IN :fofoIds AND a.status = 'OPEN' ORDER BY a.fofoId ASC, a.openedOn ASC")
})
@Table(name = "user.agenda_instance")
public class AgendaInstance {

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

    @Column(name = "fofo_id")
    private int fofoId;

    @Column(name = "agenda_type")
    private String agendaType;

    @Column(name = "source")
    private String source;

    @Column(name = "status")
    private String status;

    @Column(name = "opened_on")
    private LocalDateTime openedOn;

    @Column(name = "opened_by")
    private Integer openedBy;

    @Column(name = "open_metric")
    private String openMetric;

    @Column(name = "closed_on")
    private LocalDateTime closedOn;

    @Column(name = "closed_by")
    private Integer closedBy;

    @Column(name = "close_metric")
    private String closeMetric;

    @Column(name = "close_remark")
    private String closeRemark;

    // DB-generated: 1 while OPEN, NULL when CLOSED (backs uq_one_open).
    @Column(name = "open_marker", insertable = false, updatable = false)
    private Integer openMarker;

    public int getId() {
        return id;
    }

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

    public int getFofoId() {
        return fofoId;
    }

    public void setFofoId(int fofoId) {
        this.fofoId = fofoId;
    }

    public String getAgendaType() {
        return agendaType;
    }

    public void setAgendaType(String agendaType) {
        this.agendaType = agendaType;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public LocalDateTime getOpenedOn() {
        return openedOn;
    }

    public void setOpenedOn(LocalDateTime openedOn) {
        this.openedOn = openedOn;
    }

    public Integer getOpenedBy() {
        return openedBy;
    }

    public void setOpenedBy(Integer openedBy) {
        this.openedBy = openedBy;
    }

    public String getOpenMetric() {
        return openMetric;
    }

    public void setOpenMetric(String openMetric) {
        this.openMetric = openMetric;
    }

    public LocalDateTime getClosedOn() {
        return closedOn;
    }

    public void setClosedOn(LocalDateTime closedOn) {
        this.closedOn = closedOn;
    }

    public Integer getClosedBy() {
        return closedBy;
    }

    public void setClosedBy(Integer closedBy) {
        this.closedBy = closedBy;
    }

    public String getCloseMetric() {
        return closeMetric;
    }

    public void setCloseMetric(String closeMetric) {
        this.closeMetric = closeMetric;
    }

    public String getCloseRemark() {
        return closeRemark;
    }

    public void setCloseRemark(String closeRemark) {
        this.closeRemark = closeRemark;
    }

    public Integer getOpenMarker() {
        return openMarker;
    }
}