Subversion Repositories SmartDukaan

Rev

Rev 7029 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7026 rajveer 1
package in.shop2020.serving.controllers;
2
 
3
import in.shop2020.config.ConfigException;
4
import in.shop2020.serving.model.ShipmentUpdate;
5
import in.shop2020.thrift.clients.TransactionClient;
6
 
7
import java.util.List;
8
import java.util.ArrayList;
9
 
10
import org.apache.log4j.Logger;
11
 
12
public class RedexpressUpdatesController extends BaseController {
13
 
14
	private static final long serialVersionUID = -7381937038033808767L;
15
 
16
	private static Logger log = Logger.getLogger(Class.class);
17
	private String id;
18
	private List<ShipmentUpdate> updates = new ArrayList<ShipmentUpdate>();
19
 
20
	public RedexpressUpdatesController(){
21
		super();
22
	}
23
 
24
	public String show() {
25
    	log.info("RedExpress Updates Controller " + id);
26
    	try{
27
	    	TransactionClient tc = new TransactionClient();
28
	    	List<String> tokens= tc.getClient().receiveUpdatesForRedExpress(id);
29
	    	for(String token: tokens){
30
	    		String[] parts = token.split("~!~");
31
	    		ShipmentUpdate update = new ShipmentUpdate();
32
	        	update.date = parts[0];
33
	        	update.time = parts[1];
34
	        	update.description = parts[2];
35
	        	update.city = "--";
36
	        	updates.add(update);
37
	    	}
38
    	} catch (Exception e) {
39
    		log.info("Some problem while fetching");
40
    	}
41
		return "show";
42
	}
43
 
44
	public String getId(){
45
		return id;
46
	}
47
 
48
	public void setId(String id){
49
		this.id = id;
50
	}
51
 
52
	public  List<ShipmentUpdate> getUpdates(){
53
		return updates;
54
	}
55
}