diff --git a/services/src/main/java/com/usvisatrack/services/VisaImporter.java b/services/src/main/java/com/usvisatrack/services/VisaImporter.java index c2b7535..ec4528d 100644 --- a/services/src/main/java/com/usvisatrack/services/VisaImporter.java +++ b/services/src/main/java/com/usvisatrack/services/VisaImporter.java @@ -11,7 +11,6 @@ import org.apache.commons.cli.DefaultParser; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; import org.joda.time.DateTime; -import org.joda.time.Hours; import org.joda.time.format.DateTimeFormat; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; @@ -20,10 +19,6 @@ import org.jsoup.select.Elements; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.usvisatrack.core.dao.model.data.UserStatus; -import com.usvisatrack.core.dao.model.data.VisaEntry; -import com.usvisatrack.core.dao.model.data.VisaStatus; -import com.ctc.wstx.util.StringUtil; import com.usvisatrack.core.dao.model.CheckeeVisa; import com.usvisatrack.core.dao.model.ConfApp; import com.usvisatrack.core.dao.model.SocialMedia; @@ -32,6 +27,8 @@ import com.usvisatrack.core.dao.model.User; import com.usvisatrack.core.dao.model.Visa; import com.usvisatrack.core.dao.model.VisaClass; import com.usvisatrack.core.dao.model.VisaStatusLog; +import com.usvisatrack.core.dao.model.data.VisaEntry; +import com.usvisatrack.core.dao.model.data.VisaStatus; import com.usvisatrack.core.factories.ConfFactory; import com.usvisatrack.core.factories.LogFactory; import com.usvisatrack.core.factories.SocialMediaFactory; @@ -207,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)); @@ -240,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; } } @@ -254,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; } } @@ -287,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; } } @@ -376,7 +373,13 @@ public class VisaImporter extends DataCrawl { StringBuffer twitterContent = new StringBuffer("Case Updated "); twitterContent.append(" [" + visaStatusLog.getVisa().getVisaClass().getVisaClassName() + "]"); - twitterContent.append(" -[ #" + visaStatusLog.getVisa().getUsEmbassy().getCity() + " ] Status To"); + // Embassy + if (visaStatusLog.getVisa().getUsEmbassy() != null) { + twitterContent.append(" -[ #" + StringUtils.trim(visaStatusLog.getVisa().getUsEmbassy().getCity()) + " ] Status To"); + } else { + twitterContent.append(" -[ UNKNOW ] Status To"); + } + // Status twitterContent.append(" [ " + visaStatus + " ] in"); dt = new DateTime(visaStatusLog.getDateVisaLastUpdatedDate());