修改空对象异常

This commit is contained in:
YuCheng Hu 2017-10-04 23:39:37 -04:00
parent d4adaa5405
commit c693ecd020
1 changed files with 68 additions and 62 deletions

View File

@ -204,30 +204,30 @@ public class VisaImporter extends DataCrawl {
String visaClassName = StringUtils.trimToEmpty(tds.get(2).text());
if (StringUtils.isNotBlank(visaClassName)) {
switch (visaClassName) {
case "B1":
visaClassName = "B-1";
break;
case "B2":
visaClassName = "B-2";
break;
case "H1":
visaClassName = "H1-B";
break;
case "H4":
visaClassName = "H-4";
break;
case "F1":
visaClassName = "F-1";
break;
case "F2":
visaClassName = "F-2";
break;
case "J1":
visaClassName = "J-1";
break;
case "L1":
visaClassName = "L-1";
break;
case "B1" :
visaClassName = "B-1";
break;
case "B2" :
visaClassName = "B-2";
break;
case "H1" :
visaClassName = "H1-B";
break;
case "H4" :
visaClassName = "H-4";
break;
case "F1" :
visaClassName = "F-1";
break;
case "F2" :
visaClassName = "F-2";
break;
case "J1" :
visaClassName = "J-1";
break;
case "L1" :
visaClassName = "L-1";
break;
}
visa.setVisaClass(visaClassMap.get(visaClassName));
@ -237,12 +237,12 @@ public class VisaImporter extends DataCrawl {
String visaEntryName = StringUtils.upperCase(StringUtils.trimToEmpty(tds.get(3).text()));
if (StringUtils.isNotBlank(visaEntryName)) {
switch (visaEntryName) {
case "NEW":
visa.setVisaEntry(VisaEntry.NEW);
break;
case "RENEWAL":
visa.setVisaEntry(VisaEntry.RENEWAL);
break;
case "NEW" :
visa.setVisaEntry(VisaEntry.NEW);
break;
case "RENEWAL" :
visa.setVisaEntry(VisaEntry.RENEWAL);
break;
}
}
@ -251,27 +251,27 @@ public class VisaImporter extends DataCrawl {
String usEmbassyName = StringUtils.upperCase(StringUtils.trimToEmpty(tds.get(4).text()));
if (StringUtils.isNotBlank(usEmbassyName)) {
switch (usEmbassyName) {
case "BEIJING":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "BeiJing"));
break;
case "CHENGDU":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Chengdu"));
break;
case "GUANGZHOU":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Guangzhou"));
break;
case "SHANGHAI":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Shanghai"));
break;
case "SHENYANG":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Shenyang"));
break;
case "WUHAN":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Wuhan"));
break;
case "HONGKONG":
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "HongKong"));
break;
case "BEIJING" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "BeiJing"));
break;
case "CHENGDU" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Chengdu"));
break;
case "GUANGZHOU" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Guangzhou"));
break;
case "SHANGHAI" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Shanghai"));
break;
case "SHENYANG" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Shenyang"));
break;
case "WUHAN" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "Wuhan"));
break;
case "HONGKONG" :
visa.setUsEmbassy(USFactory.searchUSEmbassy("China", "HongKong"));
break;
}
}
@ -284,15 +284,15 @@ public class VisaImporter extends DataCrawl {
String visaStatusName = StringUtils.upperCase(StringUtils.trimToEmpty(tds.get(6).text()));
if (StringUtils.isNotBlank(visaStatusName)) {
switch (visaStatusName) {
case "CLEAR":
visa.setVisaStatus(VisaStatus.ISSUED);
break;
case "PENDING":
visa.setVisaStatus(VisaStatus.ADMINISTRATIVE_PROCESSING);
break;
case "REJECT":
visa.setVisaStatus(VisaStatus.REFUSED);
break;
case "CLEAR" :
visa.setVisaStatus(VisaStatus.ISSUED);
break;
case "PENDING" :
visa.setVisaStatus(VisaStatus.ADMINISTRATIVE_PROCESSING);
break;
case "REJECT" :
visa.setVisaStatus(VisaStatus.REFUSED);
break;
}
}
@ -372,10 +372,16 @@ public class VisaImporter extends DataCrawl {
String visaStatus = StringUtils.upperCase(StringUtils.replace(visaStatusLog.getVisaStatus().name(), "_", " "));
StringBuffer twitterContent = new StringBuffer("Case Updated ");
twitterContent.append(" [" + visaStatusLog.getVisa().getVisaClass().getVisaClassName() + "]");
// VisaClass
if (visaStatusLog.getVisa().getVisaClass() != null) {
twitterContent.append(" [" + visaStatusLog.getVisa().getVisaClass().getVisaClassName() + "]");
} else {
twitterContent.append(" [ UNKNOW ]");
}
// Embassy
if (visaStatusLog.getVisa().getUsEmbassy() != null) {
twitterContent.append(" -[ #" + StringUtils.trim(visaStatusLog.getVisa().getUsEmbassy().getCity()) + " ] Status To");
twitterContent.append(" - [ #" + StringUtils.trim(visaStatusLog.getVisa().getUsEmbassy().getCity()) + " ] Status To");
} else {
twitterContent.append(" -[ UNKNOW ] Status To");
}