Subversion Repositories SmartDukaan

Rev

Rev 35350 | Rev 35357 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
33772 amit.gupta 1
package com.spice.profitmandi.dao.entity.catalog;
2
 
3
import javax.persistence.*;
4
import java.time.LocalDateTime;
5
import java.util.Objects;
6
 
35343 ranu 7
 
8
@NamedQueries({
9
        @NamedQuery(name = "Catalog.findOtherORNullCategoryAndInStock", query = "select i.catalogItemId "
10
                + " from WarehouseInventoryItem wi "
11
                + " join Item i on i.id = wi.itemId"
12
                + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
35356 ranu 13
                + " where ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand group by i.catalogItemId having sum(wi.currentQuantity) > 0"),
35343 ranu 14
 
15
        @NamedQuery(name = "Catalog.findOtherORNullCategoryAndPartnerInStock", query = "select i.catalogItemId "
16
                + " from CurrentInventorySnapshot cis "
17
                + " join Item i on i.id = cis.itemId"
18
                + " left join CategorisedCatalog cc on cc.catalogId = i.catalogItemId and cc.endDate is null "
35356 ranu 19
                + " where  ((cc.status is null OR cc.status = 'OTHER' OR cc.status = 'SLOWMOVING')) and i.categoryId in (10006,10009,10010) and i.brand= :brand and cis.fofoId = :fofoId group by i.catalogItemId having sum(cis.availability) > 0"),
35343 ranu 20
})
21
 
33772 amit.gupta 22
@Entity
23
@Table(name = "catalog.catalog")
24
public class Catalog {
25
    @Id
26
    @GeneratedValue(strategy = GenerationType.IDENTITY)
27
    @Column(name = "id", columnDefinition = "int(11)")
28
    private int id;
29
 
30
    @Column(name="brand_id")
31
    private int brandId;
32
 
33
    @Column
34
    private String brand;
35
 
36
    @Column(name="model_number")
37
    private String modelNumber;
38
 
39
    @Column(name="model_name")
40
    private String modelName;
41
 
33888 ranu 42
    @Column(name = "category_id")
43
    private int categoryId;
44
 
33772 amit.gupta 45
    @Column(name="created_by")
46
    private String createdBy;
47
 
48
    @Column
49
    private LocalDateTime created;
50
 
51
    public int getId() {
52
        return id;
53
    }
54
 
55
    public void setId(int id) {
56
        this.id = id;
57
    }
58
 
59
    public int getBrandId() {
60
        return brandId;
61
    }
62
 
63
    public void setBrandId(int brandId) {
64
        this.brandId = brandId;
65
    }
66
 
67
    public String getBrand() {
68
        return brand;
69
    }
70
 
71
    public void setBrand(String brand) {
72
        this.brand = brand;
73
    }
74
 
75
    public String getModelNumber() {
76
        return modelNumber;
77
    }
78
 
79
    public void setModelNumber(String modelNumber) {
80
        this.modelNumber = modelNumber;
81
    }
82
 
83
    public String getModelName() {
84
        return modelName;
85
    }
86
 
87
    public void setModelName(String modelName) {
88
        this.modelName = modelName;
89
    }
90
 
91
    public String getCreatedBy() {
92
        return createdBy;
93
    }
94
 
95
    public void setCreatedBy(String createdBy) {
96
        this.createdBy = createdBy;
97
    }
98
 
99
    public LocalDateTime getCreated() {
100
        return created;
101
    }
102
 
103
    public void setCreated(LocalDateTime created) {
104
        this.created = created;
105
    }
106
 
33888 ranu 107
    public int getCategoryId() {
108
        return categoryId;
109
    }
110
 
111
    public void setCategoryId(int categoryId) {
112
        this.categoryId = categoryId;
113
    }
114
 
33772 amit.gupta 115
    @Override
116
    public boolean equals(Object o) {
117
        if (this == o) return true;
118
        if (o == null || getClass() != o.getClass()) return false;
119
        Catalog catalog = (Catalog) o;
33888 ranu 120
        return id == catalog.id && brandId == catalog.brandId && categoryId == catalog.categoryId && Objects.equals(brand, catalog.brand) && Objects.equals(modelNumber, catalog.modelNumber) && Objects.equals(modelName, catalog.modelName) && Objects.equals(createdBy, catalog.createdBy) && Objects.equals(created, catalog.created);
33772 amit.gupta 121
    }
122
 
123
    @Override
33888 ranu 124
    public int hashCode() {
125
        return Objects.hash(id, brandId, brand, modelNumber, modelName, categoryId, createdBy, created);
126
    }
127
 
33916 amit.gupta 128
    public String getDescription() {
129
        StringBuilder itemString = new StringBuilder();
130
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
131
            itemString.append(this.getBrand().trim());
132
        }
133
        itemString.append(" ");
134
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
135
            itemString.append(this.getModelName().trim());
136
        }
137
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
138
            itemString.append(" ");
139
            itemString.append(this.getModelNumber().trim());
140
        }
141
 
142
        return itemString.toString().replaceAll("\\s+", " ").trim();
143
    }
144
 
35188 amit 145
    public String getDescriptionNoBrand() {
146
        StringBuilder itemString = new StringBuilder();
147
        itemString.append(" ");
148
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
149
            itemString.append(this.getModelName().trim());
150
        }
151
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
152
            itemString.append(" ");
153
            itemString.append(this.getModelNumber().trim());
154
        }
155
 
156
        return itemString.toString().replaceAll("\\s+", " ").trim();
157
    }
158
 
33888 ranu 159
    @Override
33772 amit.gupta 160
    public String toString() {
161
        return "Catalog{" +
162
                "id=" + id +
163
                ", brandId=" + brandId +
164
                ", brand='" + brand + '\'' +
165
                ", modelNumber='" + modelNumber + '\'' +
166
                ", modelName='" + modelName + '\'' +
33888 ranu 167
                ", categoryId=" + categoryId +
33772 amit.gupta 168
                ", createdBy='" + createdBy + '\'' +
169
                ", created=" + created +
170
                '}';
171
    }
172
 
173
}
174