| Line 12... |
Line 12... |
| 12 |
import in.shop2020.metamodel.util.CreationUtils;
|
12 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 13 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
13 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 14 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
14 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 15 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
15 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
| 16 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
16 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| - |
|
17 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
| - |
|
18 |
import in.shop2020.model.v1.catalog.Item;
|
| - |
|
19 |
import in.shop2020.model.v1.catalog.status;
|
| - |
|
20 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 17 |
import in.shop2020.util.EntityUtils;
|
21 |
import in.shop2020.util.EntityUtils;
|
| 18 |
import in.shop2020.util.Utils;
|
22 |
import in.shop2020.util.Utils;
|
| 19 |
|
23 |
|
| 20 |
import java.io.BufferedWriter;
|
24 |
import java.io.BufferedWriter;
|
| 21 |
import java.io.File;
|
25 |
import java.io.File;
|
| Line 30... |
Line 34... |
| 30 |
import java.util.HashMap;
|
34 |
import java.util.HashMap;
|
| 31 |
import java.util.List;
|
35 |
import java.util.List;
|
| 32 |
import java.util.Map;
|
36 |
import java.util.Map;
|
| 33 |
import java.util.Properties;
|
37 |
import java.util.Properties;
|
| 34 |
|
38 |
|
| - |
|
39 |
import org.apache.commons.collections.CollectionUtils;
|
| - |
|
40 |
import org.apache.commons.collections.Predicate;
|
| 35 |
import org.apache.commons.logging.Log;
|
41 |
import org.apache.commons.logging.Log;
|
| 36 |
import org.apache.commons.logging.LogFactory;
|
42 |
import org.apache.commons.logging.LogFactory;
|
| 37 |
import org.apache.velocity.Template;
|
43 |
import org.apache.velocity.Template;
|
| 38 |
import org.apache.velocity.VelocityContext;
|
44 |
import org.apache.velocity.VelocityContext;
|
| 39 |
import org.apache.velocity.app.Velocity;
|
45 |
import org.apache.velocity.app.Velocity;
|
| Line 370... |
Line 376... |
| 370 |
props.put("metaKeywords", metaKeywords);
|
376 |
props.put("metaKeywords", metaKeywords);
|
| 371 |
props.put("entityUrl", entityUrl);
|
377 |
props.put("entityUrl", entityUrl);
|
| 372 |
props.put("title", title);
|
378 |
props.put("title", title);
|
| 373 |
props.put("name", EntityUtils.getProductName(expEntity));
|
379 |
props.put("name", EntityUtils.getProductName(expEntity));
|
| 374 |
boolean displayAccessories;
|
380 |
boolean displayAccessories;
|
| - |
|
381 |
|
| 375 |
if(expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY && expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY){
|
382 |
Category parentCategory = expEntity.getCategory().getParentCategory();
|
| - |
|
383 |
if(parentCategory.isHasAccessories()){
|
| 376 |
props.put("displayAccessories", "TRUE");
|
384 |
props.put("displayAccessories", "TRUE");
|
| 377 |
displayAccessories = true;
|
385 |
displayAccessories = true;
|
| 378 |
}else{
|
386 |
}else{
|
| 379 |
props.put("displayAccessories", "FALSE" );
|
387 |
props.put("displayAccessories", "FALSE" );
|
| 380 |
displayAccessories = false;
|
388 |
displayAccessories = false;
|
| Line 515... |
Line 523... |
| 515 |
if (relatedAccessories != null) {
|
523 |
if (relatedAccessories != null) {
|
| 516 |
for (Long catID : priorityList) {
|
524 |
for (Long catID : priorityList) {
|
| 517 |
int individualCount = 0;
|
525 |
int individualCount = 0;
|
| 518 |
List<Long> ents = relatedAccessories.get(catID);
|
526 |
List<Long> ents = relatedAccessories.get(catID);
|
| 519 |
if (ents != null && !ents.isEmpty()) {
|
527 |
if (ents != null && !ents.isEmpty()) {
|
| - |
|
528 |
Predicate activeOnly =new Predicate() {
|
| - |
|
529 |
|
| - |
|
530 |
@Override
|
| - |
|
531 |
public boolean evaluate(Object arg0) {
|
| - |
|
532 |
Long entityId = (Long)arg0;
|
| - |
|
533 |
CatalogClient cc;
|
| - |
|
534 |
boolean returnVal = false;
|
| - |
|
535 |
try {
|
| - |
|
536 |
cc = new CatalogClient();
|
| - |
|
537 |
Client cl = cc.getClient();
|
| - |
|
538 |
List<Item> items = cl.getItemsByCatalogId(entityId);
|
| - |
|
539 |
for(Item item: items){
|
| - |
|
540 |
if(item.getItemStatus().equals(status.ACTIVE)){
|
| - |
|
541 |
returnVal = true;
|
| - |
|
542 |
break;
|
| - |
|
543 |
}
|
| - |
|
544 |
}
|
| - |
|
545 |
} catch (Exception e) {
|
| - |
|
546 |
// TODO Auto-generated catch block
|
| - |
|
547 |
log.error("Error accessing thrift service", e);
|
| - |
|
548 |
}
|
| - |
|
549 |
return returnVal;
|
| - |
|
550 |
}
|
| - |
|
551 |
};
|
| - |
|
552 |
CollectionUtils.filter(ents, activeOnly);
|
| 520 |
if (ents.size() > individualLimit) {
|
553 |
if (ents.size() > individualLimit) {
|
| 521 |
ents = ents.subList(0, individualLimit);
|
554 |
ents = ents.subList(0, individualLimit);
|
| 522 |
}
|
555 |
}
|
| 523 |
for (Long entID : ents) {
|
556 |
for (Long entID : ents) {
|
| 524 |
if (totalLimit > totalCount) {
|
557 |
if (totalLimit > totalCount) {
|
| Line 614... |
Line 647... |
| 614 |
prodName = expEntity.getBrand().trim()
|
647 |
prodName = expEntity.getBrand().trim()
|
| 615 |
+ SPACE
|
648 |
+ SPACE
|
| 616 |
+ ((expEntity.getModelName() != null) ? expEntity
|
649 |
+ ((expEntity.getModelName() != null) ? expEntity
|
| 617 |
.getModelName().trim() : "");
|
650 |
.getModelName().trim() : "");
|
| 618 |
}
|
651 |
}
|
| - |
|
652 |
Category parentCategory = expEntity.getCategory().getParentCategory();
|
| - |
|
653 |
|
| 619 |
String categoryName = expEntity.getCategory().getLabel();
|
654 |
String categoryName = expEntity.getCategory().getLabel();
|
| 620 |
String tagline = "";
|
655 |
String tagline = "";
|
| 621 |
String warranty = "";
|
656 |
String warranty = "";
|
| 622 |
String tinySnippet = "";
|
657 |
String tinySnippet = "";
|
| 623 |
List<Feature> features = expEntity.getSlide(130054).getFeatures();
|
658 |
List<Feature> features = expEntity.getSlide(130054).getFeatures();
|
| Line 697... |
Line 732... |
| 697 |
"PRODUCT_URL",
|
732 |
"PRODUCT_URL",
|
| 698 |
URLEncoder.encode("http://www.", "UTF-8")
|
733 |
URLEncoder.encode("http://www.", "UTF-8")
|
| 699 |
+ "${domain}"
|
734 |
+ "${domain}"
|
| 700 |
+ URLEncoder.encode(
|
735 |
+ URLEncoder.encode(
|
| 701 |
EntityUtils.getEntityURL(expEntity), "UTF-8"));
|
736 |
EntityUtils.getEntityURL(expEntity), "UTF-8"));
|
| 702 |
if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY
|
- |
|
| 703 |
&& expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
|
- |
|
| 704 |
params.put("IS_MOBILE", "TRUE");
|
- |
|
| 705 |
} else {
|
- |
|
| 706 |
params.put("IS_MOBILE", "FALSE");
|
- |
|
| 707 |
}
|
- |
|
| 708 |
|
737 |
|
| 709 |
if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY) {
|
738 |
if (parentCategory.isHasAccessories()) {
|
| 710 |
params.put("IS_COMPARABLE", "TRUE");
|
739 |
params.put("IS_COMPARABLE", "TRUE");
|
| 711 |
} else {
|
740 |
} else {
|
| 712 |
params.put("IS_COMPARABLE", "FALSE");
|
741 |
params.put("IS_COMPARABLE", "FALSE");
|
| 713 |
}
|
742 |
}
|
| 714 |
|
743 |
|
| Line 776... |
Line 805... |
| 776 |
filenames.add("SearchSnippet");
|
805 |
filenames.add("SearchSnippet");
|
| 777 |
filenames.add("CategorySnippet");
|
806 |
filenames.add("CategorySnippet");
|
| 778 |
filenames.add("SlideGuide");
|
807 |
filenames.add("SlideGuide");
|
| 779 |
filenames.add("MyResearchSnippet");
|
808 |
filenames.add("MyResearchSnippet");
|
| 780 |
filenames.add("AfterSales");
|
809 |
filenames.add("AfterSales");
|
| - |
|
810 |
|
| - |
|
811 |
Category parentCategory = expEntity.getCategory().getParentCategory();
|
| - |
|
812 |
if(parentCategory.isComparable()){
|
| - |
|
813 |
filenames.add("CompareProductSnippet");
|
| - |
|
814 |
filenames.add("ComparisonSnippet");
|
| - |
|
815 |
filenames.add("CompareProductSummarySnippet");
|
| - |
|
816 |
getSlidenamesSnippet(expEntity, exportPath);
|
| - |
|
817 |
}
|
| - |
|
818 |
if(parentCategory.isHasAccessories()){
|
| - |
|
819 |
getRelatedAccessories(expEntity, exportPath);
|
| - |
|
820 |
}
|
| - |
|
821 |
if(parentCategory.getID()==Utils.MOBILE_ACCESSORIES_CATEGORY){
|
| - |
|
822 |
getMostComparedProducts(expEntity, exportPath);
|
| - |
|
823 |
filenames.add("PhonesIOwnSnippet");
|
| - |
|
824 |
}
|
| 781 |
if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY) {
|
825 |
// if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY) {
|
| 782 |
|
826 |
//
|
| 783 |
// For laptops we do not have related accessories and most comparable
|
827 |
// // For laptops we do not have related accessories and most comparable
|
| 784 |
if(expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
|
828 |
// if(expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
|
| 785 |
filenames.add("PhonesIOwnSnippet");
|
829 |
// filenames.add("PhonesIOwnSnippet");
|
| 786 |
|
830 |
//
|
| 787 |
getRelatedAccessories(expEntity, exportPath);
|
831 |
// getRelatedAccessories(expEntity, exportPath);
|
| 788 |
getMostComparedProducts(expEntity, exportPath);
|
832 |
// getMostComparedProducts(expEntity, exportPath);
|
| 789 |
}
|
833 |
// }
|
| 790 |
filenames.add("CompareProductSnippet");
|
834 |
// filenames.add("CompareProductSnippet");
|
| 791 |
filenames.add("ComparisonSnippet");
|
835 |
// filenames.add("ComparisonSnippet");
|
| 792 |
filenames.add("CompareProductSummarySnippet");
|
836 |
// filenames.add("CompareProductSummarySnippet");
|
| 793 |
// This method wont use any velocity file, So calling directly
|
837 |
// // This method wont use any velocity file, So calling directly
|
| 794 |
getSlidenamesSnippet(expEntity, exportPath);
|
- |
|
| 795 |
}
|
838 |
// }
|
| 796 |
|
839 |
|
| 797 |
// This method wont use any velocity file, So calling directly
|
840 |
// This method wont use any velocity file, So calling directly
|
| 798 |
getProductPropertiesSnippet(expEntity, exportPath);
|
841 |
getProductPropertiesSnippet(expEntity, exportPath);
|
| 799 |
|
842 |
|
| 800 |
applyVelocityTemplate(filenames, exportPath, context, catalogId);
|
843 |
applyVelocityTemplate(filenames, exportPath, context, catalogId);
|