| Line 1... |
Line 1... |
| 1 |
package in.shop2020.util;
|
1 |
package in.shop2020.util;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.logistics.DeliveryType;
|
| - |
|
4 |
import in.shop2020.logistics.LogisticsInfo;
|
| - |
|
5 |
import in.shop2020.logistics.LogisticsService;
|
| 3 |
import in.shop2020.metamodel.core.Entity;
|
6 |
import in.shop2020.metamodel.core.Entity;
|
| 4 |
import in.shop2020.metamodel.definitions.Catalog;
|
7 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 5 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
8 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 6 |
import in.shop2020.metamodel.util.CreationUtils;
|
9 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 7 |
import in.shop2020.model.v1.catalog.Item;
|
10 |
import in.shop2020.model.v1.catalog.Item;
|
| 8 |
import in.shop2020.model.v1.catalog.status;
|
11 |
import in.shop2020.model.v1.catalog.status;
|
| 9 |
import in.shop2020.model.v1.user.ItemCouponDiscount;
|
12 |
import in.shop2020.model.v1.user.ItemCouponDiscount;
|
| 10 |
import in.shop2020.thrift.clients.CatalogClient;
|
13 |
import in.shop2020.thrift.clients.CatalogClient;
|
| - |
|
14 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 11 |
import in.shop2020.thrift.clients.PromotionClient;
|
15 |
import in.shop2020.thrift.clients.PromotionClient;
|
| 12 |
|
16 |
|
| 13 |
import java.io.File;
|
17 |
import java.io.File;
|
| 14 |
import java.util.ArrayList;
|
18 |
import java.util.ArrayList;
|
| 15 |
import java.util.Date;
|
19 |
import java.util.Date;
|
| Line 30... |
Line 34... |
| 30 |
*/
|
34 |
*/
|
| 31 |
public class ProductListGenerator {
|
35 |
public class ProductListGenerator {
|
| 32 |
|
36 |
|
| 33 |
private String[] xmlIndentation = {"", " ", " ", " "," "};
|
37 |
private String[] xmlIndentation = {"", " ", " ", " "," "};
|
| 34 |
public Map<Long, List<Item>> entityIdItemMap;
|
38 |
public Map<Long, List<Item>> entityIdItemMap;
|
| - |
|
39 |
private static final String DEFAULT_PINCODE = "110001";
|
| 35 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
40 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
| 36 |
|
41 |
|
| 37 |
public ProductListGenerator(Map<Long, List<Item>> entityIdItemMap) throws Exception {
|
42 |
public ProductListGenerator(Map<Long, List<Item>> entityIdItemMap) throws Exception {
|
| 38 |
this.entityIdItemMap = entityIdItemMap;
|
43 |
this.entityIdItemMap = entityIdItemMap;
|
| 39 |
}
|
44 |
}
|
| Line 128... |
Line 133... |
| 128 |
* get xml feed for partner sites
|
133 |
* get xml feed for partner sites
|
| 129 |
* @param irDataXMLSnippets
|
134 |
* @param irDataXMLSnippets
|
| 130 |
* @throws Exception
|
135 |
* @throws Exception
|
| 131 |
*/
|
136 |
*/
|
| 132 |
private void getProductsXML(ArrayList<String> irDataXMLSnippets) throws Exception{
|
137 |
private void getProductsXML(ArrayList<String> irDataXMLSnippets) throws Exception{
|
| - |
|
138 |
LogisticsService.Client prod_client = null;
|
| - |
|
139 |
try {
|
| - |
|
140 |
LogisticsClient logistics_prod = new LogisticsClient("logistics_service_prod_server_host","logistics_service_prod_server_port");
|
| - |
|
141 |
prod_client = logistics_prod.getClient();
|
| - |
|
142 |
} catch (Exception e) {
|
| - |
|
143 |
prod_client = null;
|
| - |
|
144 |
Utils.info("Logistics estimations can't be fetched as Logistics Service is inaccessible"
|
| - |
|
145 |
+ e);
|
| - |
|
146 |
}
|
| 133 |
for(Long entityId: entityIdItemMap.keySet()){
|
147 |
for(Long entityId: entityIdItemMap.keySet()){
|
| 134 |
List<Item> items = entityIdItemMap.get(entityId);
|
148 |
List<Item> items = entityIdItemMap.get(entityId);
|
| 135 |
Item firstItem = items.get(0);
|
149 |
Item firstItem = items.get(0);
|
| 136 |
if(!isMobile(firstItem)){
|
150 |
if(!isMobile(firstItem)){
|
| 137 |
continue;
|
151 |
continue;
|
| Line 154... |
Line 168... |
| 154 |
|
168 |
|
| 155 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
|
169 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductPrice>" + getMinPrice(items) + "</ProductPrice>");
|
| 156 |
|
170 |
|
| 157 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
|
171 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductMRP>" + getMinMRP(items) + "</ProductMRP>");
|
| 158 |
|
172 |
|
| - |
|
173 |
LogisticsInfo logisticsInfo = null;
|
| - |
|
174 |
if(prod_client != null){
|
| - |
|
175 |
try {
|
| - |
|
176 |
Long itemId = prod_client.getEntityLogisticsEstimation(
|
| - |
|
177 |
entityId, DEFAULT_PINCODE, DeliveryType.PREPAID)
|
| - |
|
178 |
.get(0);
|
| - |
|
179 |
logisticsInfo = prod_client.getLogisticsEstimation(itemId,
|
| - |
|
180 |
DEFAULT_PINCODE, DeliveryType.PREPAID);
|
| - |
|
181 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductDeliveryEstimate>" + logisticsInfo.getDeliveryTime() + "</ProductDeliveryEstimate>");
|
| - |
|
182 |
} catch (Exception e1) {
|
| - |
|
183 |
Utils.info("Unable to get Estimation for Entity: " + entityId + "\n" + e1);
|
| - |
|
184 |
}
|
| - |
|
185 |
}
|
| 159 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
|
186 |
irDataXMLSnippets.add(this.xmlIndentation[2] + "<ProductImageURL>" + imageUrl + "</ProductImageURL>");
|
| 160 |
|
187 |
|
| 161 |
irDataXMLSnippets.add(this.xmlIndentation[1] + "</products>");
|
188 |
irDataXMLSnippets.add(this.xmlIndentation[1] + "</products>");
|
| 162 |
}
|
189 |
}
|
| 163 |
}
|
190 |
}
|
| Line 240... |
Line 267... |
| 240 |
items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
|
267 |
items.addAll(cl.getClient().getAllItemsByStatus(status.PAUSED_BY_RISK));
|
| 241 |
|
268 |
|
| 242 |
Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
|
269 |
Map<Long, List<Item>> entityIdItemMap1 = new HashMap<Long, List<Item>>();
|
| 243 |
ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
|
270 |
ProductListGenerator pl = new ProductListGenerator(entityIdItemMap1);
|
| 244 |
pl.populateEntityIdItemMap(items);
|
271 |
pl.populateEntityIdItemMap(items);
|
| - |
|
272 |
pl.generateProductsListXML();
|
| 245 |
pl.generateProductXMLForDisplayAds();
|
273 |
//pl.generateProductXMLForDisplayAds();
|
| 246 |
}
|
274 |
}
|
| 247 |
|
275 |
|
| 248 |
private void populateEntityIdItemMap(List<Item> items){
|
276 |
private void populateEntityIdItemMap(List<Item> items){
|
| 249 |
Date toDate = new Date();
|
277 |
Date toDate = new Date();
|
| 250 |
for(Item item: items){
|
278 |
for(Item item: items){
|