Subversion Repositories SmartDukaan

Rev

Rev 23612 | Rev 23651 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23612 amit.gupta 1
package com.spice.profitmandi.common.services;
2
 
3
import java.util.Collections;
4
import java.util.HashMap;
5
import java.util.Map;
6
 
7
import org.apache.http.HttpResponse;
8
import org.apache.http.conn.HttpHostConnectException;
9
import org.springframework.stereotype.Component;
10
 
11
import com.spice.profitmandi.common.enumuration.ReporticoProject;
12
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
13
import com.spice.profitmandi.common.web.client.RestClient;
14
 
15
@Component
16
public class ReporticoService {
17
 
18
	//private String reporticoUrl="http://192.168.134.118/reports/run.php";
19
	private String reporticoUrl="http://50.116.10.120/reports/run.php";
20
 
21
	public static final Map<ReporticoProject, Map<String, String>> projectAuthMap = Collections.unmodifiableMap(
22
			new HashMap<ReporticoProject, Map<String, String>>() {
23
				{
24
					put(ReporticoProject.FOCO, new HashMap<String, String>() {
25
						{
26
							put("project", ReporticoProject.FOCO.getValue());
27
							put("project_password", "foco");
28
						}
29
					});
23637 amit.gupta 30
					put(ReporticoProject.FOCOR, new HashMap<String, String>() {
31
						{
32
							put("project", ReporticoProject.FOCOR.getValue());
33
							put("project_password", "focor");
34
						}
35
					});
23612 amit.gupta 36
				}
37
			});
38
 
39
	public HttpResponse getReportFile(ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {
40
 
41
		RestClient restClient = new RestClient();
42
		Map<String, String> authMap = projectAuthMap.get(projectName);
43
 
44
		Map<String, String> params = new HashMap<>(authMap);
45
		params.put("xmlin", reportName);
46
		params.put("target_format", "CSV");
47
		params.put("execute_mode", "EXECUTE");
48
		return restClient.getResponse(reporticoUrl, params, new HashMap<>());
49
	}
50
 
51
	public HttpResponse getReportFile(int fofoId, ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {
52
 
53
		RestClient restClient = new RestClient();
54
		Map<String, String> authMap = projectAuthMap.get(projectName);
55
 
56
		Map<String, String> params = new HashMap<>(authMap);
57
		params.put("xmlin", reportName);
58
		params.put("target_format", "CSV");
59
		params.put("execute_mode", "EXECUTE");
23637 amit.gupta 60
		params.put("MANUAL_fofoId", String.valueOf(fofoId));
23612 amit.gupta 61
		return restClient.getResponse(reporticoUrl, params, new HashMap<>());
62
	}
63
}