Subversion Repositories SmartDukaan

Rev

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

Rev 583 Rev 590
Line 70... Line 70...
70
 
70
 
71
		Map<String,String> htmlSnippet = new HashMap<String, String>();
71
		Map<String,String> htmlSnippet = new HashMap<String, String>();
72
 
72
 
73
		boolean isLoggedIn = Boolean.parseBoolean(params.get("IS_LOGGED_IN"));
73
		boolean isLoggedIn = Boolean.parseBoolean(params.get("IS_LOGGED_IN"));
74
		long userId = Long.parseLong(params.get("USER_ID"));
74
		long userId = Long.parseLong(params.get("USER_ID"));
75
		long cartId = Long.parseLong(params.get("CART_ID"));
-
 
76
		String userName = params.get("USER_NAME");
75
		String userName = params.get("USER_NAME");
77
		
76
		
78
		long categoryId = 100000;
77
		long categoryId = 100000;
79
		long itemCount = Long.parseLong(params.get("ITEM_COUNT"));
78
		long itemCount = Long.parseLong(params.get("ITEM_COUNT"));
80
		//product.setCategoryId(categoryId);
79
		//product.setCategoryId(categoryId);
Line 135... Line 134...
135
 
134
 
136
	public Map<String, String> getRegisterPage(Map<String, String> parameters) {
135
	public Map<String, String> getRegisterPage(Map<String, String> parameters) {
137
		Map<String,String> htmlSnippet = new HashMap<String, String>();
136
		Map<String,String> htmlSnippet = new HashMap<String, String>();
138
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
137
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
139
		long userId = Long.parseLong(parameters.get("USER_ID"));
138
		long userId = Long.parseLong(parameters.get("USER_ID"));
140
		long cartId = Long.parseLong(parameters.get("CART_ID"));
-
 
141
		String userName = parameters.get("USER_NAME");
139
		String userName = parameters.get("USER_NAME");
142
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
140
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
143
		
141
		
144
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
142
		htmlSnippet.put("HEADER", getHeaderHtml(isLoggedIn, userName));
145
		System.out.println("HEADER Snippet generated");
143
		System.out.println("HEADER Snippet generated");
Line 190... Line 188...
190
	public Map<String,String> getHomePage(Map<String, String> parameters) throws TException {
188
	public Map<String,String> getHomePage(Map<String, String> parameters) throws TException {
191
 
189
 
192
		Map<String,String> htmlSnippet = new HashMap<String, String>();
190
		Map<String,String> htmlSnippet = new HashMap<String, String>();
193
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
191
		boolean isLoggedIn = Boolean.parseBoolean(parameters.get("IS_LOGGED_IN"));
194
		long userId = Long.parseLong(parameters.get("USER_ID"));
192
		long userId = Long.parseLong(parameters.get("USER_ID"));
195
		long cartId = Long.parseLong(parameters.get("CART_ID"));
-
 
196
		String userName = parameters.get("USER_NAME");
193
		String userName = parameters.get("USER_NAME");
197
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
194
		long itemCount = Long.parseLong(parameters.get("ITEM_COUNT"));
198
		
195
		
199
		long categoryId = 100000;
196
		long categoryId = 100000;
200
		//product.setCategoryId(categoryId);
197
		//product.setCategoryId(categoryId);
Line 266... Line 263...
266
		Client client = null;
263
		Client client = null;
267
		
264
		
268
		try {
265
		try {
269
			catalogServiceClient = new CatalogServiceClient();
266
			catalogServiceClient = new CatalogServiceClient();
270
			client = catalogServiceClient.getClient();
267
			client = catalogServiceClient.getClient();
271
			List<Long> items = client.getBestSellers(1, 20);
268
			List<Long> items = client.getBestSellersCatalogIds(1, 20);
272
			List<String> itemList = new ArrayList<String>();
269
			List<String> itemList = new ArrayList<String>();
273
			for(Long item: items){
270
			for(Long item: items){
274
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
271
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
275
			}
272
			}
276
			context.put("itemList", itemList);
273
			context.put("itemList", itemList);
Line 294... Line 291...
294
		Client client = null;
291
		Client client = null;
295
		
292
		
296
		try {
293
		try {
297
			catalogServiceClient = new CatalogServiceClient();
294
			catalogServiceClient = new CatalogServiceClient();
298
			client = catalogServiceClient.getClient();
295
			client = catalogServiceClient.getClient();
299
			List<Long> items = client.getLatestArrivals(1,20);
296
			List<Long> items = client.getLatestArrivalsCatalogIds(1,20);
300
			List<String> itemList = new ArrayList<String>();
297
			List<String> itemList = new ArrayList<String>();
301
			for(Long item: items){
298
			for(Long item: items){
302
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
299
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
303
			}
300
			}
304
			context.put("itemList", itemList);
301
			context.put("itemList", itemList);
Line 322... Line 319...
322
		Client client = null;
319
		Client client = null;
323
		
320
		
324
		try {
321
		try {
325
			catalogServiceClient = new CatalogServiceClient();
322
			catalogServiceClient = new CatalogServiceClient();
326
			client = catalogServiceClient.getClient();
323
			client = catalogServiceClient.getClient();
327
			List<Long> items = client.getBestDeals(1,20);
324
			List<Long> items = client.getBestDealsCatalogIds(1,20);
328
			List<String> itemList = new ArrayList<String>();
325
			List<String> itemList = new ArrayList<String>();
329
			for(Long item: items){
326
			for(Long item: items){
330
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
327
				itemList.add(FileUtils.read( Utils.EXPORT_ENTITIES_PATH + item + File.separator +"HomeSnippet.html"));
331
			}
328
			}
332
			context.put("itemList", itemList);
329
			context.put("itemList", itemList);
Line 596... Line 593...
596
	}
593
	}
597
 
594
 
598
 
595
 
599
 
596
 
600
	public String getHeaderHtml(boolean isLoggedIn, String  userName) {
597
	public String getHeaderHtml(boolean isLoggedIn, String  userName) {
601
		String htmlString = "";
-
 
602
		Map<String,String> params = new HashMap<String, String>();
-
 
603
		VelocityContext context = new VelocityContext();
598
		VelocityContext context = new VelocityContext();
604
		if (isLoggedIn) {
599
		if (isLoggedIn) {
605
			context.put("LOGGED_IN", "TRUE");
600
			context.put("LOGGED_IN", "TRUE");
606
			context.put("WELCOME_MESSAGE", "Hi, " + userName);
601
			context.put("WELCOME_MESSAGE", "Hi, " + userName);
607
		} else {
602
		} else {
Line 609... Line 604...
609
			context.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
604
			context.put("WELCOME_MESSAGE", "Hi, Welcome to Shop2020");
610
		}		
605
		}		
611
		
606
		
612
		String templateFile = "templates/header.vm";
607
		String templateFile = "templates/header.vm";
613
		
608
		
614
		htmlString = getHtmlFromVelocity(templateFile, context);
609
		return getHtmlFromVelocity(templateFile, context);
615
		return htmlString;
-
 
616
	}
610
	}
617
 
611
 
618
 
612
 
619
 
613
 
620
	public String getSlideGuideDIV(long productId){
614
	public String getSlideGuideDIV(long productId){
Line 696... Line 690...
696
	}
690
	}
697
 
691
 
698
	private	String getPriceDiv(long productId){
692
	private	String getPriceDiv(long productId){
699
		CatalogServiceClient catalogServiceClient = null;
693
		CatalogServiceClient catalogServiceClient = null;
700
		Client client = null;
694
		Client client = null;
701
		String htmlString = new String();
-
 
702
 
695
 
703
		UserContextServiceClient userServiceClient = null;
696
		UserContextServiceClient userServiceClient = null;
704
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
697
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
705
		try {
698
		try {
706
			catalogServiceClient = new CatalogServiceClient();
699
			catalogServiceClient = new CatalogServiceClient();
Line 793... Line 786...
793
	
786
	
794
	private	String getWidgetDiv(long productId, String userId, WidgetType widgetType, String velocityFileName, Boolean tobeusedLater){
787
	private	String getWidgetDiv(long productId, String userId, WidgetType widgetType, String velocityFileName, Boolean tobeusedLater){
795
		UserContextServiceClient userServiceClient = null;
788
		UserContextServiceClient userServiceClient = null;
796
		in.shop2020.model.v1.user.UserContextService.Client client = null;
789
		in.shop2020.model.v1.user.UserContextService.Client client = null;
797
		
790
		
798
		String htmlString = new String();
-
 
799
		try {
791
		try {
800
			userServiceClient = new UserContextServiceClient();
792
			userServiceClient = new UserContextServiceClient();
801
			client = userServiceClient.getClient();
793
			client = userServiceClient.getClient();
802
			long userID;
794
			long userID;
803
			if(userId.compareTo("") == 0){
795
			if(userId.compareTo("") == 0){
Line 858... Line 850...
858
		}
850
		}
859
		return "Widget";
851
		return "Widget";
860
	}
852
	}
861
	
853
	
862
	private String getItemSnippet(long productId){
854
	private String getItemSnippet(long productId){
863
			StringBuilder htmlString = new StringBuilder();
-
 
864
			String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "WidgetSnippet.html";
855
			String filename = Utils.EXPORT_ENTITIES_PATH + productId + File.separator + "WidgetSnippet.html";
865
			try {
856
			try {
866
				return FileUtils.read(filename);
857
				return FileUtils.read(filename);
867
			} catch (Exception e) {
858
			} catch (Exception e) {
868
				// TODO Auto-generated catch block
859
				// TODO Auto-generated catch block