Blame view

src/th/co/ais/ssbsrfc/substate/SubWaitAdjustmentChargeRequestResponse.java 3.29 KB
1048b156   Suraputt Suntimitr   Template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package th.co.ais.ssbsrfc.substate;

import java.util.Date;
import java.util.Random;

import javax.xml.bind.JAXBException;
import javax.xml.stream.XMLStreamException;

import ec02.af.abstracts.AbstractAF;
import ec02.af.data.EquinoxRawData;
import ec02.utils.AppLog;
import th.co.ais.ssbsrfc.config.Constant;
import th.co.ais.ssbsrfc.config.StateConfig;
import th.co.ais.ssbsrfc.instance.AdjustmentRequestRes;
import th.co.ais.ssbsrfc.instance.AdjustmentResponseIns;
import th.co.ais.ssbsrfc.instance.ChargeResponseIns;
import th.co.ais.ssbsrfc.instance.EC02Instance;
import th.co.ais.ssbsrfc.instance.EQXRawInstance;
import th.co.ais.ssbsrfc.instance.ResultHeader;
import th.co.ais.ssbsrfc.message.MessageParser;
import th.co.ais.ssbsrfc.utils.EqxStringUtils;


public class SubWaitAdjustmentChargeRequestResponse extends WaitSubState {
	private ResultHeader res = new ResultHeader();
	private AdjustmentRequestRes adj = new AdjustmentRequestRes();
	private AdjustmentResponseIns adjustresponse = new AdjustmentResponseIns();
	private ChargeResponseIns chargeResponseIns = new ChargeResponseIns();
	
	public void configSubstate(EC02Instance ec02Instance, EquinoxRawData equinoxRawData)
	{
		this._state = StateConfig.SSTATE_W_ADJUSTMENT_CHARGEREQUEST;
		this._eventType = StateConfig.Incoming_Adjustment_ChargeRequest_Response;
		this._stateType = Constant.SUBSTATE_TYPE_W_RESPONSE;
	}

	public Object getMessage(EC02Instance ec02Instance, EquinoxRawData equinoxRawData)
	{ 
		
		String value = EqxStringUtils.getMessage(equinoxRawData, ec02Instance);
		AppLog.d("## PARAMETERS : " + value);
		
		try {
			res = (ResultHeader) MessageParser.formsoapResultHeader(value);
			adj = (AdjustmentRequestRes) MessageParser.formsoapAdjust(value);
		} catch (XMLStreamException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JAXBException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		adjustresponse.setResultHeader(res);
		adjustresponse.setAdjustmentResult(adj);
		ec02Instance.getAFInstance().setAdjustmentResponseIns(adjustresponse);

		Random random = new Random();
		Date time = new Date();
		String x = time.getTime()+"";
		int y = 900000000+random.nextInt(1000);
		String MSGID =x+""+y;
		chargeResponseIns.setResult("000");
		chargeResponseIns.setdesc("SUCCESS");
		chargeResponseIns.setChargingID(MSGID);
		chargeResponseIns.setPrepaidsubscriberflag("1");
		
		return chargeResponseIns;
	}

	public void verifyMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) 
	{ 
		
		this.type = Constant.TYPE_SUCCESS;
	}

	public void buildMessage(AbstractAF abstractAF, EC02Instance ec02Instance, EquinoxRawData equinoxRawData) 
	{ 

		switch (this.type) {
		
			case Constant.TYPE_SUCCESS:
			default: