Subversion Repositories SmartDukaan

Rev

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

Rev 2320 Rev 2436
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
-
 
6
import java.io.File;
-
 
7
import java.io.IOException;
-
 
8
import java.util.HashMap;
-
 
9
import java.util.Map;
-
 
10
 
-
 
11
import org.apache.log4j.Logger;
-
 
12
import org.json.JSONException;
-
 
13
import org.json.JSONObject;
-
 
14
 
-
 
15
import in.shop2020.serving.services.SolrSearchService;
6
import in.shop2020.serving.utils.FileUtils;
16
import in.shop2020.serving.utils.FileUtils;
7
import in.shop2020.serving.utils.Utils;
17
import in.shop2020.serving.utils.Utils;
8
 
18
 
9
 
19
 
10
/**
20
/**
Line 12... Line 22...
12
 * @author Rajveer
22
 * @author Rajveer
13
 *
23
 *
14
 */
24
 */
15
@SuppressWarnings("serial")
25
@SuppressWarnings("serial")
16
public class GlossaryController extends BaseController {
26
public class GlossaryController extends BaseController {
-
 
27
	private static Logger logger = Logger.getLogger(Class.class);
17
 
28
	
18
	private String id;
29
	private String id;
19
	public GlossaryController(){
30
	public GlossaryController(){
20
		super();
31
		super();
21
	}
32
	}
22
 
33
 
Line 39... Line 50...
39
	public String getDefinition(){
50
	public String getDefinition(){
40
		String definition = "";
51
		String definition = "";
41
		try{
52
		try{
42
			definition = FileUtils.read(Utils.EXPORT_ENTITIES_PATH + "../../../ROOT/helpdocs/" + id);
53
			definition = FileUtils.read(Utils.EXPORT_ENTITIES_PATH + "../../../ROOT/helpdocs/" + id);
43
		}catch (Exception e) {
54
		}catch (Exception e) {
44
			
-
 
-
 
55
			logger.error("Unable to read helpdocs file for term " + id, e);
45
		}
56
		}
46
		return definition;
57
		return definition;
47
	}
58
	}
48
 
59
 
-
 
60
    public Map<String, String> getItems(){
-
 
61
    	Map<String, String> snippets = new HashMap<String, String>();
-
 
62
    	if(id==null){
-
 
63
    		return snippets;
-
 
64
    	}
-
 
65
    	SolrSearchService search = new SolrSearchService(id, null, null, 0, 20, null, null, Utils.MOBILE_PHONES_CATEGORY, null);
-
 
66
    	long[] items = search.getResultEntityIDs();
-
 
67
    	if(items != null){
-
 
68
    		for(long item: items){
-
 
69
    			try{
-
 
70
    	    	    JSONObject productPropertiesInJson = new JSONObject(FileUtils.read(Utils.EXPORT_ENTITIES_PATH + item + File.separator + "ProductPropertiesSnippet.html"));
-
 
71
    	    	    String entityUrl = productPropertiesInJson.getString("entityUrl");
-
 
72
    	    	    String entityName = productPropertiesInJson.getString("name");
-
 
73
    	    	    snippets.put(entityName, entityUrl);
-
 
74
    			}catch(IOException ioex){
-
 
75
    				logger.error("Unable to read json file to get product name and product urls.", ioex);
-
 
76
    			} catch (JSONException jsonex) {
-
 
77
    				logger.error("Unable to parse json file.", jsonex);
-
 
78
				}
-
 
79
			}
-
 
80
    	}
-
 
81
    	return snippets;
-
 
82
    }
-
 
83
 
49
	public String getGlossary(){
84
	public String getGlossary(){
50
		String glossary = "";
85
		String glossary = "";
51
		try{
86
		try{
52
			glossary = FileUtils.read(Utils.EXPORT_ENTITIES_PATH + "../../../ROOT/helpdocs/" + "glossary");
87
			glossary = FileUtils.read(Utils.EXPORT_ENTITIES_PATH + "../../../ROOT/helpdocs/" + "glossary");
53
		}catch (Exception e) {
88
		}catch (Exception e) {
54
			
-
 
-
 
89
			logger.error("Unable to read glossary file", e);
55
		}
90
		}
56
		return glossary;
91
		return glossary;
57
	}
92
	}
58
}
93
}