Subversion Repositories SmartDukaan

Rev

Rev 68 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68 Rev 193
Line 30... Line 30...
30
		
30
		
31
	}
31
	}
32
	
32
	
33
	public TransactionServiceClient()throws Exception{
33
	public TransactionServiceClient()throws Exception{
34
		this(TransactionServiceClient.class.getSimpleName(), ConfigClientKeys.transaction_service_hostname.toString(), ConfigClientKeys.transaction_service_port.toString());
34
		this(TransactionServiceClient.class.getSimpleName(), ConfigClientKeys.transaction_service_hostname.toString(), ConfigClientKeys.transaction_service_port.toString());
-
 
35
		if(transport.isOpen()){
-
 
36
			Logger.log("Transport was already open", this);
-
 
37
		}
-
 
38
		try {
-
 
39
			transport.open();
-
 
40
		} catch (TTransportException e) {
-
 
41
			Logger.log("Encountered exception while open transport "+ e, this);
-
 
42
		}
35
	}
43
	}
36
	
44
	
37
	@PostConstruct
45
	@PostConstruct
38
	private void openTransport(){
46
	private void openTransport(){
39
		if(transport.isOpen()){
47
		if(transport.isOpen()){
Line 47... Line 55...
47
	}
55
	}
48
	
56
	
49
	//Api methods
57
	//Api methods
50
	//TODO: Add logging to this class.
58
	//TODO: Add logging to this class.
51
	
59
	
52
	public void createTransaction(Transaction t) throws Exception{
-
 
53
		client.createTransaction(t);
60
	public Client getClient(){
54
	}
-
 
55
	
-
 
56
	public Transaction getTransactionById(long id) throws Exception{
-
 
57
		return client.getTransaction(id);
61
		return client;
58
	}
-
 
59
	
-
 
60
	public List<Transaction> getAllTransactions(TransactionStatus status, Date from, Date to) throws Exception{
-
 
61
		return client.getAllTransactions(status, from.getTime(), to.getTime());
-
 
62
	}
-
 
63
	
-
 
64
	public List<Transaction> getAllTransactions(ShipmentStatus status, Date from, Date to) throws Exception{
-
 
65
		return client.getTransactionsForShipmentStatus(status, from.getTime(), to.getTime());
-
 
66
	}
-
 
67
	
-
 
68
	public List<Transaction> getAllTransactions(long userId, Date from, Date to, TransactionStatus status) throws Exception{
-
 
69
		return client.getTransactionsForCustomer(userId, from.getTime(), to.getTime(), status);
-
 
70
	}
-
 
71
	
-
 
72
	public List<Transaction> getAllTransactions(long userId, Date from, Date to, ShipmentStatus status) throws Exception{
-
 
73
		return client.getTransactionsForCustomerAndShipmentStatus(userId, from.getTime(), to.getTime(), status);
-
 
74
	}
-
 
75
	
-
 
76
	public TransactionStatus getTransactionStatus(long id) throws Exception{
-
 
77
		return client.getTransactionStatus(id);
-
 
78
	}
-
 
79
	
-
 
80
	public boolean changeTransactionStatus(long id, TransactionStatus newStatus, String description) throws Exception {
-
 
81
		return client.changeTransactionStatus(id, newStatus, description);
-
 
82
	}
-
 
83
	
-
 
84
	public OrderInfo getOrderInfo(long transactionId) throws Exception{
-
 
85
		return client.getOrderInfo(transactionId);
-
 
86
	}
-
 
87
	
-
 
88
	public ShipmentInfo getShipmentInfo(long transactionId) throws Exception{
-
 
89
		return client.getShippingInfo(transactionId);
-
 
90
	}
-
 
91
	
-
 
92
	public BillingInfo getBillingInfo(long transactionId) throws Exception{
-
 
93
		return client.getBillingInfo(transactionId);
-
 
94
	}
-
 
95
	
-
 
96
	public boolean addBilling(long transactionId, Billing billing) throws Exception{
-
 
97
		return client.addBilling(transactionId, billing);
-
 
98
	}
-
 
99
	
-
 
100
	public boolean setShipmentTracker(long transactionId, long shippingId, String trackingId, String airwayBillNo, String provider)throws Exception{
-
 
101
		return client.setShippingTracker(transactionId, shippingId, trackingId, airwayBillNo, provider);
-
 
102
	}
-
 
103
	
-
 
104
	public boolean setShipmentDate(long transactionId, long shippingId, Date date) throws Exception{
-
 
105
		return client.setShippingDate(transactionId, shippingId, date.getTime());
-
 
106
	}
-
 
107
	
-
 
108
	public boolean setDeliveryDate(long transactionId, long shippingId, Date date) throws Exception{
-
 
109
		return client.setDeliveryDate(transactionId, shippingId, date.getTime());
-
 
110
	}
-
 
111
	
-
 
112
	public boolean changeShippingStatus(long transactionId, long shippingId, ShipmentStatus status, String description) throws Exception{
-
 
113
		return client.changeShippingStatus(transactionId, shippingId, status, description);
-
 
114
	}
-
 
115
	
-
 
116
	public boolean addTrail(long transactionId, String message)throws Exception{
-
 
117
		return client.addTrail(transactionId, message);
-
 
118
	}
62
	}
119
	
63
	
120
	@PreDestroy
64
	@PreDestroy
121
	private void closeTransport(){
65
	private void closeTransport(){
122
		if(transport != null && transport.isOpen()){
66
		if(transport != null && transport.isOpen()){