Subversion Repositories SmartDukaan

Rev

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

Rev 5945 Rev 7897
Line 5... Line 5...
5
import java.text.SimpleDateFormat;
5
import java.text.SimpleDateFormat;
6
import java.util.Calendar;
6
import java.util.Calendar;
7
import java.util.Date;
7
import java.util.Date;
8
import java.util.List;
8
import java.util.List;
9
 
9
 
-
 
10
import in.shop2020.model.v1.catalog.CatalogService;
-
 
11
import in.shop2020.model.v1.catalog.Category;
10
import in.shop2020.model.v1.catalog.Item;
12
import in.shop2020.model.v1.catalog.Item;
11
import in.shop2020.model.v1.catalog.ProductNotificationRequest;
13
import in.shop2020.model.v1.catalog.ProductNotificationRequest;
12
import in.shop2020.model.v1.catalog.ProductNotificationRequestCount;
14
import in.shop2020.model.v1.catalog.ProductNotificationRequestCount;
13
import in.shop2020.thrift.clients.CatalogClient;
15
import in.shop2020.thrift.clients.CatalogClient;
14
import in.shop2020.thrift.clients.HelperClient;
16
import in.shop2020.thrift.clients.HelperClient;
Line 45... Line 47...
45
 
47
 
46
	private static Logger logger = LoggerFactory.getLogger(ProductNotificationsController.class);
48
	private static Logger logger = LoggerFactory.getLogger(ProductNotificationsController.class);
47
	private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
49
	private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
48
	private HttpServletRequest request;
50
	private HttpServletRequest request;
49
	private HttpServletResponse response;
51
	private HttpServletResponse response;
-
 
52
	public Long category;
-
 
53
	public Long categoryId;
50
	
54
	
51
	private List<ProductNotificationRequest> notificationRequests;
55
	private List<ProductNotificationRequest> notificationRequests;
52
	private List<ProductNotificationRequestCount> notificationRequestCounts;
56
	private List<ProductNotificationRequestCount> notificationRequestCounts;
-
 
57
	private static List<Category> parentCategories;
53
 
58
 
-
 
59
	static {
-
 
60
		try {
-
 
61
			CatalogService.Client csc = new CatalogClient().getClient();
-
 
62
			parentCategories = csc.getAllParentCategories();
-
 
63
		} catch (Exception e) {
-
 
64
			logger.error("Unable to get all parent categories in ProductNotificationController", e);
-
 
65
		}
-
 
66
	}
-
 
67
	
54
	public String index()	{
68
	public String index()	{
55
		try	{
69
		try	{
56
			CatalogClient csc = new CatalogClient();
70
			CatalogClient csc = new CatalogClient();
57
			in.shop2020.model.v1.catalog.CatalogService.Client catalogClient= csc.getClient();
71
			in.shop2020.model.v1.catalog.CatalogService.Client catalogClient= csc.getClient();
58
			Date startDate;
72
			Date startDate;
Line 61... Line 75...
61
				startDate = getStartDate(request.getParameter("sp"));
75
				startDate = getStartDate(request.getParameter("sp"));
62
			} else	{
76
			} else	{
63
				startDate = getStartDate("d");
77
				startDate = getStartDate("d");
64
			}
78
			}
65
			logger.info("", startDate);
79
			logger.info("", startDate);
-
 
80
 
66
			notificationRequestCounts = catalogClient.getProductNotificationRequestCount(startDate.getTime());
81
			notificationRequestCounts = catalogClient.getProductNotificationRequestCount(startDate.getTime(), (categoryId==null)?0L:categoryId);
-
 
82
			
67
			logger.info("", notificationRequestCounts);
83
			logger.info("", notificationRequestCounts);
68
		} catch (TException e) {
84
		} catch (TException e) {
69
			logger.error("", e);
85
			logger.error("", e);
70
		}
86
		}
71
		return "index";
87
		return "index";
Line 185... Line 201...
185
	}
201
	}
186
	
202
	
187
	public String getProductNameFromItem(Item item)	{
203
	public String getProductNameFromItem(Item item)	{
188
		return ModelUtils.extractProductNameFromItem(item);
204
		return ModelUtils.extractProductNameFromItem(item);
189
	}
205
	}
-
 
206
 
-
 
207
	public Long getCategoryId() {
-
 
208
		return categoryId;
-
 
209
	}
-
 
210
 
-
 
211
	public void setCategoryId(Long categoryId) {
-
 
212
		this.categoryId = categoryId;
-
 
213
	}
-
 
214
 
-
 
215
	public static List<Category> getParentCategories() {
-
 
216
		return parentCategories;
-
 
217
	}
-
 
218
 
190
}
219
}
191
220