Subversion Repositories SmartDukaan

Rev

Rev 23637 | Go to most recent revision | Details | 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
					});
30
				}
31
			});
32
 
33
	public HttpResponse getReportFile(ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {
34
 
35
		RestClient restClient = new RestClient();
36
		Map<String, String> authMap = projectAuthMap.get(projectName);
37
 
38
		Map<String, String> params = new HashMap<>(authMap);
39
		params.put("xmlin", reportName);
40
		params.put("target_format", "CSV");
41
		params.put("execute_mode", "EXECUTE");
42
		return restClient.getResponse(reporticoUrl, params, new HashMap<>());
43
	}
44
 
45
	public HttpResponse getReportFile(int fofoId, ReporticoProject projectName, String reportName) throws HttpHostConnectException, ProfitMandiBusinessException {
46
 
47
		RestClient restClient = new RestClient();
48
		Map<String, String> authMap = projectAuthMap.get(projectName);
49
 
50
		Map<String, String> params = new HashMap<>(authMap);
51
		params.put("xmlin", reportName);
52
		params.put("target_format", "CSV");
53
		params.put("execute_mode", "EXECUTE");
54
		params.put("fofoId", String.valueOf(fofoId));
55
		return restClient.getResponse(reporticoUrl, params, new HashMap<>());
56
	}
57
}