Subversion Repositories SmartDukaan

Rev

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

Rev 2306 Rev 2578
Line 1... Line 1...
1
package in.shop2020.serving.services;
1
package in.shop2020.serving.services;
2
 
2
 
3
import in.shop2020.logistics.Provider;
3
import in.shop2020.logistics.Provider;
4
import in.shop2020.model.v1.catalog.InventoryService.Client;
-
 
5
import in.shop2020.model.v1.catalog.InventoryServiceException;
-
 
6
import in.shop2020.model.v1.order.Order;
4
import in.shop2020.model.v1.order.Order;
7
import in.shop2020.model.v1.user.Address;
5
import in.shop2020.model.v1.user.Address;
8
import in.shop2020.model.v1.user.User;
6
import in.shop2020.model.v1.user.User;
9
import in.shop2020.model.v1.user.UserContextException;
7
import in.shop2020.model.v1.user.UserContextException;
10
import in.shop2020.serving.utils.FileUtils;
-
 
11
import in.shop2020.serving.utils.Utils;
8
import in.shop2020.serving.utils.Utils;
12
import in.shop2020.thrift.clients.CatalogServiceClient;
-
 
13
import in.shop2020.thrift.clients.LogisticsServiceClient;
9
import in.shop2020.thrift.clients.LogisticsServiceClient;
14
import in.shop2020.thrift.clients.TransactionServiceClient;
10
import in.shop2020.thrift.clients.TransactionServiceClient;
15
import in.shop2020.thrift.clients.UserContextServiceClient;
11
import in.shop2020.thrift.clients.UserContextServiceClient;
16
 
12
 
17
import java.io.BufferedReader;
13
import java.io.BufferedReader;
Line 47... Line 43...
47
		String templateFile = "templates/mainbanner.vm";
43
		String templateFile = "templates/mainbanner.vm";
48
		htmlString = getHtmlFromVelocity(templateFile, context);
44
		htmlString = getHtmlFromVelocity(templateFile, context);
49
		return htmlString;
45
		return htmlString;
50
	}
46
	}
51
 
47
 
52
 
-
 
53
	public String getBestSellersHtml() {
-
 
54
		String htmlString = "";
-
 
55
		VelocityContext context = new VelocityContext();
-
 
56
		String templateFile = "templates/bestsellers.vm";
-
 
57
		
-
 
58
		CatalogServiceClient catalogServiceClient = null;
-
 
59
		Client client = null;
-
 
60
		
-
 
61
		try {
-
 
62
			catalogServiceClient = new CatalogServiceClient();
-
 
63
			client = catalogServiceClient.getClient();
-
 
64
			List<Long> items = client.getBestSellersCatalogIds(0, 4, null, -1);
-
 
65
			List<String> itemList = new ArrayList<String>();
-
 
66
			for(Long item: items){
-
 
67
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
-
 
68
			}
-
 
69
			context.put("itemList", itemList);
-
 
70
			
-
 
71
		} catch(Exception e){
-
 
72
			
-
 
73
		}
-
 
74
		
-
 
75
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
76
		return htmlString;	
-
 
77
	}
-
 
78
 
-
 
79
 
-
 
80
	public String getLatestArrivalsHtml() {
-
 
81
		String htmlString = "";
-
 
82
		VelocityContext context = new VelocityContext();
-
 
83
		String templateFile = "templates/latestarrivals.vm";
-
 
84
		
-
 
85
		CatalogServiceClient catalogServiceClient = null;
-
 
86
		Client client = null;
-
 
87
		
-
 
88
		try {
-
 
89
			catalogServiceClient = new CatalogServiceClient();
-
 
90
			client = catalogServiceClient.getClient();
-
 
91
			List<Long> items = client.getLatestArrivalsCatalogIds(0, 4, null, 10003);
-
 
92
			List<String> itemList = new ArrayList<String>();
-
 
93
			for(Long item: items){
-
 
94
				try{
-
 
95
					itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
-
 
96
				}catch(IOException ioex){
-
 
97
					ioex.printStackTrace();
-
 
98
				}
-
 
99
			}
-
 
100
			context.put("itemList", itemList);
-
 
101
			
-
 
102
		} catch(Exception e){
-
 
103
			e.printStackTrace();
-
 
104
		}
-
 
105
		
-
 
106
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
107
		return htmlString;
-
 
108
	}
-
 
109
 
-
 
110
 
-
 
111
	public String getBestDealsHtml() {
-
 
112
		String htmlString = "";
-
 
113
		VelocityContext context = new VelocityContext();
-
 
114
		String templateFile = "templates/bestdeals.vm";
-
 
115
		
-
 
116
		CatalogServiceClient catalogServiceClient = null;
-
 
117
		Client client = null;
-
 
118
		
-
 
119
		try {
-
 
120
			catalogServiceClient = new CatalogServiceClient();
-
 
121
			client = catalogServiceClient.getClient();
-
 
122
			List<Long> items = client.getBestDealsCatalogIds(0,4, null, -1);
-
 
123
			List<String> itemList = new ArrayList<String>();
-
 
124
			for(Long item: items){
-
 
125
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
-
 
126
			}
-
 
127
			context.put("itemList", itemList);
-
 
128
			
-
 
129
		} catch (InventoryServiceException e) {
-
 
130
			// TODO Auto-generated catch block
-
 
131
			e.printStackTrace();
-
 
132
		} catch (TException e) {
-
 
133
			// TODO Auto-generated catch block
-
 
134
			e.printStackTrace();
-
 
135
		} catch (Exception e) {
-
 
136
			// TODO Auto-generated catch block
-
 
137
			e.printStackTrace();
-
 
138
		} 
-
 
139
		
-
 
140
		htmlString = getHtmlFromVelocity(templateFile, context);
-
 
141
		return htmlString;
-
 
142
	}
-
 
143
 
-
 
144
 
-
 
145
	public String getFooterHtml() {
48
	public String getFooterHtml() {
146
		String htmlString = "";
49
		String htmlString = "";
147
		VelocityContext context = new VelocityContext();
50
		VelocityContext context = new VelocityContext();
148
		String templateFile = "templates/footer.vm";
51
		String templateFile = "templates/footer.vm";
149
		htmlString = getHtmlFromVelocity(templateFile, context);
52
		htmlString = getHtmlFromVelocity(templateFile, context);