| Line 5... |
Line 5... |
| 5 |
import in.shop2020.metamodel.core.EntityStatus;
|
5 |
import in.shop2020.metamodel.core.EntityStatus;
|
| 6 |
import in.shop2020.metamodel.util.CreationUtils;
|
6 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 7 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
7 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 8 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
8 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 9 |
import in.shop2020.model.v1.catalog.Item;
|
9 |
import in.shop2020.model.v1.catalog.Item;
|
| 10 |
import in.shop2020.model.v1.catalog.ItemShippingInfo;
|
- |
|
| 11 |
import in.shop2020.model.v1.catalog.Source;
|
10 |
import in.shop2020.model.v1.catalog.Source;
|
| 12 |
import in.shop2020.model.v1.catalog.status;
|
11 |
import in.shop2020.model.v1.catalog.status;
|
| 13 |
import in.shop2020.thrift.clients.CatalogClient;
|
12 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 14 |
import in.shop2020.ui.util.CatalogUploderToGAE;
|
- |
|
| 15 |
import in.shop2020.ui.util.ComparisonStatsFetcher;
|
13 |
import in.shop2020.ui.util.ComparisonStatsFetcher;
|
| 16 |
import in.shop2020.ui.util.NewVUI;
|
14 |
import in.shop2020.ui.util.NewVUI;
|
| 17 |
import in.shop2020.ui.util.PriceInsertor;
|
15 |
import in.shop2020.ui.util.PriceInsertor;
|
| 18 |
import in.shop2020.ui.util.SpecialPageJSONConvertor;
|
16 |
import in.shop2020.ui.util.SpecialPageJSONConvertor;
|
| 19 |
import in.shop2020.utils.ConfigClientKeys;
|
17 |
import in.shop2020.utils.ConfigClientKeys;
|
| Line 27... |
Line 25... |
| 27 |
import java.text.SimpleDateFormat;
|
25 |
import java.text.SimpleDateFormat;
|
| 28 |
import java.util.ArrayList;
|
26 |
import java.util.ArrayList;
|
| 29 |
import java.util.Calendar;
|
27 |
import java.util.Calendar;
|
| 30 |
import java.util.Date;
|
28 |
import java.util.Date;
|
| 31 |
import java.util.HashMap;
|
29 |
import java.util.HashMap;
|
| 32 |
import java.util.HashSet;
|
- |
|
| 33 |
import java.util.Iterator;
|
30 |
import java.util.Iterator;
|
| 34 |
import java.util.LinkedHashMap;
|
31 |
import java.util.LinkedHashMap;
|
| 35 |
import java.util.List;
|
32 |
import java.util.List;
|
| 36 |
import java.util.Map;
|
33 |
import java.util.Map;
|
| 37 |
|
34 |
|
| Line 44... |
Line 41... |
| 44 |
import org.apache.commons.cli.ParseException;
|
41 |
import org.apache.commons.cli.ParseException;
|
| 45 |
import org.apache.commons.cli.PosixParser;
|
42 |
import org.apache.commons.cli.PosixParser;
|
| 46 |
import org.apache.commons.lang.StringUtils;
|
43 |
import org.apache.commons.lang.StringUtils;
|
| 47 |
import org.apache.commons.logging.Log;
|
44 |
import org.apache.commons.logging.Log;
|
| 48 |
import org.apache.commons.logging.LogFactory;
|
45 |
import org.apache.commons.logging.LogFactory;
|
| 49 |
import org.apache.thrift.transport.TTransportException;
|
- |
|
| 50 |
|
46 |
|
| 51 |
import com.google.gson.Gson;
|
47 |
import com.google.gson.Gson;
|
| 52 |
import com.google.gson.reflect.TypeToken;
|
48 |
import com.google.gson.reflect.TypeToken;
|
| 53 |
|
49 |
|
| 54 |
public class ContentGenerationUtility {
|
50 |
public class ContentGenerationUtility {
|
| Line 78... |
Line 74... |
| 78 |
private static String [] DOMAINPATHS = Utils.DOMAIN_NAMES_FOR_CONTENT_GENERATION.split(";");
|
74 |
private static String [] DOMAINPATHS = Utils.DOMAIN_NAMES_FOR_CONTENT_GENERATION.split(";");
|
| 79 |
|
75 |
|
| 80 |
private Date timeStamp = null;
|
76 |
private Date timeStamp = null;
|
| 81 |
private CommandLine cmd = null;
|
77 |
private CommandLine cmd = null;
|
| 82 |
private Map<Long, List<Item>> entityIdItemMap = new LinkedHashMap<Long, List<Item>>();
|
78 |
private Map<Long, List<Item>> entityIdItemMap = new LinkedHashMap<Long, List<Item>>();
|
| 83 |
private List<Long> allValidEntityIds = null;
|
- |
|
| 84 |
private Long lastGenerationTime = 0l;
|
79 |
private Long lastGenerationTime = 0l;
|
| 85 |
private Map<Long, Entity> entities;
|
80 |
private Map<Long, Entity> entities;
|
| 86 |
private List<Item> items;
|
81 |
private List<Item> items;
|
| 87 |
private List<Source> sources;
|
82 |
private List<Source> sources;
|
| 88 |
private CatalogClient csc;
|
83 |
private CatalogClient csc;
|
| Line 258... |
Line 253... |
| 258 |
*
|
253 |
*
|
| 259 |
* @throws Exception
|
254 |
* @throws Exception
|
| 260 |
*/
|
255 |
*/
|
| 261 |
private void updatePrices() throws Exception {
|
256 |
private void updatePrices() throws Exception {
|
| 262 |
lastGenerationTime = new Long(0);
|
257 |
lastGenerationTime = new Long(0);
|
| - |
|
258 |
List<Long> activeItems = new ArrayList<Long>();
|
| 263 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
259 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
| 264 |
items = client.getItemsByCatalogId(Long.parseLong(ENTITY_ID));
|
260 |
items = client.getItemsByCatalogId(Long.parseLong(ENTITY_ID));
|
| 265 |
Iterator<Item> it = items.iterator();
|
261 |
Iterator<Item> it = items.iterator();
|
| 266 |
while(it.hasNext()){
|
262 |
while(it.hasNext()){
|
| - |
|
263 |
Item ite = it.next();
|
| 267 |
status st = it.next().getItemStatus();
|
264 |
status st = ite.getItemStatus();
|
| 268 |
if(!(st.equals(status.ACTIVE) || st.equals(status.PAUSED) ||
|
265 |
if(!(st.equals(status.ACTIVE) || st.equals(status.PAUSED) ||
|
| 269 |
st.equals(status.COMING_SOON) || st.equals(status.PHASED_OUT))){
|
266 |
st.equals(status.COMING_SOON))){
|
| 270 |
it.remove();
|
267 |
it.remove();
|
| 271 |
}
|
268 |
}
|
| - |
|
269 |
if(st.equals(status.ACTIVE)){
|
| - |
|
270 |
activeItems.add(ite.getId());
|
| - |
|
271 |
}
|
| 272 |
}
|
272 |
}
|
| 273 |
try {
|
- |
|
| 274 |
//Generate prices and availability data for amazon
|
- |
|
| 275 |
AmazonSCDataGenerator.generatePricesAndAvailability(items);
|
- |
|
| 276 |
} catch (Exception e) {
|
- |
|
| 277 |
log.info("Could not generate Amazon prices and availability", e);
|
- |
|
| 278 |
}
|
273 |
|
| 279 |
//ProductListGenerator.updatePriceForEntity(Long.parseLong(ENTITY_ID), items.get(0).getSellingPrice(), items.get(0).getMrp());
|
274 |
//ProductListGenerator.updatePriceForEntity(Long.parseLong(ENTITY_ID), items.get(0).getSellingPrice(), items.get(0).getMrp());
|
| 280 |
} else {
|
275 |
} else {
|
| 281 |
log.info("Before getting active items.");
|
276 |
log.info("Before getting active items.");
|
| 282 |
items = client.getAllItemsByStatus(status.ACTIVE);
|
277 |
items = client.getAllItemsByStatus(status.ACTIVE);
|
| - |
|
278 |
for (Item item : items) {
|
| - |
|
279 |
activeItems.add(item.getId());
|
| - |
|
280 |
}
|
| 283 |
log.info("Before getting coming items.");
|
281 |
log.info("Before getting coming items.");
|
| 284 |
items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
|
282 |
items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
|
| 285 |
log.info("Before getting paused items.");
|
283 |
log.info("Before getting paused items.");
|
| 286 |
items.addAll(client.getAllItemsByStatus(status.PAUSED));
|
284 |
items.addAll(client.getAllItemsByStatus(status.PAUSED));
|
| 287 |
// Clean up the data from the solr directories.
|
285 |
// Clean up the data from the solr directories.
|
| Line 294... |
Line 292... |
| 294 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_INCREMENTAL)) {
|
292 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_INCREMENTAL)) {
|
| 295 |
}
|
293 |
}
|
| 296 |
|
294 |
|
| 297 |
// Populate the entityIdIemMap
|
295 |
// Populate the entityIdIemMap
|
| 298 |
populateEntityIdItemMap();
|
296 |
populateEntityIdItemMap();
|
| 299 |
List<Long> inStockEntities = null;
|
- |
|
| 300 |
// Generate partners and json objects for phones only
|
297 |
// Generate partners and json objects for phones only
|
| 301 |
if (!GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
298 |
if (!GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
| 302 |
ProductListGenerator generator = new ProductListGenerator(entityIdItemMap);
|
- |
|
| 303 |
log.info("Before thinkdigit feed.");
|
- |
|
| 304 |
generator.generateThinkDigitFeed();
|
- |
|
| 305 |
inStockEntities = generator.getInStockCatalogItemIds();
|
- |
|
| 306 |
log.info("Before product list js.");
|
- |
|
| 307 |
generator.generateProductListJavascript();
|
- |
|
| 308 |
|
- |
|
| 309 |
try {
|
299 |
try {
|
| 310 |
log.info("Before product list xml.");
|
- |
|
| 311 |
generator.generateProductsListXML();
|
300 |
ProductListGenerator generator = new ProductListGenerator(entityIdItemMap);
|
| 312 |
log.info("Before product accessories xml.");
|
- |
|
| 313 |
generator.generateAccessoriesXML();
|
301 |
|
| 314 |
log.info("Before product camera xml.");
|
302 |
log.info("Before auto suggest json");
|
| 315 |
generator.generateCamerasXML();
|
303 |
synonymTitlesExporter();
|
| - |
|
304 |
|
| 316 |
log.info("Before product display ads.");
|
305 |
log.info("Before product list js.");
|
| 317 |
//generator.generateProductXMLForDisplayAds();
|
306 |
generator.generateProductListJavascript();
|
| - |
|
307 |
|
| 318 |
} catch (Exception e) {
|
308 |
} catch (Exception e) {
|
| 319 |
e.printStackTrace();
|
309 |
e.printStackTrace();
|
| 320 |
}
|
310 |
}
|
| 321 |
|
311 |
|
| 322 |
}
|
312 |
}
|
| 323 |
PriceInsertor priceInserter = new PriceInsertor();
|
313 |
PriceInsertor priceInserter = new PriceInsertor();
|
| 324 |
|
314 |
|
| 325 |
Map<Long,List<String>> entityTags = client.getAllEntityTags();
|
315 |
Map<Long,List<String>> entityTags = client.getAllEntityTags();
|
| 326 |
Map<Long, Integer> popularityMap = getPolularityMap();
|
316 |
Map<Long, Integer> popularityMap = getPolularityMap();
|
| - |
|
317 |
CatalogClient prod_csc = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString());
|
| - |
|
318 |
Client prod_client = prod_csc.getClient();
|
| - |
|
319 |
Map<Long,Boolean> itemsStatus = prod_client.getItemsStatus(activeItems);
|
| 327 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
320 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
| 328 |
long entityId = entry.getKey();
|
321 |
long entityId = entry.getKey();
|
| 329 |
List<Item> items = entry.getValue();
|
322 |
List<Item> items = entry.getValue();
|
| 330 |
// TODO Domain name and destination directory should be read from
|
- |
|
| 331 |
// properties file
|
- |
|
| 332 |
double minPrice = 0d;
|
323 |
double minPrice = 0d;
|
| - |
|
324 |
|
| - |
|
325 |
//Evaluating availability
|
| 333 |
String availability = "In Stock";
|
326 |
String availability = "Out of Stock";
|
| 334 |
if (inStockEntities != null ) {
|
327 |
for(Item i: items){
|
| 335 |
if (!inStockEntities.contains(entry.getKey())) {
|
328 |
if(itemsStatus.containsKey(i.getId())) {
|
| - |
|
329 |
if(itemsStatus.get(i.getId())){
|
| - |
|
330 |
availability = "In Stock";
|
| - |
|
331 |
break;
|
| - |
|
332 |
}
|
| - |
|
333 |
}else if(i.getItemStatus().equals(status.ACTIVE)){
|
| 336 |
availability = "Out of Stock";
|
334 |
availability = "In Stock";
|
| - |
|
335 |
break;
|
| 337 |
}
|
336 |
}
|
| 338 |
} else {
|
- |
|
| 339 |
availability = getAvaialability(entry.getValue());
|
- |
|
| 340 |
}
|
337 |
}
|
| 341 |
StringBuilder priceString = new StringBuilder();
|
338 |
StringBuilder priceString = new StringBuilder();
|
| 342 |
StringBuilder availabilityString = new StringBuilder();
|
339 |
StringBuilder availabilityString = new StringBuilder();
|
| 343 |
boolean domainOnce = true;
|
340 |
boolean domainOnce = true;
|
| 344 |
boolean sourceOnce = true;
|
341 |
boolean sourceOnce = true;
|
| Line 381... |
Line 378... |
| 381 |
priceInserter.insertPriceInSolrData(entityId,
|
378 |
priceInserter.insertPriceInSolrData(entityId,
|
| 382 |
priceString.toString(), availabilityString.toString());
|
379 |
priceString.toString(), availabilityString.toString());
|
| 383 |
}
|
380 |
}
|
| 384 |
|
381 |
|
| 385 |
priceInserter.copySolrSchemaFiles();
|
382 |
priceInserter.copySolrSchemaFiles();
|
| 386 |
synonymTitlesExporter();
|
- |
|
| 387 |
}
|
383 |
}
|
| 388 |
|
384 |
|
| 389 |
private boolean isStoreItem(List<Item> items2) {
|
- |
|
| 390 |
for (Item item : items2){
|
- |
|
| 391 |
if(item.isActiveOnStore()) {
|
- |
|
| 392 |
return true;
|
- |
|
| 393 |
}
|
- |
|
| 394 |
}
|
- |
|
| 395 |
return false;
|
- |
|
| 396 |
}
|
- |
|
| 397 |
|
- |
|
| 398 |
private Map<Long, Integer> getPolularityMap() {
|
385 |
private Map<Long, Integer> getPolularityMap() {
|
| 399 |
try {
|
386 |
try {
|
| 400 |
Reader reader = new FileReader(Utils.EXPORT_PATH + Utils.POPULARITY_JSON);
|
387 |
Reader reader = new FileReader(Utils.EXPORT_PATH + Utils.POPULARITY_JSON);
|
| 401 |
return new Gson().fromJson(reader, new TypeToken<Map<Long, Integer>>() {}.getType());
|
388 |
return new Gson().fromJson(reader, new TypeToken<Map<Long, Integer>>() {}.getType());
|
| 402 |
} catch (FileNotFoundException e) {
|
389 |
} catch (FileNotFoundException e) {
|
| Line 405... |
Line 392... |
| 405 |
return new HashMap<Long, Integer>();
|
392 |
return new HashMap<Long, Integer>();
|
| 406 |
}
|
393 |
}
|
| 407 |
|
394 |
|
| 408 |
}
|
395 |
}
|
| 409 |
|
396 |
|
| 410 |
private String getAvaialability(List<Item> value) {
|
- |
|
| 411 |
boolean isActive = true;
|
- |
|
| 412 |
try {
|
- |
|
| 413 |
Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
|
- |
|
| 414 |
for (Item item : value ) {
|
- |
|
| 415 |
if (item.getItemStatus().equals(status.ACTIVE)) {
|
- |
|
| 416 |
if(item.isRisky()){
|
- |
|
| 417 |
try {
|
- |
|
| 418 |
ItemShippingInfo isi = catalogClientProd.isActive(item.getId());
|
- |
|
| 419 |
isActive = isi.isIsActive();
|
- |
|
| 420 |
} catch (Exception e) {
|
- |
|
| 421 |
e.printStackTrace();
|
- |
|
| 422 |
isActive = true;
|
- |
|
| 423 |
}
|
- |
|
| 424 |
}
|
- |
|
| 425 |
}
|
- |
|
| 426 |
if(isActive) break;
|
- |
|
| 427 |
}
|
- |
|
| 428 |
} catch (TTransportException e) {
|
- |
|
| 429 |
// TODO Auto-generated catch block
|
- |
|
| 430 |
e.printStackTrace();
|
- |
|
| 431 |
}
|
- |
|
| 432 |
return isActive ? "In Stock" : "Out of Stock";
|
- |
|
| 433 |
}
|
- |
|
| 434 |
|
- |
|
| 435 |
/**
|
397 |
/**
|
| 436 |
* Generates content for the specified entity embedding links to the
|
398 |
* Generates content for the specified entity embedding links to the
|
| 437 |
* specified domain name.
|
399 |
* specified domain name.
|
| 438 |
*
|
400 |
*
|
| 439 |
* The method will not generate content if one of the following conditions
|
401 |
* The method will not generate content if one of the following conditions
|
| Line 448... |
Line 410... |
| 448 |
*/
|
410 |
*/
|
| 449 |
private void generateContent() throws Exception {
|
411 |
private void generateContent() throws Exception {
|
| 450 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL)) {
|
412 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL)) {
|
| 451 |
entities = CreationUtils.getEntities();
|
413 |
entities = CreationUtils.getEntities();
|
| 452 |
lastGenerationTime = new Long(0);
|
414 |
lastGenerationTime = new Long(0);
|
| - |
|
415 |
items = client.getAllItemsByStatus(status.CONTENT_COMPLETE);
|
| - |
|
416 |
items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
|
| - |
|
417 |
items.addAll(client.getAllItemsByStatus(status.ACTIVE));
|
| - |
|
418 |
items.addAll(client.getAllItemsByStatus(status.PAUSED));
|
| 453 |
} else if (GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
419 |
} else if (GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
| 454 |
entities = new HashMap<Long, Entity>();
|
420 |
entities = new HashMap<Long, Entity>();
|
| 455 |
entities.put(Long.parseLong(ENTITY_ID),
|
421 |
entities.put(Long.parseLong(ENTITY_ID),
|
| 456 |
CreationUtils.getEntity(Long.parseLong(ENTITY_ID)));
|
422 |
CreationUtils.getEntity(Long.parseLong(ENTITY_ID)));
|
| - |
|
423 |
items = client.getItemsByCatalogId(Long.parseLong(ENTITY_ID));
|
| - |
|
424 |
Iterator<Item> ite = items.iterator();
|
| - |
|
425 |
while(ite.hasNext()) {
|
| - |
|
426 |
Item i = ite.next();
|
| - |
|
427 |
if(!(i.getItemStatus().equals(status.ACTIVE) || i.getItemStatus().equals(status.PAUSED)
|
| - |
|
428 |
|| i.getItemStatus().equals(status.CONTENT_COMPLETE) || i.getItemStatus().equals(status.COMING_SOON))){
|
| - |
|
429 |
ite.remove();
|
| - |
|
430 |
}
|
| - |
|
431 |
}
|
| 457 |
lastGenerationTime = new Long(0);
|
432 |
lastGenerationTime = new Long(0);
|
| 458 |
} else {
|
433 |
} else {
|
| 459 |
entities = CreationUtils.getEntities();
|
434 |
entities = CreationUtils.getEntities();
|
| 460 |
// When we read lastGenerationTime from database
|
435 |
// When we read lastGenerationTime from database
|
| 461 |
// then only we should mark the
|
436 |
// then only we should mark the
|
| Line 469... |
Line 444... |
| 469 |
|
444 |
|
| 470 |
log.info("lastGenerationTime: " + lastGenerationTime);
|
445 |
log.info("lastGenerationTime: " + lastGenerationTime);
|
| 471 |
if (lastGenerationTime == null) {
|
446 |
if (lastGenerationTime == null) {
|
| 472 |
lastGenerationTime = new Long(0);
|
447 |
lastGenerationTime = new Long(0);
|
| 473 |
}
|
448 |
}
|
| - |
|
449 |
items = client.getAllItemsByStatus(status.CONTENT_COMPLETE);
|
| - |
|
450 |
items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
|
| 474 |
}
|
451 |
}
|
| 475 |
|
452 |
|
| 476 |
// Filter invalid entities here
|
453 |
// Filter invalid entities here
|
| 477 |
List<Entity> validEntities = new ArrayList<Entity>();
|
454 |
List<Entity> validEntities = new ArrayList<Entity>();
|
| - |
|
455 |
List<Long> validEntityIds = new ArrayList<Long>();
|
| - |
|
456 |
|
| 478 |
for (long entityID : entities.keySet()) {
|
457 |
for (long entityID : entities.keySet()) {
|
| 479 |
if (isValidEntity(entities.get(entityID))) {
|
458 |
if (isValidEntity(entities.get(entityID))) {
|
| 480 |
validEntities.add(entities.get(entityID));
|
459 |
validEntities.add(entities.get(entityID));
|
| - |
|
460 |
validEntityIds.add(entityID);
|
| 481 |
}
|
461 |
}
|
| 482 |
}
|
462 |
}
|
| 483 |
|
463 |
|
| 484 |
// Calculate comparison scores
|
464 |
// Calculate comparison scores
|
| 485 |
log.info("Calculating comparison scores");
|
465 |
log.info("Calculating comparison scores");
|
| 486 |
NewCMP cmp = new NewCMP(validEntities);
|
466 |
NewCMP cmp = new NewCMP(validEntities);
|
| 487 |
Map<Long, Map<Long, Double>> slideScoresByEntity = cmp.getSlideScores();
|
467 |
Map<Long, Map<Long, Double>> slideScoresByEntity = cmp.getSlideScores();
|
| 488 |
CreationUtils.storeSlideScores(slideScoresByEntity);
|
468 |
CreationUtils.storeSlideScores(slideScoresByEntity);
|
| 489 |
|
469 |
|
| 490 |
// Fetch comparison statistics everyday and store them in BDB
|
470 |
// Fetch comparison statistics everyday and store them in BDB
|
| - |
|
471 |
//This might be remove.
|
| 491 |
log.info("Fetching comparison statistics");
|
472 |
log.info("Fetching comparison statistics");
|
| 492 |
ComparisonStatsFetcher csf = new ComparisonStatsFetcher();
|
473 |
ComparisonStatsFetcher csf = new ComparisonStatsFetcher();
|
| 493 |
csf.fetchAndStoreComparisonStats();
|
474 |
csf.fetchAndStoreComparisonStats();
|
| 494 |
|
- |
|
| 495 |
// Upload catalog to Google App Engine.
|
- |
|
| 496 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL)) {
|
- |
|
| 497 |
log.info("Uploading Catalog to Google app engine");
|
- |
|
| 498 |
List<Item> allItems = client.getAllItems(false);
|
- |
|
| 499 |
allItems.addAll(client.getAllItems(true));
|
- |
|
| 500 |
CatalogUploderToGAE catalogUploaderToGAE = new CatalogUploderToGAE();
|
- |
|
| 501 |
catalogUploaderToGAE.uploadItems(allItems);
|
- |
|
| 502 |
}
|
- |
|
| 503 |
|
- |
|
| 504 |
items = client.getAllItemsByStatus(status.ACTIVE);
|
- |
|
| 505 |
items.addAll(client.getAllItemsByStatus(status.PAUSED));
|
- |
|
| 506 |
items.addAll(client.getAllItemsByStatus(status.CONTENT_COMPLETE));
|
- |
|
| 507 |
items.addAll(client.getAllItemsByStatus(status.COMING_SOON));
|
- |
|
| 508 |
populateEntityIdItemMap();
|
475 |
populateEntityIdItemMap();
|
| 509 |
|
476 |
|
| 510 |
//FIXME Avoiding the finding of accesories, as list of categories for which we need to find accessories is hardocoded in code.
|
- |
|
| 511 |
// We need to make that configurable. Also creating ticket to improve it.
|
- |
|
| 512 |
try{
|
- |
|
| 513 |
log.info("Finding accessories");
|
- |
|
| 514 |
AccessoriesFinder af = new AccessoriesFinder(new HashSet<Long>(allValidEntityIds));
|
- |
|
| 515 |
Map<Long, Map<Long, List<Long>>> relatedAccessories = af.findAccessories();
|
- |
|
| 516 |
CreationUtils.storeRelatedAccessories(relatedAccessories);
|
- |
|
| 517 |
}catch (Exception e) {
|
- |
|
| 518 |
log.error("Error while generating accessories" + e);
|
- |
|
| 519 |
}
|
- |
|
| 520 |
|
477 |
|
| 521 |
log.info("Writing JSON file for special pages");
|
478 |
log.info("Writing JSON file for special pages");
|
| 522 |
SpecialPageJSONConvertor bjc = new SpecialPageJSONConvertor();
|
479 |
SpecialPageJSONConvertor bjc = new SpecialPageJSONConvertor();
|
| 523 |
bjc.writeToJSONFile(new File(Utils.EXPORT_JAVASCRIPT_CONTENT_PATH
|
480 |
bjc.writeToJSONFile(new File(Utils.EXPORT_JAVASCRIPT_CONTENT_PATH
|
| 524 |
+ "special-pages.json"));
|
481 |
+ "special-pages.json"));
|
| Line 528... |
Line 485... |
| 528 |
for (Entity entity : validEntities) {
|
485 |
for (Entity entity : validEntities) {
|
| 529 |
log.info("Processing Entityid: " + entity.getID());
|
486 |
log.info("Processing Entityid: " + entity.getID());
|
| 530 |
vui.generateContentForOneEntity(entity, Utils.EXPORT_VELOCITY_PATH);
|
487 |
vui.generateContentForOneEntity(entity, Utils.EXPORT_VELOCITY_PATH);
|
| 531 |
}
|
488 |
}
|
| 532 |
|
489 |
|
| 533 |
// Generate synonyms list. This will be used in PriceComparisonTool to
|
- |
|
| 534 |
// resolve the product names.
|
- |
|
| 535 |
log.info("Generating synonyms");
|
- |
|
| 536 |
SynonymExporter sx = new SynonymExporter();
|
- |
|
| 537 |
sx.storeSynonyms(validEntities);
|
- |
|
| 538 |
|
- |
|
| 539 |
List<Entity> allValidEntities;
|
- |
|
| 540 |
|
- |
|
| 541 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_ALL)) {
|
- |
|
| 542 |
allValidEntities = validEntities;
|
- |
|
| 543 |
|
- |
|
| 544 |
} else {
|
- |
|
| 545 |
allValidEntities = new ArrayList<Entity>();
|
- |
|
| 546 |
for (Long entityId : allValidEntityIds) {
|
- |
|
| 547 |
allValidEntities.add(CreationUtils.getEntity(entityId));
|
- |
|
| 548 |
}
|
- |
|
| 549 |
}
|
- |
|
| 550 |
|
- |
|
| 551 |
log.info("Generating HTML for Site Index");
|
- |
|
| 552 |
ProductIndexGenerator indexGenerator = new ProductIndexGenerator(allValidEntities);
|
- |
|
| 553 |
indexGenerator.generate();
|
- |
|
| 554 |
|
- |
|
| 555 |
log.info("Generating HTML for Site for Product Documents");
|
- |
|
| 556 |
ProductDocumentsGenerator asGenerator = new ProductDocumentsGenerator(allValidEntities);
|
- |
|
| 557 |
asGenerator.generate();
|
- |
|
| 558 |
|
- |
|
| 559 |
log.info("Generating HTML for Accessories Compatibility Index");
|
- |
|
| 560 |
CompatibleAccessoriesIndexGenerator generator = new CompatibleAccessoriesIndexGenerator(allValidEntities);
|
- |
|
| 561 |
generator.generate();
|
- |
|
| 562 |
|
- |
|
| 563 |
log.info("Generating HTML for Most Frequently searched keywords");
|
- |
|
| 564 |
MostFrequentlySearchedKeywords mfsk = new MostFrequentlySearchedKeywords();
|
- |
|
| 565 |
mfsk.generate();
|
- |
|
| 566 |
|
- |
|
| 567 |
log.info("Generating HTML for Most Compared Index");
|
- |
|
| 568 |
MostComparedIndexGenerator mostCompGenerator = new MostComparedIndexGenerator(allValidEntityIds);
|
- |
|
| 569 |
mostCompGenerator.generate();
|
- |
|
| 570 |
|
- |
|
| 571 |
log.info("Generating XML for Mobile Site XML feed");
|
- |
|
| 572 |
MobileSiteDataXMLGenerator mSiteXMLGenerator = new MobileSiteDataXMLGenerator(allValidEntities);
|
- |
|
| 573 |
mSiteXMLGenerator.generate();
|
- |
|
| 574 |
|
490 |
|
| 575 |
if (newLastGenerationTime != 0) {
|
491 |
if (newLastGenerationTime != 0) {
|
| 576 |
CreationUtils.storeLastContentGenerationTime(newLastGenerationTime);
|
492 |
CreationUtils.storeLastContentGenerationTime(newLastGenerationTime);
|
| 577 |
}
|
493 |
}
|
| 578 |
|
494 |
|
| 579 |
|
495 |
|
| 580 |
log.info("Generating Solr files");
|
496 |
log.info("Generating Solr files");
|
| 581 |
NewIR ir = new NewIR(validEntities);
|
497 |
NewIR ir = new NewIR(validEntities);
|
| 582 |
ir.exportIRData();
|
498 |
ir.exportIRData();
|
| 583 |
// ir.transformIrDataXMLtoSolrXML();
|
499 |
// ir.transformIrDataXMLtoSolrXML();
|
| - |
|
500 |
|
| - |
|
501 |
if(!GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
| 584 |
ir.exportIRMetaData();
|
502 |
ir.exportIRMetaData();
|
| 585 |
ir.transformIrMetaDataXMLtoSolrSchemaXML();
|
503 |
ir.transformIrMetaDataXMLtoSolrSchemaXML();
|
| 586 |
ir.transformIrMetaDataXMLtoSolrCatchAllXML();
|
504 |
ir.transformIrMetaDataXMLtoSolrCatchAllXML();
|
| - |
|
505 |
}
|
| 587 |
|
506 |
|
| 588 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
507 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
| 589 |
List<Item> items = entry.getValue();
|
508 |
List<Item> items = entry.getValue();
|
| 590 |
for (Item item : items) {
|
509 |
for (Item item : items) {
|
| 591 |
if (item.getItemStatus() == status.CONTENT_COMPLETE || item.getItemStatus() == status.COMING_SOON) {
|
510 |
if ( (item.getItemStatus() == status.CONTENT_COMPLETE && validEntityIds.contains(item.getCatalogItemId()))
|
| - |
|
511 |
|| item.getItemStatus() == status.COMING_SOON) {
|
| 592 |
if(item.getStartDate() <= new Date().getTime() + ONE_DAY){
|
512 |
if(item.getStartDate() <= new Date().getTime() + ONE_DAY){
|
| 593 |
item.setItemStatus(status.ACTIVE);
|
513 |
item.setItemStatus(status.ACTIVE);
|
| 594 |
item.setStatus_description("This item is active");
|
514 |
item.setStatus_description("This item is active");
|
| 595 |
} else {
|
515 |
} else {
|
| 596 |
item.setItemStatus(status.COMING_SOON);
|
516 |
item.setItemStatus(status.COMING_SOON);
|
| Line 611... |
Line 531... |
| 611 |
client.updateItem(item);
|
531 |
client.updateItem(item);
|
| 612 |
}
|
532 |
}
|
| 613 |
}
|
533 |
}
|
| 614 |
}
|
534 |
}
|
| 615 |
sendAlertToCategoryTeam(alertItems);
|
535 |
sendAlertToCategoryTeam(alertItems);
|
| 616 |
try {
|
- |
|
| 617 |
//generate products list that is to be uploaded in Amazon.
|
- |
|
| 618 |
AmazonSCDataGenerator ascdGenerator = new AmazonSCDataGenerator(validEntities, GENERATION_TYPE);
|
- |
|
| 619 |
ascdGenerator.generateSCProdData();
|
- |
|
| 620 |
} catch (Exception e) {
|
- |
|
| 621 |
e.printStackTrace();
|
- |
|
| 622 |
log.info("Could not generate Amazon data", e);
|
- |
|
| 623 |
}
|
- |
|
| 624 |
}
|
536 |
}
|
| 625 |
|
537 |
|
| 626 |
private void sendAlertToCategoryTeam(List<Item> items) {
|
538 |
private void sendAlertToCategoryTeam(List<Item> items) {
|
| 627 |
if(items!=null && items.size()!=0){
|
539 |
if(items!=null && items.size()!=0){
|
| 628 |
GmailUtils util = new GmailUtils();
|
540 |
GmailUtils util = new GmailUtils();
|
| Line 725... |
Line 637... |
| 725 |
}
|
637 |
}
|
| 726 |
if (!isValidEntity) {
|
638 |
if (!isValidEntity) {
|
| 727 |
removeEntities.add(entityId);
|
639 |
removeEntities.add(entityId);
|
| 728 |
}
|
640 |
}
|
| 729 |
}
|
641 |
}
|
| 730 |
//Simply assign allValidEntityIds to a class variable as these need to be used where all valid entites
|
- |
|
| 731 |
//are needed.
|
- |
|
| 732 |
allValidEntityIds = new ArrayList<Long>(entityIdItemMap.keySet());
|
- |
|
| - |
|
642 |
|
| 733 |
for (Long entityId : removeEntities) {
|
643 |
for (Long entityId : removeEntities) {
|
| 734 |
entityIdItemMap.remove(entityId);
|
644 |
entityIdItemMap.remove(entityId);
|
| 735 |
}
|
645 |
}
|
| 736 |
|
646 |
|
| 737 |
Utils.info("Final valid entities to be processed: " + entityIdItemMap.size());
|
647 |
Utils.info("Final valid entities to be processed: " + entityIdItemMap.size());
|