Subversion Repositories SmartDukaan

Rev

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

Rev 8749 Rev 11706
Line 50... Line 50...
50
        }
50
        }
51
	}
51
	}
52
	
52
	
53
	void generate() throws Exception	{
53
	void generate() throws Exception	{
54
    	List<String> productXMLSnippets = new ArrayList<String>();
54
    	List<String> productXMLSnippets = new ArrayList<String>();
55
		productXMLSnippets.add("<Products>");
55
		productXMLSnippets.add("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
-
 
56
		productXMLSnippets.add("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");
56
		
57
		
57
		for (Entity entity: entities)	{
58
		for (Entity entity: entities)	{
58
			try	{
59
			try	{
59
				long categoryId = defContainer.getCategory(entity.getCategoryID()).getParentCategory().getID();
60
				long categoryId = defContainer.getCategory(entity.getCategoryID()).getParentCategory().getID();
60
				
-
 
61
				if(categoryId != Utils.MOBILE_PHONES_CATAGORY && categoryId != Utils.TABLETS_CATEGORY && categoryId != Utils.LAPTOPS_CATEGORY)	{
-
 
62
					continue;
-
 
63
				}
-
 
64
			} catch (NullPointerException e) {
61
			} catch (NullPointerException e) {
65
				continue;
62
				continue;
66
			}
63
			}
67
			
-
 
68
			String description = "";
-
 
69
			Slide slide = entity.getSlide(130054);
-
 
70
			
-
 
71
			if (slide == null)	continue;
-
 
72
			
-
 
73
			List<Feature> features = slide.getFeatures();
-
 
74
			
-
 
75
			if (features == null)	continue;
-
 
76
			
-
 
77
			for(Feature feature: slide.getFeatures())	{
-
 
78
			
-
 
79
				if (feature.getFeatureDefinitionID() == 120081) {
-
 
80
	                List<Bullet> bullets = feature.getBullets();
-
 
81
	                
-
 
82
	                if (bullets == null)	continue;
-
 
83
	                
-
 
84
	                int counter = 0;
-
 
85
	                
-
 
86
	                for (Bullet bullet : bullets) {
-
 
87
	                	
-
 
88
	                    PrimitiveDataObject dataObject = (PrimitiveDataObject) bullet.getDataObject();
-
 
89
	                    
-
 
90
	                    description += dataObject.getValue();
-
 
91
	                    if(counter < 2)	description += ", ";
-
 
92
	                    counter ++;
-
 
93
	                }
-
 
94
	            }
-
 
95
			}
-
 
96
			if (! entityItemMap.containsKey(entity.getID()))	continue;
64
			if (! entityItemMap.containsKey(entity.getID()))	continue;
97
			
65
			
98
			Item item = entityItemMap.get(entity.getID());
66
			Item item = entityItemMap.get(entity.getID());
99
			String productType = "";
-
 
100
			String url = getProductURL(entity.getID(), item);
67
			String url = getProductURL(entity.getID(), item);
101
			String imageUrl = "http://www.saholic.com/images/website" + File.separator + entity.getID() + File.separator + "thumbnail.jpg";
-
 
102
			
-
 
103
			if (entity.getCategoryID() == 10006)	{
-
 
104
				productType = "Mobile Phone";
-
 
105
			
-
 
106
			} else if (entity.getCategoryID() == 10010)	{
-
 
107
				productType = "Tablet";
-
 
108
				
-
 
109
			} else if (entity.getCategoryID() == 10050)	{
-
 
110
				productType = "Laptop";
-
 
111
			}
-
 
112
			productXMLSnippets.add(this.xmlIndentation[1] + "<Product>");	
-
 
113
			
-
 
114
			productXMLSnippets.add(this.xmlIndentation[2] + "<ID>" + entity.getID() + "</ID>");
-
 
115
			productXMLSnippets.add(this.xmlIndentation[2] + "<Type>" + productType + "</Type>");
-
 
116
			productXMLSnippets.add(this.xmlIndentation[2] + "<Brand>" + item.getBrand() + "</Brand>");
-
 
117
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelName>" + item.getModelName() + "</ModelName>");
-
 
118
			productXMLSnippets.add(this.xmlIndentation[2] + "<ModelNumber>" + item.getModelNumber() + "</ModelNumber>");
-
 
119
			productXMLSnippets.add(this.xmlIndentation[2] + "<URL>" + url + "</URL>");
68
			productXMLSnippets.add(this.xmlIndentation[2] + "<url><loc>" + url + "</loc></url>");
120
			productXMLSnippets.add(this.xmlIndentation[2] + "<ImageURL>" + imageUrl + "</ImageURL>");
-
 
121
			productXMLSnippets.add(this.xmlIndentation[2] + "<ShortDesc>" + StringEscapeUtils.escapeXml(description) + "</ShortDesc>");
-
 
122
			productXMLSnippets.add(this.xmlIndentation[2] + "<MRP>" + item.getMrp() + "</MRP>");
-
 
123
			productXMLSnippets.add(this.xmlIndentation[2] + "<SellingPrice>" + (int)item.getSellingPrice() + "</SellingPrice>");
-
 
124
			
-
 
125
			productXMLSnippets.add(this.xmlIndentation[1] + "</Product>");
-
 
126
		}
69
		}
127
		productXMLSnippets.add("</Products>");
70
		productXMLSnippets.add("</Products>");
128
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
71
		String productDataXML = StringUtils.join(productXMLSnippets, "\n");
129
		
72
		
130
		Utils.info(productDataXML);
73
		Utils.info(productDataXML);