Subversion Repositories SmartDukaan

Rev

Rev 3829 | Rev 3888 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3829 Rev 3869
Line 3... Line 3...
3
import in.shop2020.metamodel.core.Bullet;
3
import in.shop2020.metamodel.core.Bullet;
4
import in.shop2020.metamodel.core.Entity;
4
import in.shop2020.metamodel.core.Entity;
5
import in.shop2020.metamodel.core.Feature;
5
import in.shop2020.metamodel.core.Feature;
6
import in.shop2020.metamodel.core.Media;
6
import in.shop2020.metamodel.core.Media;
7
import in.shop2020.metamodel.core.PrimitiveDataObject;
7
import in.shop2020.metamodel.core.PrimitiveDataObject;
-
 
8
import in.shop2020.metamodel.core.Slide;
8
import in.shop2020.metamodel.definitions.Catalog;
9
import in.shop2020.metamodel.definitions.Catalog;
9
import in.shop2020.metamodel.definitions.Category;
10
import in.shop2020.metamodel.definitions.Category;
10
import in.shop2020.metamodel.util.CreationUtils;
11
import in.shop2020.metamodel.util.CreationUtils;
11
import in.shop2020.metamodel.util.ExpandedBullet;
12
import in.shop2020.metamodel.util.ExpandedBullet;
12
import in.shop2020.metamodel.util.ExpandedEntity;
13
import in.shop2020.metamodel.util.ExpandedEntity;
Line 485... Line 486...
485
	 * @param expEntity
486
	 * @param expEntity
486
	 * @return
487
	 * @return
487
	 * @throws Exception
488
	 * @throws Exception
488
	 */
489
	 */
489
	private Map<String, String> getEntityParameters(ExpandedEntity expEntity) throws Exception{
490
	private Map<String, String> getEntityParameters(ExpandedEntity expEntity) throws Exception{
490
		Map<String,String> params = new HashMap<String, String>();
491
		 Map<String, String> params = new HashMap<String, String>();
491
		String title = EntityUtils.getProductName(expEntity);
492
	        String title = EntityUtils.getProductName(expEntity);
492
		String brandName = expEntity.getBrand().trim();
493
	        String brandName = expEntity.getBrand().trim();
493
		String productName =  ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() + " " : "")
494
	        String productName = ((expEntity.getModelName() != null) ? expEntity
-
 
495
	                .getModelName().trim() + " " : "")
494
		+ ((expEntity.getModelNumber() != null) ? expEntity.getModelNumber().trim() : "");
496
	                + ((expEntity.getModelNumber() != null) ? expEntity
-
 
497
	                        .getModelNumber().trim() : "");
495
		
498
 
496
		String prodName = title;
499
	        String prodName = title;
-
 
500
	        if (expEntity.getModelName() != null
-
 
501
	                && !expEntity.getModelName().isEmpty()
497
		if (expEntity.getModelName() != null && !expEntity.getModelName().isEmpty() && (expEntity.getBrand().equals("Samsung") || expEntity.getBrand().equals("Sony Ericsson"))) {
502
	                && (expEntity.getBrand().equals("Samsung") || expEntity
-
 
503
	                        .getBrand().equals("Sony Ericsson"))) {
-
 
504
	            prodName = expEntity.getBrand().trim()
-
 
505
	                    + " "
498
			prodName = expEntity.getBrand().trim() + " " + ((expEntity.getModelName() != null) ? expEntity.getModelName().trim() : "");
506
	                    + ((expEntity.getModelName() != null) ? expEntity
-
 
507
	                            .getModelName().trim() : "");
499
		}
508
	        }
500
		String categoryName = expEntity.getCategory().getLabel();
509
	        String categoryName = expEntity.getCategory().getLabel();
501
		String tagline = "";
510
	        String tagline = "";
502
		String warranty = "";
511
	        String warranty = "";
503
		String tinySnippet = "";
512
	        String tinySnippet = "";
504
		List<Feature>  features = expEntity.getSlide(130054).getFeatures();
513
	        List<Feature> features = expEntity.getSlide(130054).getFeatures();
505
		for(Feature feature: features){
514
	        for (Feature feature : features) {
506
			if(feature.getFeatureDefinitionID() == 120084){
515
	            if (feature.getFeatureDefinitionID() == 120084) {
507
				PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
516
	                PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
-
 
517
	                        .getBullets().get(0).getDataObject();
508
				tagline = dataObject.getValue(); 
518
	                tagline = dataObject.getValue();
509
			}
519
	            }
510
			if(feature.getFeatureDefinitionID() == 120125){
520
	            if (feature.getFeatureDefinitionID() == 120089) {
511
				ExpandedFeature expFeature = new ExpandedFeature(feature);
521
	                PrimitiveDataObject dataObject = (PrimitiveDataObject) feature
512
				ExpandedBullet expBullet =expFeature.getExpandedBullets().get(0);
-
 
513
				if(expBullet != null){
-
 
514
					warranty = expBullet.getValue() + " "+ expBullet.getUnit().getShortForm();
-
 
515
				}
-
 
516
			}
-
 
517
			if(feature.getFeatureDefinitionID() == 120089){
-
 
518
				PrimitiveDataObject dataObject= (PrimitiveDataObject)feature.getBullets().get(0).getDataObject();
522
	                        .getBullets().get(0).getDataObject();
519
				tinySnippet = dataObject.getValue(); 
523
	                tinySnippet = dataObject.getValue();
520
			}
524
	            }
521
			if(feature.getFeatureDefinitionID() == 120081){
525
	            if (feature.getFeatureDefinitionID() == 120081) {
522
				List<Bullet> bullets = feature.getBullets();
526
	                List<Bullet> bullets = feature.getBullets();
523
				int count = 1;
527
	                int count = 1;
524
				for(Bullet bullet: bullets){
528
	                for (Bullet bullet : bullets) {
525
					PrimitiveDataObject dataObject = (PrimitiveDataObject)bullet.getDataObject();
529
	                    PrimitiveDataObject dataObject = (PrimitiveDataObject) bullet
526
					params.put("SNIPPET_"+count++, dataObject.getValue());
-
 
527
				}
-
 
528
			}
-
 
529
		}
-
 
530
		
-
 
531
		
-
 
532
		long categoryId = expEntity.getCategory().getID();
530
	                            .getDataObject();
533
		params.put("PROD_NAME", prodName);
-
 
534
		params.put("URL", EntityUtils.getEntityURL(expEntity));
531
	                    params.put("SNIPPET_" + count++, dataObject.getValue());
535
		params.put("TITLE", title);
532
	                }
536
		params.put("BRAND_NAME", brandName);
-
 
537
		params.put("PRODUCT_NAME", productName);
-
 
538
		params.put("CATEGORY_ID", ((int)categoryId)+"");
-
 
539
		params.put("CATEGORY_NAME", categoryName);
-
 
540
		params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-").toLowerCase() + "/" + categoryId);
-
 
541
		params.put("PRODUCT_URL", URLEncoder.encode("http://www.", "UTF-8") + "${domain}"  + URLEncoder.encode(EntityUtils.getEntityURL(expEntity), "UTF-8"));
-
 
542
		if(expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY && expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY){
-
 
543
			params.put("IS_MOBILE", "TRUE" );
-
 
544
		}else{
533
	            }
545
			params.put("IS_MOBILE", "FALSE" );
-
 
546
		}
534
	        }
547
		params.put("CATALOG_ID", expEntity.getID()+"");
-
 
548
		params.put("TAGLINE", tagline);
-
 
549
		params.put("WARRANTY", warranty);
-
 
550
		params.put("TINY_SNIPPET", tinySnippet);
-
 
551
		params.put("IMAGE_PREFIX", EntityUtils.getImagePrefix(expEntity));
-
 
552
		params.put("contentVersion", contentVersion);
-
 
553
 
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
	                }
