| 390 |
rajveer |
1 |
package in.shop2020.serving.controllers;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.serving.pages.PageContentKeys;
|
|
|
4 |
import in.shop2020.serving.pages.PageEnum;
|
|
|
5 |
import in.shop2020.serving.pages.PageManager;
|
|
|
6 |
|
|
|
7 |
import java.util.HashMap;
|
|
|
8 |
import java.util.Map;
|
|
|
9 |
import java.util.StringTokenizer;
|
|
|
10 |
|
|
|
11 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
|
|
12 |
import org.apache.struts2.rest.HttpHeaders;
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
public class RatingsController extends BaseController {
|
|
|
18 |
|
|
|
19 |
//id is in format entityID_ratingType_rating_userID
|
|
|
20 |
private String id;
|
|
|
21 |
|
|
|
22 |
private String customer_id;
|
|
|
23 |
|
|
|
24 |
private String entity_id;
|
|
|
25 |
|
|
|
26 |
private String rating_type;
|
|
|
27 |
|
|
|
28 |
private String rating;
|
|
|
29 |
|
|
|
30 |
//Handle /ratings/{id}
|
|
|
31 |
public HttpHeaders show(){
|
|
|
32 |
getFields();
|
|
|
33 |
Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
|
|
|
34 |
params.put(PageContentKeys.ENTITY_ID, entity_id);
|
|
|
35 |
params.put(PageContentKeys.CUSTOMER_ID, customer_id);
|
|
|
36 |
params.put(PageContentKeys.RATING_TYPE, rating_type);
|
|
|
37 |
params.put(PageContentKeys.RATING, rating);
|
|
|
38 |
PageManager.getPageManager().getPageContents(PageEnum.RATINGS_PAGE, params);
|
|
|
39 |
return new DefaultHttpHeaders("show");
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
private void getFields(){
|
|
|
43 |
StringTokenizer tokenizer = new StringTokenizer(id,"_");
|
|
|
44 |
entity_id = tokenizer.nextToken();
|
|
|
45 |
rating_type = tokenizer.nextToken();
|
|
|
46 |
rating = tokenizer.nextToken();
|
|
|
47 |
if(tokenizer.hasMoreTokens()){
|
|
|
48 |
customer_id = tokenizer.nextToken();
|
|
|
49 |
}
|
|
|
50 |
else{
|
|
|
51 |
customer_id = "";
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
}
|