| Line 7... |
Line 7... |
| 7 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
7 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 8 |
import in.shop2020.model.v1.catalog.InventoryService;
|
8 |
import in.shop2020.model.v1.catalog.InventoryService;
|
| 9 |
import in.shop2020.model.v1.catalog.status;
|
9 |
import in.shop2020.model.v1.catalog.status;
|
| 10 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
10 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
| 11 |
import in.shop2020.utils.CategoryManager;
|
11 |
import in.shop2020.utils.CategoryManager;
|
| - |
|
12 |
import in.shop2020.utils.ConfigClientKeys;
|
| 12 |
|
13 |
|
| - |
|
14 |
import java.io.ByteArrayOutputStream;
|
| - |
|
15 |
import java.io.IOException;
|
| 13 |
import java.util.ArrayList;
|
16 |
import java.util.ArrayList;
|
| 14 |
import java.util.Calendar;
|
17 |
import java.util.Calendar;
|
| 15 |
import java.util.Collections;
|
18 |
import java.util.Collections;
|
| 16 |
import java.util.HashMap;
|
19 |
import java.util.HashMap;
|
| 17 |
import java.util.List;
|
20 |
import java.util.List;
|
| 18 |
import java.util.Map;
|
21 |
import java.util.Map;
|
| - |
|
22 |
import java.util.Map.Entry;
|
| - |
|
23 |
|
| - |
|
24 |
import javax.servlet.ServletOutputStream;
|
| - |
|
25 |
import javax.servlet.http.HttpServletResponse;
|
| 19 |
|
26 |
|
| 20 |
import com.google.gwt.core.client.GWT;
|
27 |
import com.google.gwt.core.client.GWT;
|
| 21 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
28 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
| 22 |
|
29 |
|
| 23 |
@SuppressWarnings("serial")
|
30 |
@SuppressWarnings("serial")
|
| 24 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
31 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
| 25 |
|
32 |
|
| 26 |
public List<Item> getAllItems(){
|
33 |
public List<Item> getAllItems(){
|
| 27 |
List<Item> itemList = new ArrayList<Item>();
|
34 |
List<Item> itemList = new ArrayList<Item>();
|
| 28 |
|
35 |
|
| 29 |
try {
|
36 |
try {
|
| 30 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
37 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 31 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
38 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 32 |
|
39 |
|
| 33 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(false);
|
40 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(false);
|
| 34 |
|
41 |
|
| 35 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
42 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 36 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
- |
|
| 37 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
43 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 38 |
}
|
44 |
}
|
| 39 |
} catch (Exception e) {
|
45 |
} catch (Exception e) {
|
| 40 |
e.printStackTrace();
|
46 |
e.printStackTrace();
|
| 41 |
}
|
47 |
}
|
| 42 |
Collections.sort(itemList, new ItemsComparator());
|
48 |
Collections.sort(itemList, new ItemsComparator());
|
| 43 |
return itemList;
|
49 |
return itemList;
|
| 44 |
}
|
50 |
}
|
| 45 |
|
51 |
|
| 46 |
public List<Item> getAllPhasedOutItems(){
|
52 |
public List<Item> getAllActiveItems(){
|
| 47 |
List<Item> itemList = new ArrayList<Item>();
|
53 |
List<Item> itemList = new ArrayList<Item>();
|
| 48 |
|
54 |
|
| 49 |
try {
|
55 |
try {
|
| 50 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
56 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 51 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
57 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 52 |
|
58 |
|
| 53 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(status.PHASED_OUT);
|
59 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(true);
|
| 54 |
|
60 |
|
| 55 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
61 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 56 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
62 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| - |
|
63 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| 57 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
64 |
itemList.add(getItemFromThriftItem(thriftItem, vip, vim));
|
| 58 |
}
|
65 |
}
|
| 59 |
} catch (Exception e) {
|
66 |
} catch (Exception e) {
|
| 60 |
e.printStackTrace();
|
67 |
e.printStackTrace();
|
| 61 |
}
|
68 |
}
|
| 62 |
Collections.sort(itemList, new ItemsComparator());
|
69 |
Collections.sort(itemList, new ItemsComparator());
|
| 63 |
return itemList;
|
70 |
return itemList;
|
| 64 |
}
|
71 |
}
|
| - |
|
72 |
|
| - |
|
73 |
@Override
|
| - |
|
74 |
public List<Item> getAllPhasedOutItems(){
|
| - |
|
75 |
return getItemsByStatus(status.PHASED_OUT);
|
| 65 |
|
76 |
}
|
| - |
|
77 |
|
| - |
|
78 |
@Override
|
| 66 |
public List<Item> getAllPausedItems(){
|
79 |
public List<Item> getAllPausedItems(){
|
| 67 |
List<Item> itemList = new ArrayList<Item>();
|
80 |
return getItemsByStatus(status.PAUSED);
|
| 68 |
|
- |
|
| 69 |
try {
|
- |
|
| 70 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
- |
|
| 71 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
- |
|
| 72 |
|
- |
|
| 73 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(status.PAUSED);
|
- |
|
| 74 |
|
- |
|
| 75 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
- |
|
| 76 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
- |
|
| 77 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
- |
|
| 78 |
}
|
- |
|
| 79 |
} catch (Exception e) {
|
- |
|
| 80 |
e.printStackTrace();
|
- |
|
| 81 |
}
|
- |
|
| 82 |
Collections.sort(itemList, new ItemsComparator());
|
- |
|
| 83 |
return itemList;
|
- |
|
| 84 |
}
|
81 |
}
|
| - |
|
82 |
|
| - |
|
83 |
@Override
|
| - |
|
84 |
public List<Item> getAllInProcessItems() {
|
| - |
|
85 |
return getItemsByStatus(status.IN_PROCESS);
|
| 85 |
|
86 |
}
|
| - |
|
87 |
|
| - |
|
88 |
@Override
|
| - |
|
89 |
public List<Item> getAllContentCompleteItems() {
|
| - |
|
90 |
return getItemsByStatus(status.CONTENT_COMPLETE);
|
| - |
|
91 |
}
|
| - |
|
92 |
|
| 86 |
public List<Item> getAllActiveItems(){
|
93 |
public List<Item> getBestDeals(){
|
| 87 |
List<Item> itemList = new ArrayList<Item>();
|
94 |
List<Item> itemList = new ArrayList<Item>();
|
| 88 |
|
- |
|
| 89 |
try {
|
95 |
try {
|
| 90 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
96 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 91 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
97 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 92 |
|
98 |
|
| 93 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(true);
|
99 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
| 94 |
|
- |
|
| 95 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
100 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 96 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
- |
|
| 97 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
101 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 98 |
}
|
102 |
}
|
| 99 |
} catch (Exception e) {
|
103 |
} catch(Exception e){
|
| 100 |
e.printStackTrace();
|
104 |
e.printStackTrace();
|
| 101 |
}
|
105 |
}
|
| 102 |
Collections.sort(itemList, new ItemsComparator());
|
106 |
Collections.sort(itemList, new ItemsComparator());
|
| 103 |
return itemList;
|
107 |
return itemList;
|
| 104 |
}
|
108 |
}
|
| 105 |
|
109 |
|
| - |
|
110 |
@Override
|
| 106 |
public List<Item> getBestDeals(){
|
111 |
public List<Item> getRiskyItems() {
|
| 107 |
List<Item> itemList = new ArrayList<Item>();
|
112 |
List<Item> itemList = new ArrayList<Item>();
|
| 108 |
|
- |
|
| 109 |
try {
|
113 |
try {
|
| 110 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
114 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 111 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
115 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 112 |
|
116 |
|
| 113 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
117 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
|
| 114 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
118 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 115 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
- |
|
| 116 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
119 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 117 |
}
|
120 |
}
|
| 118 |
} catch(Exception e){
|
121 |
} catch(Exception e){
|
| 119 |
e.printStackTrace();
|
122 |
e.printStackTrace();
|
| 120 |
}
|
123 |
}
|
| 121 |
Collections.sort(itemList, new ItemsComparator());
|
124 |
Collections.sort(itemList, new ItemsComparator());
|
| 122 |
return itemList;
|
125 |
return itemList;
|
| 123 |
}
|
126 |
}
|
| 124 |
|
127 |
|
| 125 |
public List<Item> getBestSellers(){
|
128 |
public List<Item> getBestSellers(){
|
| 126 |
List<Item> itemList = new ArrayList<Item>();
|
129 |
List<Item> itemList = new ArrayList<Item>();
|
| 127 |
|
130 |
|
| 128 |
try {
|
131 |
try {
|
| 129 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
132 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 130 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
133 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 131 |
|
134 |
|
| 132 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
135 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
| 133 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
136 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 134 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
137 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 135 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
138 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 136 |
}
|
139 |
}
|
| Line 138... |
Line 141... |
| 138 |
e.printStackTrace();
|
141 |
e.printStackTrace();
|
| 139 |
}
|
142 |
}
|
| 140 |
Collections.sort(itemList, new ItemsComparator());
|
143 |
Collections.sort(itemList, new ItemsComparator());
|
| 141 |
return itemList;
|
144 |
return itemList;
|
| 142 |
}
|
145 |
}
|
| 143 |
|
146 |
|
| 144 |
public List<Item> getLatestArrivals(){
|
147 |
public List<Item> getLatestArrivals(){
|
| 145 |
List<Item> itemList = new ArrayList<Item>();
|
148 |
List<Item> itemList = new ArrayList<Item>();
|
| 146 |
|
149 |
|
| 147 |
try {
|
150 |
try {
|
| 148 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
151 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 149 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
152 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 150 |
|
153 |
|
| 151 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
154 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getLatestArrivals();
|
| 152 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
155 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 153 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
156 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 154 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
157 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 155 |
}
|
158 |
}
|
| Line 157... |
Line 160... |
| 157 |
e.printStackTrace();
|
160 |
e.printStackTrace();
|
| 158 |
}
|
161 |
}
|
| 159 |
Collections.sort(itemList, new ItemsComparator());
|
162 |
Collections.sort(itemList, new ItemsComparator());
|
| 160 |
return itemList;
|
163 |
return itemList;
|
| 161 |
}
|
164 |
}
|
| 162 |
|
165 |
|
| 163 |
public Item getItem(long itemId){
|
166 |
public Item getItem(long itemId){
|
| 164 |
try{
|
167 |
try{
|
| 165 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
168 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 166 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
169 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 167 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
170 |
in.shop2020.model.v1.catalog.Item thriftItem = catalogClient.getItem(itemId);
|
| 168 |
|
171 |
|
| 169 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
172 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 170 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
173 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| 171 |
return getItemFromThriftItem(thriftItem, vip, vim);
|
174 |
return getItemFromThriftItem(thriftItem, vip, vim);
|
| 172 |
}catch(Exception e){
|
175 |
}catch(Exception e){
|
| 173 |
// Oops! We didn't receive the details. We should let the user know
|
- |
|
| 174 |
// that the catalog service is currently unavailable.
|
- |
|
| 175 |
e.printStackTrace();
|
176 |
e.printStackTrace();
|
| 176 |
}
|
177 |
}
|
| 177 |
return null;
|
178 |
return null;
|
| 178 |
}
|
179 |
}
|
| 179 |
|
180 |
|
| 180 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
181 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
| 181 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings,
|
182 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings,
|
| 182 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings){
|
183 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings){
|
| 183 |
|
184 |
|
| 184 |
Map<Long, VendorItemMapping> vItemMap = new HashMap<Long, VendorItemMapping>();
|
185 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
| 185 |
VendorItemMapping vItemMapping;
|
186 |
VendorItemMapping vItemMapping;
|
| 186 |
if(tVendorMappings != null) {
|
187 |
if(tVendorMappings != null) {
|
| 187 |
for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
|
188 |
for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
|
| 188 |
vItemMapping = new VendorItemMapping();
|
189 |
vItemMapping = new VendorItemMapping();
|
| 189 |
vItemMapping.setVendorId(vim.getVendorId());
|
190 |
vItemMapping.setVendorId(vim.getVendorId());
|
| 190 |
vItemMapping.setItemKey(vim.getItemKey());
|
191 |
vItemMapping.setItemKey(vim.getItemKey());
|
| 191 |
vItemMap.put(vItemMapping.getVendorId(), vItemMapping);
|
192 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
| 192 |
}
|
193 |
}
|
| 193 |
}
|
194 |
}
|
| 194 |
|
195 |
|
| 195 |
// TODO: For testing. Remove this code before moving to production.
|
196 |
// TODO: For testing. Remove this code before moving to production.
|
| 196 |
/*
|
197 |
/*
|
| 197 |
Map<Long, VendorItemMapping> vItemMap = new HashMap<Long, VendorItemMapping>();
|
198 |
Map<Long, VendorItemMapping> vItemMap = new HashMap<Long, VendorItemMapping>();
|
| 198 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 1"));
|
199 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 1"));
|
| 199 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 2"));
|
200 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 2"));
|
| 200 |
*/
|
201 |
*/
|
| 201 |
|
202 |
|
| 202 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
203 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
| 203 |
VendorPricings vPricings;
|
204 |
VendorPricings vPricings;
|
| 204 |
if(tVendorPricings != null) {
|
205 |
if(tVendorPricings != null) {
|
| 205 |
for(in.shop2020.model.v1.catalog.VendorItemPricing vip : tVendorPricings) {
|
206 |
for(in.shop2020.model.v1.catalog.VendorItemPricing vip : tVendorPricings) {
|
| 206 |
vPricings = new VendorPricings();
|
207 |
vPricings = new VendorPricings();
|
| Line 209... |
Line 210... |
| 209 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
210 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
| 210 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
211 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
| 211 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
212 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
| 212 |
}
|
213 |
}
|
| 213 |
}
|
214 |
}
|
| 214 |
|
215 |
|
| 215 |
Item item = new Item(thriftItem.getId(),
|
216 |
Item item = new Item(thriftItem.getId(),
|
| 216 |
thriftItem.getProductGroup(),
|
217 |
thriftItem.getProductGroup(),
|
| 217 |
thriftItem.getBrand(),
|
218 |
thriftItem.getBrand(),
|
| 218 |
thriftItem.getModelNumber(),
|
219 |
thriftItem.getModelNumber(),
|
| 219 |
thriftItem.getModelName(),
|
220 |
thriftItem.getModelName(),
|
| Line 234... |
Line 235... |
| 234 |
thriftItem.getStartDate(),
|
235 |
thriftItem.getStartDate(),
|
| 235 |
thriftItem.getRetireDate(),
|
236 |
thriftItem.getRetireDate(),
|
| 236 |
thriftItem.getUpdatedOn(),
|
237 |
thriftItem.getUpdatedOn(),
|
| 237 |
thriftItem.getItemStatus().name(),
|
238 |
thriftItem.getItemStatus().name(),
|
| 238 |
thriftItem.getItemStatus().getValue(),
|
239 |
thriftItem.getItemStatus().getValue(),
|
| - |
|
240 |
thriftItem.getStatus_description(),
|
| 239 |
thriftItem.getOtherInfo(),
|
241 |
thriftItem.getOtherInfo(),
|
| 240 |
thriftItem.getBestDealText(),
|
242 |
thriftItem.getBestDealText(),
|
| 241 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : -1,
|
243 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : -1,
|
| 242 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : -1,
|
244 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : -1,
|
| 243 |
thriftItem.isDefaultForEntity(),
|
245 |
thriftItem.isDefaultForEntity(),
|
| 244 |
thriftItem.isRisky(),
|
246 |
thriftItem.isRisky(),
|
| 245 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
247 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
| 246 |
vendorPricingMap,
|
248 |
vendorPricingMap,
|
| 247 |
vItemMap
|
249 |
vItemMap);
|
| 248 |
);
|
- |
|
| 249 |
return item;
|
250 |
return item;
|
| 250 |
}
|
251 |
}
|
| 251 |
|
252 |
|
| 252 |
@Override
|
253 |
@Override
|
| 253 |
public boolean updateItem(Item item) {
|
254 |
public boolean updateItem(Item item) {
|
| 254 |
GWT.log("Got a call to update item, Item Id: " + item.getId());
|
255 |
GWT.log("Got a call to update item, Item Id: " + item.getId());
|
| 255 |
try{
|
256 |
try{
|
| 256 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
257 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 257 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
258 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 258 |
|
259 |
|
| 259 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
260 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
| 260 |
setThriftItemParams(tItem, item);
|
261 |
setThriftItemParams(tItem, item);
|
| 261 |
// tItem.setAddedOn(item.getAddedOn());
|
262 |
// tItem.setAddedOn(item.getAddedOn());
|
| 262 |
|
263 |
|
| 263 |
// tItem.setCatalogItemId(item.getCatalogItemId());
|
264 |
// tItem.setCatalogItemId(item.getCatalogItemId());
|
| 264 |
// tItem.setCategory(item.getCategory());
|
265 |
// tItem.setCategory(item.getCategory());
|
| 265 |
|
266 |
|
| 266 |
// tItem.setFeatureId(item.getFeatureId());
|
267 |
// tItem.setFeatureId(item.getFeatureId());
|
| 267 |
// tItem.setFeatureDescription(item.getFeatureDescription());
|
268 |
// tItem.setFeatureDescription(item.getFeatureDescription());
|
| 268 |
|
269 |
|
| 269 |
long rItemId;
|
270 |
long rItemId;
|
| 270 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
271 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
| 271 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
272 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
| 272 |
return false;
|
273 |
return false;
|
| 273 |
}
|
274 |
}
|
| 274 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
275 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
| 275 |
|
276 |
|
| 276 |
Map<Long, VendorItemMapping> vendorMappings = item.getVendorMappingsMap();
|
277 |
Map<String, VendorItemMapping> vendorMappings = item.getVendorKeysMap();
|
| 277 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
278 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
| 278 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
279 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
| - |
|
280 |
|
| 279 |
for(VendorItemMapping v : vendorMappings.values()) {
|
281 |
for(Entry<String, VendorItemMapping> e : vendorMappings.entrySet()) {
|
| 280 |
tVendorMapping = new in.shop2020.model.v1.catalog.VendorItemMapping();
|
282 |
tVendorMapping = new in.shop2020.model.v1.catalog.VendorItemMapping();
|
| - |
|
283 |
VendorItemMapping v = e.getValue();
|
| 281 |
tVendorMapping.setVendorId(v.getVendorId());
|
284 |
tVendorMapping.setVendorId(v.getVendorId());
|
| 282 |
tVendorMapping.setItemKey(v.getItemKey());
|
285 |
tVendorMapping.setItemKey(v.getItemKey());
|
| 283 |
tVendorMapping.setItemId(item.getId());
|
286 |
tVendorMapping.setItemId(item.getId());
|
| 284 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
287 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| 285 |
catalogClient.addVendorItemMapping(tVendorMapping);
|
288 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 286 |
GWT.log("VendorItemMapping updated. " + tVendorMapping.getVendorId() + ", " + tVendorMapping.getItemId() + ", " +
|
289 |
GWT.log("VendorItemMapping updated. " + tVendorMapping.getVendorId() + ", " + tVendorMapping.getItemId() + ", " +
|
| 287 |
tVendorMapping.getItemKey() + ", " + tVendorMapping.getVendorCategory());
|
290 |
tVendorMapping.getItemKey() + ", " + tVendorMapping.getVendorCategory());
|
| 288 |
}
|
291 |
}
|
| 289 |
}
|
292 |
}
|
| 290 |
|
293 |
|
| 291 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
294 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
| 292 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
295 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| 293 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
296 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
| 294 |
for(VendorPricings v : vendorPricings.values()) {
|
297 |
for(VendorPricings v : vendorPricings.values()) {
|
| 295 |
tVendorPricing = new in.shop2020.model.v1.catalog.VendorItemPricing();
|
298 |
tVendorPricing = new in.shop2020.model.v1.catalog.VendorItemPricing();
|
| Line 301... |
Line 304... |
| 301 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
304 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
| 302 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
305 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
| 303 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
306 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
| 304 |
}
|
307 |
}
|
| 305 |
}
|
308 |
}
|
| 306 |
|
309 |
|
| 307 |
}catch(Exception e){
|
310 |
}catch(Exception e){
|
| 308 |
e.printStackTrace();
|
311 |
e.printStackTrace();
|
| 309 |
}
|
312 |
}
|
| 310 |
return true;
|
313 |
return true;
|
| 311 |
}
|
314 |
}
|
| 312 |
|
315 |
|
| 313 |
|
316 |
|
| 314 |
@Override
|
317 |
@Override
|
| 315 |
public Map<Long, String> getAllVendors() {
|
318 |
public Map<Long, String> getAllVendors() {
|
| 316 |
Map<Long, String> vendorMap = new HashMap<Long, String>();
|
319 |
Map<Long, String> vendorMap = new HashMap<Long, String>();
|
| 317 |
try {
|
320 |
try {
|
| 318 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
321 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 319 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
322 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 320 |
|
323 |
|
| 321 |
List<in.shop2020.model.v1.catalog.Vendor> vendors = catalogClient.getAllVendors();
|
324 |
List<in.shop2020.model.v1.catalog.Vendor> vendors = catalogClient.getAllVendors();
|
| 322 |
|
325 |
|
| 323 |
for(in.shop2020.model.v1.catalog.Vendor v : vendors) {
|
326 |
for(in.shop2020.model.v1.catalog.Vendor v : vendors) {
|
| 324 |
vendorMap.put(v.getId(), v.getName());
|
327 |
vendorMap.put(v.getId(), v.getName());
|
| 325 |
}
|
328 |
}
|
| 326 |
} catch (Exception e) {
|
329 |
} catch (Exception e) {
|
| 327 |
e.printStackTrace();
|
330 |
e.printStackTrace();
|
| Line 333... |
Line 336... |
| 333 |
public Map<Long, String> getAllWarehouses() {
|
336 |
public Map<Long, String> getAllWarehouses() {
|
| 334 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
337 |
Map<Long, String> warehouseMap = new HashMap<Long, String>();
|
| 335 |
try {
|
338 |
try {
|
| 336 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
339 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 337 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
340 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 338 |
|
341 |
|
| 339 |
List<in.shop2020.model.v1.catalog.Warehouse> warehouses = catalogClient.getAllWarehouses(true);
|
342 |
List<in.shop2020.model.v1.catalog.Warehouse> warehouses = catalogClient.getAllWarehouses(true);
|
| 340 |
|
343 |
|
| 341 |
for(in.shop2020.model.v1.catalog.Warehouse w : warehouses) {
|
344 |
for(in.shop2020.model.v1.catalog.Warehouse w : warehouses) {
|
| 342 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
345 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
| 343 |
}
|
346 |
}
|
| 344 |
} catch (Exception e) {
|
347 |
} catch (Exception e) {
|
| 345 |
e.printStackTrace();
|
348 |
e.printStackTrace();
|
| Line 352... |
Line 355... |
| 352 |
long itemId = 0;
|
355 |
long itemId = 0;
|
| 353 |
try {
|
356 |
try {
|
| 354 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
357 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 355 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
358 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 356 |
|
359 |
|
| 357 |
|
360 |
|
| 358 |
in.shop2020.model.v1.catalog.Item tItem = new in.shop2020.model.v1.catalog.Item();
|
361 |
in.shop2020.model.v1.catalog.Item tItem = new in.shop2020.model.v1.catalog.Item();
|
| 359 |
setThriftItemParams(tItem, item);
|
362 |
setThriftItemParams(tItem, item);
|
| 360 |
itemId = catalogClient.addItem(tItem);
|
363 |
itemId = catalogClient.addItem(tItem);
|
| 361 |
|
364 |
|
| 362 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
365 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
| Line 370... |
Line 373... |
| 370 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
373 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| 371 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
374 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 372 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
375 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
| 373 |
}
|
376 |
}
|
| 374 |
}
|
377 |
}
|
| 375 |
|
378 |
|
| 376 |
Map<Long, VendorItemMapping> vendorKeysMap = item.getVendorMappingsMap();
|
379 |
Map<String, VendorItemMapping> vendorKeysMap = item.getVendorKeysMap();
|
| 377 |
if(vendorKeysMap != null && !vendorKeysMap.isEmpty()) {
|
380 |
if(vendorKeysMap != null && !vendorKeysMap.isEmpty()) {
|
| 378 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
381 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
| 379 |
for(VendorItemMapping v : vendorKeysMap.values()) {
|
382 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()) {
|
| 380 |
tVendorMapping = new in.shop2020.model.v1.catalog.VendorItemMapping();
|
383 |
tVendorMapping = new in.shop2020.model.v1.catalog.VendorItemMapping();
|
| - |
|
384 |
VendorItemMapping v = e.getValue();
|
| 381 |
tVendorMapping.setVendorId(v.getVendorId());
|
385 |
tVendorMapping.setVendorId(v.getVendorId());
|
| 382 |
tVendorMapping.setItemKey(v.getItemKey());
|
386 |
tVendorMapping.setItemKey(v.getItemKey());
|
| 383 |
tVendorMapping.setItemId(itemId);
|
387 |
tVendorMapping.setItemId(itemId);
|
| 384 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
388 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| 385 |
catalogClient.addVendorItemMapping(tVendorMapping);
|
389 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 386 |
}
|
390 |
}
|
| 387 |
}
|
391 |
}
|
| 388 |
} catch (Exception e) {
|
392 |
} catch (Exception e) {
|
| 389 |
e.printStackTrace();
|
393 |
e.printStackTrace();
|
| 390 |
}
|
394 |
}
|
| 391 |
return itemId;
|
395 |
return itemId;
|
| 392 |
}
|
396 |
}
|
| 393 |
|
397 |
|
| 394 |
@Override
|
398 |
@Override
|
| 395 |
public long checkSimilarItem(String productGroup, String brand, String modelNumber, String color) {
|
399 |
public long checkSimilarItem(String productGroup, String brand, String modelNumber, String color) {
|
| 396 |
|
400 |
|
| 397 |
try {
|
401 |
try {
|
| 398 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
402 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 399 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
403 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 400 |
return catalogClient.checkSimilarItem(productGroup, brand, modelNumber, color);
|
404 |
return catalogClient.checkSimilarItem(productGroup, brand, modelNumber, color);
|
| 401 |
} catch (Exception e) {
|
405 |
} catch (Exception e) {
|
| 402 |
// TODO Auto-generated catch block
|
406 |
// TODO Auto-generated catch block
|
| 403 |
e.printStackTrace();
|
407 |
e.printStackTrace();
|
| 404 |
}
|
408 |
}
|
| 405 |
return 0;
|
409 |
return 0;
|
| 406 |
}
|
410 |
}
|
| 407 |
|
411 |
|
| 408 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
412 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
| 409 |
tItem.setId(tItem.getId());
|
413 |
tItem.setId(tItem.getId());
|
| 410 |
tItem.setProductGroup(item.getProductGroup());
|
414 |
tItem.setProductGroup(item.getProductGroup());
|
| 411 |
tItem.setBrand(item.getBrand());
|
415 |
tItem.setBrand(item.getBrand());
|
| 412 |
tItem.setModelName(item.getModelName());
|
416 |
tItem.setModelName(item.getModelName());
|
| 413 |
tItem.setModelNumber(item.getModelNumber());
|
417 |
tItem.setModelNumber(item.getModelNumber());
|
| 414 |
tItem.setColor(item.getColor());
|
418 |
tItem.setColor(item.getColor());
|
| 415 |
|
419 |
|
| - |
|
420 |
tItem.setStatus_description(item.getItemStatusDesc());
|
| 416 |
tItem.setComments(item.getComments());
|
421 |
tItem.setComments(item.getComments());
|
| 417 |
|
422 |
|
| 418 |
if(item.getMrp() != -1) {
|
423 |
if(item.getMrp() != -1) {
|
| 419 |
tItem.setMrp(item.getMrp());
|
424 |
tItem.setMrp(item.getMrp());
|
| 420 |
} else {
|
425 |
} else {
|
| 421 |
tItem.setMrpIsSet(false);
|
426 |
tItem.setMrpIsSet(false);
|
| 422 |
}
|
427 |
}
|
| Line 428... |
Line 433... |
| 428 |
if(item.getWeight() != -1) {
|
433 |
if(item.getWeight() != -1) {
|
| 429 |
tItem.setWeight(item.getWeight());
|
434 |
tItem.setWeight(item.getWeight());
|
| 430 |
} else {
|
435 |
} else {
|
| 431 |
tItem.setWeightIsSet(false);
|
436 |
tItem.setWeightIsSet(false);
|
| 432 |
}
|
437 |
}
|
| 433 |
|
438 |
|
| 434 |
tItem.setMop(item.getMop());
|
439 |
tItem.setMop(item.getMop());
|
| 435 |
tItem.setDealerPrice(item.getDealerPrice());
|
440 |
tItem.setDealerPrice(item.getDealerPrice());
|
| 436 |
tItem.setTransferPrice(item.getTransferPrice());
|
441 |
tItem.setTransferPrice(item.getTransferPrice());
|
| 437 |
|
442 |
|
| 438 |
tItem.setBestDealText(item.getBestDealsText());
|
443 |
tItem.setBestDealText(item.getBestDealsText());
|
| Line 446... |
Line 451... |
| 446 |
} else {
|
451 |
} else {
|
| 447 |
tItem.setBestSellingRankIsSet(false);
|
452 |
tItem.setBestSellingRankIsSet(false);
|
| 448 |
}
|
453 |
}
|
| 449 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
454 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
| 450 |
tItem.setRisky(item.isRisky());
|
455 |
tItem.setRisky(item.isRisky());
|
| 451 |
|
456 |
|
| 452 |
tItem.setStartDate(item.getStartDate());
|
457 |
tItem.setStartDate(item.getStartDate());
|
| 453 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
458 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
| 454 |
tItem.setRetireDate(item.getRetireDate());
|
459 |
tItem.setRetireDate(item.getRetireDate());
|
| 455 |
tItem.setHotspotCategory(item.getVendorCategory());
|
460 |
tItem.setHotspotCategory(item.getVendorCategory());
|
| 456 |
}
|
461 |
}
|
| Line 458... |
Line 463... |
| 458 |
@Override
|
463 |
@Override
|
| 459 |
public void pauseItem(long itemId) {
|
464 |
public void pauseItem(long itemId) {
|
| 460 |
try {
|
465 |
try {
|
| 461 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
466 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 462 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
467 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 463 |
|
468 |
|
| 464 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
469 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
| 465 |
} catch (Exception e) {
|
470 |
} catch (Exception e) {
|
| 466 |
e.printStackTrace();
|
471 |
e.printStackTrace();
|
| 467 |
}
|
472 |
}
|
| 468 |
|
473 |
|
| 469 |
}
|
474 |
}
|
| 470 |
|
475 |
|
| 471 |
@Override
|
476 |
@Override
|
| 472 |
public void markInProcess(long itemId) {
|
477 |
public void markInProcess(long itemId) {
|
| 473 |
try {
|
478 |
try {
|
| 474 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
479 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 475 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
480 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 476 |
|
481 |
|
| 477 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
482 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
| 478 |
} catch (Exception e) {
|
483 |
} catch (Exception e) {
|
| 479 |
e.printStackTrace();
|
484 |
e.printStackTrace();
|
| 480 |
}
|
485 |
}
|
| 481 |
|
- |
|
| 482 |
}
|
486 |
}
|
| 483 |
|
487 |
|
| 484 |
@Override
|
488 |
@Override
|
| 485 |
public void phaseoutItem(long itemId) {
|
489 |
public void phaseoutItem(long itemId) {
|
| 486 |
try {
|
490 |
try {
|
| 487 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
491 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 488 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
492 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 489 |
|
493 |
|
| 490 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
494 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
| 491 |
} catch (Exception e) {
|
495 |
} catch (Exception e) {
|
| 492 |
e.printStackTrace();
|
496 |
e.printStackTrace();
|
| 493 |
}
|
497 |
}
|
| 494 |
}
|
498 |
}
|
| 495 |
|
499 |
|
| 496 |
@Override
|
500 |
@Override
|
| 497 |
public void activateItem(long itemId) {
|
501 |
public void activateItem(long itemId) {
|
| 498 |
try {
|
502 |
try {
|
| 499 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
503 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| 500 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
504 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 501 |
|
505 |
|
| 502 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
506 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
| 503 |
} catch (Exception e) {
|
507 |
} catch (Exception e) {
|
| 504 |
e.printStackTrace();
|
508 |
e.printStackTrace();
|
| 505 |
}
|
509 |
}
|
| 506 |
}
|
510 |
}
|
| - |
|
511 |
|
| - |
|
512 |
/*@Override
|
| - |
|
513 |
public void uploadItems(String filename, long vendorId, String category, boolean fullUpdate, boolean dryRun, String suppliedProductGroup) {
|
| - |
|
514 |
try {
|
| - |
|
515 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
516 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
517 |
|
| - |
|
518 |
catalogClient.runItemLoader(filename, vendorId, category, fullUpdate, dryRun, suppliedProductGroup);
|
| - |
|
519 |
} catch (Exception e) {
|
| - |
|
520 |
e.printStackTrace();
|
| - |
|
521 |
}
|
| - |
|
522 |
|
| - |
|
523 |
}*/
|
| - |
|
524 |
|
| - |
|
525 |
@Override
|
| - |
|
526 |
public boolean changeItemRiskyFlag(long itemId, boolean risky) {
|
| - |
|
527 |
try {
|
| - |
|
528 |
// Initialize client for staging server
|
| - |
|
529 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
530 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
531 |
|
| - |
|
532 |
// Initialize client for production server
|
| - |
|
533 |
CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(),
|
| - |
|
534 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
| - |
|
535 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| - |
|
536 |
InventoryService.Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| - |
|
537 |
catalogClient.changeItemRiskyFlag(itemId, risky);
|
| - |
|
538 |
|
| - |
|
539 |
try{
|
| - |
|
540 |
catalogClient_Prod.changeItemRiskyFlag(itemId, risky);
|
| - |
|
541 |
}catch(Exception e){
|
| - |
|
542 |
e.printStackTrace();
|
| - |
|
543 |
// If not able to change risky flag on production, revert on staging and return false (to show error to user).
|
| - |
|
544 |
catalogClient.changeItemRiskyFlag(itemId, !risky);
|
| - |
|
545 |
return false;
|
| - |
|
546 |
}
|
| - |
|
547 |
} catch (Exception e) {
|
| - |
|
548 |
e.printStackTrace();
|
| - |
|
549 |
return false;
|
| - |
|
550 |
}
|
| - |
|
551 |
return true;
|
| - |
|
552 |
}
|
| - |
|
553 |
|
| - |
|
554 |
List<Item> getItemsByVendorCategory(String category) {
|
| - |
|
555 |
List<Item> itemList = new ArrayList<Item>();
|
| - |
|
556 |
try {
|
| - |
|
557 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
558 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
559 |
|
| - |
|
560 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByVendorCategory(category);
|
| - |
|
561 |
|
| - |
|
562 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| - |
|
563 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| - |
|
564 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| - |
|
565 |
itemList.add(getItemFromThriftItem(thriftItem, vip, vim));
|
| - |
|
566 |
}
|
| - |
|
567 |
} catch (Exception e) {
|
| - |
|
568 |
e.printStackTrace();
|
| - |
|
569 |
}
|
| - |
|
570 |
Collections.sort(itemList, new ItemsComparator());
|
| - |
|
571 |
return itemList;
|
| - |
|
572 |
}
|
| - |
|
573 |
|
| - |
|
574 |
List<Item> getItemsByStatus(status st) {
|
| - |
|
575 |
List<Item> itemList = new ArrayList<Item>();
|
| - |
|
576 |
try {
|
| - |
|
577 |
CatalogServiceClient catalogServiceClient = new CatalogServiceClient();
|
| - |
|
578 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
579 |
|
| - |
|
580 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(st);
|
| - |
|
581 |
|
| - |
|
582 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| - |
|
583 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| - |
|
584 |
}
|
| - |
|
585 |
} catch (Exception e) {
|
| - |
|
586 |
e.printStackTrace();
|
| - |
|
587 |
}
|
| - |
|
588 |
Collections.sort(itemList, new ItemsComparator());
|
| - |
|
589 |
return itemList;
|
| - |
|
590 |
}
|
| - |
|
591 |
|
| - |
|
592 |
@Override
|
| - |
|
593 |
public boolean updateItemOnProduction(Item item) {
|
| - |
|
594 |
GWT.log("Update item on production, Item Id: " + item.getId());
|
| - |
|
595 |
try{
|
| - |
|
596 |
CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(),
|
| - |
|
597 |
ConfigClientKeys.catalog_service_server_host_prod.toString(),
|
| - |
|
598 |
ConfigClientKeys.catalog_service_server_port.toString());
|
| - |
|
599 |
|
| - |
|
600 |
//for testing, put catalog_service_server_port_test in shop2020.cfg
|
| - |
|
601 |
/*CatalogServiceClient catalogServiceClient_Prod = new CatalogServiceClient(CatalogServiceClient.class.getSimpleName(),
|
| - |
|
602 |
ConfigClientKeys.catalog_service_server_host.toString(), "catalog_service_server_port_test");*/
|
| - |
|
603 |
|
| - |
|
604 |
InventoryService.Client catalogClient_Prod = catalogServiceClient_Prod.getClient();
|
| - |
|
605 |
|
| - |
|
606 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
|
| - |
|
607 |
if(item.getMrp() != -1) {
|
| - |
|
608 |
tItem.setMrp(item.getMrp());
|
| - |
|
609 |
} else {
|
| - |
|
610 |
tItem.setMrpIsSet(false);
|
| - |
|
611 |
}
|
| - |
|
612 |
if(item.getSellingPrice() != -1) {
|
| - |
|
613 |
tItem.setSellingPrice(item.getSellingPrice());
|
| - |
|
614 |
} else {
|
| - |
|
615 |
tItem.setSellingPriceIsSet(false);
|
| - |
|
616 |
}
|
| - |
|
617 |
if(item.getMop() != -1) {
|
| - |
|
618 |
tItem.setMop(item.getMop());
|
| - |
|
619 |
} else {
|
| - |
|
620 |
tItem.setMopIsSet(false);
|
| - |
|
621 |
}
|
| - |
|
622 |
if(item.getDealerPrice() != -1) {
|
| - |
|
623 |
tItem.setDealerPrice(item.getDealerPrice());
|
| - |
|
624 |
} else {
|
| - |
|
625 |
tItem.setDealerPriceIsSet(false);
|
| - |
|
626 |
}
|
| - |
|
627 |
if(item.getTransferPrice() != -1) {
|
| - |
|
628 |
tItem.setTransferPrice(item.getTransferPrice());
|
| - |
|
629 |
} else {
|
| - |
|
630 |
tItem.setTransferPriceIsSet(false);
|
| - |
|
631 |
}
|
| - |
|
632 |
|
| - |
|
633 |
long rItemId;
|
| - |
|
634 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != item.getId()) {
|
| - |
|
635 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
| - |
|
636 |
return false;
|
| - |
|
637 |
}
|
| - |
|
638 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
| - |
|
639 |
|
| - |
|
640 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
| - |
|
641 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| - |
|
642 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
| - |
|
643 |
for(VendorPricings v : vendorPricings.values()) {
|
| - |
|
644 |
tVendorPricing = new in.shop2020.model.v1.catalog.VendorItemPricing();
|
| - |
|
645 |
tVendorPricing.setVendorId(v.getVendorId());
|
| - |
|
646 |
tVendorPricing.setItemId(item.getId());
|
| - |
|
647 |
tVendorPricing.setMop(v.getMop());
|
| - |
|
648 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| - |
|
649 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| - |
|
650 |
catalogClient_Prod.addVendorItemPricing(tVendorPricing);
|
| - |
|
651 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
| - |
|
652 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
| - |
|
653 |
}
|
| - |
|
654 |
}
|
| - |
|
655 |
} catch (Exception e) {
|
| - |
|
656 |
e.printStackTrace();
|
| - |
|
657 |
return false;
|
| - |
|
658 |
}
|
| - |
|
659 |
return true;
|
| - |
|
660 |
}
|
| 507 |
}
|
661 |
}
|
| - |
|
662 |
|
| - |
|
663 |
|