Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
37738 vikas 1
package com.spice.profitmandi.dao.entity.user;
2
 
3
import javax.persistence.Column;
4
import javax.persistence.Entity;
5
import javax.persistence.GeneratedValue;
6
import javax.persistence.GenerationType;
7
import javax.persistence.Id;
8
import javax.persistence.Table;
9
import java.time.LocalDateTime;
10
 
11
/**
12
 * One question on the first-call checklist (SOP §9 Path A step 2).
13
 *
14
 * <p>The question set is data, not code: the screen renders whatever rows are active here, in
15
 * {@code sortOrder}, so the script can be reworded or extended without a deploy.
16
 *
17
 * <p>Retire a question by clearing {@code active}, never by deleting the row — answers reference it,
18
 * and a deleted question would orphan everything ever recorded against it.
19
 */
20
@Entity
21
@Table(name = "user.lead_call_question")
22
public class LeadCallQuestion {
23
 
24
    @Id
25
    @GeneratedValue(strategy = GenerationType.IDENTITY)
26
    @Column(name = "id", unique = true, updatable = false)
27
    private int id;
28
 
29
    @Column(name = "sort_order")
30
    private int sortOrder;
31
 
32
    @Column(name = "prompt")
33
    private String prompt;
34
 
35
    /** TEXT | NUMBER | YESNO | CHOICE. */
36
    @Column(name = "answer_type")
37
    private String answerType;
38
 
39
    /** Pipe-separated options for CHOICE, e.g. {@code Yes|No|Not sure}. Null for other types. */
40
    @Column(name = "choices")
41
    private String choices;
42
 
43
    @Column(name = "required")
44
    private boolean required;
45
 
46
    /** Score contributed when this question is answered. */
47
    @Column(name = "points")
48
    private int points;
49
 
50
    /**
51
     * Pipe-separated {@code LeadStage} names this question applies to, e.g.
52
     * {@code NEW|ASSIGNED|CONTACTED}. Empty or null means every stage.
53
     */
54
    @Column(name = "stages")
55
    private String stages;
56
 
57
    @Column(name = "active")
58
    private boolean active = true;
59
 
60
    @Column(name = "created_timestamp")
61
    private LocalDateTime createdTimestamp;
62
 
63
    @Column(name = "updated_timestamp")
64
    private LocalDateTime updatedTimestamp;
65
 
66
    public int getId() { return id; }
67
    public void setId(int id) { this.id = id; }
68
 
69
    public int getSortOrder() { return sortOrder; }
70
    public void setSortOrder(int sortOrder) { this.sortOrder = sortOrder; }
71
 
72
    public String getPrompt() { return prompt; }
73
    public void setPrompt(String prompt) { this.prompt = prompt; }
74
 
75
    public String getAnswerType() { return answerType; }
76
    public void setAnswerType(String answerType) { this.answerType = answerType; }
77
 
78
    public String getChoices() { return choices; }
79
    public void setChoices(String choices) { this.choices = choices; }
80
 
81
    public boolean isRequired() { return required; }
82
    public void setRequired(boolean required) { this.required = required; }
83
 
84
    public int getPoints() { return points; }
85
    public void setPoints(int points) { this.points = points; }
86
 
87
    public String getStages() { return stages; }
88
    public void setStages(String stages) { this.stages = stages; }
89
 
90
    /** Does this question apply at {@code stage}? An empty stage list means "everywhere". */
91
    public boolean appliesTo(String stage) {
92
        if (stages == null || stages.trim().isEmpty()) {
93
            return true;
94
        }
95
        if (stage == null) {
96
            return false;
97
        }
98
        for (String s : stages.split("\\|")) {
99
            if (s.trim().equalsIgnoreCase(stage.trim())) {
100
                return true;
101
            }
102
        }
103
        return false;
104
    }
105
 
106
    public boolean isActive() { return active; }
107
    public void setActive(boolean active) { this.active = active; }
108
 
109
    public LocalDateTime getCreatedTimestamp() { return createdTimestamp; }
110
    public void setCreatedTimestamp(LocalDateTime createdTimestamp) { this.createdTimestamp = createdTimestamp; }
111
 
112
    public LocalDateTime getUpdatedTimestamp() { return updatedTimestamp; }
113
    public void setUpdatedTimestamp(LocalDateTime updatedTimestamp) { this.updatedTimestamp = updatedTimestamp; }
114
}