Subversion Repositories SmartDukaan

Rev

Rev 4882 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4882 Rev 5460
Line 1... Line 1...
1
package in.shop2020.serving.controllers;
1
package in.shop2020.serving.controllers;
2
 
2
 
3
import in.shop2020.serving.cache.SnippetCacheWrapper;
3
import in.shop2020.serving.cache.SnippetCacheWrapper;
4
import in.shop2020.serving.cache.EhcacheWrapper.CacheKeys;
4
import in.shop2020.serving.cache.EhcacheWrapper.CacheKeys;
-
 
5
import in.shop2020.thrift.clients.CatalogClient;
5
 
6
 
6
import java.util.ArrayList;
7
import java.util.ArrayList;
7
import java.util.HashMap;
-
 
8
import java.util.List;
8
import java.util.List;
-
 
9
 
9
import java.util.Map;
10
import org.apache.log4j.Logger;
10
 
11
 
11
/**
12
/**
12
 * @author Varun Gupta
13
 * @author Varun Gupta
13
 */
14
 */
14
@SuppressWarnings("serial")
15
@SuppressWarnings("serial")
15
public class ClearanceSaleController extends BaseController {
16
public class ClearanceSaleController extends BaseController {
16
 
17
 
-
 
18
	private static Logger log = Logger.getLogger(ClearanceSaleController.class);
17
	private List<String> entityIds = new ArrayList<String>();
19
	private List<Long> entityIds = new ArrayList<Long>();
18
	private Map<String, String> snippets = new HashMap<String, String>();
20
	private List<String> snippets = new ArrayList<String>();
-
 
21
	
-
 
22
	CatalogClient catalogClientService = null;
-
 
23
	
-
 
24
	public ClearanceSaleController() {
-
 
25
		super();
-
 
26
		try {
-
 
27
			catalogClientService = new CatalogClient();
-
 
28
			in.shop2020.model.v1.catalog.InventoryService.Client client = catalogClientService.getClient();
-
 
29
			log.info("Getting clearance sale products snippets.");
-
 
30
			entityIds = client.getClearanceSaleCatalogIds();
-
 
31
		} catch (Exception e) {
-
 
32
			log.error("Unable to get clearance sale products from inventory service", e);
-
 
33
		}
-
 
34
	}
19
	
35
	
20
	public String index()	{
36
	public String index()	{
-
 
37
		for(long entityId: entityIds){
-
 
38
			addEntityId(entityId);
-
 
39
		}
21
		return "index";
40
		return "index";
22
	}
41
	}
23
	
42
	
24
	public void addEntityId(String entityId)	{
43
	public void addEntityId(Long entityId)	{
25
		entityIds.add(entityId);
-
 
26
 
44
 
27
	    String snippet = (String) SnippetCacheWrapper.getSnippet(CacheKeys.CATEGORY_SNIPPET_CACHE_KEY, entityId, sourceId);
45
	    String snippet = (String) SnippetCacheWrapper.getSnippet(CacheKeys.CATEGORY_SNIPPET_CACHE_KEY, entityId+"", sourceId);
28
	    
46
	    
29
	    if (snippet != null)	{
47
	    if (snippet != null)	{
30
	        snippets.put(entityId, snippet);
48
	        snippets.add(snippet);
31
	    }
49
	    }
32
	}
50
	}
33
	
51
	
34
	public List<String> getEntityIds()	{
52
	public List<String> getSnippets()	{
35
		return entityIds;
-
 
36
	}
-
 
37
	
-
 
38
	public Map<String, String> getSnippets()	{
-
 
39
		return snippets;
53
		return snippets;
40
	}
54
	}
41
}
55
}
42
56