Subversion Repositories SmartDukaan

Rev

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

Rev 7930 Rev 8353
Line 5... Line 5...
5
import in.shop2020.thrift.clients.config.ConfigClient;
5
import in.shop2020.thrift.clients.config.ConfigClient;
6
 
6
 
7
import java.text.SimpleDateFormat;
7
import java.text.SimpleDateFormat;
8
import java.util.ArrayList;
8
import java.util.ArrayList;
9
import java.util.List;
9
import java.util.List;
-
 
10
 
-
 
11
import org.apache.commons.logging.Log;
-
 
12
import org.apache.commons.logging.LogFactory;
-
 
13
 
10
import com.TrackWebServiceClient;
14
import com.TrackWebServiceClient;
11
import com.fedex.track.stub.ClientDetail;
15
import com.fedex.track.stub.ClientDetail;
12
import com.fedex.track.stub.TrackDetail;
16
import com.fedex.track.stub.TrackDetail;
13
import com.fedex.track.stub.TrackEvent;
17
import com.fedex.track.stub.TrackEvent;
14
import com.fedex.track.stub.TrackReply;
18
import com.fedex.track.stub.TrackReply;
15
import com.fedex.track.stub.WebAuthenticationCredential;
19
import com.fedex.track.stub.WebAuthenticationCredential;
16
import com.fedex.track.stub.WebAuthenticationDetail;
20
import com.fedex.track.stub.WebAuthenticationDetail;
17
 
21
 
18
public class FedExTrackingService {
22
public class FedExTrackingService {
19
 
23
	
-
 
24
	private static final Log log = LogFactory.getLog(FedExTrackingService.class);
20
	private TrackReply trackreply;
25
	private TrackReply trackreply;
21
	/**
26
	/**
22
	 * @param args
27
	 * @param args
23
	 */
28
	 */
24
	
29
	
Line 48... Line 53...
48
	        wac.setPassword(password);
53
	        wac.setPassword(password);
49
         String endPoint="";
54
         String endPoint="";
50
			try {
55
			try {
51
				endPoint = ConfigClient.getClient().get("fedex_endpoint_address_track");
56
				endPoint = ConfigClient.getClient().get("fedex_endpoint_address_track");
52
			} catch (ConfigException e) {
57
			} catch (ConfigException e) {
53
				e.printStackTrace();
58
				log.error("Could not fetch End Point Address", e);
54
			}
59
			}
55
	        
60
	        
56
		trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetail, new WebAuthenticationDetail(wac), endPoint);
61
		trackreply = TrackWebServiceClient.getTrackingUpdates(awbNumber, clientDetail, new WebAuthenticationDetail(wac), endPoint);
57
		if(trackreply!=null){
62
		if(trackreply!=null){
58
			TrackDetail[] trackDetails=trackreply.getTrackDetails();
63
			TrackDetail[] trackDetails=trackreply.getTrackDetails();
Line 60... Line 65...
60
			SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
65
			SimpleDateFormat timeformat = new SimpleDateFormat("HH:mm:ss");
61
			for (int i=0; i< trackDetails.length; i++) {
66
			for (int i=0; i< trackDetails.length; i++) {
62
				TrackEvent trackEvents[]= trackDetails[i].getEvents();
67
				TrackEvent trackEvents[]= trackDetails[i].getEvents();
63
				for(TrackEvent te : trackEvents){
68
				for(TrackEvent te : trackEvents){
64
					ShipmentUpdate shipUpdate = new ShipmentUpdate();
69
					ShipmentUpdate shipUpdate = new ShipmentUpdate();
-
 
70
					if(te.getAddress()!=null){
-
 
71
						if(te.getAddress().getCity()!=null){
65
					shipUpdate.city= te.getAddress().getCity();
72
							shipUpdate.city= te.getAddress().getCity();
-
 
73
						}
-
 
74
						else{
-
 
75
							shipUpdate.city="Unknown";
-
 
76
						}
-
 
77
					}
-
 
78
					else{
-
 
79
						shipUpdate.city="Unknown";
-
 
80
					}
66
					shipUpdate.date= dateformat.format(te.getTimestamp().getTime());
81
					shipUpdate.date= dateformat.format(te.getTimestamp().getTime());
67
					shipUpdate.time= timeformat.format(te.getTimestamp().getTime());
82
					shipUpdate.time= timeformat.format(te.getTimestamp().getTime());
68
					shipUpdate.description= te.getEventDescription();
83
					shipUpdate.description= te.getEventDescription();
69
					updates.add(shipUpdate);
84
					updates.add(shipUpdate);
70
				}			
85
				}			
Line 76... Line 91...
76
		}
91
		}
77
	}
92
	}
78
	
93
	
79
	public static void main(String[] args) {
94
	public static void main(String[] args) {
80
		FedExTrackingService trackClient = new FedExTrackingService();
95
		FedExTrackingService trackClient = new FedExTrackingService();
81
		List<ShipmentUpdate> updates = trackClient.getUpdates("59104178545");
96
		List<ShipmentUpdate> updates = trackClient.getUpdates("796869799244");
82
		for(ShipmentUpdate update: updates){
97
		for(ShipmentUpdate update: updates){
83
			System.out.println(update.toString());
98
			System.out.println(update.toString());
84
		}
99
		}
85
	}
100
	}
86
 
101