| 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;
|
| 10 |
import in.shop2020.model.v1.catalog.Source;
|
11 |
import in.shop2020.model.v1.catalog.Source;
|
| 11 |
import in.shop2020.model.v1.catalog.status;
|
12 |
import in.shop2020.model.v1.catalog.status;
|
| 12 |
import in.shop2020.thrift.clients.CatalogClient;
|
13 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 13 |
import in.shop2020.ui.util.CatalogUploderToGAE;
|
14 |
import in.shop2020.ui.util.CatalogUploderToGAE;
|
| 14 |
import in.shop2020.ui.util.ComparisonStatsFetcher;
|
15 |
import in.shop2020.ui.util.ComparisonStatsFetcher;
|
| 15 |
import in.shop2020.ui.util.NewVUI;
|
16 |
import in.shop2020.ui.util.NewVUI;
|
| 16 |
import in.shop2020.ui.util.PriceInsertor;
|
17 |
import in.shop2020.ui.util.PriceInsertor;
|
| 17 |
import in.shop2020.ui.util.SpecialPageJSONConvertor;
|
18 |
import in.shop2020.ui.util.SpecialPageJSONConvertor;
|
| - |
|
19 |
import in.shop2020.utils.ConfigClientKeys;
|
| 18 |
import in.shop2020.utils.GmailUtils;
|
20 |
import in.shop2020.utils.GmailUtils;
|
| 19 |
|
21 |
|
| 20 |
import java.io.File;
|
22 |
import java.io.File;
|
| 21 |
import java.io.IOException;
|
23 |
import java.io.IOException;
|
| 22 |
import java.text.SimpleDateFormat;
|
24 |
import java.text.SimpleDateFormat;
|
| Line 39... |
Line 41... |
| 39 |
import org.apache.commons.cli.ParseException;
|
41 |
import org.apache.commons.cli.ParseException;
|
| 40 |
import org.apache.commons.cli.PosixParser;
|
42 |
import org.apache.commons.cli.PosixParser;
|
| 41 |
import org.apache.commons.lang.StringUtils;
|
43 |
import org.apache.commons.lang.StringUtils;
|
| 42 |
import org.apache.commons.logging.Log;
|
44 |
import org.apache.commons.logging.Log;
|
| 43 |
import org.apache.commons.logging.LogFactory;
|
45 |
import org.apache.commons.logging.LogFactory;
|
| - |
|
46 |
import org.apache.thrift.transport.TTransportException;
|
| 44 |
|
47 |
|
| 45 |
import com.google.gson.Gson;
|
48 |
import com.google.gson.Gson;
|
| 46 |
|
49 |
|
| 47 |
public class ContentGenerationUtility {
|
50 |
public class ContentGenerationUtility {
|
| 48 |
private static final String UPDATE_TYPE_CATALOG = "CATALOG";
|
51 |
private static final String UPDATE_TYPE_CATALOG = "CATALOG";
|
| Line 283... |
Line 286... |
| 283 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_INCREMENTAL)) {
|
286 |
if (GENERATION_TYPE.equals(GENERATION_TYPE_INCREMENTAL)) {
|
| 284 |
}
|
287 |
}
|
| 285 |
|
288 |
|
| 286 |
// Populate the entityIdIemMap
|
289 |
// Populate the entityIdIemMap
|
| 287 |
populateEntityIdItemMap();
|
290 |
populateEntityIdItemMap();
|
| - |
|
291 |
List<Long> inStockEntities = null;
|
| - |
|
292 |
// Generate partners and json objects for phones only
|
| - |
|
293 |
if (!GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
| - |
|
294 |
ProductListGenerator generator = new ProductListGenerator(entityIdItemMap);
|
| - |
|
295 |
generator.generateThinkDigitFeed();
|
| - |
|
296 |
inStockEntities = generator.getInStockCatalogItemIds();
|
| - |
|
297 |
generator.generateProductsListXML();
|
| - |
|
298 |
generator.generateAccessoriesXML();
|
| - |
|
299 |
generator.generateCamerasXML();
|
| - |
|
300 |
generator.generateProductListJavascript();
|
| 288 |
|
301 |
|
| - |
|
302 |
try {
|
| - |
|
303 |
generator.generateProductXMLForDisplayAds();
|
| - |
|
304 |
} catch (Exception e) {
|
| - |
|
305 |
|
| - |
|
306 |
}
|
| - |
|
307 |
|
| - |
|
308 |
}
|
| 289 |
PriceInsertor priceInserter = new PriceInsertor();
|
309 |
PriceInsertor priceInserter = new PriceInsertor();
|
| 290 |
|
310 |
|
| 291 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
311 |
for (Map.Entry<Long, List<Item>> entry : entityIdItemMap.entrySet()) {
|
| 292 |
long entityId = entry.getKey();
|
312 |
long entityId = entry.getKey();
|
| 293 |
List<Item> items = entry.getValue();
|
313 |
List<Item> items = entry.getValue();
|
| 294 |
// TODO Domain name and destination directory should be read from
|
314 |
// TODO Domain name and destination directory should be read from
|
| 295 |
// properties file
|
315 |
// properties file
|
| 296 |
double minPrice = 0d;
|
316 |
double minPrice = 0d;
|
| - |
|
317 |
String availability = "In Stock";
|
| - |
|
318 |
if (inStockEntities != null ) {
|
| - |
|
319 |
if (!inStockEntities.contains(entry.getKey())) {
|
| - |
|
320 |
availability = "Out of Stock";
|
| - |
|
321 |
}
|
| - |
|
322 |
} else {
|
| - |
|
323 |
availability = getAvaialability(entry.getValue());
|
| - |
|
324 |
}
|
| 297 |
StringBuilder priceString = new StringBuilder();
|
325 |
StringBuilder priceString = new StringBuilder();
|
| - |
|
326 |
StringBuilder availabilityString = new StringBuilder();
|
| 298 |
boolean domainOnce = true;
|
327 |
boolean domainOnce = true;
|
| 299 |
boolean sourceOnce = true;
|
328 |
boolean sourceOnce = true;
|
| 300 |
for(String domainPath : DOMAINPATHS){
|
329 |
for(String domainPath : DOMAINPATHS){
|
| 301 |
String domainName = domainPath;
|
330 |
String domainName = domainPath;
|
| 302 |
String pathName = domainPath.split("\\.")[0].split(":")[0];
|
331 |
String pathName = domainPath.split("\\.")[0].split(":")[0];
|
| 303 |
minPrice = priceInserter.insertPriceInHtml(items, entityId,
|
332 |
minPrice = priceInserter.insertPriceInHtml(items, entityId,
|
| 304 |
domainName, Utils.EXPORT_PATH + "html/entities-" + pathName + "/", null);
|
333 |
domainName, Utils.EXPORT_PATH + "html/entities-" + pathName + "/", null);
|
| 305 |
if(domainOnce){
|
334 |
if(domainOnce){
|
| 306 |
priceString.append(
|
335 |
priceString.append("<field name=\"F_50002\">" + minPrice + "</field>");
|
| 307 |
"<field name=\"F_50002\">" + minPrice + "</field>");
|
336 |
availabilityString.append("<field name=\"F_500028\">" + availability + "</field>");
|
| 308 |
domainOnce = false;
|
337 |
domainOnce = false;
|
| 309 |
}
|
338 |
}
|
| 310 |
if(sources != null){
|
339 |
if(sources != null){
|
| 311 |
for (Source source : sources) {
|
340 |
for (Source source : sources) {
|
| 312 |
minPrice = priceInserter.insertPriceInHtml(items, entityId,
|
341 |
minPrice = priceInserter.insertPriceInHtml(items, entityId,
|
| 313 |
domainName, Utils.EXPORT_PATH + "html/entities-" + pathName + "/",
|
342 |
domainName, Utils.EXPORT_PATH + "html/entities-" + pathName + "/",
|
| 314 |
source);
|
343 |
source);
|
| 315 |
if(sourceOnce){
|
344 |
if(sourceOnce){
|
| 316 |
priceString.append("<field name=\"F_50002_"
|
345 |
priceString.append("<field name=\"F_50002_"
|
| 317 |
+ source.getId() + "\">" + minPrice + "</field>");
|
346 |
+ source.getId() + "\">" + minPrice + "</field>");
|
| - |
|
347 |
availabilityString.append("<field name=\"F_50028_"
|
| - |
|
348 |
+ source.getId() + "\">" + availability + "</field>");
|
| 318 |
}
|
349 |
}
|
| 319 |
}
|
350 |
}
|
| 320 |
sourceOnce = false;
|
351 |
sourceOnce = false;
|
| 321 |
}
|
352 |
}
|
| 322 |
}
|
353 |
}
|
| 323 |
|
354 |
|
| 324 |
priceInserter.insertPriceInSolrData(entityId,
|
355 |
priceInserter.insertPriceInSolrData(entityId,
|
| 325 |
priceString.toString());
|
356 |
priceString.toString(), availabilityString.toString());
|
| 326 |
}
|
357 |
}
|
| 327 |
|
358 |
|
| 328 |
priceInserter.copySolrSchemaFiles();
|
359 |
priceInserter.copySolrSchemaFiles();
|
| 329 |
synonymTitlesExporter();
|
360 |
synonymTitlesExporter();
|
| 330 |
// Generate partners and json objects for phones only
|
- |
|
| 331 |
if (!GENERATION_TYPE.equals(GENERATION_TYPE_ONE)) {
|
- |
|
| 332 |
ProductListGenerator generator = new ProductListGenerator(entityIdItemMap);
|
- |
|
| 333 |
generator.generateThinkDigitFeed();
|
- |
|
| 334 |
generator.generateProductsListXML();
|
- |
|
| 335 |
generator.generateAccessoriesXML();
|
- |
|
| 336 |
generator.generateCamerasXML();
|
- |
|
| 337 |
generator.generateProductListJavascript();
|
- |
|
| 338 |
|
- |
|
| 339 |
try {
|
- |
|
| 340 |
generator.generateProductXMLForDisplayAds();
|
- |
|
| 341 |
} catch (Exception e) {
|
- |
|
| 342 |
|
- |
|
| 343 |
}
|
- |
|
| 344 |
|
- |
|
| 345 |
}
|
- |
|
| 346 |
}
|
361 |
}
|
| 347 |
|
362 |
|
| - |
|
363 |
private String getAvaialability(List<Item> value) {
|
| - |
|
364 |
boolean isActive = true;
|
| - |
|
365 |
try {
|
| - |
|
366 |
Client catalogClientProd = new CatalogClient(ConfigClientKeys.catalog_service_server_host_prod.toString(), ConfigClientKeys.catalog_service_server_port.toString()).getClient();
|
| - |
|
367 |
for (Item item : value ) {
|
| - |
|
368 |
if (item.getItemStatus().equals(status.ACTIVE)) {
|
| - |
|
369 |
if(item.isRisky()){
|
| - |
|
370 |
try {
|
| - |
|
371 |
ItemShippingInfo isi = catalogClientProd.isActive(item.getId());
|
| - |
|
372 |
isActive = isi.isIsActive();
|
| - |
|
373 |
} catch (Exception e) {
|
| - |
|
374 |
e.printStackTrace();
|
| - |
|
375 |
isActive = true;
|
| - |
|
376 |
}
|
| 348 |
/**
|
377 |
}
|
| - |
|
378 |
}
|
| - |
|
379 |
if(isActive) break;
|
| - |
|
380 |
}
|
| - |
|
381 |
} catch (TTransportException e) {
|
| - |
|
382 |
// TODO Auto-generated catch block
|
| - |
|
383 |
e.printStackTrace();
|
| - |
|
384 |
}
|
| - |
|
385 |
return isActive ? "In Stock" : "Out of Stock";
|
| - |
|
386 |
}
|
| - |
|
387 |
|
| - |
|
388 |
/**
|
| 349 |
* Generates content for the specified entity embedding links to the
|
389 |
* Generates content for the specified entity embedding links to the
|
| 350 |
* specified domain name.
|
390 |
* specified domain name.
|
| 351 |
*
|
391 |
*
|
| 352 |
* The method will not generate content if one of the following conditions
|
392 |
* The method will not generate content if one of the following conditions
|
| 353 |
* is met:
|
393 |
* is met:
|