Subversion Repositories SmartDukaan

Rev

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

Rev 7073 Rev 7096
Line 10... Line 10...
10
import java.util.HashMap;
10
import java.util.HashMap;
11
import java.util.List;
11
import java.util.List;
12
import java.util.Map;
12
import java.util.Map;
13
 
13
 
14
import org.apache.log4j.Logger;
14
import org.apache.log4j.Logger;
15
import org.apache.struts2.convention.annotation.Action;
15
import org.apache.struts2.convention.annotation.Result;
-
 
16
import org.apache.struts2.convention.annotation.Results;
-
 
17
 
-
 
18
import com.google.gson.Gson;
-
 
19
 
-
 
20
@Results({
-
 
21
    @Result(name = "redirect", location = "${redirectUrl}", type = "redirect")
-
 
22
})
16
 
23
 
17
public class HomeController extends BaseController {
24
public class HomeController extends BaseController {
18
    
25
    
19
    /**
26
    /**
20
     * 
27
     * 
Line 25... Line 32...
25
    private String error = "";
32
    private String error = "";
26
    private String operatorId;
33
    private String operatorId;
27
    private String operatorName;
34
    private String operatorName;
28
    private String serviceName;
35
    private String serviceName;
29
    private String denominationType;
36
    private String denominationType;
30
    private String circleCode;
37
    private String circlecode;
31
    private List<RechargeDenomination> rechargeDenominations = null;
38
    private List<RechargeDenomination> rechargeDenominations = null;
32
    private static final long serialVersionUID = 2079308723099307749L;
39
    private static final long serialVersionUID = 2079308723099307749L;
33
 
40
 
-
 
41
    private String storeIdString;
-
 
42
    private Long storeId;
34
    private static Logger log = Logger.getLogger(Class.class);
43
    private static Logger log = Logger.getLogger(Class.class);
35
    private static Map<Long, String> mobileProvidersMap;
44
    private static Map<Long, String> mobileProvidersMap;
36
    private static Map<Long, String> dthProvidersMap;
45
    private static Map<Long, String> dthProvidersMap;
37
    private static Map<Long, List<RechargePlan>> operatorPlanMap;
46
    private static Map<Long, List<RechargePlan>> operatorPlanMap;
38
    private static String errorMsg = "";
47
    private String errorMsg = "";
-
 
48
    private String redirectUrl;
39
    
49
    
40
    
50
    
41
    static {
51
    static {
42
        TransactionClient tcl;
52
        TransactionClient tcl;
43
        try {
53
        try {
Line 50... Line 60...
50
                if (!plans.isEmpty()) {
60
                if (!plans.isEmpty()) {
51
                    operatorPlanMap.put(operatorId, plans);
61
                    operatorPlanMap.put(operatorId, plans);
52
                }
62
                }
53
            }
63
            }
54
        } catch(Exception e) {
64
        } catch(Exception e) {
55
            setErrorMsg("There seems to be some problem. Please try again.");
65
            ;
56
        }
66
        }
57
    }
67
    }
58
    
68
    
-
 
69
    public String getPlanMapInJson() {
-
 
70
        Gson gson = new Gson();
-
 
71
            return (gson.toJson(operatorPlanMap));
-
 
72
    }
59
    
73
    
60
    @Action("/")
-
 
61
    public String index() {
74
    public String index() {
62
        System.out.println("Index method");
-
 
63
        
75
        
64
//        uri = request.getRequestURI();
-
 
65
//        uri = uri.replace("/", "");
-
 
66
//        log.info("Uri: " + uri);
-
 
67
//        Map<String, String> valueMap = Utils.getOperatorByUri(uri);
76
        String loginStatus = (String) request.getSession().getAttribute("LOGGED_IN");
68
//        operatorId  = valueMap.get("Id");
-
 
69
//        operatorName = valueMap.get("Name"); 
-
 
70
//        serviceName  = valueMap.get("ServiceName");
77
        if(loginStatus != null && loginStatus.equals("TRUE")){
71
//        if(deviceType == null){
78
            return "index";
72
//            deviceType  = valueMap.get("deviceType");
-
 
73
//        }
-
 
74
        
79
        }
75
        return "index";
80
        return "authfail";
76
    }
81
    }
77
    
82
    
78
    public String create() {
83
    public String create() {
79
        return index();
84
        return index();
80
    }
85
    }
Line 101... Line 106...
101
            log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  deviceType, e);
106
            log.error("Unable to get service provider for Device number " + deviceNumber + " and rechargeType : " +  deviceType, e);
102
            return ":";
107
            return ":";
103
        }
108
        }
104
    }
109
    }
105
    
110
    
106
    public String getAllDenominations() {
-
 
107
        TransactionClient tcl;
-
 
108
        try {
-
 
109
            tcl = new TransactionClient();
-
 
110
            rechargeDenominations =  tcl.getClient().getRechargeDenominations(Long.parseLong(operatorId), circleCode, DenominationType.findByValue(Integer.parseInt(denominationType)));
-
 
111
            if(rechargeDenominations == null || rechargeDenominations.isEmpty()) {
-
 
112
                setError("This information is unavailable for now.<br>You can recharge with the amount you normally use or you can try later.");
-
 
113
            }
-
 
114
        } catch (Exception e) {
-
 
115
            log.error("Unable to get rechargeDenominations for operatorId " + operatorId + " and circleCode : " +  circleCode + " and DenominationType : " + denominationType, e);
-
 
116
            setError("This information is unavailable for now.<br>You can recharge with the amount you normally use or you can try later.");
-
 
117
        }
-
 
118
        return "recharge-denomination";
-
 
119
    }
-
 
120
    
-
 
121
//    public String getPlanMapInJson() {
-
 
122
//        Gson gson = new Gson();
-
 
123
//            return (gson.toJson(Utils.getOperatorPlanMap()));
-
 
124
//    }
-
 
125
 
-
 
126
    public void setDeviceType(String incomingdeviceType) {
111
    public void setDeviceType(String incomingdeviceType) {
127
        deviceType = incomingdeviceType;
112
        deviceType = incomingdeviceType;
128
    }
113
    }
129
    
114
    
130
    public void setDeviceNumber(String deviceNumber){
115
    public void setDeviceNumber(String deviceNumber){
Line 177... Line 162...
177
 
162
 
178
    public void setDenominationType(String denominationType) {
163
    public void setDenominationType(String denominationType) {
179
        this.denominationType = denominationType;
164
        this.denominationType = denominationType;
180
    }
165
    }
181
 
166
 
182
    public String getCircleCode() {
167
    public String getCirclecode() {
183
        return circleCode;
168
        return circlecode;
184
    }
169
    }
185
 
170
 
186
    public void setCircleCode(String circleCode) {
171
    public void setCircleCode(String circlecode) {
187
        this.circleCode = circleCode;
172
        this.circlecode = circlecode;
188
    }
173
    }
189
 
174
 
190
    public List<RechargeDenomination> getRechargeDenominations() {
175
    public List<RechargeDenomination> getRechargeDenominations() {
191
        return rechargeDenominations;
176
        return rechargeDenominations;
192
    }
177
    }
Line 198... Line 183...
198
 
183
 
199
    public void setOperatorId(String operatorId) {
184
    public void setOperatorId(String operatorId) {
200
        this.operatorId = operatorId;
185
        this.operatorId = operatorId;
201
    }
186
    }
202
 
187
 
203
    public static void setErrorMsg(String errorMsg) {
188
    public void setErrorMsg(String errorMsg) {
204
        HomeController.errorMsg = errorMsg;
189
        this.errorMsg = errorMsg;
205
    }
190
    }
206
 
191
 
207
    public static String getErrorMsg() {
192
    public String getErrorMsg() {
208
        return errorMsg;
193
        return errorMsg;
209
    }
194
    }
210
 
195
 
211
    public static void setDthProvidersMap(Map<Long, String> dthProvidersMap) {
196
    public static void setDthProvidersMap(Map<Long, String> dthProvidersMap) {
212
        HomeController.dthProvidersMap = dthProvidersMap;
197
        HomeController.dthProvidersMap = dthProvidersMap;
Line 221... Line 206...
221
    }
206
    }
222
 
207
 
223
    public static Map<Long, String> getMobileProvidersMap() {
208
    public static Map<Long, String> getMobileProvidersMap() {
224
        return mobileProvidersMap;
209
        return mobileProvidersMap;
225
    }
210
    }
-
 
211
 
-
 
212
    public Long getStoreId() {
-
 
213
        return storeId;
-
 
214
    }
-
 
215
 
-
 
216
    public void setStoreId(Long storeId) {
-
 
217
        this.storeId = storeId;
-
 
218
    }
-
 
219
 
-
 
220
    public String getRedirectUrl() {
-
 
221
        return redirectUrl;
-
 
222
    }
-
 
223
 
-
 
224
    public void setRedirectUrl(String redirectUrl) {
-
 
225
        this.redirectUrl = redirectUrl;
-
 
226
    }
226
}
227
}
227
228