| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import in.shop2020.config.ConfigException;
|
3 |
import in.shop2020.config.ConfigException;
|
| 4 |
import in.shop2020.serving.model.ShipmentUpdate;
|
4 |
import in.shop2020.serving.model.ShipmentUpdate;
|
| 5 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
5 |
import in.shop2020.thrift.clients.config.ConfigClient;
|
| 6 |
|
6 |
|
| - |
|
7 |
import java.text.ParseException;
|
| - |
|
8 |
import java.text.SimpleDateFormat;
|
| 7 |
import java.util.ArrayList;
|
9 |
import java.util.ArrayList;
|
| - |
|
10 |
import java.util.Date;
|
| 8 |
import java.util.List;
|
11 |
import java.util.List;
|
| 9 |
|
12 |
|
| 10 |
import javax.xml.xpath.XPath;
|
13 |
import javax.xml.xpath.XPath;
|
| 11 |
import javax.xml.xpath.XPathConstants;
|
14 |
import javax.xml.xpath.XPathConstants;
|
| 12 |
import javax.xml.xpath.XPathExpressionException;
|
15 |
import javax.xml.xpath.XPathExpressionException;
|
| Line 30... |
Line 33... |
| 30 |
}
|
33 |
}
|
| 31 |
}
|
34 |
}
|
| 32 |
|
35 |
|
| 33 |
public List<ShipmentUpdate> getUpdates(String awbNumber){
|
36 |
public List<ShipmentUpdate> getUpdates(String awbNumber){
|
| 34 |
//String uri = "http://trackntrace.aflwiz.com/aflwiztrack?shpntnum=" + awbNumber;
|
37 |
//String uri = "http://trackntrace.aflwiz.com/aflwiztrack?shpntnum=" + awbNumber;
|
| 35 |
String uri = AFL_URL + awbNumber + ",";
|
38 |
String uri = AFL_URL + awbNumber;
|
| 36 |
log.info("Blue Dart Update URL: " + uri);
|
39 |
log.info("AFL Update URL: " + uri);
|
| 37 |
InputSource inputSource = new InputSource(uri);
|
40 |
InputSource inputSource = new InputSource(uri);
|
| 38 |
XPath xpath = XPathFactory.newInstance().newXPath();
|
41 |
XPath xpath = XPathFactory.newInstance().newXPath();
|
| 39 |
|
42 |
|
| 40 |
String expression = "/SHIPMENTTRACK/SHIPMENTREPORT/CHECKPOINTDETAILS/CHECKPOINTS";
|
43 |
String expression = "/SHIPMENTTRACK/SHIPMENTREPORT/CHECKPOINTDETAILS/CHECKPOINTS";
|
| 41 |
NodeList nodes = null;
|
44 |
NodeList nodes = null;
|
| Line 50... |
Line 53... |
| 50 |
System.out.println("Action date\t\t\tUpdate City\t\t\tTracki Code Desc" );
|
53 |
System.out.println("Action date\t\t\tUpdate City\t\t\tTracki Code Desc" );
|
| 51 |
for(int i=0; i<nodes.getLength(); i++) {
|
54 |
for(int i=0; i<nodes.getLength(); i++) {
|
| 52 |
Element hawbUpdate = (Element) nodes.item(i);
|
55 |
Element hawbUpdate = (Element) nodes.item(i);
|
| 53 |
ShipmentUpdate update = new ShipmentUpdate();
|
56 |
ShipmentUpdate update = new ShipmentUpdate();
|
| 54 |
update.date = getElementTextContent(hawbUpdate, "CHECKDATE");
|
57 |
update.date = getElementTextContent(hawbUpdate, "CHECKDATE");
|
| - |
|
58 |
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd"),
|
| - |
|
59 |
sdfDestination = new SimpleDateFormat("dd-MMM-yyyy");
|
| - |
|
60 |
Date date = null;
|
| - |
|
61 |
try {
|
| - |
|
62 |
date = sdfSource.parse(update.date);
|
| - |
|
63 |
update.date = sdfDestination.format(date);
|
| - |
|
64 |
} catch (ParseException e) {
|
| - |
|
65 |
e.printStackTrace();
|
| - |
|
66 |
}
|
| 55 |
update.time = getElementTextContent(hawbUpdate, "CHECKTIME");
|
67 |
update.time = getElementTextContent(hawbUpdate, "CHECKTIME");
|
| 56 |
update.city = getElementTextContent(hawbUpdate, "LOCATIONNAME");
|
68 |
update.city = getElementTextContent(hawbUpdate, "LOCATIONNAME");
|
| 57 |
update.description = getElementTextContent(hawbUpdate, "CHECKPOINTDESCRIPTION");
|
69 |
update.description = getElementTextContent(hawbUpdate, "CHECKPOINTDESCRIPTION");
|
| 58 |
updates.add(update);
|
70 |
updates.add(update);
|
| 59 |
}
|
71 |
}
|