Subversion Repositories SmartDukaan

Rev

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

Rev 2130 Rev 2227
Line 49... Line 49...
49
		if(args.length == 2){
49
		if(args.length == 2){
50
			inputID = args[1];
50
			inputID = args[1];
51
		}
51
		}
52
		*/
52
		*/
53
		ProductListGenerator generator = new ProductListGenerator();
53
		ProductListGenerator generator = new ProductListGenerator();
54
		generator.generateXMLList();
54
		generator.generateProductsListXML();
-
 
55
		generator.generateProductListJavascript();
55
	}
56
	}
56
	
57
	
57
	public ProductListGenerator() throws Exception {
58
	public ProductListGenerator() throws Exception {
58
		catalogServiceClient = new CatalogServiceClient();
59
		catalogServiceClient = new CatalogServiceClient();
59
		client = catalogServiceClient.getClient();
60
		client = catalogServiceClient.getClient();
Line 146... Line 147...
146
	
147
	
147
	/**
148
	/**
148
	 * Generate the xml list of all the active phones and store in a file
149
	 * Generate the xml list of all the active phones and store in a file
149
	 * @throws Exception
150
	 * @throws Exception
150
	 */
151
	 */
151
	public void generateXMLList() throws Exception {
152
	public void generateProductsListXML() throws Exception {
152
		ArrayList<String> productXMLSnippets = new ArrayList<String>();
153
		ArrayList<String> productXMLSnippets = new ArrayList<String>();
153
		productXMLSnippets.add("<saholic.com>");
154
		productXMLSnippets.add("<saholic.com>");
154
		
155
		
155
		getProductsXML(productXMLSnippets);
156
		getProductsXML(productXMLSnippets);
156
		
157
		
Line 162... Line 163...
162
		
163
		
163
		// Write it to file
164
		// Write it to file
164
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicmobilephones.xml";
165
		String productXMLFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "saholicmobilephones.xml";
165
		DBUtils.store(productDataXML, productXMLFilename);
166
		DBUtils.store(productDataXML, productXMLFilename);
166
	}
167
	}
-
 
168
 
-
 
169
 
-
 
170
 
-
 
171
 
-
 
172
	/**
-
 
173
	 * get xml feed for partner sites
-
 
174
	 * @param irDataXMLSnippets
-
 
175
	 * @throws Exception
-
 
176
	 */
-
 
177
	private void getProductsJavascript(StringBuffer sb) throws Exception{
-
 
178
		
-
 
179
		Map<Long, Entity> entities =  CreationUtils.getEntities();
-
 
180
		for(Entity entity: entities.values()){
-
 
181
			EntityState state = CreationUtils.getEntityState(entity.getID());
-
 
182
			
-
 
183
			ExpandedEntity expEntity = new ExpandedEntity(entity);
-
 
184
			if(expEntity.getCategoryID() == -1 || expEntity.getCategory().getParentCategory().getID() != MOBILE_PHONES){
-
 
185
				continue;
-
 
186
			}
-
 
187
			if(state.getStatus() != EntityStatus.READY){
-
 
188
				continue;
-
 
189
			}
-
 
190
			
-
 
191
			double itemPrice = 0;
-
 
192
			
-
 
193
			List<Item> items = client.getItemsByCatalogId(entity.getID());
-
 
194
			if(items == null){
-
 
195
				continue;
-
 
196
			}
-
 
197
			
-
 
198
			Date todate = new Date();
-
 
199
			Boolean hasActiveItem = false;
-
 
200
			for(Item item: items){
-
 
201
				if((item.getItemStatus() == status.ACTIVE || item.getItemStatus() == status.PAUSED) && todate.getTime() > item.getStartDate()){
-
 
202
						hasActiveItem = true;
-
 
203
				}
-
 
204
				
-
 
205
				if(itemPrice == 0){
-
 
206
					itemPrice = item.getSellingPrice();
-
 
207
				}else if(itemPrice>item.getSellingPrice()){
-
 
208
					itemPrice = item.getSellingPrice();
-
 
209
				}
-
 
210
			}
-
 
211
			if(!hasActiveItem){
-
 
212
				continue;
-
 
213
			}
-
 
214
			
-
 
215
			long categoryID = expEntity.getCategoryID();
-
 
216
			if(categoryID == -1){
-
 
217
				continue;
-
 
218
			}
-
 
219
			String title = expEntity.getBrand() + " " + expEntity.getModelName() + " " + expEntity.getModelNumber();
-
 
220
			sb.append("\"" + title + "\":" + entity.getID());
-
 
221
		}
-
 
222
	}
-
 
223
	
-
 
224
	
-
 
225
	/**
-
 
226
	 * Generate the javascript list of all the active phones and store in a file
-
 
227
	 * @throws Exception
-
 
228
	 */
-
 
229
	public void generateProductListJavascript() throws Exception {
-
 
230
		StringBuffer productsJavascript = new StringBuffer();
-
 
231
		
-
 
232
		productsJavascript.append("var productIdNames={");
-
 
233
		
-
 
234
		getProductsJavascript(productsJavascript);
-
 
235
		
-
 
236
		productsJavascript.append("};");
-
 
237
		
-
 
238
		// Write it to file
-
 
239
		String productXMLFilename = Utils.EXPORT_JAVASCRIPT_CONTENT_PATH + "saholicmobilephones.js";
-
 
240
		DBUtils.store(productsJavascript.toString(), productXMLFilename);
-
 
241
	}
-
 
242
 
167
}
243
}