Subversion Repositories SmartDukaan

Rev

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

Rev 6885 Rev 6902
Line 12... Line 12...
12
import in.shop2020.utils.DataLogger;
12
import in.shop2020.utils.DataLogger;
13
 
13
 
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.ArrayList;
15
import java.util.ArrayList;
16
import java.util.Arrays;
16
import java.util.Arrays;
-
 
17
import java.util.HashMap;
17
import java.util.List;
18
import java.util.List;
-
 
19
import java.util.Map;
18
 
20
 
19
import net.sf.ehcache.CacheManager;
21
import net.sf.ehcache.CacheManager;
20
 
22
 
21
import org.apache.log4j.Logger;
23
import org.apache.log4j.Logger;
22
import org.apache.struts2.convention.annotation.Action;
24
import org.apache.struts2.convention.annotation.Action;
Line 36... Line 38...
36
	private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
38
	private static final String LATEST_ARRIVALS_CACHE_KEY = "home_latest_arrivals_snippet";
37
	
39
	
38
	private List<String> bestDealSnippets = null;
40
	private List<String> bestDealSnippets = null;
39
	private List<String> bestSellerSnippets = null;
41
	private List<String> bestSellerSnippets = null;
40
	private List<String> latestArrivalSnippets = null;
42
	private List<String> latestArrivalSnippets = null;
-
 
43
	private static List<Banner> activeBanners = null;
-
 
44
	private static Map<String, List<BannerMap>> allBannersMap = null;
41
	
45
	
42
	public HomeController(){
46
	public HomeController(){
43
		super();
47
		super();
44
	}
48
	}
45
 
49
 
Line 73... Line 77...
73
	public String destroy() throws SecurityException, IOException{
77
	public String destroy() throws SecurityException, IOException{
74
        logger.info("Reloading best deals, best sellers and latest arrivals");
78
        logger.info("Reloading best deals, best sellers and latest arrivals");
75
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
79
        EhcacheWrapper<String, List<String>> homeSnippetCache = new EhcacheWrapper<String, List<String>>(
76
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
80
                EhcacheWrapper.HOME_PAGE_SNIPPET_CACHE_NAME, CacheManager.create());
77
        homeSnippetCache.removeAll();
81
        homeSnippetCache.removeAll();
-
 
82
        activeBanners = null;
-
 
83
    	allBannersMap = null;
78
	    setSnippets();
84
	    setSnippets();
79
	    return "index";
85
	    return "index";
80
	}
86
	}
81
	
87
	
82
	public List<String> getBestDealSnippets(){
88
	public List<String> getBestDealSnippets(){
Line 116... Line 122...
116
        int latestArrivalCount = 4;
122
        int latestArrivalCount = 4;
117
        
123
        
118
        try {
124
        try {
119
            CatalogClient catalogServiceClient = new CatalogClient();
125
            CatalogClient catalogServiceClient = new CatalogClient();
120
            Client client = catalogServiceClient.getClient();
126
            Client client = catalogServiceClient.getClient();
-
 
127
        
-
 
128
            activeBanners = client.getActiveBanners();
-
 
129
            if(activeBanners != null){
-
 
130
            	allBannersMap = new HashMap<String, List<BannerMap>>();
-
 
131
            	for(Banner banner: activeBanners){
-
 
132
            		allBannersMap.put(banner.getBannerName(), client.getBannerMapDetails(banner.getBannerName()));
-
 
133
            	}
121
            
134
            }
-
 
135
 
-
 
136
        	
122
            //Get top 4 best deals 
137
            //Get top 4 best deals 
123
            bestDealCatalogIds = client.getBestDealsCatalogIds(0, 4, null, -1);
138
            bestDealCatalogIds = client.getBestDealsCatalogIds(0, 4, null, -1);
124
            
139
            
125
            //Get top 8 best sellers b'coz 4 of them may overlap with best deals.
140
            //Get top 8 best sellers b'coz 4 of them may overlap with best deals.
126
            bestSellerCatalogIds = client.getBestSellersCatalogIds(0, 8, null, -1);
141
            bestSellerCatalogIds = client.getBestSellersCatalogIds(0, 8, null, -1);
Line 174... Line 189...
174
        }
189
        }
175
        return snippets;
190
        return snippets;
176
    }
191
    }
177
    
192
    
178
    public List<Banner> getActiveBanners() {
193
    public List<Banner> getActiveBanners() {
179
		try {
-
 
180
			Client catalogClient = new CatalogClient().getClient();
-
 
181
    	    return catalogClient.getActiveBanners();
194
    	return activeBanners;
182
		}
-
 
183
		catch(TException e) {
-
 
184
			return null;
-
 
185
		}
-
 
186
    }
195
    }
187
    
196
    
188
    public List<BannerMap> getbannermapdetails(String bannerName) {
197
    public List<BannerMap> getbannermapdetails(String bannerName) {
189
    	try {
-
 
190
    	Client catalogClient = new CatalogClient().getClient();
-
 
191
    	return catalogClient.getBannerMapDetails(bannerName);
198
    	return allBannersMap.get(bannerName);
192
    	}
-
 
193
    	catch(TException e) {
-
 
194
			return null;
-
 
195
		}
-
 
196
    }
199
    }
197
    
200
    
198
    public int activeBannerCount() {
201
    public int activeBannerCount() {
199
    	try {
-
 
200
    	Client catalogClient = new CatalogClient().getClient();
-
 
201
    	return catalogClient.getActiveBanners().size();
202
    	return activeBanners.size();
202
    	}
-
 
203
    	catch (TException e) {
-
 
204
    		return 0;
-
 
205
    	}
-
 
206
    }
203
    }
207
    
204
    
208
    @Override
205
    @Override
209
	public String getHeaderSnippet() {
206
	public String getHeaderSnippet() {
210
		String url = request.getQueryString();
207
		String url = request.getQueryString();