| Line 45... |
Line 45... |
| 45 |
*
|
45 |
*
|
| 46 |
* @author rajveer
|
46 |
* @author rajveer
|
| 47 |
*
|
47 |
*
|
| 48 |
*/
|
48 |
*/
|
| 49 |
public class NewVUI {
|
49 |
public class NewVUI {
|
| - |
|
50 |
private static final String SPACE = " ";
|
| - |
|
51 |
private static final String HYPHON = "-";
|
| - |
|
52 |
|
| 50 |
String contentVersion;
|
53 |
String contentVersion;
|
| 51 |
|
54 |
|
| 52 |
public NewVUI(Long contentVersion) throws Exception {
|
55 |
public NewVUI(Long contentVersion) throws Exception {
|
| 53 |
this.contentVersion = contentVersion.toString();
|
56 |
this.contentVersion = contentVersion.toString();
|
| 54 |
}
|
57 |
}
|
| Line 486... |
Line 489... |
| 486 |
* @param expEntity
|
489 |
* @param expEntity
|
| 487 |
* @return
|
490 |
* @return
|
| 488 |
* @throws Exception
|
491 |
* @throws Exception
|
| 489 |
*/
|
492 |
*/
|
| 490 |
private Map<String, String> getEntityParameters(ExpandedEntity expEntity) throws Exception{
|
493 |
private Map<String, String> getEntityParameters(ExpandedEntity expEntity) throws Exception{
|
| 491 |
Map<String, String> params = new HashMap<String, String>();
|
494 |
Map<String, String> params = new HashMap<String, String>();
|
| 492 |
String title = EntityUtils.getProductName(expEntity);
|
495 |
String title = EntityUtils.getProductName(expEntity);
|
| 493 |
String brandName = expEntity.getBrand().trim();
|
496 |
String brandName = expEntity.getBrand().trim();
|
| 494 |
String productName = ((expEntity.getModelName() != null) ? expEntity
|
497 |
String productName = ((expEntity.getModelName() != null) ? expEntity
|
| 495 |
.getModelName().trim() + " " : "")
|
498 |
.getModelName().trim() + SPACE : "")
|
| 496 |
+ ((expEntity.getModelNumber() != null) ? expEntity
|
499 |
+ ((expEntity.getModelNumber() != null) ? expEntity
|
| 497 |
.getModelNumber().trim() : "");
|
500 |
.getModelNumber().trim() : "");
|
| 498 |
|
501 |
|
| 499 |
String prodName = title;
|
502 |
String prodName = title;
|
| 500 |
if (expEntity.getModelName() != null
|
503 |
if (expEntity.getModelName() != null
|
| 501 |
&& !expEntity.getModelName().isEmpty()
|
504 |
&& !expEntity.getModelName().isEmpty()
|
| 502 |
&& (expEntity.getBrand().equals("Samsung") || expEntity
|
505 |
&& (expEntity.getBrand().equals("Samsung") || expEntity
|
| 503 |
.getBrand().equals("Sony Ericsson"))) {
|
506 |
.getBrand().equals("Sony Ericsson"))) {
|
| 504 |
prodName = expEntity.getBrand().trim()
|
507 |
prodName = expEntity.getBrand().trim()
|
| 505 |
+ " "
|
508 |
+ SPACE
|
| 506 |
+ ((expEntity.getModelName() != null) ? expEntity
|
509 |
+ ((expEntity.getModelName() != null) ? expEntity
|
| 507 |
.getModelName().trim() : "");
|
510 |
.getModelName().trim() : "");
|
| 508 |
}
|
511 |
}
|
| 509 |
String categoryName = expEntity.getCategory().getLabel();
|
512 |
String categoryName = expEntity.getCategory().getLabel();
|
| 510 |
String tagline = "";
|
513 |
String tagline = "";
|
| 511 |
String warranty = "";
|
514 |
String warranty = "";
|
| 512 |
String tinySnippet = "";
|
515 |
String tinySnippet = "";
|
| 513 |
List<Feature> features = expEntity.getSlide(130054).getFeatures();
|
516 |
List<Feature> features = expEntity.getSlide(130054).getFeatures();
|
| 514 |
for (Feature feature : features) {
|
517 |
for (Feature feature : features) {
|
| 515 |
if (feature.getFeatureDefinitionID() == 120084) {
|
518 |
if (feature.getFeatureDefinitionID() == 120084) {
|
| 516 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
|
519 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
|
| 517 |
.getBullets().get(0).getDataObject();
|
520 |
.getBullets().get(0).getDataObject();
|
| 518 |
tagline = dataObject.getValue();
|
521 |
tagline = dataObject.getValue();
|
| 519 |
}
|
522 |
}
|
| 520 |
if (feature.getFeatureDefinitionID() == 120089) {
|
523 |
if (feature.getFeatureDefinitionID() == 120089) {
|
| 521 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
|
524 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
|
| 522 |
.getBullets().get(0).getDataObject();
|
525 |
.getBullets().get(0).getDataObject();
|
| 523 |
tinySnippet = dataObject.getValue();
|
526 |
tinySnippet = dataObject.getValue();
|
| 524 |
}
|
527 |
}
|
| 525 |
if (feature.getFeatureDefinitionID() == 120081) {
|
528 |
if (feature.getFeatureDefinitionID() == 120081) {
|
| 526 |
List<Bullet> bullets = feature.getBullets();
|
529 |
List<Bullet> bullets = feature.getBullets();
|
| 527 |
int count = 1;
|
530 |
int count = 1;
|
| 528 |
for (Bullet bullet : bullets) {
|
531 |
for (Bullet bullet : bullets) {
|
| 529 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) bullet
|
532 |
PrimitiveDataObject dataObject = (PrimitiveDataObject) bullet
|
| 530 |
.getDataObject();
|
533 |
.getDataObject();
|
| 531 |
params.put("SNIPPET_" + count++, dataObject.getValue());
|
534 |
params.put("SNIPPET_" + count++, dataObject.getValue());
|
| 532 |
}
|
- |
|
| 533 |
}
|
- |
|
| 534 |
}
|
- |
|
| 535 |
|
- |
|
| 536 |
boolean warrantyCoverageAdded = false;
|
- |
|
| 537 |
for (Slide slide : expEntity.getSlide(130054).getChildrenSlides()) {
|
- |
|
| 538 |
if (slide.getSlideDefinitionID() == 130105) {
|
- |
|
| 539 |
for (Feature feature : slide.getFeatures()) {
|
- |
|
| 540 |
if (feature.getFeatureDefinitionID() == 120125) {
|
- |
|
| 541 |
ExpandedFeature expFeature = new ExpandedFeature(feature);
|
- |
|
| 542 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(
|
- |
|
| 543 |
0);
|
- |
|
| 544 |
if (expBullet != null) {
|
- |
|
| 545 |
warranty += expBullet.getValue() + " "
|
- |
|
| 546 |
+ expBullet.getUnit().getShortForm();
|
- |
|
| 547 |
}
|
- |
|
| 548 |
}
|
- |
|
| 549 |
if (feature.getFeatureDefinitionID() == 120219) {
|
- |
|
| 550 |
ExpandedFeature expFeature = new ExpandedFeature(feature);
|
- |
|
| 551 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(
|
- |
|
| 552 |
0);
|
- |
|
| 553 |
if (expBullet != null) {
|
- |
|
| 554 |
warranty += " " + expBullet.getExpandedEnumDataObject().getEnumValue().getValue();
|
- |
|
| 555 |
}
|
- |
|
| 556 |
}
|
- |
|
| 557 |
if (feature.getFeatureDefinitionID() == 120220) {
|
- |
|
| 558 |
ExpandedFeature expFeature = new ExpandedFeature(feature);
|
- |
|
| 559 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(
|
- |
|
| 560 |
0);
|
- |
|
| 561 |
if (expBullet != null) {
|
- |
|
| 562 |
warranty += " - " + expBullet.getExpandedEnumDataObject().getEnumValue().getValue();
|
- |
|
| 563 |
warrantyCoverageAdded = true;
|
- |
|
| 564 |
}
|
- |
|
| 565 |
}
|
- |
|
| 566 |
}
|
535 |
}
|
| 567 |
}
|
536 |
}
|
| 568 |
}
|
- |
|
| 569 |
|
- |
|
| 570 |
if (warrantyCoverageAdded) {
|
- |
|
| 571 |
warranty += "<br />";
|
- |
|
| 572 |
}
|
- |
|
| 573 |
else {
|
- |
|
| 574 |
warranty += " - ";
|
- |
|
| 575 |
}
|
537 |
}
|
| 576 |
|
538 |
|
| - |
|
539 |
// Creating warranty string!
|
| - |
|
540 |
for (Slide slide : expEntity.getSlide(130054).getChildrenSlides()) {
|
| - |
|
541 |
if (slide.getSlideDefinitionID() == 130105) {
|
| - |
|
542 |
ExpandedSlide expSlide = new ExpandedSlide(slide);
|
| - |
|
543 |
Feature warrantyDurationFeature = expSlide.getExpandedFeature(120125);
|
| - |
|
544 |
if (warrantyDurationFeature != null) {
|
| - |
|
545 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyDurationFeature);
|
| - |
|
546 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
547 |
if (expBullet != null) {
|
| - |
|
548 |
String shortForm = expBullet.getUnit().getShortForm();
|
| - |
|
549 |
|
| - |
|
550 |
// Append 's' to month and year
|
| - |
|
551 |
if (!expBullet.getValue().trim().equals("1")) {
|
| 577 |
warranty += "With proper bill";
|
552 |
shortForm += "s";
|
| - |
|
553 |
}
|
| - |
|
554 |
warranty += expBullet.getValue() + SPACE + shortForm;
|
| - |
|
555 |
}
|
| - |
|
556 |
}
|
| - |
|
557 |
|
| - |
|
558 |
Feature warrantyTypeFeature = expSlide.getExpandedFeature(120219);
|
| - |
|
559 |
if (warrantyTypeFeature != null) {
|
| - |
|
560 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyTypeFeature);
|
| - |
|
561 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
562 |
if (expBullet != null) {
|
| - |
|
563 |
warranty += SPACE + expBullet.getExpandedEnumDataObject()
|
| - |
|
564 |
.getEnumValue().getValue();
|
| - |
|
565 |
}
|
| - |
|
566 |
}
|
| - |
|
567 |
|
| - |
|
568 |
Feature warrantyCoverageFeature = expSlide.getExpandedFeature(120220);
|
| - |
|
569 |
if (warrantyCoverageFeature != null) {
|
| - |
|
570 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyCoverageFeature);
|
| - |
|
571 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
572 |
if (expBullet != null) {
|
| - |
|
573 |
warranty += SPACE + HYPHON + SPACE + expBullet.getExpandedEnumDataObject().getEnumValue().getValue();
|
| - |
|
574 |
}
|
| - |
|
575 |
}
|
| - |
|
576 |
}
|
| - |
|
577 |
}
|
| 578 |
|
578 |
|
| 579 |
long categoryId = expEntity.getCategory().getID();
|
579 |
long categoryId = expEntity.getCategory().getID();
|
| 580 |
params.put("PROD_NAME", prodName);
|
580 |
params.put("PROD_NAME", prodName);
|
| 581 |
params.put("URL", EntityUtils.getEntityURL(expEntity));
|
581 |
params.put("URL", EntityUtils.getEntityURL(expEntity));
|
| 582 |
params.put("TITLE", title);
|
582 |
params.put("TITLE", title);
|
| 583 |
params.put("BRAND_NAME", brandName);
|
583 |
params.put("BRAND_NAME", brandName);
|
| 584 |
params.put("PRODUCT_NAME", productName);
|
584 |
params.put("PRODUCT_NAME", productName);
|
| 585 |
params.put("CATEGORY_ID", ((int) categoryId) + "");
|
585 |
params.put("CATEGORY_ID", ((int) categoryId) + "");
|
| 586 |
params.put("CATEGORY_NAME", categoryName);
|
586 |
params.put("CATEGORY_NAME", categoryName);
|
| 587 |
params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-")
|
587 |
params.put("CATEGORY_URL", categoryName.replaceAll(SPACE, HYPHON)
|
| 588 |
.toLowerCase() + "/" + categoryId);
|
588 |
.toLowerCase() + "/" + categoryId);
|
| 589 |
params.put(
|
589 |
params.put(
|
| 590 |
"PRODUCT_URL",
|
590 |
"PRODUCT_URL",
|
| 591 |
URLEncoder.encode("http://www.", "UTF-8")
|
591 |
URLEncoder.encode("http://www.", "UTF-8")
|
| 592 |
+ "${domain}"
|
592 |
+ "${domain}"
|
| 593 |
+ URLEncoder.encode(
|
593 |
+ URLEncoder.encode(
|
| 594 |
EntityUtils.getEntityURL(expEntity), "UTF-8"));
|
594 |
EntityUtils.getEntityURL(expEntity), "UTF-8"));
|
| 595 |
if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY
|
595 |
if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY
|
| 596 |
&& expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
|
596 |
&& expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
|
| 597 |
params.put("IS_MOBILE", "TRUE");
|
597 |
params.put("IS_MOBILE", "TRUE");
|
| 598 |
} else {
|
598 |
} else {
|
| 599 |
params.put("IS_MOBILE", "FALSE");
|
599 |
params.put("IS_MOBILE", "FALSE");
|
| 600 |
}
|
600 |
}
|
| 601 |
params.put("CATALOG_ID", expEntity.getID() + "");
|
601 |
params.put("CATALOG_ID", expEntity.getID() + "");
|
| 602 |
params.put("TAGLINE", tagline);
|
602 |
params.put("TAGLINE", tagline);
|
| 603 |
params.put("WARRANTY", warranty);
|
603 |
params.put("WARRANTY", warranty);
|
| 604 |
params.put("TINY_SNIPPET", tinySnippet);
|
604 |
params.put("TINY_SNIPPET", tinySnippet);
|
| 605 |
params.put("IMAGE_PREFIX", EntityUtils.getImagePrefix(expEntity));
|
605 |
params.put("IMAGE_PREFIX", EntityUtils.getMediaPrefix(expEntity));
|
| 606 |
params.put("contentVersion", contentVersion);
|
606 |
params.put("contentVersion", contentVersion);
|
| 607 |
|
607 |
|
| 608 |
return params;
|
608 |
return params;
|
| 609 |
}
|
609 |
}
|
| 610 |
|
610 |
|
| 611 |
|
611 |
|
| 612 |
/**
|
612 |
/**
|
| 613 |
* Generates content for the specified entity embedding links to the
|
613 |
* Generates content for the specified entity embedding links to the
|
| 614 |
* specified domain name.
|
614 |
* specified domain name.
|