| Line 27... |
Line 27... |
| 27 |
import java.util.Map;
|
27 |
import java.util.Map;
|
| 28 |
import java.util.Map.Entry;
|
28 |
import java.util.Map.Entry;
|
| 29 |
|
29 |
|
| 30 |
import org.apache.log4j.Logger;
|
30 |
import org.apache.log4j.Logger;
|
| 31 |
|
31 |
|
| 32 |
import com.google.gwt.core.client.GWT;
|
- |
|
| 33 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
32 |
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
| 34 |
|
33 |
|
| 35 |
@SuppressWarnings("serial")
|
34 |
@SuppressWarnings("serial")
|
| 36 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
35 |
public class CatalogServiceImpl extends RemoteServiceServlet implements CatalogService {
|
| 37 |
|
36 |
|
| - |
|
37 |
private static Logger logger = Logger.getLogger(CatalogServiceImpl.class);
|
| - |
|
38 |
|
| 38 |
private static Date pushToProdDate;
|
39 |
private static Date pushToProdDate;
|
| 39 |
|
40 |
|
| 40 |
public List<Item> getAllItems(){
|
41 |
public List<Item> getAllItems(){
|
| 41 |
List<Item> itemList = new ArrayList<Item>();
|
42 |
List<Item> itemList = new ArrayList<Item>();
|
| 42 |
|
43 |
|
| Line 48... |
Line 49... |
| 48 |
|
49 |
|
| 49 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
50 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 50 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
51 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 51 |
}
|
52 |
}
|
| 52 |
} catch (Exception e) {
|
53 |
} catch (Exception e) {
|
| 53 |
e.printStackTrace();
|
54 |
logger.error("Error while getting all items from the catalog service", e);
|
| 54 |
}
|
55 |
}
|
| 55 |
Collections.sort(itemList, new ItemsComparator());
|
56 |
Collections.sort(itemList, new ItemsComparator());
|
| 56 |
return itemList;
|
57 |
return itemList;
|
| 57 |
}
|
58 |
}
|
| 58 |
|
59 |
|
| 59 |
public List<Item> getAllActiveItems(){
|
60 |
public List<Item> getAllActiveItems(){
|
| 60 |
List<Item> itemList = new ArrayList<Item>();
|
61 |
return getItemsByStatus(status.ACTIVE);
|
| 61 |
|
- |
|
| 62 |
try {
|
- |
|
| 63 |
CatalogClient catalogServiceClient = new CatalogClient();
|
- |
|
| 64 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
- |
|
| 65 |
|
- |
|
| 66 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItems(true);
|
- |
|
| 67 |
|
- |
|
| 68 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
- |
|
| 69 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
- |
|
| 70 |
}
|
- |
|
| 71 |
} catch (Exception e) {
|
- |
|
| 72 |
e.printStackTrace();
|
- |
|
| 73 |
}
|
- |
|
| 74 |
Collections.sort(itemList, new ItemsComparator());
|
- |
|
| 75 |
return itemList;
|
- |
|
| 76 |
}
|
62 |
}
|
| 77 |
|
63 |
|
| 78 |
@Override
|
64 |
@Override
|
| 79 |
public List<Item> getAllPhasedOutItems(){
|
65 |
public List<Item> getAllPhasedOutItems(){
|
| 80 |
return getItemsByStatus(status.PHASED_OUT);
|
66 |
return getItemsByStatus(status.PHASED_OUT);
|
| Line 104... |
Line 90... |
| 104 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
90 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestDeals();
|
| 105 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
91 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 106 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
92 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 107 |
}
|
93 |
}
|
| 108 |
} catch(Exception e){
|
94 |
} catch(Exception e){
|
| 109 |
e.printStackTrace();
|
95 |
logger.error("Error while getting the best deals from the catalog service", e);
|
| 110 |
}
|
96 |
}
|
| 111 |
//Collections.sort(itemList, new ItemsComparator());
|
97 |
//Collections.sort(itemList, new ItemsComparator());
|
| 112 |
return itemList;
|
98 |
return itemList;
|
| 113 |
}
|
99 |
}
|
| 114 |
|
100 |
|
| Line 122... |
Line 108... |
| 122 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
|
108 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getItemsByRiskyFlag();
|
| 123 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
109 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 124 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
110 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 125 |
}
|
111 |
}
|
| 126 |
} catch(Exception e){
|
112 |
} catch(Exception e){
|
| 127 |
e.printStackTrace();
|
113 |
logger.error("Error while getting the risky items from the catalog service", e);
|
| 128 |
}
|
114 |
}
|
| 129 |
Collections.sort(itemList, new ItemsComparator());
|
115 |
Collections.sort(itemList, new ItemsComparator());
|
| 130 |
return itemList;
|
116 |
return itemList;
|
| 131 |
}
|
117 |
}
|
| 132 |
|
118 |
|
| Line 140... |
Line 126... |
| 140 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
126 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getBestSellers();
|
| 141 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
127 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 142 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
128 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 143 |
}
|
129 |
}
|
| 144 |
} catch(Exception e){
|
130 |
} catch(Exception e){
|
| 145 |
e.printStackTrace();
|
131 |
logger.error("Error while getting the best sellers from the catalog service", e);
|
| 146 |
}
|
132 |
}
|
| 147 |
//Collections.sort(itemList, new ItemsComparator());
|
- |
|
| 148 |
return itemList;
|
133 |
return itemList;
|
| 149 |
}
|
134 |
}
|
| 150 |
|
135 |
|
| 151 |
public List<Item> getLatestArrivals(){
|
136 |
public List<Item> getLatestArrivals(){
|
| 152 |
List<Item> itemList = new ArrayList<Item>();
|
137 |
List<Item> itemList = new ArrayList<Item>();
|
| Line 159... |
Line 144... |
| 159 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
144 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| 160 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
145 |
//List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 161 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
146 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| 162 |
}
|
147 |
}
|
| 163 |
} catch(Exception e){
|
148 |
} catch(Exception e){
|
| 164 |
e.printStackTrace();
|
149 |
logger.error("Error while getting the latest arrivals from the catalog service", e);
|
| 165 |
}
|
150 |
}
|
| 166 |
//Collections.sort(itemList, new ItemsComparator());
|
- |
|
| 167 |
return itemList;
|
151 |
return itemList;
|
| 168 |
}
|
152 |
}
|
| 169 |
|
153 |
|
| 170 |
public Item getItem(long itemId){
|
154 |
public Item getItem(long itemId){
|
| 171 |
try{
|
155 |
try{
|
| Line 175... |
Line 159... |
| 175 |
|
159 |
|
| 176 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
160 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 177 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
161 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| 178 |
return getItemFromThriftItem(thriftItem, vip, vim);
|
162 |
return getItemFromThriftItem(thriftItem, vip, vim);
|
| 179 |
}catch(Exception e){
|
163 |
}catch(Exception e){
|
| 180 |
e.printStackTrace();
|
164 |
logger.error("Error while getting the item from the catalog service", e);
|
| 181 |
}
|
165 |
}
|
| 182 |
return null;
|
166 |
return null;
|
| 183 |
}
|
167 |
}
|
| 184 |
|
- |
|
| 185 |
/**
|
- |
|
| 186 |
* Creates a new Item object and populates its attributes from thrift item passed as parameter.
|
- |
|
| 187 |
* Also creates a Map each for VendorItemPricing and VendorItemMapping and adds these maps to the
|
- |
|
| 188 |
* new Item object.
|
- |
|
| 189 |
* @param thriftItem
|
- |
|
| 190 |
* @param tVendorPricings
|
- |
|
| 191 |
* @param tVendorMappings
|
- |
|
| 192 |
* @return item object with attributes copied from thrift item object.
|
- |
|
| 193 |
*/
|
- |
|
| 194 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
- |
|
| 195 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings,
|
- |
|
| 196 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings){
|
- |
|
| 197 |
|
- |
|
| 198 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
- |
|
| 199 |
VendorItemMapping vItemMapping;
|
- |
|
| 200 |
if(tVendorMappings != null) {
|
- |
|
| 201 |
for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
|
- |
|
| 202 |
vItemMapping = new VendorItemMapping();
|
- |
|
| 203 |
vItemMapping.setVendorId(vim.getVendorId());
|
- |
|
| 204 |
vItemMapping.setItemKey(vim.getItemKey());
|
- |
|
| 205 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
- |
|
| 206 |
}
|
- |
|
| 207 |
}
|
- |
|
| 208 |
|
- |
|
| 209 |
// TODO: For testing. Remove this code before moving to production.
|
- |
|
| 210 |
/*
|
- |
|
| 211 |
Map<Long, VendorItemMapping> vItemMap = new HashMap<Long, VendorItemMapping>();
|
- |
|
| 212 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 1"));
|
- |
|
| 213 |
vItemMap.put(1L, new VendorItemMapping(1, "Item Key Test 2"));
|
- |
|
| 214 |
*/
|
- |
|
| 215 |
|
- |
|
| 216 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
- |
|
| 217 |
VendorPricings vPricings;
|
- |
|
| 218 |
if(tVendorPricings != null) {
|
- |
|
| 219 |
for(in.shop2020.model.v1.catalog.VendorItemPricing vip : tVendorPricings) {
|
- |
|
| 220 |
vPricings = new VendorPricings();
|
- |
|
| 221 |
vPricings.setVendorId(vip.getVendorId());
|
- |
|
| 222 |
vPricings.setMop(vip.getMop());
|
- |
|
| 223 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
- |
|
| 224 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
- |
|
| 225 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
- |
|
| 226 |
}
|
- |
|
| 227 |
}
|
- |
|
| 228 |
|
- |
|
| 229 |
Item item = new Item(thriftItem.getId(),
|
- |
|
| 230 |
thriftItem.getHotspotCategory(),
|
- |
|
| 231 |
thriftItem.getProductGroup(),
|
- |
|
| 232 |
thriftItem.getBrand(),
|
- |
|
| 233 |
thriftItem.getModelNumber(),
|
- |
|
| 234 |
thriftItem.getModelName(),
|
- |
|
| 235 |
thriftItem.getColor(),
|
- |
|
| 236 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
- |
|
| 237 |
thriftItem.getCategory(),
|
- |
|
| 238 |
thriftItem.getComments(),
|
- |
|
| 239 |
thriftItem.getCatalogItemId(),
|
- |
|
| 240 |
thriftItem.getFeatureId(),
|
- |
|
| 241 |
thriftItem.getFeatureDescription(),
|
- |
|
| 242 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
- |
|
| 243 |
thriftItem.getMop(),
|
- |
|
| 244 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
- |
|
| 245 |
thriftItem.getDealerPrice(),
|
- |
|
| 246 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
- |
|
| 247 |
thriftItem.getAddedOn(),
|
- |
|
| 248 |
thriftItem.getStartDate(),
|
- |
|
| 249 |
thriftItem.getRetireDate(),
|
- |
|
| 250 |
thriftItem.getUpdatedOn(),
|
- |
|
| 251 |
thriftItem.getItemStatus().name(),
|
- |
|
| 252 |
thriftItem.getItemStatus().getValue(),
|
- |
|
| 253 |
thriftItem.getStatus_description(),
|
- |
|
| 254 |
thriftItem.getOtherInfo(),
|
- |
|
| 255 |
thriftItem.getBestDealText(),
|
- |
|
| 256 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
- |
|
| 257 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
- |
|
| 258 |
thriftItem.isDefaultForEntity(),
|
- |
|
| 259 |
thriftItem.isRisky(),
|
- |
|
| 260 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
- |
|
| 261 |
vendorPricingMap,
|
- |
|
| 262 |
vItemMap);
|
- |
|
| 263 |
return item;
|
- |
|
| 264 |
}
|
- |
|
| 265 |
|
168 |
|
| 266 |
@Override
|
169 |
@Override
|
| 267 |
public boolean updateItem(Item item) {
|
170 |
public boolean updateItem(Item item) {
|
| 268 |
GWT.log("Got a call to update item, Item Id: " + item.getId());
|
171 |
logger.info("Updating item with Id: " + item.getId());
|
| 269 |
try{
|
172 |
try{
|
| 270 |
CatalogClient catalogServiceClient = new CatalogClient();
|
173 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 271 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
174 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 272 |
|
175 |
|
| 273 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
176 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient.getItem(item.getId());
|
| 274 |
setThriftItemParams(tItem, item);
|
177 |
setThriftItemParams(tItem, item);
|
| 275 |
|
178 |
|
| 276 |
long rItemId;
|
179 |
long rItemId;
|
| 277 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
180 |
if((rItemId = catalogClient.updateItem(tItem)) != item.getId()) {
|
| 278 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
181 |
logger.error("Error updating item, returned Item Id: " + rItemId);
|
| 279 |
return false;
|
182 |
return false;
|
| 280 |
}
|
183 |
}
|
| 281 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
184 |
logger.info("Successfully updated item with id: " + item.getId());
|
| 282 |
|
185 |
|
| 283 |
Map<String, VendorItemMapping> vendorMappings = item.getVendorKeysMap();
|
186 |
Map<String, VendorItemMapping> vendorMappings = item.getVendorKeysMap();
|
| 284 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
187 |
if(vendorMappings != null && !vendorMappings.isEmpty()) {
|
| 285 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
188 |
in.shop2020.model.v1.catalog.VendorItemMapping tVendorMapping;
|
| 286 |
|
189 |
|
| Line 290... |
Line 193... |
| 290 |
tVendorMapping.setVendorId(v.getVendorId());
|
193 |
tVendorMapping.setVendorId(v.getVendorId());
|
| 291 |
tVendorMapping.setItemKey(v.getItemKey());
|
194 |
tVendorMapping.setItemKey(v.getItemKey());
|
| 292 |
tVendorMapping.setItemId(item.getId());
|
195 |
tVendorMapping.setItemId(item.getId());
|
| 293 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
196 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| 294 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
197 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 295 |
GWT.log("VendorItemMapping updated. " + tVendorMapping.getVendorId() + ", " + tVendorMapping.getItemId() + ", " +
|
- |
|
| 296 |
tVendorMapping.getItemKey() + ", " + tVendorMapping.getVendorCategory());
|
198 |
logger.info("Updates VendorItemMapping: " + tVendorMapping.toString());
|
| 297 |
}
|
199 |
}
|
| 298 |
}
|
200 |
}
|
| 299 |
|
201 |
|
| 300 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
202 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
| 301 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
203 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| Line 306... |
Line 208... |
| 306 |
tVendorPricing.setItemId(item.getId());
|
208 |
tVendorPricing.setItemId(item.getId());
|
| 307 |
tVendorPricing.setMop(v.getMop());
|
209 |
tVendorPricing.setMop(v.getMop());
|
| 308 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
210 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| 309 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
211 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 310 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
212 |
catalogClient.addVendorItemPricing(tVendorPricing);
|
| 311 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
213 |
logger.info("Updated VendorItemPricing: " + tVendorPricing.toString());
|
| 312 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
- |
|
| 313 |
}
|
214 |
}
|
| 314 |
}
|
215 |
}
|
| 315 |
|
- |
|
| 316 |
}catch(Exception e){
|
216 |
}catch(Exception e){
|
| 317 |
e.printStackTrace();
|
217 |
logger.error("Error while updating item: ", e);
|
| 318 |
return false;
|
218 |
return false;
|
| 319 |
}
|
219 |
}
|
| 320 |
return true;
|
220 |
return true;
|
| 321 |
}
|
221 |
}
|
| 322 |
|
222 |
|
| Line 332... |
Line 232... |
| 332 |
|
232 |
|
| 333 |
for(in.shop2020.model.v1.catalog.Vendor v : vendors) {
|
233 |
for(in.shop2020.model.v1.catalog.Vendor v : vendors) {
|
| 334 |
vendorMap.put(v.getId(), v.getName());
|
234 |
vendorMap.put(v.getId(), v.getName());
|
| 335 |
}
|
235 |
}
|
| 336 |
} catch (Exception e) {
|
236 |
} catch (Exception e) {
|
| 337 |
e.printStackTrace();
|
237 |
logger.error("Error while getting all the vendors: ", e);
|
| 338 |
}
|
238 |
}
|
| 339 |
return vendorMap;
|
239 |
return vendorMap;
|
| 340 |
}
|
240 |
}
|
| 341 |
|
241 |
|
| 342 |
@Override
|
242 |
@Override
|
| Line 350... |
Line 250... |
| 350 |
|
250 |
|
| 351 |
for(in.shop2020.model.v1.catalog.Warehouse w : warehouses) {
|
251 |
for(in.shop2020.model.v1.catalog.Warehouse w : warehouses) {
|
| 352 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
252 |
warehouseMap.put(w.getId(), w.getDisplayName());
|
| 353 |
}
|
253 |
}
|
| 354 |
} catch (Exception e) {
|
254 |
} catch (Exception e) {
|
| 355 |
e.printStackTrace();
|
255 |
logger.error("Error while getting all the warehouses:", e );
|
| 356 |
}
|
256 |
}
|
| 357 |
return warehouseMap;
|
257 |
return warehouseMap;
|
| 358 |
}
|
258 |
}
|
| 359 |
|
259 |
|
| 360 |
@Override
|
260 |
@Override
|
| Line 395... |
Line 295... |
| 395 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
295 |
tVendorMapping.setVendorCategory(item.getVendorCategory());
|
| 396 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
296 |
catalogClient.addVendorItemMapping(e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1), tVendorMapping);
|
| 397 |
}
|
297 |
}
|
| 398 |
}
|
298 |
}
|
| 399 |
} catch (Exception e) {
|
299 |
} catch (Exception e) {
|
| 400 |
e.printStackTrace();
|
300 |
logger.error("Error while adding an item: ", e);
|
| 401 |
}
|
301 |
}
|
| 402 |
return itemId;
|
302 |
return itemId;
|
| 403 |
}
|
303 |
}
|
| 404 |
|
304 |
|
| 405 |
@Override
|
305 |
@Override
|
| Line 408... |
Line 308... |
| 408 |
try {
|
308 |
try {
|
| 409 |
CatalogClient catalogServiceClient = new CatalogClient();
|
309 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 410 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
310 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 411 |
return catalogClient.checkSimilarItem(productGroup, brand, modelNumber, color);
|
311 |
return catalogClient.checkSimilarItem(productGroup, brand, modelNumber, color);
|
| 412 |
} catch (Exception e) {
|
312 |
} catch (Exception e) {
|
| 413 |
e.printStackTrace();
|
313 |
logger.error("Error while checking for a similar item: ", e);
|
| 414 |
}
|
314 |
}
|
| 415 |
return 0;
|
315 |
return 0;
|
| 416 |
}
|
316 |
}
|
| 417 |
|
317 |
|
| 418 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
318 |
private void setThriftItemParams(in.shop2020.model.v1.catalog.Item tItem, Item item) {
|
| Line 426... |
Line 326... |
| 426 |
tItem.setStatus_description(item.getItemStatusDesc());
|
326 |
tItem.setStatus_description(item.getItemStatusDesc());
|
| 427 |
tItem.setComments(item.getComments());
|
327 |
tItem.setComments(item.getComments());
|
| 428 |
|
328 |
|
| 429 |
if(item.getMrp() != null) {
|
329 |
if(item.getMrp() != null) {
|
| 430 |
tItem.setMrp(item.getMrp());
|
330 |
tItem.setMrp(item.getMrp());
|
| 431 |
} else {
|
- |
|
| 432 |
tItem.setMrpIsSet(false);
|
- |
|
| 433 |
}
|
331 |
}
|
| - |
|
332 |
|
| 434 |
if(item.getSellingPrice() != null) {
|
333 |
if(item.getSellingPrice() != null) {
|
| 435 |
tItem.setSellingPrice(item.getSellingPrice());
|
334 |
tItem.setSellingPrice(item.getSellingPrice());
|
| 436 |
} else {
|
- |
|
| 437 |
tItem.setSellingPriceIsSet(false);
|
- |
|
| 438 |
}
|
335 |
}
|
| - |
|
336 |
|
| 439 |
if(item.getWeight() != null) {
|
337 |
if(item.getWeight() != null) {
|
| 440 |
tItem.setWeight(item.getWeight());
|
338 |
tItem.setWeight(item.getWeight());
|
| 441 |
} else {
|
- |
|
| 442 |
tItem.setWeightIsSet(false);
|
- |
|
| 443 |
}
|
339 |
}
|
| - |
|
340 |
|
| 444 |
if(item.getMop() != null) {
|
341 |
if(item.getMop() != null) {
|
| 445 |
tItem.setMop(item.getMop());
|
342 |
tItem.setMop(item.getMop());
|
| 446 |
} else {
|
- |
|
| 447 |
tItem.setMopIsSet(false);
|
- |
|
| 448 |
}
|
343 |
}
|
| - |
|
344 |
|
| 449 |
if(item.getDealerPrice() != null) {
|
345 |
if(item.getDealerPrice() != null) {
|
| 450 |
tItem.setDealerPrice(item.getDealerPrice());
|
346 |
tItem.setDealerPrice(item.getDealerPrice());
|
| 451 |
} else {
|
- |
|
| 452 |
tItem.setTransferPriceIsSet(false);
|
- |
|
| 453 |
}
|
347 |
}
|
| - |
|
348 |
|
| 454 |
if(item.getTransferPrice() != null) {
|
349 |
if(item.getTransferPrice() != null) {
|
| 455 |
tItem.setTransferPrice(item.getTransferPrice());
|
350 |
tItem.setTransferPrice(item.getTransferPrice());
|
| 456 |
} else {
|
- |
|
| 457 |
tItem.setTransferPriceIsSet(false);
|
- |
|
| 458 |
}
|
351 |
}
|
| - |
|
352 |
|
| 459 |
tItem.setBestDealText(item.getBestDealsText());
|
353 |
tItem.setBestDealText(item.getBestDealsText());
|
| 460 |
if(item.getBestDealsValue() != null) {
|
354 |
if(item.getBestDealsValue() != null) {
|
| 461 |
tItem.setBestDealValue(item.getBestDealsValue());
|
355 |
tItem.setBestDealValue(item.getBestDealsValue());
|
| 462 |
} else {
|
- |
|
| 463 |
tItem.setBestDealValueIsSet(false);
|
- |
|
| 464 |
}
|
356 |
}
|
| - |
|
357 |
|
| 465 |
if(item.getBestSellingRank() != null) {
|
358 |
if(item.getBestSellingRank() != null) {
|
| 466 |
tItem.setBestSellingRank(item.getBestSellingRank());
|
359 |
tItem.setBestSellingRank(item.getBestSellingRank());
|
| 467 |
} else {
|
- |
|
| 468 |
tItem.setBestSellingRankIsSet(false);
|
- |
|
| 469 |
}
|
360 |
}
|
| - |
|
361 |
|
| 470 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
362 |
tItem.setDefaultForEntity(item.isDefaultForEntity());
|
| 471 |
tItem.setRisky(item.isRisky());
|
363 |
tItem.setRisky(item.isRisky());
|
| 472 |
|
364 |
|
| 473 |
if(item.getStartDate() != null) {
|
365 |
if(item.getStartDate() != null) {
|
| 474 |
tItem.setStartDate(item.getStartDate());
|
366 |
tItem.setStartDate(item.getStartDate());
|
| 475 |
} else {
|
- |
|
| 476 |
tItem.setStartDateIsSet(false);
|
- |
|
| 477 |
}
|
367 |
}
|
| - |
|
368 |
|
| 478 |
if(item.getRetireDate() != null) {
|
369 |
if(item.getRetireDate() != null) {
|
| 479 |
tItem.setRetireDate(item.getRetireDate());
|
370 |
tItem.setRetireDate(item.getRetireDate());
|
| 480 |
} else {
|
- |
|
| 481 |
tItem.setRetireDateIsSet(false);
|
- |
|
| 482 |
}
|
371 |
}
|
| - |
|
372 |
|
| 483 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
373 |
tItem.setUpdatedOn(Calendar.getInstance().getTimeInMillis());
|
| 484 |
|
374 |
|
| 485 |
tItem.setHotspotCategory(item.getVendorCategory());
|
375 |
tItem.setHotspotCategory(item.getVendorCategory());
|
| 486 |
}
|
376 |
}
|
| 487 |
|
377 |
|
| Line 491... |
Line 381... |
| 491 |
CatalogClient catalogServiceClient = new CatalogClient();
|
381 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 492 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
382 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 493 |
|
383 |
|
| 494 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
384 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PAUSED);
|
| 495 |
} catch (Exception e) {
|
385 |
} catch (Exception e) {
|
| 496 |
e.printStackTrace();
|
386 |
logger.error("Error while pausing the item: " + itemId, e);
|
| 497 |
}
|
387 |
}
|
| 498 |
|
388 |
|
| 499 |
}
|
389 |
}
|
| 500 |
|
390 |
|
| 501 |
@Override
|
391 |
@Override
|
| Line 504... |
Line 394... |
| 504 |
CatalogClient catalogServiceClient = new CatalogClient();
|
394 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 505 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
395 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 506 |
|
396 |
|
| 507 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
397 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.IN_PROCESS);
|
| 508 |
} catch (Exception e) {
|
398 |
} catch (Exception e) {
|
| 509 |
e.printStackTrace();
|
399 |
logger.error("Error while marking in-process the item: " + itemId, e);
|
| 510 |
}
|
400 |
}
|
| 511 |
}
|
401 |
}
|
| 512 |
|
402 |
|
| 513 |
@Override
|
403 |
@Override
|
| 514 |
public void phaseoutItem(long itemId) {
|
404 |
public void phaseoutItem(long itemId) {
|
| Line 516... |
Line 406... |
| 516 |
CatalogClient catalogServiceClient = new CatalogClient();
|
406 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 517 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
407 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 518 |
|
408 |
|
| 519 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
409 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.PHASED_OUT);
|
| 520 |
} catch (Exception e) {
|
410 |
} catch (Exception e) {
|
| 521 |
e.printStackTrace();
|
411 |
logger.error("Error while phasing out the item: " + itemId, e);
|
| 522 |
}
|
412 |
}
|
| 523 |
}
|
413 |
}
|
| 524 |
|
414 |
|
| 525 |
@Override
|
415 |
@Override
|
| 526 |
public void activateItem(long itemId) {
|
416 |
public void activateItem(long itemId) {
|
| Line 528... |
Line 418... |
| 528 |
CatalogClient catalogServiceClient = new CatalogClient();
|
418 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 529 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
419 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 530 |
|
420 |
|
| 531 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
421 |
catalogClient.changeItemStatus(itemId, Calendar.getInstance().getTimeInMillis(), status.ACTIVE);
|
| 532 |
} catch (Exception e) {
|
422 |
} catch (Exception e) {
|
| 533 |
e.printStackTrace();
|
423 |
logger.error("Error while activating the item: " + itemId, e);
|
| 534 |
}
|
424 |
}
|
| 535 |
}
|
425 |
}
|
| 536 |
|
426 |
|
| 537 |
@Override
|
427 |
@Override
|
| 538 |
public boolean changeItemRiskyFlag(long itemId, boolean risky) {
|
428 |
public boolean changeItemRiskyFlag(long itemId, boolean risky) {
|
| Line 548... |
Line 438... |
| 548 |
catalogClient.changeItemRiskyFlag(itemId, risky);
|
438 |
catalogClient.changeItemRiskyFlag(itemId, risky);
|
| 549 |
|
439 |
|
| 550 |
try{
|
440 |
try{
|
| 551 |
catalogClient_Prod.changeItemRiskyFlag(itemId, risky);
|
441 |
catalogClient_Prod.changeItemRiskyFlag(itemId, risky);
|
| 552 |
}catch(Exception e){
|
442 |
}catch(Exception e){
|
| 553 |
e.printStackTrace();
|
443 |
logger.error("Error while updating item's risky flag on production", e);
|
| 554 |
// If not able to change risky flag on production, revert on staging and return false (to show error to user).
|
444 |
// If not able to change risky flag on production, revert on staging and return false (to show error to user).
|
| 555 |
catalogClient.changeItemRiskyFlag(itemId, !risky);
|
445 |
catalogClient.changeItemRiskyFlag(itemId, !risky);
|
| 556 |
return false;
|
446 |
return false;
|
| 557 |
}
|
447 |
}
|
| 558 |
} catch (Exception e) {
|
448 |
} catch (Exception e) {
|
| 559 |
e.printStackTrace();
|
449 |
logger.error("Error while updating item's risky flag on staging", e);
|
| 560 |
return false;
|
450 |
return false;
|
| 561 |
}
|
451 |
}
|
| 562 |
return true;
|
452 |
return true;
|
| 563 |
}
|
453 |
}
|
| 564 |
|
454 |
|
| Line 567... |
Line 457... |
| 567 |
* Retuns list of Items filtered by Vendor category (column is hotspotCategory in catalog.item table)
|
457 |
* Retuns list of Items filtered by Vendor category (column is hotspotCategory in catalog.item table)
|
| 568 |
* This list is used to generate master sheet (excel sheet)
|
458 |
* This list is used to generate master sheet (excel sheet)
|
| 569 |
* @param category
|
459 |
* @param category
|
| 570 |
* @return
|
460 |
* @return
|
| 571 |
*/
|
461 |
*/
|
| 572 |
List<Item> getItemsByVendorCategory(String category) {
|
462 |
public List<Item> getItemsByVendorCategory(String category) {
|
| 573 |
List<Item> itemList = new ArrayList<Item>();
|
463 |
List<Item> itemList = new ArrayList<Item>();
|
| 574 |
try {
|
464 |
try {
|
| 575 |
CatalogClient catalogServiceClient = new CatalogClient();
|
465 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| 576 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
466 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| 577 |
|
467 |
|
| Line 581... |
Line 471... |
| 581 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
471 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> vip = catalogClient.getAllItemPricing(thriftItem.getId());
|
| 582 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
472 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> vim = catalogClient.getVendorItemMappings(thriftItem.getId());
|
| 583 |
itemList.add(getItemFromThriftItem(thriftItem, vip, vim));
|
473 |
itemList.add(getItemFromThriftItem(thriftItem, vip, vim));
|
| 584 |
}
|
474 |
}
|
| 585 |
} catch (Exception e) {
|
475 |
} catch (Exception e) {
|
| 586 |
e.printStackTrace();
|
- |
|
| 587 |
}
|
- |
|
| 588 |
Collections.sort(itemList, new ItemsComparator());
|
- |
|
| 589 |
return itemList;
|
- |
|
| 590 |
}
|
- |
|
| 591 |
|
- |
|
| 592 |
/**
|
- |
|
| 593 |
* Returns list of items with a particular status.
|
- |
|
| 594 |
* @param st
|
- |
|
| 595 |
* @return
|
- |
|
| 596 |
*/
|
- |
|
| 597 |
List<Item> getItemsByStatus(status st) {
|
- |
|
| 598 |
List<Item> itemList = new ArrayList<Item>();
|
- |
|
| 599 |
try {
|
- |
|
| 600 |
CatalogClient catalogServiceClient = new CatalogClient();
|
- |
|
| 601 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
476 |
logger.error("Error while getting items by vendor category: " + category, e);
|
| 602 |
|
- |
|
| 603 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(st);
|
- |
|
| 604 |
|
- |
|
| 605 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
- |
|
| 606 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
- |
|
| 607 |
}
|
- |
|
| 608 |
} catch (Exception e) {
|
- |
|
| 609 |
e.printStackTrace();
|
- |
|
| 610 |
}
|
477 |
}
|
| 611 |
Collections.sort(itemList, new ItemsComparator());
|
478 |
Collections.sort(itemList, new ItemsComparator());
|
| 612 |
return itemList;
|
479 |
return itemList;
|
| 613 |
}
|
480 |
}
|
| 614 |
|
481 |
|
| 615 |
@Override
|
482 |
@Override
|
| 616 |
public String updateItemOnProduction(Item item) {
|
483 |
public String updateItemOnProduction(Item item) {
|
| 617 |
GWT.log("Update item on production call, Item Id: " + item.getId());
|
484 |
logger.info("Update item on production call, Item Id: " + item.getId());
|
| 618 |
|
485 |
|
| 619 |
String errMsg = checkPushToProdCount();
|
486 |
String errMsg = checkPushToProdCount();
|
| 620 |
// If errMsg is not null, then return that message to user
|
487 |
// If errMsg is not null, then return that message to user
|
| 621 |
// else move forward with update.
|
488 |
// else move forward with update.
|
| 622 |
if(errMsg != null) {
|
489 |
if(errMsg != null) {
|
| Line 635... |
Line 502... |
| 635 |
|
502 |
|
| 636 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
|
503 |
in.shop2020.model.v1.catalog.Item tItem = catalogClient_Prod.getItem(item.getId());
|
| 637 |
|
504 |
|
| 638 |
if(item.getMrp() != null) {
|
505 |
if(item.getMrp() != null) {
|
| 639 |
tItem.setMrp(item.getMrp());
|
506 |
tItem.setMrp(item.getMrp());
|
| 640 |
} else {
|
- |
|
| 641 |
tItem.setMrpIsSet(false);
|
- |
|
| 642 |
}
|
507 |
}
|
| - |
|
508 |
|
| 643 |
if(item.getSellingPrice() != null) {
|
509 |
if(item.getSellingPrice() != null) {
|
| 644 |
tItem.setSellingPrice(item.getSellingPrice());
|
510 |
tItem.setSellingPrice(item.getSellingPrice());
|
| 645 |
} else {
|
- |
|
| 646 |
tItem.setSellingPriceIsSet(false);
|
- |
|
| 647 |
}
|
511 |
}
|
| - |
|
512 |
|
| 648 |
if(item.getMop() != null) {
|
513 |
if(item.getMop() != null) {
|
| 649 |
tItem.setMop(item.getMop());
|
514 |
tItem.setMop(item.getMop());
|
| 650 |
} else {
|
- |
|
| 651 |
tItem.setMopIsSet(false);
|
- |
|
| 652 |
}
|
515 |
}
|
| - |
|
516 |
|
| 653 |
if(item.getDealerPrice() != null) {
|
517 |
if(item.getDealerPrice() != null) {
|
| 654 |
tItem.setDealerPrice(item.getDealerPrice());
|
518 |
tItem.setDealerPrice(item.getDealerPrice());
|
| 655 |
} else {
|
- |
|
| 656 |
tItem.setDealerPriceIsSet(false);
|
- |
|
| 657 |
}
|
519 |
}
|
| - |
|
520 |
|
| 658 |
if(item.getTransferPrice() != null) {
|
521 |
if(item.getTransferPrice() != null) {
|
| 659 |
tItem.setTransferPrice(item.getTransferPrice());
|
522 |
tItem.setTransferPrice(item.getTransferPrice());
|
| 660 |
} else {
|
- |
|
| 661 |
tItem.setTransferPriceIsSet(false);
|
- |
|
| 662 |
}
|
523 |
}
|
| - |
|
524 |
|
| 663 |
long rItemId;
|
525 |
long rItemId;
|
| 664 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != item.getId()) {
|
526 |
if((rItemId = catalogClient_Prod.updateItem(tItem)) != item.getId()) {
|
| 665 |
GWT.log("Error updating item, returned Item Id: " + rItemId);
|
527 |
logger.error("Error updating item on production, returned Item Id: " + rItemId);
|
| 666 |
return "Error updating item prices on production";
|
528 |
return "Error updating item prices on production";
|
| 667 |
}
|
529 |
}
|
| 668 |
GWT.log("Item updated successfully, Item Id: " + item.getId());
|
530 |
logger.info("Successfully updated item: " + item.getId());
|
| 669 |
|
531 |
|
| 670 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
532 |
Map<Long, VendorPricings> vendorPricings = item.getVendorPricesMap();
|
| 671 |
StringBuilder sb = new StringBuilder();
|
533 |
StringBuilder sb = new StringBuilder();
|
| 672 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
534 |
if(vendorPricings != null && !vendorPricings.isEmpty()) {
|
| 673 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
535 |
in.shop2020.model.v1.catalog.VendorItemPricing tVendorPricing;
|
| Line 677... |
Line 539... |
| 677 |
tVendorPricing.setItemId(item.getId());
|
539 |
tVendorPricing.setItemId(item.getId());
|
| 678 |
tVendorPricing.setMop(v.getMop());
|
540 |
tVendorPricing.setMop(v.getMop());
|
| 679 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
541 |
tVendorPricing.setTransferPrice(v.getTransferPrice());
|
| 680 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
542 |
tVendorPricing.setDealerPrice(v.getDealerPrice());
|
| 681 |
catalogClient_Prod.addVendorItemPricing(tVendorPricing);
|
543 |
catalogClient_Prod.addVendorItemPricing(tVendorPricing);
|
| 682 |
GWT.log("VendorItemPricing updated. " + tVendorPricing.getVendorId() + ", " + tVendorPricing.getItemId() + ", " +
|
544 |
logger.info("VendorItemPricing updated. " + tVendorPricing.toString());
|
| 683 |
tVendorPricing.getMop() + ", " + tVendorPricing.getTransferPrice() + ", " + tVendorPricing.getDealerPrice());
|
- |
|
| 684 |
sb.append("[VId:" + v.getVendorId() + ",MOP=" + v.getMop() + ",TP=" + v.getTransferPrice() + ",DP=" + v.getDealerPrice() + "], ");
|
545 |
sb.append("[VId:" + v.getVendorId() + ",MOP=" + v.getMop() + ",TP=" + v.getTransferPrice() + ",DP=" + v.getDealerPrice() + "], ");
|
| 685 |
}
|
546 |
}
|
| 686 |
}
|
547 |
}
|
| 687 |
logItemDetails("Id=" + item.getId() + ",MRP=" + item.getMrp() + ",SP=" + " " + item.getSellingPrice() + sb.toString());
|
548 |
logItemDetails("Id=" + item.getId() + ",MRP=" + item.getMrp() + ",SP=" + " " + item.getSellingPrice() + sb.toString());
|
| 688 |
} catch (Exception e) {
|
549 |
} catch (Exception e) {
|
| 689 |
e.printStackTrace();
|
550 |
logger.error("Error while updating prices on production", e);
|
| 690 |
return "Error while updating all prices on production. Some of the prices may have been updated";
|
551 |
return "Error while updating all prices on production. Some of the prices may have been updated";
|
| 691 |
}
|
552 |
}
|
| 692 |
|
553 |
|
| 693 |
/*
|
554 |
/*
|
| 694 |
// Push the content of one item to production
|
555 |
// Push the content of one item to production
|
| Line 704... |
Line 565... |
| 704 |
} catch (InterruptedException e) {
|
565 |
} catch (InterruptedException e) {
|
| 705 |
GWT.log("Not able to update content on production");
|
566 |
GWT.log("Not able to update content on production");
|
| 706 |
e.printStackTrace();
|
567 |
e.printStackTrace();
|
| 707 |
return "Error generating content. Prices updated successfully.";
|
568 |
return "Error generating content. Prices updated successfully.";
|
| 708 |
} catch (ConfigException e) {
|
569 |
} catch (ConfigException e) {
|
| 709 |
// TODO Auto-generated catch block
|
- |
|
| 710 |
e.printStackTrace();
|
570 |
e.printStackTrace();
|
| 711 |
return "Error getting content script path";
|
571 |
return "Error getting content script path";
|
| 712 |
}*/
|
572 |
}*/
|
| 713 |
return "Prices updated and content generated successfully";
|
573 |
return "Prices updated and content generated successfully";
|
| 714 |
}
|
574 |
}
|
| 715 |
|
575 |
|
| 716 |
/**
|
576 |
/**
|
| - |
|
577 |
* Returns list of items with a particular status.
|
| - |
|
578 |
* @param st
|
| - |
|
579 |
* @return
|
| - |
|
580 |
*/
|
| - |
|
581 |
private List<Item> getItemsByStatus(status st) {
|
| - |
|
582 |
List<Item> itemList = new ArrayList<Item>();
|
| - |
|
583 |
try {
|
| - |
|
584 |
CatalogClient catalogServiceClient = new CatalogClient();
|
| - |
|
585 |
InventoryService.Client catalogClient = catalogServiceClient.getClient();
|
| - |
|
586 |
|
| - |
|
587 |
List<in.shop2020.model.v1.catalog.Item> thriftItems = catalogClient.getAllItemsByStatus(st);
|
| - |
|
588 |
|
| - |
|
589 |
for(in.shop2020.model.v1.catalog.Item thriftItem : thriftItems) {
|
| - |
|
590 |
itemList.add(getItemFromThriftItem(thriftItem, null, null));
|
| - |
|
591 |
}
|
| - |
|
592 |
} catch (Exception e) {
|
| - |
|
593 |
logger.error("Error while getting items by status: " + st, e);
|
| - |
|
594 |
}
|
| - |
|
595 |
Collections.sort(itemList, new ItemsComparator());
|
| - |
|
596 |
return itemList;
|
| - |
|
597 |
}
|
| - |
|
598 |
|
| - |
|
599 |
/**
|
| - |
|
600 |
* Creates a new Item object and populates its attributes from thrift item passed as parameter.
|
| - |
|
601 |
* Also creates a Map each for VendorItemPricing and VendorItemMapping and adds these maps to the
|
| - |
|
602 |
* new Item object.
|
| - |
|
603 |
* @param thriftItem
|
| - |
|
604 |
* @param tVendorPricings
|
| - |
|
605 |
* @param tVendorMappings
|
| - |
|
606 |
* @return item object with attributes copied from thrift item object.
|
| - |
|
607 |
*/
|
| - |
|
608 |
private Item getItemFromThriftItem(in.shop2020.model.v1.catalog.Item thriftItem,
|
| - |
|
609 |
List<in.shop2020.model.v1.catalog.VendorItemPricing> tVendorPricings,
|
| - |
|
610 |
List<in.shop2020.model.v1.catalog.VendorItemMapping> tVendorMappings){
|
| - |
|
611 |
|
| - |
|
612 |
Map<String, VendorItemMapping> vItemMap = new HashMap<String, VendorItemMapping>();
|
| - |
|
613 |
VendorItemMapping vItemMapping;
|
| - |
|
614 |
if(tVendorMappings != null) {
|
| - |
|
615 |
for(in.shop2020.model.v1.catalog.VendorItemMapping vim : tVendorMappings) {
|
| - |
|
616 |
vItemMapping = new VendorItemMapping();
|
| - |
|
617 |
vItemMapping.setVendorId(vim.getVendorId());
|
| - |
|
618 |
vItemMapping.setItemKey(vim.getItemKey());
|
| - |
|
619 |
vItemMap.put(vItemMapping.getVendorId() + Item.KEY_SEPARATOR + vim.getItemKey(), vItemMapping);
|
| - |
|
620 |
}
|
| - |
|
621 |
}
|
| - |
|
622 |
|
| - |
|
623 |
Map<Long, VendorPricings> vendorPricingMap = new HashMap<Long, VendorPricings>();
|
| - |
|
624 |
VendorPricings vPricings;
|
| - |
|
625 |
if(tVendorPricings != null) {
|
| - |
|
626 |
for(in.shop2020.model.v1.catalog.VendorItemPricing vip : tVendorPricings) {
|
| - |
|
627 |
vPricings = new VendorPricings();
|
| - |
|
628 |
vPricings.setVendorId(vip.getVendorId());
|
| - |
|
629 |
vPricings.setMop(vip.getMop());
|
| - |
|
630 |
vPricings.setDealerPrice(vip.getDealerPrice());
|
| - |
|
631 |
vPricings.setTransferPrice(vip.getTransferPrice());
|
| - |
|
632 |
vendorPricingMap.put(vPricings.getVendorId(), vPricings);
|
| - |
|
633 |
}
|
| - |
|
634 |
}
|
| - |
|
635 |
|
| - |
|
636 |
Item item = new Item(thriftItem.getId(),
|
| - |
|
637 |
thriftItem.getHotspotCategory(),
|
| - |
|
638 |
thriftItem.getProductGroup(),
|
| - |
|
639 |
thriftItem.getBrand(),
|
| - |
|
640 |
thriftItem.getModelNumber(),
|
| - |
|
641 |
thriftItem.getModelName(),
|
| - |
|
642 |
thriftItem.getColor(),
|
| - |
|
643 |
CategoryManager.getCategoryManager().getCategoryLabel(thriftItem.getCategory()),
|
| - |
|
644 |
thriftItem.getCategory(),
|
| - |
|
645 |
thriftItem.getComments(),
|
| - |
|
646 |
thriftItem.getCatalogItemId(),
|
| - |
|
647 |
thriftItem.getFeatureId(),
|
| - |
|
648 |
thriftItem.getFeatureDescription(),
|
| - |
|
649 |
thriftItem.isSetMrp() ? thriftItem.getMrp() : null,
|
| - |
|
650 |
thriftItem.getMop(),
|
| - |
|
651 |
thriftItem.isSetSellingPrice() ? thriftItem.getSellingPrice() : null,
|
| - |
|
652 |
thriftItem.getDealerPrice(),
|
| - |
|
653 |
thriftItem.isSetWeight() ? thriftItem.getWeight() : null,
|
| - |
|
654 |
thriftItem.getAddedOn(),
|
| - |
|
655 |
thriftItem.getStartDate(),
|
| - |
|
656 |
thriftItem.getRetireDate(),
|
| - |
|
657 |
thriftItem.getUpdatedOn(),
|
| - |
|
658 |
thriftItem.getItemStatus().name(),
|
| - |
|
659 |
thriftItem.getItemStatus().getValue(),
|
| - |
|
660 |
thriftItem.getStatus_description(),
|
| - |
|
661 |
thriftItem.getOtherInfo(),
|
| - |
|
662 |
thriftItem.getBestDealText(),
|
| - |
|
663 |
thriftItem.isSetBestDealValue() ? thriftItem.getBestDealValue() : null,
|
| - |
|
664 |
thriftItem.isSetBestSellingRank() ? thriftItem.getBestSellingRank() : null,
|
| - |
|
665 |
thriftItem.isDefaultForEntity(),
|
| - |
|
666 |
thriftItem.isRisky(),
|
| - |
|
667 |
(thriftItem.getItemInventory() != null ? thriftItem.getItemInventory().getAvailability() : null),
|
| - |
|
668 |
vendorPricingMap,
|
| - |
|
669 |
vItemMap);
|
| - |
|
670 |
return item;
|
| - |
|
671 |
}
|
| - |
|
672 |
|
| - |
|
673 |
/**
|
| 717 |
*
|
674 |
*
|
| 718 |
* @return null if push to production count is less than maximum allowed.
|
675 |
* @return null if push to production count is less than maximum allowed.
|
| 719 |
* <br>otherwise error message to be passed to the client side for showing to the user
|
676 |
* <br>otherwise error message to be passed to the client side for showing to the user
|
| 720 |
*/
|
677 |
*/
|
| 721 |
private String checkPushToProdCount() {
|
678 |
private String checkPushToProdCount() {
|
| 722 |
int count = 0, maxCount;
|
679 |
int count = 0, maxCount;
|
| 723 |
try {
|
680 |
try {
|
| 724 |
String logfile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
|
681 |
//String logFile = ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_log_file.toString());
|
| 725 |
maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
|
682 |
maxCount = Integer.parseInt(ConfigClient.getClient().get(ConfigClientKeys.push_prices_to_prod_max_count.toString()));
|
| 726 |
count = getPushToProdCount(logfile);
|
683 |
//count = getPushToProdCount(logFile);
|
| 727 |
if(count >= maxCount) {
|
684 |
if(count >= maxCount) {
|
| 728 |
return "Maximum push to production count reached for today";
|
685 |
return "Maximum push to production count reached for today";
|
| 729 |
}
|
686 |
}
|
| 730 |
} catch (ConfigException e1) {
|
687 |
} catch (ConfigException e) {
|
| 731 |
e1.printStackTrace();
|
688 |
logger.error("Error while getting the max count from the config server", e);
|
| 732 |
return "Error getting push to production parameters";
|
689 |
return "Error getting push to production parameters";
|
| 733 |
}
|
690 |
}
|
| 734 |
return null;
|
691 |
return null;
|
| 735 |
}
|
692 |
}
|
| 736 |
|
693 |
|
| 737 |
/**
|
694 |
/**
|
| 738 |
* Log push to production details
|
695 |
* Log push to production details
|
| 739 |
* @param str
|
696 |
* @param str
|
| 740 |
*/
|
697 |
*/
|
| 741 |
private void logItemDetails(String str) {
|
698 |
private void logItemDetails(String str) {
|
| 742 |
Logger log = Logger.getLogger(CatalogServiceImpl.class);
|
- |
|
| 743 |
log.info(str);
|
699 |
logger.info(str);
|
| 744 |
}
|
700 |
}
|
| 745 |
|
701 |
|
| 746 |
/**
|
702 |
/**
|
| 747 |
* If this is the first attempt to push to production for current date, returns 0
|
703 |
* If this is the first attempt to push to production for current date, returns 0
|
| 748 |
* else reads number of lines from daily rolling log file to get the count.
|
704 |
* else reads number of lines from daily rolling log file to get the count.
|
| Line 762... |
Line 718... |
| 762 |
BufferedReader br = new BufferedReader(new FileReader(logfile));
|
718 |
BufferedReader br = new BufferedReader(new FileReader(logfile));
|
| 763 |
while (br.readLine() != null) {
|
719 |
while (br.readLine() != null) {
|
| 764 |
lineCount++;
|
720 |
lineCount++;
|
| 765 |
}
|
721 |
}
|
| 766 |
} catch (IOException e) {
|
722 |
} catch (IOException e) {
|
| 767 |
e.printStackTrace();
|
723 |
logger.error("Error while reading the log file", e);
|
| 768 |
}
|
724 |
}
|
| 769 |
return lineCount;
|
725 |
return lineCount;
|
| 770 |
}
|
726 |
}
|
| 771 |
}
|
727 |
}
|
| 772 |
|
728 |
|