-
 
567
	            }
-
 
568
	        }
-
 
569
 
-
 
570
	        if (warrantyCoverageAdded) {
-
 
571
	            warranty += "<br />";
-
 
572
	        }
-
 
573
	        else {
-
 
574
	            warranty += " - ";
-
 
575
	        }
-
 
576
 
-
 
577
	        warranty += "With proper bill";
-
 
578
 
-
 
579
	        long categoryId = expEntity.getCategory().getID();
-
 
580
	        params.put("PROD_NAME", prodName);
-
 
581
	        params.put("URL", EntityUtils.getEntityURL(expEntity));
-
 
582
	        params.put("TITLE", title);
-
 
583
	        params.put("BRAND_NAME", brandName);
-
 
584
	        params.put("PRODUCT_NAME", productName);
-
 
585
	        params.put("CATEGORY_ID", ((int) categoryId) + "");
-
 
586
	        params.put("CATEGORY_NAME", categoryName);
-
 
587
	        params.put("CATEGORY_URL", categoryName.replaceAll(" ", "-")
-
 
588
	                .toLowerCase() + "/" + categoryId);
-
 
589
	        params.put(
-
 
590
	                "PRODUCT_URL",
-
 
591
	                URLEncoder.encode("http://www.", "UTF-8")
-
 
592
	                        + "${domain}"
-
 
593
	                        + URLEncoder.encode(
-
 
594
	                                EntityUtils.getEntityURL(expEntity), "UTF-8"));
-
 
595
	        if (expEntity.getCategory().getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY
-
 
596
	                && expEntity.getCategory().getID() != Utils.LAPTOPS_CATEGORY) {
-
 
597
	            params.put("IS_MOBILE", "TRUE");
-
 
598
	        } else {
-
 
599
	            params.put("IS_MOBILE", "FALSE");
-
 
600
	        }
-
 
601
	        params.put("CATALOG_ID", expEntity.getID() + "");
-
 
602
	        params.put("TAGLINE", tagline);
-
 
603
	        params.put("WARRANTY", warranty);
-
 
604
	        params.put("TINY_SNIPPET", tinySnippet);
-
 
605
	        params.put("IMAGE_PREFIX", EntityUtils.getImagePrefix(expEntity));
-
 
606
	        params.put("contentVersion", contentVersion);
-
 
607
 
554
		return params;
608
	        return params;
555
	}
609
	 }
556
	
610
	
557
 
611
 
558
	/**
612
	/**
559
	 * Generates content for the specified entity embedding links to the
613
	 * Generates content for the specified entity embedding links to the
560
	 * specified domain name.
614
	 * specified domain name.