package com.gpc.tams.comm.io; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.type.TypeFactory; import com.gpc.client.common.ClientApplicationContext; import com.gpc.common.*; import com.gpc.common.exception.ApplicationException; import com.gpc.common.util.LockableBoolean; import com.gpc.common.util.azure.monitor.AzureLogger; import com.gpc.common.util.azure.monitor.AzureMonitorFeedLogRecord; import com.gpc.common.util.azure.monitor.LogType; import com.gpc.server.ServerPropConstants; import com.gpc.server.util.ConversionToVO; import com.gpc.valueobjects.common.AddressVO; import com.gpc.valueobjects.common.IDValuePairVO; import com.gpc.valueobjects.customer.CustomerCertificateVO; import com.gpc.valueobjects.customer.CustomerContactVO; import com.gpc.valueobjects.customer.CustomerDeliveryVO; import com.gpc.valueobjects.customer.CustomerVO; import com.gpc.valueobjects.customer.db.TaxTableBracket; import com.gpc.valueobjects.customer.db.TaxTableBracketKey; import com.gpc.valueobjects.inventory.*; import com.gpc.valueobjects.inventory.db.Inventory; import com.gpc.valueobjects.invoice.InvoiceVO; import com.gpc.valueobjects.invoice.line.BaseLineItemVO; import com.gpc.valueobjects.misc.TerminalVO; import com.gpc.valueobjects.ordering.BuyoutItemVO; import com.gpc.valueobjects.ordering.BuyoutVO; import com.gpc.valueobjects.ordering.JoeiPreloadVO; import com.gpc.valueobjects.ordering.notification.OrderNotificationStatus; import com.gpc.valueobjects.ordering.notification.OrderUpdateDetail; import com.gpc.valueobjects.ordering.salesorder.SalesOrderVO; import com.gpc.valueobjects.price.PricesInVO; import com.gpc.valueobjects.price.PricesOutVO; import com.gpc.valueobjects.profile.MultiStoreProfileVO; import com.gpc.valueobjects.profile.PhoneRoomProfileVO; import com.gpc.valueobjects.profile.StoreProfileVO; import com.gpc.valueobjects.regulation.Regulation; import com.gpc.valueobjects.tax.TaxInfoVO; import com.gpc.valueobjects.tax.TaxTableVO; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.log4j.Logger; import javax.swing.*; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*; import static com.gpc.server.util.ConversionToVO.CovertToDateFr; public class PhoneRoomTaapRouter { private static final Logger logger = Logger.getLogger(PhoneRoomTaapRouter.class); public static final String LOCATION = "location"; public static final String SALES_ORDER_ID = "salesOrderId"; public static final String REASON_CODE = "reasonCode"; public static final String INVOICE_TOTAL = "invoiceTotal"; public static final String NUMBER_OF_LINES = "numberOfLines"; public static final String REF_ORDER_STATUS = "refOrderStatusId"; public static final String INVOICED_BY_EMPID = "empId"; public static final String EMP_ID = "id"; public static final String SALESORDERVO_IPADDRESS = "salesorderIPAddress"; public static final String SAVED_INVOICEID = "invoiceId"; public static final String TYPE ="type"; public static final String DATEPARAM="date"; public static final String CUSTID="custId"; public static final String LANG="lang"; //phone room messages changes public static final String EMP_NUM = "employeeNum"; public static final String LOC = "loc"; public static final String PASSWORD = "password"; public static final String IP_ADDRESS = "currentStoreIp"; public static final String STORE_NUM = "currentStoreNum"; public static final String SERVING_STORE_IP_ADDRESS = "servingStoreIPAddress"; //remote store message acknowledge changes public static final String ACK_EMP_NUM = "employeeNum"; public static final String MESSAGE_HEADER_ID = "messageHeaderId"; public static final String CUSTOMERNUM = "custNum"; public static final String EMPNUM = "empNum"; public static final String PARTNUM = "partNum"; public static final String LINEABBR = "lineAbbr"; private static final int TAAP_SERVLET_PORT = 18080; private static final String TAAP_NOTIFY_NOL_WAR_NAME = "/taap/notificationmanagement"; private static final String TAAP_NOTIFY_NOL_ORDER_UPDATE_URI = "/notifyNolOrderUpdate"; private static final String TAAP_NOTIFY_NOL_ORDER_CANCEL_URI = "/notifyNolOrderCancel"; private static final String TAAP_NOTIFY_NOL_ORDER_PICKUP_URI = "/notifyNolOrderPickup"; private static final String TAAP_NOL_ORDER_PAYMENT_VALIDATION_URI = "/nolOrderPaymentValidation"; private static final String TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URI= "/notifyInterstoreOrderAcknowledgement"; private static final String TAAP_NOTIFY_NOL_ORDER_UPDATE_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_UPDATE_URI; private static final String TAAP_NOTIFY_NOL_ORDER_CANCEL_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_CANCEL_URI; private static final String TAAP_NOTIFY_NOL_ORDER_PICKUP_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_NOL_ORDER_PICKUP_URI; private static final String TAAP_NOL_ORDER_PAYMENT_VALIDATION_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOL_ORDER_PAYMENT_VALIDATION_URI; private static final String TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URL = TAAP_SERVLET_PORT + TAAP_NOTIFY_NOL_WAR_NAME + TAAP_NOTIFY_INTERSTORE_ACKNOWLEDGEMENT_URI; private static String ipAddress = null; private static String protocol = null; private static final int TAAP_HTTPS_MESSAGES_SERVLET_PORT = 18080; private static final String TAAP_MESSAGES_WAR_NAME = "/taap/messagemanagement"; private static final String TAAP_MESSAGE_RETRIEVAL_URI = "/retrieveStoreMessages"; private static final String NULL_VALUE = "null"; private static final String TAAP_MESSAGE_RETRIEVAL_URL = TAAP_HTTPS_MESSAGES_SERVLET_PORT + TAAP_MESSAGES_WAR_NAME + TAAP_MESSAGE_RETRIEVAL_URI; private String getProtocol() { if (protocol == null) { ipAddress = System.getProperty("jboss.bind.address"); protocol = "http://"+ipAddress+":"; } return protocol; } public StoreProfileVO getStoreProfile(String remoteStoreIp) { StoreProfileVO storeProfileVO = new StoreProfileVO(); String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/sp"; logger.debug("getEmployeeVOURL = " + url);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); try { long startMilliSeconds = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMilliSeconds = System.currentTimeMillis(); long duration = (endMilliSeconds - startMilliSeconds); createAndLogDataToAzure("Making getStoreProfile remote call","No Query String",remoteStoreIp, statusCode, duration); if (statusCode == HttpStatus.SC_OK) { final byte[] response = httpGet.getResponseBody(); String result = new String(response); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("storeProfile") && !jsonObject.getJSONObject("storeProfile").isNullObject()) { JSONObject storeProfileJSON = jsonObject.getJSONObject("storeProfile"); long startConversionMilliSeconds = System.currentTimeMillis(); storeProfileVO = convertjsonToStoreProfileVO(storeProfileJSON); long endConversionMilliSeconds = System.currentTimeMillis(); long conversionDuration = (endConversionMilliSeconds - startConversionMilliSeconds); createAndLogConversionDataToAzure("Store profile VO conversion ",remoteStoreIp,"storeProfileJSON",conversionDuration); } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return storeProfileVO; } private StoreProfileVO convertjsonToStoreProfileVO(JSONObject storeProfileJSON) { StoreProfileVO storeProfileVO = new StoreProfileVO(); if(storeProfileJSON.containsKey("id") && storeProfileJSON.getString("id")!=null){storeProfileVO.setID(storeProfileJSON.getInt("id"));} if(storeProfileJSON.containsKey("location")&& storeProfileJSON.getString("location")!=null){storeProfileVO.setLocation(storeProfileJSON.getInt("location"));} if(storeProfileJSON.containsKey("storeNum")){storeProfileVO.setStoreNum(storeProfileJSON.getString("storeNum"));} if(storeProfileJSON.containsKey("storeName")){storeProfileVO.setStoreName(storeProfileJSON.getString("storeName"));} if(storeProfileJSON.containsKey("address1")){storeProfileVO.setAddress1(storeProfileJSON.getString("address1"));} if(storeProfileJSON.containsKey("address2")){storeProfileVO.setAddress2(storeProfileJSON.getString("address2"));} if(storeProfileJSON.containsKey("address3")){storeProfileVO.setAddress3(storeProfileJSON.getString("address3"));} if(storeProfileJSON.containsKey("address4")){storeProfileVO.setAddress4(storeProfileJSON.getString("address4"));} if(storeProfileJSON.containsKey("city")){storeProfileVO.setCity(storeProfileJSON.getString("city"));} if(storeProfileJSON.containsKey("postalCode")){storeProfileVO.setPostalCode(storeProfileJSON.getString("postalCode"));} if(storeProfileJSON.containsKey("countyCode")){storeProfileVO.setCountyCode(storeProfileJSON.getString("countyCode"));} if(storeProfileJSON.containsKey("telephoneNum")){storeProfileVO.setTelephoneNum(storeProfileJSON.getString("telephoneNum"));} if(storeProfileJSON.containsKey("faxNum")){storeProfileVO.setFaxNum(storeProfileJSON.getString("faxNum"));} if(storeProfileJSON.containsKey("storeAlias")){storeProfileVO.setStoreAlias(storeProfileJSON.getString("storeAlias"));} if(storeProfileJSON.containsKey("storeType")){storeProfileVO.setStoreType(storeProfileJSON.getString("storeType"));} if(storeProfileJSON.containsKey("tsuInstallDate")){storeProfileVO.setTsuInstallDate(ConvertStringToDate1(storeProfileJSON.getString("tsuInstallDate")));} if(storeProfileJSON.containsKey("unattendedBackup")){storeProfileVO.setUnattendedBackup(ConvertStringToDate1(storeProfileJSON.getString("unattendedBackup")));} if(storeProfileJSON.containsKey("numBusinessDays") && storeProfileJSON.getString("numBusinessDays")!=null){storeProfileVO.setNumBusinessDays(storeProfileJSON.getInt("numBusinessDays"));} if(storeProfileJSON.containsKey("cdinvFlag")&& storeProfileJSON.getString("cdinvFlag")!=null){storeProfileVO.setCdinvFlag(storeProfileJSON.getInt("cdinvFlag"));} if(storeProfileJSON.containsKey("currAcctDay")&& storeProfileJSON.getString("currAcctDay")!=null){storeProfileVO.setCurrAcctDay(storeProfileJSON.getInt("currAcctDay"));} if(storeProfileJSON.containsKey("currentSalesYearMonth")){storeProfileVO.setCurrentSalesYearMonth(ConvertStringToDate1(storeProfileJSON.getString("currentSalesYearMonth")));} if(storeProfileJSON.containsKey("currentQtr")&& storeProfileJSON.getString("currentQtr")!=null){storeProfileVO.setCurrentQtr(storeProfileJSON.getInt("currentQtr"));} if(storeProfileJSON.containsKey("acctMthendDay")&& storeProfileJSON.getString("acctMthendDay")!=null){storeProfileVO.setAcctMthendDay(storeProfileJSON.getInt("acctMthendDay"));} if(storeProfileJSON.containsKey("lastMthFiscalYr")&& storeProfileJSON.getString("lastMthFiscalYr")!=null){storeProfileVO.setLastMthFiscalYr(storeProfileJSON.getInt("lastMthFiscalYr"));} if(storeProfileJSON.containsKey("as400NetworkFlag")&& storeProfileJSON.getString("as400NetworkFlag")!=null){storeProfileVO.setAs400NetworkFlag(storeProfileJSON.getInt("as400NetworkFlag"));} if(storeProfileJSON.containsKey("as400HostName")){storeProfileVO.setAs400HostName(storeProfileJSON.getString("as400HostName"));} if(storeProfileJSON.containsKey("catalogRevisionNum")&& storeProfileJSON.getString("catalogRevisionNum")!=null){storeProfileVO.setCatalogRevisionNum(storeProfileJSON.getInt("catalogRevisionNum"));} if(storeProfileJSON.containsKey("catalogCDLoadDate")){storeProfileVO.setCatalogCDLoadDate(ConvertStringToDate1(storeProfileJSON.getString("catalogCDLoadDate")));} if(storeProfileJSON.containsKey("gstExemptNum")){storeProfileVO.setGstExemptNum(storeProfileJSON.getString("gstExemptNum"));} if(storeProfileJSON.containsKey("environmentalDerogNum")){storeProfileVO.setEnvironmentalDerogNum(storeProfileJSON.getString("environmentalDerogNum"));} if(storeProfileJSON.containsKey("defaultTimeoutMinutes")&& storeProfileJSON.getString("defaultTimeoutMinutes")!=null){storeProfileVO.setDefaultTimeoutMinutes(storeProfileJSON.getInt("defaultTimeoutMinutes"));} if(storeProfileJSON.containsKey("landedResalePriceFactor")){storeProfileVO.setLandedResalePriceFactor(convertStringToBigDecimal(storeProfileJSON.getString("landedResalePriceFactor")));} if(storeProfileJSON.containsKey("landedCostFactor")){storeProfileVO.setLandedCostFactor(convertStringToBigDecimal(storeProfileJSON.getString("landedCostFactor")));} if(storeProfileJSON.containsKey("landedCorePriceFactor")){storeProfileVO.setLandedCorePriceFactor(convertStringToBigDecimal(storeProfileJSON.getString("landedCorePriceFactor")));} if(storeProfileJSON.containsKey("landedCoreCostFactor")){storeProfileVO.setLandedCoreCostFactor(convertStringToBigDecimal(storeProfileJSON.getString("landedCoreCostFactor")));} if(storeProfileJSON.containsKey("currencyConversionFactor")){storeProfileVO.setCurrencyConversionFactor(convertStringToBigDecimal(storeProfileJSON.getString("currencyConversionFactor")));} if(storeProfileJSON.containsKey("currencySymbol")){storeProfileVO.setCurrencySymbol(storeProfileJSON.getString("currencySymbol"));} if(storeProfileJSON.containsKey("currencyDecimals")&& storeProfileJSON.getString("currencyDecimals")!=null){storeProfileVO.setCurrencyDecimals((byte) storeProfileJSON.getInt("currencyDecimals"));} if(storeProfileJSON.containsKey("keepStoreSalesHistoryMonths")&& storeProfileJSON.getString("keepStoreSalesHistoryMonths")!=null){storeProfileVO.setKeepStoreSalesHistoryMonths((byte) storeProfileJSON.getInt("keepStoreSalesHistoryMonths"));} if(storeProfileJSON.containsKey("keepEmployeeSalesHistoryMonths")&& storeProfileJSON.getString("keepReportsMonths")!=null){storeProfileVO.setKeepEmployeeSalesHistoryMonths((byte) storeProfileJSON.getInt("keepEmployeeSalesHistoryMonths"));} if(storeProfileJSON.containsKey("keepReportsMonths")&& storeProfileJSON.getString("keepReportsMonths")!=null){storeProfileVO.setKeepReportsMonths((byte) storeProfileJSON.getInt("keepReportsMonths"));} if(storeProfileJSON.containsKey("keepAlertMonths")&& storeProfileJSON.getString("keepAlertMonths")!=null){storeProfileVO.setKeepAlertMonths((byte) storeProfileJSON.getInt("keepAlertMonths"));} if(storeProfileJSON.containsKey("backupMediaCode")){storeProfileVO.setBackupMediaCode(storeProfileJSON.getString("backupMediaCode"));} if(storeProfileJSON.containsKey("jdeAddressBookNumber")&& storeProfileJSON.getString("ejoeiInUse")!=null){storeProfileVO.setJdeAddressBookNumber(storeProfileJSON.getInt("jdeAddressBookNumber"));} if(storeProfileJSON.containsKey("lastModifiedDate")){storeProfileVO.setLastModifiedDate(ConvertStringToDate(storeProfileJSON.getString("lastModifiedDate")));} if(storeProfileJSON.containsKey("ejoeiInUse")&& storeProfileJSON.getString("ejoeiInUse")!=null){storeProfileVO.setEjoeiInUse((byte) storeProfileJSON.getInt("ejoeiInUse"));} if(storeProfileJSON.containsKey("retailDeliveryFee")){storeProfileVO.setRetailDeliveryFee(storeProfileJSON.getString("retailDeliveryFee"));} if(storeProfileJSON.containsKey("ipcStoreNumber")&& storeProfileJSON.getString("ipcStoreNumber")!=null){storeProfileVO.setIpcStoreNumber(storeProfileJSON.getInt("ipcStoreNumber"));} if(storeProfileJSON.containsKey("federalTaxID")){storeProfileVO.setFederalTaxID(storeProfileJSON.getString("federalTaxID"));} if(storeProfileJSON.containsKey("useMultiStoreBalance")){storeProfileVO.setUseMultiStoreBalance(storeProfileJSON.getString("useMultiStoreBalance"));} if(storeProfileJSON.containsKey("useEmailCustomer")){storeProfileVO.setUseEmailCustomer(storeProfileJSON.getString("useEmailCustomer"));} if(storeProfileJSON.containsKey("useBusinessRulesEngine")){storeProfileVO.setUseBusinessRulesEngine(storeProfileJSON.getString("useBusinessRulesEngine"));} if(storeProfileJSON.containsKey("dbUseGiftCardV2")){storeProfileVO.setDbUseGiftCardV2(storeProfileJSON.getString("dbUseGiftCardV2"));} //if(storeProfileJSON.containsKey("dbUseBopisLog")){storeProfileVO.setDbUseBopisLog(storeProfileJSON.getInt("dbUseBopisLog"));} if(storeProfileJSON.containsKey("companyID")&& storeProfileJSON.getString("companyID")!=null){storeProfileVO.setCompanyId(storeProfileJSON.getInt("companyID"));} if(storeProfileJSON.containsKey("refLanguageCD")){storeProfileVO.setRefLanguageCd(storeProfileJSON.getString("refLanguageCD"));} if(storeProfileJSON.containsKey("modifiedByEmployeeID")&& storeProfileJSON.getString("modifiedByEmployeeID")!=null){storeProfileVO.setModifiedByEmployeeId(storeProfileJSON.getInt("modifiedByEmployeeID"));} if(storeProfileJSON.containsKey("refCountryCD")){storeProfileVO.setRefCountryCd(storeProfileJSON.getString("refCountryCD"));} if(storeProfileJSON.containsKey("refStateCD")){storeProfileVO.setRefStateCd(storeProfileJSON.getString("refStateCD"));} if(storeProfileJSON.containsKey("napaAcctDCCode")&& storeProfileJSON.getString("napaAcctDCCode")!=null){storeProfileVO.setNapaAcctDcCode((short) storeProfileJSON.getInt("napaAcctDCCode"));} if(storeProfileJSON.containsKey("refModemErrorControlID")&& storeProfileJSON.getString("refModemErrorControlID")!=null){storeProfileVO.setRefModemErrorControlId(storeProfileJSON.getInt("refModemErrorControlID"));} if(storeProfileJSON.containsKey("refDateFormatID")&& storeProfileJSON.getString("refDateFormatID")!=null){storeProfileVO.setRefDateFormatId((byte) storeProfileJSON.getInt("refDateFormatID"));} //if(storeProfileJSON.containsKey("division")){storeProfileVO.setDivision(storeProfileJSON.getInt("division"));} if(storeProfileJSON.containsKey("address") && !storeProfileJSON.getJSONObject("address").isNullObject()){ JSONObject j = storeProfileJSON.getJSONObject("address"); AddressVO addressVO = new AddressVO(); if(j.containsKey("extension")){addressVO.setExtension(j.getString("extension"));} if(j.containsKey("phone")){addressVO.setPhone(j.getString("phone"));} if(j.containsKey("city")){addressVO.setCity(j.getString("city"));} if(j.containsKey("postalCode")){addressVO.setPostalCode(j.getString("postalCode"));} if(j.containsKey("address1")){addressVO.setAddress1(j.getString("address1"));} if(j.containsKey("address2")){addressVO.setAddress2(j.getString("address2"));} if(j.containsKey("address3")){addressVO.setAddress3(j.getString("address3"));} if(j.containsKey("address4")){addressVO.setAddress4(j.getString("address4"));} if(j.containsKey("countryCD")){addressVO.setCountryCD(j.getString("countryCD"));} if(j.containsKey("stateCD")){addressVO.setStateCD(j.getString("stateCD"));} //if(j.containsKey("cityStateZip")){addressVO.setCityStateZip(j.getInt("cityStateZip"));} storeProfileVO.setAddress(addressVO); } if(storeProfileJSON.containsKey("indagoInUse")){storeProfileVO.setIndagoInUse(convertLockableJsonObject(storeProfileJSON.getString("indagoInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("gpcOwned")){storeProfileVO.setGpcOwned(convertLockableJsonObject(storeProfileJSON.getString("gpcOwned")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("includeTaxInPrice")){storeProfileVO.setIncludeTaxInPrice(convertLockableJsonObject(storeProfileJSON.getString("includeTaxInPrice")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("useAvgCost")){storeProfileVO.setUseAvgCost(convertLockableJsonObject(storeProfileJSON.getString("useAvgCost")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("useProtobase")){storeProfileVO.setUseProtobase(convertLockableJsonObject(storeProfileJSON.getString("useProtobase")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("jobberAcctInUse")){storeProfileVO.setJobberAcctInUse(convertLockableJsonObject(storeProfileJSON.getString("jobberAcctInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("cashJournalInUse")){storeProfileVO.setCashJournalInUse(convertLockableJsonObject(storeProfileJSON.getString("cashJournalInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("itemPriceIncludesEnvCharges")){storeProfileVO.setItemPriceIncludesEnvCharges(convertLockableJsonObject(storeProfileJSON.getString("itemPriceIncludesEnvCharges")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("useMilitaryTime")){storeProfileVO.setUseMilitaryTime(convertLockableJsonObject(storeProfileJSON.getString("useMilitaryTime")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("dcStore")){storeProfileVO.setDcStore(convertLockableJsonObject(storeProfileJSON.getString("dcStore")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("dcStoreHasInventory")){storeProfileVO.setDcStoreHasInventory(convertLockableJsonObject(storeProfileJSON.getString("dcStoreHasInventory")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("salesLoginAllowed")){storeProfileVO.setSalesLoginAllowed(convertLockableJsonObject(storeProfileJSON.getString("salesLoginAllowed")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("buyoutPickupPOInUse")){storeProfileVO.setBuyoutPickupPOInUse(convertLockableJsonObject(storeProfileJSON.getString("buyoutPickupPOInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("rgnInUse")){storeProfileVO.setRgnInUse(convertLockableJsonObject(storeProfileJSON.getString("rgnInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("multiStoreInUse")){storeProfileVO.setMultiStoreInUse(convertLockableJsonObject(storeProfileJSON.getString("multiStoreInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("copyCatalogInfoToHarddrive")){storeProfileVO.setCopyCatalogInfoToHarddrive(convertLockableJsonObject(storeProfileJSON.getString("copyCatalogInfoToHarddrive")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("servingDCOnJDE")){storeProfileVO.setServingDCOnJDE(convertLockableJsonObject(storeProfileJSON.getString("servingDCOnJDE")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("employeeAccessValidation")){storeProfileVO.setEmployeeAccessValidation(convertLockableJsonObject(storeProfileJSON.getString("employeeAccessValidation")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("phoneRoomInUse")){storeProfileVO.setPhoneRoomInUse(convertLockableJsonObject(storeProfileJSON.getString("phoneRoomInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("ibsPortalInUse")){storeProfileVO.setIbsPortalInUse(convertLockableJsonObject(storeProfileJSON.getString("ibsPortalInUse")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("useNapaXpress")){storeProfileVO.setUseNapaXpress(convertLockableJsonObject(storeProfileJSON.getString("useNapaXpress")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(storeProfileJSON.containsKey("manageGpAtPos")){storeProfileVO.setManageGpAtPos(convertLockableJsonObject(storeProfileJSON.getString("manageGpAtPos")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} return storeProfileVO; } public String getSpecialFuntionDescription(String lineAbbrev, String storeLanguageCd, String remoteStoreIp) { String deliveryDescription = ""; String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/special"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbrev), new NameValuePair("lang", storeLanguageCd)}); try { long startMilliSeconds = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMilliSeconds = System.currentTimeMillis(); long duration = (endMilliSeconds - startMilliSeconds); createAndLogDataToAzure("Making getSpecialFuntionDescription remote call",httpGet.getQueryString(),remoteStoreIp, statusCode, duration); if (statusCode == HttpStatus.SC_OK) { final byte[] delDescResponse = httpGet.getResponseBody(); String result = new String(delDescResponse); return deliveryDescription; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return deliveryDescription; } public boolean isRebateApplicable(BaseLineItemVO baseLineItemVO, InvoiceVO invoiceVO,String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/rebate"; if (baseLineItemVO == null){ return false; } Integer customerID = invoiceVO.getCustomerID(); Integer loc = invoiceVO.getLOC(); if ((customerID == null) || (loc == null)){ return false; } if(baseLineItemVO.isCoreTransaction().booleanValue()) { return false; } Integer iCustID = customerID.intValue(), iLOC = loc.intValue(); logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); //doubt date value Date d = new Date(); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", baseLineItemVO.getLineAbbr().trim()), new NameValuePair("part", baseLineItemVO.getPartNum()!=null?baseLineItemVO.getPartNum():""), new NameValuePair("custId", iCustID.toString()), new NameValuePair("loc", invoiceVO.getLOC().toString()), new NameValuePair("uc", baseLineItemVO.getUnitCost().toString()), new NameValuePair("up", baseLineItemVO.getUnitPrice().toString()), new NameValuePair("ct", baseLineItemVO.getCoreTransaction().toString())}); try { long startMilliSeconds = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMilliSeconds = System.currentTimeMillis(); long duration = (endMilliSeconds - startMilliSeconds); createAndLogDataToAzure("Making isRebateApplicable remote call",httpGet.getQueryString(),remoteStoreIp, statusCode, duration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return false; } public String getInvoiceLineDescription(Integer id, String storeLanguageCd, String remoteStoreIp) { String lineDesc = ""; String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/invoicelinedesc"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("id", id.toString()), new NameValuePair("lang", storeLanguageCd)}); try { long startMilliSeconds = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMilliSeconds = System.currentTimeMillis(); long duration = (endMilliSeconds - startMilliSeconds); createAndLogDataToAzure("Making getInvoiceLineDescription remote call",httpGet.getQueryString(),remoteStoreIp, statusCode, duration); if (statusCode == HttpStatus.SC_OK) { final byte[] delDescResponse = httpGet.getResponseBody(); String result = new String(delDescResponse); if(result!=null)return result; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return lineDesc; } public InventoryVO getPartDetailInfo(CustomerVO customerVO, String lineAbbr, String partNum, Boolean b, String remoteStoreIp, String language,Boolean kitVOFlag) { InventoryVO inventoryVO = null; String getInventoryVOURL = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/partinfo"; logger.debug("getInventoryVOURL = " + getInventoryVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getInventoryVOURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbr), new NameValuePair("lang", language), new NameValuePair("part", partNum), new NameValuePair("loc", customerVO.getLOC().toString()), new NameValuePair("flag",b.toString()), new NameValuePair("custNo",customerVO.getCustomerNumber().toString()), new NameValuePair("kitVOFlag",kitVOFlag.toString())}); try { long startMilliSeconds = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMilliSeconds = System.currentTimeMillis(); long duration = (endMilliSeconds - startMilliSeconds); createAndLogDataToAzure("Making getPartDetailInfo remote call",httpGet.getQueryString(),remoteStoreIp, statusCode, duration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("inventoryVO") && !jsonObject.getJSONObject("inventoryVO").isNullObject()) { JSONObject invJson = jsonObject.getJSONObject("inventoryVO"); long millSec = System.currentTimeMillis(); inventoryVO = convertjsonToInventoryVO(invJson); long endMillSec = System.currentTimeMillis(); long conDuration = (endMillSec-millSec); createAndLogConversionDataToAzure("Conversion of convertjsonToInventoryVO vo starts",remoteStoreIp,invJson.toString(),conDuration); return inventoryVO; }else if (jsonObject.containsKey("kitInventoryVO") && !jsonObject.getJSONObject("kitInventoryVO").isNullObject()) { inventoryVO = new KitInventoryVO(); JSONObject kitInventoryJSON = jsonObject.getJSONObject("kitInventoryVO"); kitInventoryJSON.put("forKitInventory","true"); long millSec = System.currentTimeMillis(); inventoryVO = convertjsonToKIVO(kitInventoryJSON); long endMillSec = System.currentTimeMillis(); long conDuration = (endMillSec-millSec); createAndLogConversionDataToAzure("Conversion of convertjsonToKitInventoryVO vo starts",remoteStoreIp,kitInventoryJSON.toString(),conDuration); return inventoryVO; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return inventoryVO; } public InventoryVO convertjsonToInventoryVO(JSONObject invJson) { InventoryVO invVO = new InventoryVO(); boolean forKitInventoryConversion =false; if(invJson.containsKey("forKitInventory") && invJson.getString("forKitInventory").equalsIgnoreCase("true")){ invVO = new KitInventoryVO(); forKitInventoryConversion=true; } if(invJson.containsKey("id") && invJson.getString("id")!=null){invVO.setID(invJson.getInt("id"));} if(invJson.containsKey("loc")&& invJson.getString("loc")!=null){invVO.setLOC(invJson.getInt("loc"));} if(invJson.containsKey("currentYearRefClassCD")){invVO.setCurrentYearRefClassCD(invJson.getString("currentYearRefClassCD"));} if(invJson.containsKey("refSeasonalFlagCD")){invVO.setRefSeasonalFlagCD(invJson.getString("refSeasonalFlagCD"));} if(invJson.containsKey("refUnitDesignatorCD")){invVO.setRefUnitDesignatorCD(invJson.getString("refUnitDesignatorCD"));} if(invJson.containsKey("refUnitDesignatorDescription")){invVO.setRefUnitDesignatorDescription(invJson.getString("refUnitDesignatorDescription"));} if(invJson.containsKey("perCarQty")&& invJson.getString("perCarQty")!=null){invVO.setPerCarQty((short) invJson.getInt("perCarQty"));} if(invJson.containsKey("supplierID")&& invJson.getString("supplierID")!=null){invVO.setSupplierID((short) invJson.getInt("supplierID"));} if(invJson.containsKey("supplierName")){invVO.setSupplierName(invJson.getString("supplierName"));} if(invJson.containsKey("standardPkg")&& invJson.getString("standardPkg")!=null){invVO.setStandardPkg((short) invJson.getInt("standardPkg"));} if(invJson.containsKey("factoryStdPkg")&& invJson.getString("factoryStdPkg")!=null){invVO.setFactoryStdPkg((short) invJson.getInt("factoryStdPkg"));} if(invJson.containsKey("caseQty")&& invJson.getString("caseQty")!=null){invVO.setCaseQty((short) invJson.getInt("caseQty"));} if(invJson.containsKey("refSeasonalFlagDescription")){invVO.setRefSeasonalFlagDescription(invJson.getString("refSeasonalFlagDescription"));} if(invJson.containsKey("isLockResalePrices")&& invJson.getString("isLockResalePrices")!=null){invVO.setLockResalePrices(invJson.getBoolean("isLockResalePrices"));} if(invJson.containsKey("isLockCoreCost")&& invJson.getString("isLockCoreCost")!=null){invVO.setLockCoreCost(invJson.getBoolean("isLockCoreCost"));} if(invJson.containsKey("isReportable")&& invJson.getString("isReportable")!=null){invVO.setReportable(invJson.getBoolean("isReportable"));} if(invJson.containsKey("taxStatusPrimaryRefOptnCD")){invVO.setTaxStatusPrimaryRefOptnCD(invJson.getString("taxStatusPrimaryRefOptnCD"));} if(invJson.containsKey("taxStatusSecondaryRefOptnCD")){invVO.setTaxStatusSecondaryRefOptnCD(invJson.getString("taxStatusSecondaryRefOptnCD"));} if(invJson.containsKey("coreSalesTaxStatusPrimaryRefOptnCD")){invVO.setCoreSalesTaxStatusPrimaryRefOptnCD(invJson.getString("coreSalesTaxStatusPrimaryRefOptnCD"));} if(invJson.containsKey("coreSalesTaxStatusSecondaryRefOptnCD")){invVO.setCoreSalesTaxStatusSecondaryRefOptnCD(invJson.getString("coreSalesTaxStatusSecondaryRefOptnCD"));} if(invJson.containsKey("coreReturnsTaxStatusPrimaryRefOptnCD")){invVO.setCoreReturnsTaxStatusPrimaryRefOptnCD(invJson.getString("coreReturnsTaxStatusPrimaryRefOptnCD"));} if(invJson.containsKey("coreReturnsTaxStatusSecondaryRefOptnCD")){invVO.setCoreReturnsTaxStatusSecondaryRefOptnCD(invJson.getString("coreReturnsTaxStatusSecondaryRefOptnCD"));} if(invJson.containsKey("list")){invVO.setList(convertStringToBigDecimal(invJson.getString("list")));} if(invJson.containsKey("red")){invVO.setRed(convertStringToBigDecimal(invJson.getString("red")));} if(invJson.containsKey("yellow")){invVO.setYellow(convertStringToBigDecimal(invJson.getString("yellow")));} if(invJson.containsKey("green")){invVO.setGreen(convertStringToBigDecimal(invJson.getString("green")));} if(invJson.containsKey("pink")){invVO.setPink(convertStringToBigDecimal(invJson.getString("pink")));} if(invJson.containsKey("masterInstaller")){invVO.setMasterInstaller(convertStringToBigDecimal(invJson.getString("masterInstaller")));} if(invJson.containsKey("blue")){invVO.setBlue(convertStringToBigDecimal(invJson.getString("blue")));} if(invJson.containsKey("corePrice")){invVO.setCorePrice(convertStringToBigDecimal(invJson.getString("corePrice")));} if(invJson.containsKey("cost")){invVO.setCost(convertStringToBigDecimal(invJson.getString("cost")));} if(invJson.containsKey("jobberStockedCost")){invVO.setJobberStockedCost(convertStringToBigDecimal(invJson.getString("jobberStockedCost")));} if(invJson.containsKey("jobberNonStockedCost")){invVO.setJobberNonStockedCost(convertStringToBigDecimal(invJson.getString("jobberNonStockedCost")));} if(invJson.containsKey("coreCost")){invVO.setCoreCost(convertStringToBigDecimal(invJson.getString("coreCost")));} if(invJson.containsKey("jobberCoreCost")){invVO.setJobberCoreCost(convertStringToBigDecimal(invJson.getString("jobberCoreCost")));} if(invJson.containsKey("storeRetailPrice1")){invVO.setStoreRetailPrice1(convertStringToBigDecimal(invJson.getString("storeRetailPrice1")));} if(invJson.containsKey("storeRetailPrice2")){invVO.setStoreRetailPrice2(convertStringToBigDecimal(invJson.getString("storeRetailPrice2")));} if(invJson.containsKey("storeRetailPrice3")){invVO.setStoreRetailPrice3(convertStringToBigDecimal(invJson.getString("storeRetailPrice3")));} if(invJson.containsKey("averageCost")){invVO.setAverageCost(convertStringToBigDecimal(invJson.getString("averageCost")));} if(invJson.containsKey("economicOrderQty") && invJson.getString("economicOrderQty")!=null){invVO.setEconomicOrderQty((short) invJson.getInt("economicOrderQty"));} if(invJson.containsKey("economicOrderQtyDiscountPct")){invVO.setEconomicOrderQtyDiscountPct(convertStringToBigDecimal(invJson.getString("economicOrderQtyDiscountPct")));} if(invJson.containsKey("lastYrCost")){invVO.setLastYrCost(convertStringToBigDecimal(invJson.getString("lastYrCost")));} if(invJson.containsKey("lastYrCoreCost")){invVO.setRefSeasonalFlagDescription(invJson.getString("lastYrCoreCost"));} if(invJson.containsKey("invQtyMinForDiscount")){invVO.setInvQtyMinForDiscount(convertStringToBigDecimal(invJson.getString("invQtyMinForDiscount")));} if(invJson.containsKey("discountForLargeInv")){invVO.setDiscountForLargeInv(convertStringToBigDecimal(invJson.getString("discountForLargeInv")));} if(invJson.containsKey("weightKilos")&& invJson.getString("weightKilos")!=null){invVO.setWeightKilos(invJson.getInt("weightKilos"));} if(invJson.containsKey("forSavedWip")&& invJson.getString("forSavedWip")!=null){invVO.setForSavedWip(invJson.getBoolean( "forSavedWip"));} if(invJson.containsKey("dvdcost")){invVO.setDVDCost(convertStringToBigDecimal(invJson.getString("dvdcost")));} if(invJson.containsKey("dVDCost")){invVO.setDVDCost(convertStringToBigDecimal(invJson.getString("dVDCost")));} if(invJson.containsKey("miscCharges") && invJson.get("miscCharges")!=null) { JSONArray jsonArr = invJson.getJSONArray("miscCharges"); Vector v = new Vector(); if(!jsonArr.isEmpty()){ Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { MiscChgVO miscChgVO = new MiscChgVO(); JSONObject json = JSONObject.fromObject(itr2.next()); if(json.containsKey("miscChgID")&& json.getString("miscChgID")!=null)miscChgVO.setMiscChgID(json.getInt("miscChgID")); if(json.containsKey("refResvLineCD"))miscChgVO.setRefResvLineCD(json.getString("refResvLineCD")); if(json.containsKey("cd"))miscChgVO.setCD(json.getString("cd")); if(json.containsKey("description"))miscChgVO.setDescription(json.getString("description")); if(json.containsKey("refMiscChgFlagID")&& json.getString("refMiscChgFlagID")!=null)miscChgVO.setRefMiscChgFlagID((byte) json.getInt("refMiscChgFlagID")); if(json.containsKey("chargeAmount"))miscChgVO.setChargeAmount(convertStringToBigDecimal(json.getString("chargeAmount"))); if(json.containsKey("taxStatusPrimRefOptnCD"))miscChgVO.setTaxStatusPrimRefOptnCD(json.getString("taxStatusPrimRefOptnCD")); if(json.containsKey("taxStatusSecRefOptnCD "))miscChgVO.setTaxStatusSecRefOptnCD (json.getString("taxStatusSecRefOptnCD ")); if(json.containsKey("appliesToProRataWarrantyReturns"))miscChgVO.setAppliesToProRataWarrantyReturns(json.getString("appliesToProRataWarrantyReturns")); if(json.containsKey("taxable1")&& json.getString("taxable1")!=null)miscChgVO.setTaxable1(json.getBoolean("taxable1")); if(json.containsKey("taxable2")&& json.getString("taxable2")!=null)miscChgVO.setTaxable2(json.getBoolean("taxable2")); v.add(miscChgVO); } } invVO.setMiscCharges(v); } if(invJson.containsKey("warrantyList") && invJson.get("warrantyList")!=null){ JSONArray jsonArr = invJson.getJSONArray("warrantyList"); Vector v = new Vector(); Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { WarrantyVO warrantyVO = new WarrantyVO(); JSONObject json = JSONObject.fromObject(itr2.next()); if(json.containsKey("id") && json.getString("id")!=null)warrantyVO.setID(json.getInt("id")); if(json.containsKey("loc")&& json.getString("loc")!=null)warrantyVO.setLOC(json.getInt("loc")); if(json.containsKey("lineAbbrev"))warrantyVO.setLineAbbrev(json.getString("lineAbbrev")); if(json.containsKey("partNumber"))warrantyVO.setPartNumber(json.getString("partNumber")); if(json.containsKey("beginDate"))warrantyVO.setBeginDate(ConvertStringToDate(json.getString("beginDate"))); if(json.containsKey("endDate"))warrantyVO.setEndDate(ConvertStringToDate(json.getString("endDate"))); if(json.containsKey("freeReplMonths")&& json.getString("freeReplMonths")!=null)warrantyVO.setFreeReplMonths((short)json.getInt("freeReplMonths")); if(json.containsKey("adjustmentMonths")&& json.getString("adjustmentMonths")!=null)warrantyVO.setAdjustmentMonths((short)json.getInt("adjustmentMonths")); if(json.containsKey("consumerAdjAmount"))warrantyVO.setConsumerAdjAmount(convertStringToBigDecimal(json.getString("consumerAdjAmount"))); if(json.containsKey("preferredConsAdjAmount"))warrantyVO.setPreferredConsAdjAmount(convertStringToBigDecimal(json.getString("preferredConsAdjAmount"))); if(json.containsKey("miAdjAmount"))warrantyVO.setMIAdjAmount(convertStringToBigDecimal(json.getString("miAdjAmount"))); v.add(warrantyVO); } invVO.setWarrantyList(v);} if(invJson.containsKey("lastPriceChangeDate") && invJson.getString( "lastPriceChangeDate")!=null){invVO.setLastPriceChangeDate(ConvertStringToDate(invJson.getString( "lastPriceChangeDate")));} if(invJson.containsKey("storeGroupID") && invJson.getString("storeGroupID")!=null){ invVO.setStoreGroupID(Short.valueOf(invJson.getString( "storeGroupID"))); } if(invJson.containsKey("hazMatID") && invJson.getString("hazMatID")!=null){ invVO.setHazMatID(Short.valueOf(invJson.getString( "hazMatID"))); } if(invJson.containsKey("expandedPartNumber") && invJson.getString("expandedPartNumber")!=null){ invVO.setExpandedPartNumber(invJson.getString( "expandedPartNumber")); } if(invJson.containsKey("description") && invJson.getString("description")!=null){ invVO.setDescription(invJson.getString( "description")); }if(invJson.containsKey("departmentID") && invJson.getString("departmentID")!=null){ invVO.setDepartmentID(Short.valueOf(invJson.getString( "departmentID"))); }if(invJson.containsKey("subDepartmentID") && invJson.getString("subDepartmentID")!=null){ invVO.setSubDepartmentID(Short.valueOf(invJson.getString( "subDepartmentID"))); } if(invJson.containsKey("groupCode") && invJson.getString("groupCode")!=null){ invVO.setGroupCode(Short.valueOf(invJson.getString( "groupCode"))); } if(invJson.containsKey("partNumber") && invJson.getString("partNumber")!=null){ invVO.setPartNumber(invJson.getString( "partNumber")); } if(invJson.containsKey("lineAbbrev") && invJson.getString("lineAbbrev")!=null){ invVO.setLineAbbrev(invJson.getString( "lineAbbrev")); } if(invJson.containsKey("sortNumber") && invJson.getString("sortNumber")!=null){ invVO.setSortNumber(Integer.valueOf(invJson.getString( "sortNumber"))); } if(invJson.containsKey("isCD") && invJson.getString("isCD")!=null){ invVO.setCD(invJson.getBoolean( "isCD")); } if(invJson.containsKey("inventoryStockVO") && !invJson.getJSONObject("inventoryStockVO").isNullObject()){ JSONObject jsonObj = invJson.getJSONObject("inventoryStockVO"); invVO.setInventoryStockVO(convertjsonToInvStock(jsonObj,forKitInventoryConversion));} if(invJson.containsKey("inventorySpecialSaleVO") && !invJson.getJSONObject("inventorySpecialSaleVO").isNullObject()){ JSONObject jsonObj = invJson.getJSONObject("inventorySpecialSaleVO"); InventorySpecialSaleVO vo = new InventorySpecialSaleVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){vo.setID(jsonObj.getInt( "id"));} if(jsonObj.containsKey("loc") && jsonObj.getString("loc")!=null){vo.setLOC(jsonObj.getInt( "loc"));} if(jsonObj.containsKey("inventoryID") && jsonObj.getString("inventoryID")!=null){vo.setInventoryID(jsonObj.getInt( "inventoryID"));} if(jsonObj.containsKey("code") && jsonObj.getString("code")!=null){vo.setCode(jsonObj.getString( "code"));} if(jsonObj.containsKey("price") && jsonObj.getString("price")!=null){vo.setPrice(convertStringToBigDecimal(jsonObj.getString( "price")));} if(jsonObj.containsKey("cost") && jsonObj.getString("cost")!=null){vo.setCost(convertStringToBigDecimal(jsonObj.getString( "cost")));} if(jsonObj.containsKey("onHandQty") && jsonObj.getString("onHandQty")!=null){vo.setOnHandQty(convertStringToBigDecimal(jsonObj.getString( "onHandQty")));} if(jsonObj.containsKey("history") && jsonObj.getString("history")!=null){vo.setHistory(convertStringToBigDecimal(jsonObj.getString( "history")));} if(jsonObj.containsKey("beginDate") && jsonObj.getString("beginDate")!=null){vo.setBeginDate(ConvertStringToDate(jsonObj.getString( "beginDate")));} if(jsonObj.containsKey("endDate") && jsonObj.getString("endDate")!=null){vo.setEndDate(ConvertStringToDate(jsonObj.getString( "endDate")));} if(jsonObj.containsKey("onSaleLabelGenerated") && jsonObj.getString("onSaleLabelGenerated")!=null){vo.setOnSaleLabelGenerated(jsonObj.getBoolean( "onSaleLabelGenerated"));} if(jsonObj.containsKey("offSaleLabelGenerated") && jsonObj.getString("offSaleLabelGenerated")!=null){vo.setOffSaleLabelGenerated(jsonObj.getBoolean( "offSaleLabelGenerated"));} if(jsonObj.containsKey("lastModifiedDate") && jsonObj.getString("lastModifiedDate")!=null){vo.setLastModifiedDate(ConvertStringToDate(jsonObj.getString( "lastModifiedDate")));} if(jsonObj.containsKey("modifiedByEmployeeID") && jsonObj.getString("modifiedByEmployeeID")!=null){vo.setModifiedByEmployeeID(jsonObj.getInt( "modifiedByEmployeeID"));} invVO.setInventorySpecialSaleVO(vo); } if(invJson.containsKey("inventoryStockLocations") && invJson.get("inventoryStockLocations")!=null){ JSONArray jsonArr = invJson.getJSONArray("inventoryStockLocations"); Vector v = new Vector(); Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { InventoryStockLocationVO invStLoVO = new InventoryStockLocationVO(); JSONObject json = JSONObject.fromObject(itr2.next()); if(json.containsKey("displayQty")){invStLoVO.setDisplayQty(convertStringToBigDecimal(json.getString("displayQty")));} if(json.containsKey("id") && json.getString("id")!=null){invStLoVO.setId(json.getInt("id"));} if(json.containsKey("externalIdentifier")){invStLoVO.setExternalIdentifier(json.getString("externalIdentifier"));} if(json.containsKey("fileName")){invStLoVO.setFileName(json.getString("fileName"));} if(json.containsKey("inventoryID") && json.getString("inventoryID")!=null){invStLoVO.setInventoryID(json.getInt("inventoryID"));} if(json.containsKey("labelRequired") && json.getString("labelRequired")!=null){invStLoVO.setLabelRequired(json.getBoolean("labelRequired"));} if(json.containsKey("lastModifiedDate") && json.getString("lastModifiedDate") !=null){invStLoVO.setLastModifiedDate(ConvertStringToDate(json.getString("lastModifiedDate")));} if(json.containsKey("loc")&& json.getString("loc") !=null){invStLoVO.setLoc(json.getInt("loc"));} if(json.containsKey("modifiedByEmployeeID")&& json.getString("modifiedByEmployeeID") !=null){invStLoVO.setModifiedByEmployeeID(json.getInt("modifiedByEmployeeID"));} if(json.containsKey("numberOfFacings")&& json.getString("numberOfFacings") !=null){invStLoVO.setNumberOfFacings(Short.valueOf(json.getString("numberOfFacings")));} if(json.containsKey("planogramReference")){invStLoVO.setPlanogramReference(json.getString("planogramReference"));} if(json.containsKey("refBinLabelTypeID")&& json.getString("refBinLabelTypeID") !=null){invStLoVO.setRefBinLabelTypeID((byte) json.getInt("refBinLabelTypeID"));} if(json.containsKey("stockLocation")){invStLoVO.setStockLocation(json.getString("stockLocation"));} if(json.containsKey("version")&& json.getString("version") !=null){invStLoVO.setVersion(json.getInt("version"));} v.add(invStLoVO); } invVO.setInventoryStockLocations(v);} if(invJson.containsKey("partCertificationVO") && !invJson.getJSONObject("partCertificationVO").isNullObject()){ JSONObject jsonObj = invJson.getJSONObject("partCertificationVO"); PartCertificationVO vo = new PartCertificationVO(); if(jsonObj.containsKey("certificationPartGroupId") && jsonObj.getString("certificationPartGroupId")!=null){vo.setCertificationPartGroupId(jsonObj.getInt( "certificationPartGroupId"));} if(jsonObj.containsKey("beginDate") && jsonObj.getString("beginDate")!=null){vo.setBeginDate(ConvertStringToDate(jsonObj.getString( "beginDate")));} if(jsonObj.containsKey("endDate") && jsonObj.getString("endDate")!=null){vo.setEndDate(ConvertStringToDate(jsonObj.getString( "endDate")));} if(jsonObj.containsKey("napaReserved") && jsonObj.getString("napaReserved")!=null){vo.setNapaReserved(jsonObj.getBoolean( "napaReserved"));} if(jsonObj.containsKey("govCertExistForCustomer") && jsonObj.getString("govCertExistForCustomer")!=null){vo.setGovCertExistForCustomer(jsonObj.getBoolean( "govCertExistForCustomer"));} if(jsonObj.containsKey("certificationCategory") && jsonObj.getString("certificationCategory")!=null){vo.setCertificationCategory(jsonObj.getString( "certificationCategory"));} if(jsonObj.containsKey("certificationGroup") && jsonObj.getString("certificationGroup")!=null){vo.setCertificationGroup(jsonObj.getInt( "certificationGroup"));} if(jsonObj.containsKey("description") && jsonObj.getString("description")!=null){vo.setDescription(jsonObj.getString( "description"));} invVO.setPartCertificationVO(vo); } return invVO; } private InventoryStockVO convertjsonToInvStock(JSONObject jsonObj, Boolean forKitInventoryConversion) { InventoryStockVO inventoryStockVO = new InventoryStockVO(); if(forKitInventoryConversion.booleanValue()==true) inventoryStockVO= new KitInventoryStockVO(); if(jsonObj.containsKey("LOC") && jsonObj.getString("LOC")!=null){inventoryStockVO.setLOC(jsonObj.getInt("LOC"));} if(jsonObj.containsKey("daysAllocatedToWIP")&& jsonObj.getString("daysAllocatedToWIP")!=null){inventoryStockVO.setDaysAllocatedToWIP((short) jsonObj.getInt("daysAllocatedToWIP"));} if(jsonObj.containsKey("daysOnBackOrder")&& jsonObj.getString("daysOnBackOrder")!=null){inventoryStockVO.setDaysOnBackOrder((short) jsonObj.getInt("daysOnBackOrder"));} if(jsonObj.containsKey("daysOnFactoryOrder")&& jsonObj.getString("daysOnFactoryOrder")!=null){inventoryStockVO.setDaysOnFactoryOrder((short) jsonObj.getInt("daysOnFactoryOrder"));} if(jsonObj.containsKey("daysOnOrder")&& jsonObj.getString("daysOnOrder")!=null){inventoryStockVO.setDaysOnOrder((short) jsonObj.getInt("daysOnOrder"));} if(jsonObj.containsKey("externalIdentifier")){inventoryStockVO.setExternalIdentifier(jsonObj.getString("externalIdentifier"));} if(jsonObj.containsKey("factoryOrder")&& jsonObj.getString("factoryOrder")!=null){inventoryStockVO.setFactoryOrder(jsonObj.getBoolean("factoryOrder"));} if(jsonObj.containsKey("factoryOrderFlag")){inventoryStockVO.setFactoryOrderFlag(jsonObj.getString("factoryOrderFlag"));} if(jsonObj.containsKey("faimCode")){inventoryStockVO.setFaimCode(jsonObj.getString("faimCode"));} if(jsonObj.containsKey("id")&& jsonObj.getString("id")!=null){inventoryStockVO.setId(jsonObj.getInt("id"));} if(jsonObj.containsKey("initialStockingDate")&& jsonObj.getString("initialStockingDate")!=null){inventoryStockVO.setInitialStockingDate(ConvertStringToDate(jsonObj.getString("initialStockingDate")) );} if(jsonObj.containsKey("inventoryID")&& jsonObj.getString("inventoryID")!=null){inventoryStockVO.setInventoryID(jsonObj.getInt("inventoryID"));} if(jsonObj.containsKey("inventoryNoteID") && jsonObj.getString("inventoryNoteID")!=null){inventoryStockVO.setInventoryNoteID((short) jsonObj.getInt("inventoryNoteID"));} if(jsonObj.containsKey("inventoryNoteVO") && !jsonObj.getJSONObject("inventoryNoteVO").isNullObject()){ InventoryNoteVO invNoteVO = new InventoryNoteVO(); JSONObject job = jsonObj.getJSONObject("inventoryNoteVO"); if(job.containsKey("id") && job.getString("id")!=null)invNoteVO.setID((short) job.getInt("id")); if(job.containsKey("loc") && job.getString("loc")!=null)invNoteVO.setLOC(job.getInt("loc")); if(job.containsKey("text"))invNoteVO.setText(job.getString("text")); if(job.containsKey("refNoteHandlingID") && job.getString("refNoteHandlingID")!=null)invNoteVO.setRefNoteHandlingID((byte) job.getInt("refNoteHandlingIDOC")); if(job.containsKey("expirationDate") && job.getString("expirationDate")!=null)invNoteVO.setExpirationDate(ConvertStringToDate(job.getString("expirationDate"))); inventoryStockVO.setInventoryNoteVO(invNoteVO);} if(jsonObj.containsKey("lastLostSaleDate") && jsonObj.getString("lastLostSaleDate")!=null){inventoryStockVO.setLastLostSaleDate(ConvertStringToDate(jsonObj.getString("lastLostSaleDate")));} if(jsonObj.containsKey("lastReceiptDate") && jsonObj.getString("lastReceiptDate")!=null){inventoryStockVO.setLastReceiptDate(ConvertStringToDate(jsonObj.getString("lastReceiptDate")));} if(jsonObj.containsKey("lastReturnDate")&& jsonObj.getString("lastReturnDate")!=null){inventoryStockVO.setLastReturnDate(ConvertStringToDate(jsonObj.getString("lastReturnDate")));} if(jsonObj.containsKey("lastSaleDate")&& jsonObj.getString("lastSaleDate")!=null){inventoryStockVO.setLastSaleDate(ConvertStringToDate(jsonObj.getString("lastSaleDate")));} if(jsonObj.containsKey("maxStockQty")&& jsonObj.getString("maxStockQty")!=null){inventoryStockVO.setMaxStockQty((short) jsonObj.getInt("maxStockQty"));} if(jsonObj.containsKey("minSaleQty")){inventoryStockVO.setMinSaleQty(convertStringToBigDecimal(jsonObj.getString("minSaleQty")));} if(jsonObj.containsKey("minStockQty")&& jsonObj.getString("minStockQty")!=null){inventoryStockVO.setMinStockQty(Short.valueOf(jsonObj.getString("minStockQty")));} if(jsonObj.containsKey("onBackOrder")&& jsonObj.getString("onBackOrder")!=null){inventoryStockVO.setOnBackOrder(Short.valueOf(jsonObj.getString("onBackOrder")));} if(jsonObj.containsKey("onFactoryOrder")&& jsonObj.getString("onFactoryOrder")!=null){inventoryStockVO.setOnFactoryOrder(jsonObj.getInt("onFactoryOrder"));} if(jsonObj.containsKey("onHand")){inventoryStockVO.setOnHand(convertStringToBigDecimal(jsonObj.getString("onHand")));} if(jsonObj.containsKey("onOrder")){inventoryStockVO.setOnOrder(Short.valueOf(jsonObj.getString("onOrder")));} if(jsonObj.containsKey("physicalInventoryDate") && jsonObj.getString("physicalInventoryDate")!=null){inventoryStockVO.setPhysicalInventoryDate(ConvertStringToDate(jsonObj.getString("physicalInventoryDate")));} if(jsonObj.containsKey("previousLostSaleDate")&& jsonObj.getString("previousLostSaleDate")!=null){inventoryStockVO.setPreviousLostSaleDate(ConvertStringToDate( jsonObj.getString("previousLostSaleDate")));} if(jsonObj.containsKey("refInitialStockingReasonCD")){inventoryStockVO.setRefInitialStockingReasonCD(jsonObj.getString("refInitialStockingReasonCD"));} if(jsonObj.containsKey("refMinMaxStatusCD")){inventoryStockVO.setRefMinMaxStatusCD(jsonObj.getString("refMinMaxStatusCD"));} if(jsonObj.containsKey("refMinMaxStatusDescription")){inventoryStockVO.setRefMinMaxStatusDescription(jsonObj.getString("refMinMaxStatusDescription"));} if(jsonObj.containsKey("refOrderSuspenseCD")){inventoryStockVO.setRefOrderSuspenseCD(jsonObj.getString("refOrderSuspenseCD"));} if(jsonObj.containsKey("refOrderSuspenseCDDescription")){inventoryStockVO.setRefOrderSuspenseCDDescription(jsonObj.getString("refOrderSuspenseCDDescription"));} if(jsonObj.containsKey("returnedCoresOnHand")){inventoryStockVO.setReturnedCoresOnHand(convertStringToBigDecimal(jsonObj.getString("returnedCoresOnHand")));} if(jsonObj.containsKey("returnedDefectivesOnHand")){inventoryStockVO.setReturnedDefectivesOnHand(convertStringToBigDecimal(jsonObj.getString("returnedDefectivesOnHand")));} if(jsonObj.containsKey("storeDepartmentID")&& jsonObj.getString("storeDepartmentID")!=null){inventoryStockVO.setStoreDepartmentID(Short.valueOf(jsonObj.getString("storeDepartmentID")));} if(jsonObj.containsKey("useEconomicOrderQty")){inventoryStockVO.setUseEconomicOrderQty(jsonObj.getString("useEconomicOrderQty"));} if(jsonObj.containsKey("version")&& jsonObj.getString("version")!=null){inventoryStockVO.setVersion(jsonObj.getInt("version"));} if(jsonObj.containsKey("workInProgress")){inventoryStockVO.setWorkInProgress(convertStringToBigDecimal(jsonObj.getString("workInProgress")));} return inventoryStockVO; } public TaxInfoVO getProductLineTaxInfo(String lineAbbr, Short group,Integer loc, String remoteStoreIp) { TaxInfoVO taxInfoVO =null; String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/tax"; logger.debug("url = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); Integer id=10; httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbr", lineAbbr), new NameValuePair("grp", group!=null?group.toString():null), new NameValuePair("loc", loc.toString()), new NameValuePair("id", id!=null?id.toString():null), new NameValuePair("type", "TI")}); try { long millSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long endMillSec = System.currentTimeMillis(); long callDuration = (endMillSec-millSec); createAndLogDataToAzure("Making getProductLineTaxInfo remote call",httpGet.getQueryString(),remoteStoreIp, statusCode, callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] responseObj = httpGet.getResponseBody(); String result = new String(responseObj); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("taxInfoVO") && !jsonObject.getJSONObject("taxInfoVO").isNullObject()){ JSONObject invJson = jsonObject.getJSONObject("taxInfoVO"); long conMillSec = System.currentTimeMillis(); taxInfoVO = convertjsonToTaxInfoVO(invJson); long conMillSecEnds = System.currentTimeMillis(); long conDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of ConvertjsonToTaxInfoVO",remoteStoreIp,invJson.toString(),conDuration); return taxInfoVO; } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return taxInfoVO; } private TaxInfoVO convertjsonToTaxInfoVO(JSONObject infJson) { TaxInfoVO tiVO = new TaxInfoVO(); if(infJson.containsKey("coreReturnsTaxStatusPrimaryRefOptionCd")){tiVO.setCoreReturnsTaxStatusPrimaryRefOptionCd(infJson.getString("coreReturnsTaxStatusPrimaryRefOptionCd"));} if(infJson.containsKey("coreReturnsTaxStatusSecondaryRefOptionCd")){tiVO.setCoreReturnsTaxStatusSecondaryRefOptionCd(infJson.getString("coreReturnsTaxStatusSecondaryRefOptionCd"));} if(infJson.containsKey("coreSalesTaxStatusPrimaryRefOptionCd")){tiVO.setCoreSalesTaxStatusPrimaryRefOptionCd(infJson.getString("coreSalesTaxStatusPrimaryRefOptionCd"));} if(infJson.containsKey("coreSalesTaxStatusSecondaryRefOptionCd")){tiVO.setCoreSalesTaxStatusSecondaryRefOptionCd(infJson.getString("coreSalesTaxStatusSecondaryRefOptionCd"));} if(infJson.containsKey("externalIdentifier")){tiVO.setExternalIdentifier(infJson.getString("externalIdentifier"));} if(infJson.containsKey("id") && infJson.getString("id")!=null){tiVO.setId(infJson.getInt("id"));} if(infJson.containsKey("primaryTaxTable") && infJson.getJSONObject("primaryTaxTable")!=null && !infJson.getJSONObject("primaryTaxTable").isNullObject()){ TaxTableVO primaryTaxTableVO = convertJsonToTaxTableVO(infJson.getJSONObject("primaryTaxTable")); tiVO.setPrimaryTaxTable(primaryTaxTableVO);} if(infJson.containsKey("secondaryTaxTable") && infJson.getJSONObject("secondaryTaxTable")!=null && !infJson.getJSONObject("secondaryTaxTable").isNullObject()){ TaxTableVO secTaxTableVO = convertJsonToTaxTableVO(infJson.getJSONObject("secondaryTaxTable")); tiVO.setSecondaryTaxTable(secTaxTableVO);} if(infJson.containsKey("taxExemptPrimaryExpDate") && infJson.getJSONObject("taxExemptPrimaryExpDate")!=null){tiVO.setTaxExemptPrimaryExpDate(ConvertStringToDate(infJson.getString("taxExemptPrimaryExpDate")));} if(infJson.containsKey("taxExemptSecondaryExpDate")&& infJson.getJSONObject("taxExemptSecondaryExpDate")!=null){tiVO.setTaxExemptSecondaryExpDate(ConvertStringToDate(infJson.getString("taxExemptSecondaryExpDate")));} if(infJson.containsKey("taxStatusPrimaryRefOptionCD")){tiVO.setTaxStatusPrimaryRefOptionCD(infJson.getString("taxStatusPrimaryRefOptionCD"));} if(infJson.containsKey("taxStatusSecondaryRefOptionCD")){tiVO.setTaxStatusSecondaryRefOptionCD(infJson.getString("taxStatusSecondaryRefOptionCD"));} if(infJson.containsKey("version") && infJson.getString("version")!=null){tiVO.setVersion(infJson.getInt("version"));} return tiVO; } private TaxTableVO convertJsonToTaxTableVO(JSONObject jsonObject) { TaxTableVO taxTableVO = new TaxTableVO(); if(jsonObject.containsKey("ID") && jsonObject.getString("ID")!=null){taxTableVO.setId((jsonObject.getInt("ID")));} if(jsonObject.containsKey("LOC")&& jsonObject.getString("LOC")!=null){taxTableVO.setLOC(jsonObject.getInt("LOC"));} if(jsonObject.containsKey("description")){taxTableVO.setDescription(jsonObject.getString("description"));} if(jsonObject.containsKey("externalIdentifier")){taxTableVO.setExternalIdentifier(jsonObject.getString("externalIdentifier"));} if(jsonObject.containsKey("id")&& jsonObject.getString("id")!=null){taxTableVO.setID(Short.valueOf(jsonObject.getString("id")));} if(jsonObject.containsKey("maxTaxAmtCharged")){taxTableVO.setMaxTaxAmtCharged(convertStringToBigDecimal(jsonObject.getString("maxTaxAmtCharged")));} if(jsonObject.containsKey("maximumTaxBracket")&& jsonObject.getString("maximumTaxBracket")!=null){taxTableVO.setMaximumTaxBracket(jsonObject.getInt("maximumTaxBracket"));} if(jsonObject.containsKey("refTaxMethodCD")){taxTableVO.setRefTaxMethodCD(jsonObject.getString("refTaxMethodCD"));} if(jsonObject.containsKey("salesTaxPercent")){taxTableVO.setSalesTaxPercent(convertStringToBigDecimal(jsonObject.getString("salesTaxPercent")));} if(jsonObject.containsKey("secondaryTaxTableID")&& jsonObject.getString("secondaryTaxTableID")!=null && jsonObject.getString("secondaryTaxTableID")!="0"){ taxTableVO.setSecondaryTaxTableID(Short.valueOf(jsonObject.getString("secondaryTaxTableID")));} if(jsonObject.containsKey("taxBagRefOptionCD")){taxTableVO.setTaxBagRefOptionCD(jsonObject.getString("taxBagRefOptionCD"));} if(jsonObject.containsKey("taxCORReturnsRefOptionCD")){taxTableVO.setTaxCORReturnsRefOptionCD(jsonObject.getString("taxCORReturnsRefOptionCD"));} if(jsonObject.containsKey("taxCORSalesRefOptionCD")){taxTableVO.setTaxCORSalesRefOptionCD(jsonObject.getString("taxCORSalesRefOptionCD"));} if(jsonObject.containsKey("taxDelRefOptionCD")){taxTableVO.setTaxDelRefOptionCD(jsonObject.getString("taxDelRefOptionCD"));} if(jsonObject.containsKey("taxENVRefOptionCD")){taxTableVO.setTaxENVRefOptionCD(jsonObject.getString("taxENVRefOptionCD"));} if(jsonObject.containsKey("taxFederalEXCChgRefOptionCD")){taxTableVO.setTaxFederalEXCChgRefOptionCD(jsonObject.getString("taxFederalEXCChgRefOptionCD"));} if(jsonObject.containsKey("taxFrtRefOptionCD")){taxTableVO.setTaxFrtRefOptionCD(jsonObject.getString("taxFrtRefOptionCD"));} if(jsonObject.containsKey("taxLABRefOptionCD")){taxTableVO.setTaxLABRefOptionCD(jsonObject.getString("taxLABRefOptionCD"));} if(jsonObject.containsKey("taxLoyaltyRedemptions")){taxTableVO.setTaxLoyaltyRedemptions(jsonObject.getString("taxLoyaltyRedemptions"));} if(jsonObject.containsKey("taxMISRefOptionCD")){taxTableVO.setTaxMISRefOptionCD(jsonObject.getString("taxMISRefOptionCD"));} if(jsonObject.containsKey("taxOTHRefOptionCD")){taxTableVO.setTaxOTHRefOptionCD(jsonObject.getString("taxOTHRefOptionCD"));} if(jsonObject.containsKey("taxServiceChargesRefOptionCD")){taxTableVO.setTaxServiceChargesRefOptionCD(jsonObject.getString("taxServiceChargesRefOptionCD"));} if(jsonObject.containsKey("taxTelRefOptionCD")){taxTableVO.setTaxTelRefOptionCD(jsonObject.getString("taxTelRefOptionCD"));} if(jsonObject.containsKey("taxWLCRefOptionCD")){taxTableVO.setTaxWLCRefOptionCD(jsonObject.getString("taxWLCRefOptionCD"));} if(jsonObject.containsKey("taxtableBracket") && jsonObject.get("taxtableBracket")!=null){ JSONArray jsonArray = jsonObject.getJSONArray("taxtableBracket"); Vector v = new Vector(); if(!jsonArray.isEmpty()){ TaxTableBracket taxTableBracket = new TaxTableBracket(); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if(j.containsKey("key"))taxTableBracket.setKey((TaxTableBracketKey) j.get("key")); if(j.containsKey("loc") && j.getString("loc")!=null)taxTableBracket.setLoc( j.getInt("loc")); if(j.containsKey("taxableSaleAmount"))taxTableBracket.setTaxableSaleAmount( convertStringToBigDecimal(j.getString("taxableSaleAmount"))); if(j.containsKey("taxTableId") && j.getString("taxTableId")!=null)taxTableBracket.setTaxTableId( j.getInt("taxTableId")); if(j.containsKey("taxCharged"))taxTableBracket.setTaxCharged( convertStringToBigDecimal(j.getString("taxCharged"))); v.add(taxTableBracket); } } taxTableVO.setTaxtableBracket(v); } if(jsonObject.containsKey("validateCoreReturnTaxNumber")&& jsonObject.getString("validateCoreReturnTaxNumber")!=null){taxTableVO.setValidateCoreReturnTaxNumber(jsonObject.getBoolean("validateCoreReturnTaxNumber"));} if(jsonObject.containsKey("version")&& jsonObject.getString("version")!=null){taxTableVO.setVersion(jsonObject.getInt("version"));} return taxTableVO; } public TaxTableVO getTaxTable(Integer loc, Short defaultTaxTableID, String remoteStoreIP) { TaxTableVO taxTableVO = null; if(defaultTaxTableID==null){ return null; } String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/tax"; logger.debug("url = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("id", defaultTaxTableID==null?null:defaultTaxTableID.toString()), new NameValuePair("type", "TT")}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getTaxTable remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] responseObj = httpGet.getResponseBody(); String result = new String(responseObj); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("primaryTaxTableVO") && !jsonObject.getJSONObject("primaryTaxTableVO").isNullObject()){ JSONObject invJson = jsonObject.getJSONObject("primaryTaxTableVO"); long conMillSec = System.currentTimeMillis(); taxTableVO = convertJsonToTaxTableVO(invJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJsonToTaxTableVO ends",remoteStoreIP,invJson.toString(), convDuration); return taxTableVO; } }else{ logger.error("Server encountered an http error while getting invoice profile response "); //throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return taxTableVO; } public boolean getKitDefinition(String lineAbbrev, String partNumber, String remoteStoreIp,String loc) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/kitdefinition"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbrev), new NameValuePair("part", partNumber), new NameValuePair("loc", loc)}); boolean checkInv = false; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getKitDefinition remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] checkExistResponse = httpGet.getResponseBody(); String result = new String(checkExistResponse); if(result!=null && result.equalsIgnoreCase("true"))return true; else return false; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return checkInv; } public void createJoeiPreload(JoeiPreloadVO joeiPreloadVO, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/joei"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", joeiPreloadVO.getLineAbbrev()), new NameValuePair("part", joeiPreloadVO.getPartNumber()), new NameValuePair("loc", joeiPreloadVO.getLOC().toString()), new NameValuePair("invoiceQty", joeiPreloadVO.getQuantity().toString()), new NameValuePair("empId", joeiPreloadVO.getModifiedByEmployeeID().toString()), new NameValuePair("custId", joeiPreloadVO.getCustomerID().toString()) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making createJoeiPreload remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] checkExistResponse = httpGet.getResponseBody(); String result = new String(checkExistResponse); } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } } public boolean checkInventory(String lineAbbreviation, String partNumber, Integer loc, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/checkinventory"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbr", lineAbbreviation), new NameValuePair("loc", loc.toString()), new NameValuePair("part", partNumber)}); boolean checkInv = false; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making checkInventory remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] checkExistResponse = httpGet.getResponseBody(); String result = new String(checkExistResponse); if(result!=null && result.equalsIgnoreCase("true"))return true; else return false; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return checkInv; } public PricesOutVO getPricesFromInventory(PricesInVO pricesInputVO, String remoteStoreIP) { PricesOutVO pricesOutVO = null; JSONObject req_json = convertPricesInputVOToJSON(pricesInputVO); String json_string = req_json.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/pricefrominv"; logger.debug("getURL = " + url); byte[] responseBody; HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("updateMessagePartURL Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPricesFromInventory remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("pricesOutVO") && !jsonObject.getJSONObject("pricesOutVO").isNullObject()){ JSONObject pricesOutJson = jsonObject.getJSONObject("pricesOutVO"); long conMillSec = System.currentTimeMillis(); pricesOutVO = convertJSONToPricesOutVO(pricesOutJson); long conMillSecEnd = System.currentTimeMillis(); long convDuration = (conMillSecEnd-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToPricesOutVO from Inventory ",remoteStoreIP,pricesOutJson.toString(),convDuration); return pricesOutVO; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return pricesOutVO; } public PricesOutVO convertJSONToPricesOutVO(JSONObject pricesOutJSON) { PricesOutVO pricesOutVO = new PricesOutVO(); if(pricesOutJSON.containsKey("externalIdentifier")){pricesOutVO.setExternalIdentifier((pricesOutJSON.getString("externalIdentifier")));} if(pricesOutJSON.containsKey("id") && pricesOutJSON.getString("id")!=null){pricesOutVO.setId(pricesOutJSON.getInt("id"));} if(pricesOutJSON.containsKey("version") && pricesOutJSON.getString("version")!=null){pricesOutVO.setVersion(pricesOutJSON.getInt("version"));} if(pricesOutJSON.containsKey("markedForDeletion")&& pricesOutJSON.getString("markedForDeletion")!=null){pricesOutVO.setMarkedForDeletion(pricesOutJSON.getBoolean("markedForDeletion"));} if(pricesOutJSON.containsKey("calculatedList")){pricesOutVO.setCalculatedList(convertStringToBigDecimal(pricesOutJSON.getString("calculatedList")));} if(pricesOutJSON.containsKey("unitPrice")){pricesOutVO.setUnitPrice(convertStringToBigDecimal(pricesOutJSON.getString("unitPrice")));} if(pricesOutJSON.containsKey("priceDecision")){pricesOutVO.setPriceDecision((pricesOutJSON.getString("priceDecision")));} if(pricesOutJSON.containsKey("calcString")){pricesOutVO.setCalcString((pricesOutJSON.getString("calcString")));} if(pricesOutJSON.containsKey("markup")){pricesOutVO.setMarkup(convertStringToBigDecimal(pricesOutJSON.getString("markup")));} if(pricesOutJSON.containsKey("unitCost")){pricesOutVO.setUnitCost(convertStringToBigDecimal(pricesOutJSON.getString("unitCost")));} if(pricesOutJSON.containsKey("unitRebate")){pricesOutVO.setUnitRebate((pricesOutJSON.getString("unitRebate")));} if(pricesOutJSON.containsKey("coreCost")){pricesOutVO.setCoreCost(convertStringToBigDecimal(pricesOutJSON.getString("coreCost")));} if(pricesOutJSON.containsKey("corePrice")){pricesOutVO.setCorePrice(convertStringToBigDecimal(pricesOutJSON.getString("corePrice")));} if(pricesOutJSON.containsKey("usualPrice")){pricesOutVO.setUsualPrice(convertStringToBigDecimal(pricesOutJSON.getString("usualPrice")));} if(pricesOutJSON.containsKey("customPrice")){pricesOutVO.setCustomPrice(convertStringToBigDecimal(pricesOutJSON.getString("customPrice")));} if(pricesOutJSON.containsKey("specialPrice")){pricesOutVO.setSpecialPrice(convertStringToBigDecimal(pricesOutJSON.getString("specialPrice")));} if(pricesOutJSON.containsKey("specialCost")){pricesOutVO.setSpecialCost(convertStringToBigDecimal(pricesOutJSON.getString("specialCost")));} if(pricesOutJSON.containsKey("specialSaleCode")){pricesOutVO.setSpecialSaleCode((pricesOutJSON.getString("specialSaleCode")));} if(pricesOutJSON.containsKey("coreUsualPrice")){pricesOutVO.setCoreUsualPrice(convertStringToBigDecimal(pricesOutJSON.getString("coreUsualPrice")));} if(pricesOutJSON.containsKey("coreCustomPrice")){pricesOutVO.setCoreCustomPrice(convertStringToBigDecimal(pricesOutJSON.getString("coreCustomPrice")));} if(pricesOutJSON.containsKey("corePriceDecision")){pricesOutVO.setCorePriceDecision((pricesOutJSON.getString("corePriceDecision")));} if(pricesOutJSON.containsKey("profileName")){pricesOutVO.setProfileName((pricesOutJSON.getString("profileName")));} if(pricesOutJSON.containsKey("profileFlag")){pricesOutVO.setProfileFlag((pricesOutJSON.getString("profileFlag")));} if(pricesOutJSON.containsKey("profileNumber")&& pricesOutJSON.getString("profileNumber")!=null){pricesOutVO.setProfileNumber((pricesOutJSON.getInt("profileNumber")));} if(pricesOutJSON.containsKey("detailProfileNumber")&& pricesOutJSON.getString("detailProfileNumber")!=null){pricesOutVO.setDetailProfileNumber((pricesOutJSON.getInt("detailProfileNumber")));} if(pricesOutJSON.containsKey("pricingTypeCode")){pricesOutVO.setPricingTypeCode((pricesOutJSON.getString("pricingTypeCode")));} if(pricesOutJSON.containsKey("coreProfileName")){pricesOutVO.setCoreProfileName(pricesOutJSON.getString("coreProfileName"));} if(pricesOutJSON.containsKey("unitSaved")){pricesOutVO.setUnitSaved(convertStringToBigDecimal(pricesOutJSON.getString("unitSaved")));} if(pricesOutJSON.containsKey("displayListPrice")){pricesOutVO.setDisplayListPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayListPrice")));} if(pricesOutJSON.containsKey("displayUnitPrice")){pricesOutVO.setDisplayUnitPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayUnitPrice")));} if(pricesOutJSON.containsKey("displayCustomPrice")){pricesOutVO.setDisplayCustomPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayCustomPrice")));} if(pricesOutJSON.containsKey("displayUsualPrice")){pricesOutVO.setDisplayUsualPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayUsualPrice")));} if(pricesOutJSON.containsKey("displaySpecialPrice")){pricesOutVO.setDisplaySpecialPrice(convertStringToBigDecimal(pricesOutJSON.getString("displaySpecialPrice")));} if(pricesOutJSON.containsKey("displayUnitCost")){pricesOutVO.setDisplayUnitCost(convertStringToBigDecimal(pricesOutJSON.getString("displayUnitCost")));} if(pricesOutJSON.containsKey("displayCorePrice")){pricesOutVO.setDisplayCorePrice(convertStringToBigDecimal(pricesOutJSON.getString("displayCorePrice")));} if(pricesOutJSON.containsKey("displayCoreUsualPrice")){pricesOutVO.setDisplayCoreUsualPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayCoreUsualPrice")));} if(pricesOutJSON.containsKey("displayCoreCustomPrice")){pricesOutVO.setDisplayCoreCustomPrice(convertStringToBigDecimal(pricesOutJSON.getString("displayCoreCustomPrice")));} if(pricesOutJSON.containsKey("displayCoreCost")){pricesOutVO.setDisplayCoreCost(convertStringToBigDecimal(pricesOutJSON.getString("displayCoreCost")));} if(pricesOutJSON.containsKey("perCar")&& pricesOutJSON.getString("perCar")!=null){pricesOutVO.setPerCar((short) pricesOutJSON.getInt("perCar"));} if(pricesOutJSON.containsKey("priceSheetCD")){pricesOutVO.setPriceSheetCd(pricesOutJSON.getString("priceSheetCD"));} if(pricesOutJSON.containsKey("priceSheetCd")){pricesOutVO.setPriceSheetCd(pricesOutJSON.getString("priceSheetCd"));} return pricesOutVO; } private JSONObject convertPricesInputVOToJSON(PricesInVO vo) { JSONObject jsonObject = new JSONObject(); jsonObject.put("loc",vo.getLocation()); jsonObject.put("customer_type_cd",vo.getCustomerTypeCD()); jsonObject.put("customer_id",vo.getCustomerId()); jsonObject.put("quantity_billed",vo.getQuantityBilled()); jsonObject.put("line_abbreviation",vo.getLineAbbreviation()); jsonObject.put("part_number",vo.getPartNumber()); jsonObject.put("felds_passed_in",vo.getFieldsPassedIn()); jsonObject.put("inventory_id",vo.getInventoryId()); jsonObject.put("store_group_id",vo.getStoreGroupId()); jsonObject.put("department_id",vo.getDepartmentId()); jsonObject.put("sub_department_id",vo.getSubDepartmentId()); jsonObject.put("group_code",vo.getGroupCode()); jsonObject.put("class_cd",vo.getClassCd()); jsonObject.put("store_department_id",vo.getStoreDepartmentId()); jsonObject.put("reportable",vo.getReportable()); jsonObject.put("display_qty",vo.getDisplayQty()); jsonObject.put("list",vo.getList()); jsonObject.put("gray",vo.getGray()); jsonObject.put("yellow",vo.getYellow()); jsonObject.put("green",vo.getGreen()); jsonObject.put("pink",vo.getPink()); jsonObject.put("master_installer",vo.getMasterInstaller()); jsonObject.put("blue",vo.getBlue()); jsonObject.put("core_price",vo.getCorePrice()); jsonObject.put("jobber_stocked_cost",vo.getJobberStockedCost()); jsonObject.put("jobber_non_stocked_cost",vo.getJobberNonStockedCost()); jsonObject.put("cost",vo.getCost()); jsonObject.put("core_cost",vo.getCoreCost()); jsonObject.put("jobber_core_cost",vo.getJobberCoreCost()); jsonObject.put("average_cost",vo.getAverageCost()); jsonObject.put("invoice_qty_min_for_discount",vo.getInvoiceQtyMinForDiscount()); jsonObject.put("discount_for_large_invoices",vo.getDiscountForLargeInvoices()); jsonObject.put("store_retail_price_1",vo.getStoreRetailPrice1()); jsonObject.put("store_retail_price_2",vo.getStoreRetailPrice2()); jsonObject.put("store_retail_price_3",vo.getStoreRetailPrice3()); jsonObject.put("per_car",vo.getPerCar()); return jsonObject; } public PricesOutVO getPricesFromDVD(PricesInVO pricesInputVO, String remoteStoreIP) { PricesOutVO pricesOutVO =null; JSONObject req_json = convertPricesInputVOToJSON(pricesInputVO); String json_string = req_json.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/pricefromdvd"; logger.debug("getURL = " + url); byte[] responseBody; HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("updateMessagePartURL Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPricesFromDVD remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { responseBody = taapRequest.getResponseBody(); String result = new String(responseBody); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("pricesOutVO") && !jsonObject.getJSONObject("pricesOutVO").isNullObject()){ JSONObject pricesOutJson = jsonObject.getJSONObject("pricesOutVO"); long conMillSec = System.currentTimeMillis(); pricesOutVO = convertJSONToPricesOutVO(pricesOutJson); long conMillSecEnd = System.currentTimeMillis(); long convDuration = (conMillSecEnd-conMillSec); createAndLogConversionDataToAzure(" Conversion of convertJSONToPricesOutVO from DVD ",remoteStoreIP, pricesOutVO.toString(),convDuration); return pricesOutVO; } } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return pricesOutVO; } private Date ConvertStringToDate(String sdate) { String format= "yyyy-MM-dd HH:MM:SS"; try{ SimpleDateFormat df = new SimpleDateFormat(format); return new java.sql.Date(df.parse(sdate).getTime()); } catch (Exception e){ return null; } } private Date ConvertStringToDate1(String sdate) { String format= "yyyy-MM-dd"; try{ SimpleDateFormat df = new SimpleDateFormat(format); return df.parse(sdate); } catch (Exception e){ return null; } } private BigDecimal convertStringToBigDecimal(String s){ BigDecimal bigDecimalValue = new BigDecimal((String) s); bigDecimalValue.setScale(4); return bigDecimalValue; } private Timestamp convertStringToTimeStamp(String date) { return Timestamp.valueOf(date); } private Boolean convertLockableJsonObject(String bool){ if(bool!=null) if(bool.equalsIgnoreCase("true")) return true; return false; } public boolean checkNotNullgetProductLineVO(String lineAbbrev, String remoteStoreIp, String loc) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/pl"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbr", lineAbbrev), new NameValuePair("loc", loc)}); boolean isNull = false; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making checkNotNullgetProductLineVO remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] checkExistResponse = httpGet.getResponseBody(); String result = new String(checkExistResponse); if(result!=null && result.equalsIgnoreCase("true"))return true; else return false; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return isNull; } public boolean quickAddPart(InventoryVO inventoryVO, Integer employeeId, String pointOfSale, String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/addparts"; String expandedPart = (inventoryVO.getExpandedPartNumber() != null && inventoryVO.getExpandedPartNumber().trim().length() > 0) ? inventoryVO.getExpandedPartNumber() : inventoryVO.getPartNumber(); logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("expPartNump", expandedPart), new NameValuePair("partNum", inventoryVO.getPartNumber()), new NameValuePair("ip", remoteStoreIp), new NameValuePair("line", inventoryVO.getLineAbbrev()), new NameValuePair("loc", inventoryVO.getLOC().toString()), new NameValuePair("empId", employeeId.toString()), new NameValuePair("ps", pointOfSale), new NameValuePair("corecst", inventoryVO.getCoreCost().toString()), new NameValuePair("cst", inventoryVO.getCost().toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making quickAddPart remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { return true; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return false; } public KitInventoryVO getPartDetailInfoByKitDef(CustomerVO customerVO, String lineAbbr, String partNum, Boolean logWarn, String remoteIpAddress, String lang, Boolean kitVOFlag) { KitInventoryVO kiVO = null; String getInventoryVOURL = "http://" + remoteIpAddress + ":8080/TAMSII/Servlets/partinfo"; logger.debug("getInventoryVOURL = " + getInventoryVOURL); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getInventoryVOURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbr), new NameValuePair("lang", lang), new NameValuePair("part", partNum), new NameValuePair("loc", customerVO.getLOC().toString()), new NameValuePair("flag",logWarn.toString()), new NameValuePair("custNo",customerVO.getCustomerNumber().toString()), new NameValuePair("kitVOFlag",kitVOFlag.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPartDetailInfoByKitDef remote call",httpGet.getQueryString(),remoteIpAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("kitInventoryVO") && !jsonObject.getJSONObject("kitInventoryVO").isNullObject()) { JSONObject kivoJSON = jsonObject.getJSONObject("kitInventoryVO"); kivoJSON.put("forKitInventory","true"); long conMillSec = System.currentTimeMillis(); kiVO = convertjsonToKIVO(kivoJSON); long conMillSecEnd = System.currentTimeMillis(); long convDuration = (conMillSecEnd-conMillSec); createAndLogConversionDataToAzure("Conversion of convertjsonToKIVO ",remoteIpAddress,kivoJSON.toString(),convDuration); return kiVO; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return kiVO; } private KitInventoryVO convertjsonToKIVO(JSONObject kivoJSON) { KitInventoryVO kitInventoryVO = null; kitInventoryVO = (KitInventoryVO)convertjsonToInventoryVO(kivoJSON); if(kivoJSON.containsKey("kitDefinition") && !kivoJSON.getJSONObject("kitDefinition").isNullObject()){ JSONObject jo =kivoJSON.getJSONObject("kitDefinition"); KitDefinitionVO kitDefinitionVO = new KitDefinitionVO(); if(jo.containsKey("externalIdentifier")&& jo.getString("externalIdentifier")!=null)kitDefinitionVO.setExternalIdentifier(jo.getString("externalIdentifier")); if(jo.containsKey("id")&& jo.getString("id")!=null)kitDefinitionVO.setId(jo.getInt("id")); if(jo.containsKey("version")&& jo.getString("version")!=null)kitDefinitionVO.setVersion(jo.getInt("version")); if(jo.containsKey("markedForDeletion")&& jo.getString("markedForDeletion")!=null)kitDefinitionVO.setMarkedForDeletion(jo.getBoolean("markedForDeletion")); if(jo.containsKey("kitPartIdentifier")&& !jo.getJSONObject("kitPartIdentifier").isNullObject()) { JSONObject kpiJson = kivoJSON.getJSONObject("kitPartIdentifier"); kitDefinitionVO.setKitPartIdentifier(convertjsonToPartIdentifierVO(kpiJson)); } if(jo.containsKey("kitDefinitionComponents")&& jo.getJSONArray("kitDefinitionComponents")!=null) { List kitDefinitionComponentVOList = new ArrayList(); JSONArray jsonArray = jo.getJSONArray("kitDefinitionComponents"); if(!jsonArray.isEmpty()) { Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { KitDefinitionComponentVO kitDefinitionComponentVO = new KitDefinitionComponentVO(); JSONObject json = JSONObject.fromObject(itr2.next()); if(json.containsKey("kitComponentPartIdentifier")&& !json.getJSONObject("kitComponentPartIdentifier").isNullObject()) { JSONObject kpiJson = json.getJSONObject("kitComponentPartIdentifier"); kitDefinitionComponentVO.setKitComponentPartIdentifier(convertjsonToPartIdentifierVO(kpiJson)); } if(json.containsKey("requiredQuantity")&& json.getString("requiredQuantity")!=null) kitDefinitionComponentVO.setRequiredQuantity(json.getInt("requiredQuantity")); if(json.containsKey("substitutionGroup")&& json.getString("substitutionGroup")!=null) kitDefinitionComponentVO.setSubstitutionGroup(json.getInt("substitutionGroup")); kitDefinitionComponentVOList.add(kitDefinitionComponentVO); } } kitDefinitionVO.setKitDefinitionComponents(kitDefinitionComponentVOList); } kitInventoryVO.setKitDefinition(kitDefinitionVO); } if(kivoJSON.containsKey("componentInventoryList") && kivoJSON.getJSONArray("componentInventoryList")!=null) { JSONArray componentJsonArray = kivoJSON.getJSONArray("componentInventoryList"); if (!componentJsonArray.isEmpty()) { Iterator componentJsonIterator = componentJsonArray.iterator(); while (componentJsonIterator.hasNext()) { InventoryVO inventoryVO = new InventoryVO(); JSONObject componentJson = JSONObject.fromObject(componentJsonIterator.next()); if(componentJson.containsKey("id")&& componentJson.getString("id")!=null) inventoryVO.setID(componentJson.getInt("id")); if(componentJson.containsKey("partNumber")&& componentJson.getString("partNumber")!=null) inventoryVO.setPartNumber(componentJson.getString("partNumber")); if (componentJson.containsKey("lineAbbrev") && componentJson.getString("lineAbbrev") != null) inventoryVO.setLineAbbrev(componentJson.getString("lineAbbrev")); if (componentJson.containsKey("expandedPartNumber") && componentJson.getString("expandedPartNumber") != null) inventoryVO.setExpandedPartNumber(componentJson.getString("expandedPartNumber")); if (componentJson.containsKey("description") && componentJson.getString("description") != null) inventoryVO.setDescription(componentJson.getString("description")); if (componentJson.containsKey("loc") && componentJson.getString("loc") != null) inventoryVO.setLOC(componentJson.getInt("loc")); kitInventoryVO.addComponentInventory(inventoryVO); } } } return kitInventoryVO; } private PartIdentifierVO convertjsonToPartIdentifierVO(JSONObject kpiJson) { PartIdentifierVO partIdentifierVO = new PartIdentifierVO(); if (kpiJson.containsKey("externalIdentifier") && kpiJson.getString("externalIdentifier") != null) partIdentifierVO.setExternalIdentifier(kpiJson.getString("externalIdentifier")); if (kpiJson.containsKey("id") && kpiJson.getString("id") != null) partIdentifierVO.setId(kpiJson.getInt("id")); if (kpiJson.containsKey("version") && kpiJson.getString("version") != null) partIdentifierVO.setVersion(kpiJson.getInt("version")); if (kpiJson.containsKey("markedForDeletion") && kpiJson.getString("markedForDeletion") != null) partIdentifierVO.setMarkedForDeletion(kpiJson.getBoolean("markedForDeletion")); if (kpiJson.containsKey("loc") && kpiJson.getString("loc") != null) partIdentifierVO.setLoc(kpiJson.getInt("loc")); if (kpiJson.containsKey("lineAbbrev") && kpiJson.getString("lineAbbrev") != null) partIdentifierVO.setLineAbbrev(kpiJson.getString("lineAbbrev")); if (kpiJson.containsKey("partNumber") && kpiJson.getString("partNumber") != null) partIdentifierVO.setPartNumber(kpiJson.getString("partNumber")); return partIdentifierVO; } public Vector getDistributionCenterList(String expandedPartNumber, String lineAbbrev, String language, Integer custNo, Integer location, TsoCurrentUser currentUser,String remoteStoreIP) { //http://10.5.28.35:8080/TAMSII/Servlets/servingdc?lineAb=FIL&lang=EN&part=1515&loc=1&custNo=1 JSONObject jsonObject = convertUserVOToJSON(currentUser); String json_string = jsonObject.toString(); Vector vector = new Vector(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/servingdc"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbrev), new NameValuePair("lang", language), new NameValuePair("part", expandedPartNumber), new NameValuePair("loc", location.toString()), new NameValuePair("custNo", custNo.toString()), new NameValuePair("ud", json_string)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getDistributionCenterList remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jObj = JSONObject.fromObject(result); if (jObj.containsKey("dcList") && jObj.getJSONArray("dcList")!=null) { JSONArray jsonArr = jObj.getJSONArray("dcList"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { if (j.containsKey("id") && j.containsKey("value")) { IDValuePairVO idValuePairVO = new IDValuePairVO(j.getString("id"), j.getString("value")); vector.add(idValuePairVO); } } } } return vector; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return vector; } private JSONObject convertUserVOToJSON(TsoCurrentUser vo) { JSONObject jsonObject = new JSONObject(); jsonObject.put("firstName",vo.getFirstName()); jsonObject.put("lastName",vo.getLastName()); jsonObject.put("employeeNum",vo.getEmployeeNum()); jsonObject.put("employeeLoc",vo.getEmployeeLoc()); jsonObject.put("employeeId",vo.getEmployeeId()); jsonObject.put("invoicingAllowed",vo.getInvoicingAllowed()); jsonObject.put("email",vo.getEmail()); jsonObject.put("refLanguageCd",vo.getRefLanguageCd()); jsonObject.put("timeOutSeconds",vo.getTimeOutSeconds()); jsonObject.put("password",vo.getPassword()); jsonObject.put("payPeriodProfileId",vo.getPayPeriodProfileId()); jsonObject.put("payTypeId",vo.getPayTypeId()); jsonObject.put("userId",vo.getUserId()); String format= "yyyy-MM-dd"; SimpleDateFormat sdf = new SimpleDateFormat(format); String dateString = sdf.format(vo.getPasswordExpDate()); jsonObject.put("passwordExpDate",dateString); jsonObject.put("refPasswordStatus",vo.getRefPasswordStatus()); jsonObject.put("employeeLdapId",vo.getEmployeeLdapId()); return jsonObject; } public MiscChgVO getMiscChargeStateDetail(String lineAbbr, String partNum, String state, String countryCD, String remoteStoreIP,Integer loc) { //http://10.5.28.35:8080/TAMSII/Servlets/misccharge?lineAb=FIL&part=1515&loc=1&stateCode=SC&cntryCode=US String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/misccharge"; logger.debug("getURL = " + url); MiscChgVO miscChgVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", lineAbbr), new NameValuePair("part", partNum), new NameValuePair("stateCode", state), new NameValuePair("cntryCode", countryCD), new NameValuePair("loc", loc.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getMiscChargeStateDetail remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] response = httpGet.getResponseBody(); String result = new String(response); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("miscChgVO") && !jsonObject.getJSONObject("miscChgVO").isNullObject() && jsonObject.getJSONObject("miscChgVO")!=null) { JSONObject jsonOb = jsonObject.getJSONObject("miscChgVO"); long conMillSec = System.currentTimeMillis(); miscChgVO = convertjsonToMiscCHG(jsonOb); long conMillSecEnd = System.currentTimeMillis(); long convDuration = (conMillSecEnd-conMillSec); createAndLogConversionDataToAzure("Conversion of convertjsonToMiscCHG ",remoteStoreIP,jsonOb.toString(),convDuration); return miscChgVO; } } }else{ logger.error("Server encountered an http error while getting multu store profilevo "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting multu store profilevo"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting multu store profilevo"); } catch (Exception exception) { logger.error("Exception occured while getting multu store profilevo"); } finally { httpGet.releaseConnection(); } return miscChgVO; } private MiscChgVO convertjsonToMiscCHG(JSONObject json) { MiscChgVO miscChgVO = new MiscChgVO(); if(json.containsKey("miscChgID")&& json.getString("miscChgID")!=null)miscChgVO.setMiscChgID(json.getInt("miscChgID")); if(json.containsKey("refResvLineCD"))miscChgVO.setRefResvLineCD(json.getString("refResvLineCD")); if(json.containsKey("cD"))miscChgVO.setCD(json.getString("cD")); if(json.containsKey("description"))miscChgVO.setDescription(json.getString("description")); if(json.containsKey("refMiscChgFlagID")&& json.getString("refMiscChgFlagID")!=null)miscChgVO.setRefMiscChgFlagID((byte) json.getInt("refMiscChgFlagID")); if(json.containsKey("chargeAmount"))miscChgVO.setChargeAmount(convertStringToBigDecimal(json.getString("chargeAmount"))); if(json.containsKey("taxStatusPrimRefOptnCD"))miscChgVO.setTaxStatusPrimRefOptnCD(json.getString("taxStatusPrimRefOptnCD")); if(json.containsKey("taxStatusSecRefOptnCD "))miscChgVO.setTaxStatusSecRefOptnCD (json.getString("taxStatusSecRefOptnCD ")); if(json.containsKey("appliesToProRataWarrantyReturns"))miscChgVO.setAppliesToProRataWarrantyReturns(json.getString("appliesToProRataWarrantyReturns")); if(json.containsKey("taxable1")&& json.getString("taxable1")!=null)miscChgVO.setTaxable1(json.getBoolean("taxable1")); if(json.containsKey("taxable2")&& json.getString("taxable2")!=null)miscChgVO.setTaxable2(json.getBoolean("taxable2")); return miscChgVO; } public BigDecimal getPriceWithLandedFactor(InventoryVO inventoryVO, BigDecimal warrantyAmount, Byte aByte, String remoteStoreIP,Integer loc) { //http://10.5.28.35:8080/TAMSII/Servlets/pwlf?lineAb=FIL&loc=1&grpCode=0&price=1&lft=1 BigDecimal pricewithLandedFactor = null; String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/pwlf"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAb", inventoryVO.getLineAbbrev()), new NameValuePair("loc", loc.toString()), new NameValuePair("grpCode", inventoryVO.getGroupCode().toString()), new NameValuePair("price",warrantyAmount.toString()), new NameValuePair("lft",aByte.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPriceWithLandedFactor remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] delDescResponse = httpGet.getResponseBody(); String result = new String(delDescResponse); pricewithLandedFactor = convertStringToBigDecimal(result); return pricewithLandedFactor; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return pricewithLandedFactor; } public MultiStoreProfileVO getMulitStoreProfile(String remoteStoreIP,Integer loc) { //http://10.5.28.35:8080/TAMSII/Servlets/multistoreprofile?loc= String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/multistoreprofile"; logger.debug("getURL = " + url); MultiStoreProfileVO multiStoreProfileVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getMulitStoreProfile remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] response = httpGet.getResponseBody(); String result = new String(response); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject.containsKey("multiStoreProfileVO") &&!jsonObject.getJSONObject("multiStoreProfileVO").isNullObject()) { JSONObject jsonOb = jsonObject.getJSONObject("multiStoreProfileVO"); long convMillSec = System.currentTimeMillis(); multiStoreProfileVO = convertJSONToMultiStoreProfileVO(jsonOb); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToMultiStoreProfileVO",remoteStoreIP,jsonOb.toString(),convDuration); } } }else{ logger.error("Server encountered an http error while getting multu store profilevo "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting multu store profilevo"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting multu store profilevo"); } catch (Exception exception) { logger.error("Exception occured while getting multu store profilevo"); } finally { httpGet.releaseConnection(); } return multiStoreProfileVO; } private MultiStoreProfileVO convertJSONToMultiStoreProfileVO(JSONObject jsonObj) { MultiStoreProfileVO multiStoreProfileVO = new MultiStoreProfileVO(); if(jsonObj.containsKey("location") && jsonObj.getString("location")!=null){multiStoreProfileVO.setLocation(jsonObj.getInt("location"));} if(jsonObj.containsKey("companyID") && jsonObj.getString("companyID")!=null){multiStoreProfileVO.setCompanyID(jsonObj.getInt("companyID"));} if(jsonObj.containsKey("locationAtMain") && jsonObj.getString("locationAtMain")!=null){multiStoreProfileVO.setLocationAtMain(jsonObj.getInt("locationAtMain"));} if(jsonObj.containsKey("mainStoreNetworkName") && jsonObj.getString("mainStoreNetworkName")!=null){multiStoreProfileVO.setMainStoreNetworkName(jsonObj.getString("mainStoreNetworkName"));} if(jsonObj.containsKey("useMultiStoreAR") && !jsonObj.getJSONObject("useMultiStoreAR").isNullObject()){ JSONObject jo = jsonObj.getJSONObject("useMultiStoreAR"); multiStoreProfileVO.setUseMultiStoreAR(convertLockableJsonObject(jo.getString("locked")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(jsonObj.containsKey("defaultStore") && jsonObj.getJSONObject("defaultStore").isNullObject()){ JSONObject jo = jsonObj.getJSONObject("defaultStore"); multiStoreProfileVO.setDefaultStore(convertLockableJsonObject(jo.getString("locked")).booleanValue()==true?LockableBoolean.TRUE:LockableBoolean.FALSE);} if(jsonObj.containsKey("serverCompanyIDNumber") && jsonObj.getString("serverCompanyIDNumber")!=null){multiStoreProfileVO.setServerCompanyIDNumber(Short.valueOf(jsonObj.getString("serverCompanyIDNumber")));} if(jsonObj.containsKey("serverStoreIDNumber") && jsonObj.getString("serverStoreIDNumber")!=null){multiStoreProfileVO.setServerStoreIDNumber(Short.valueOf(jsonObj.getString("serverStoreIDNumber")));} if(jsonObj.containsKey("historyUpdateActive") && jsonObj.getString("historyUpdateActive")!=null){multiStoreProfileVO.setHistoryUpdateActive(jsonObj.getString("historyUpdateActive"));} if(jsonObj.containsKey("ipAddress") && jsonObj.getString("ipAddress")!=null){multiStoreProfileVO.setIPAddress(jsonObj.getString("ipAddress"));} if(jsonObj.containsKey("odbcConnectionName") && jsonObj.getString("odbcConnectionName")!=null){multiStoreProfileVO.setODBCConnectionName(jsonObj.getString("odbcConnectionName"));} if(jsonObj.containsKey("lastModifiedDate") && jsonObj.getString("lastModifiedDate")!=null){multiStoreProfileVO.setLastModifiedDate(ConvertStringToDate(jsonObj.getString("lastModifiedDate")));} if(jsonObj.containsKey("modifiedByEmployeeID") && jsonObj.getString("modifiedByEmployeeID")!=null){multiStoreProfileVO.setModifiedByEmployeeID(jsonObj.getInt("modifiedByEmployeeID"));} if(jsonObj.containsKey("databaseServerName") && jsonObj.getString("databaseServerName")!=null){multiStoreProfileVO.setDatabaseServerName(jsonObj.getString("databaseServerName"));} if(jsonObj.containsKey("databaseName") && jsonObj.getString("databaseName")!=null){multiStoreProfileVO.setDatabaseName(jsonObj.getString("databaseName"));} if(jsonObj.containsKey("databasePortNumber") && jsonObj.getString("databasePortNumber")!=null){multiStoreProfileVO.setDatabasePortNumber(jsonObj.getInt("databasePortNumber"));} if(jsonObj.containsKey("replicatingToServerFarm") && jsonObj.getString("replicatingToServerFarm")!=null){multiStoreProfileVO.setReplicatingToServerFarm(jsonObj.getBoolean("replicatingToServerFarm"));} if(jsonObj.containsKey("allowBranchArDataInquiry") && jsonObj.getString("allowBranchArDataInquiry")!=null){multiStoreProfileVO.setAllowBranchArDataInquiry(jsonObj.getString("allowBranchArDataInquiry"));} return multiStoreProfileVO; } public Vector getMSStockCheck(Integer loc, String lineAbbreviation, String partNumber, String remoteStoreIP) { //http://10.5.28.35:8080/TAMSII/Servlets/multistoresc?loc=1&lineAbbrev=FIL&partNo=1515 Vector vector =new Vector(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/multistoresc"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("lineAbbrev", lineAbbreviation), new NameValuePair("partNo", partNumber)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getMSStockCheck remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jObj = JSONObject.fromObject(result); if (jObj.containsKey("multiStoreStockCheck") && jObj.getJSONArray("multiStoreStockCheck")!=null) { JSONArray jsonArr = jObj.getJSONArray("multiStoreStockCheck"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { MSStockCheckVO msStockCheckVO = new MSStockCheckVO(); JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { long convMillSec = System.currentTimeMillis(); msStockCheckVO = convertJSONToMSStockCheckVO(j); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToMSStockCheckVO",remoteStoreIP,j.toString(),convDuration); vector.add(msStockCheckVO); } } } return vector; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return vector; } private MSStockCheckVO convertJSONToMSStockCheckVO(JSONObject jsonObj) { MSStockCheckVO msStockCheckVO = new MSStockCheckVO(); if(jsonObj.containsKey("lineAbbreviation") && jsonObj.getString("lineAbbreviation")!=null){msStockCheckVO.setLineAbbreviation(jsonObj.getString("lineAbbreviation"));} if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null){msStockCheckVO.setPartNumber(jsonObj.getString("partNumber"));} if(jsonObj.containsKey("coID") && jsonObj.getString("coID")!=null){msStockCheckVO.setCoID(jsonObj.getInt("coID"));} if(jsonObj.containsKey("stID") && jsonObj.getString("stID")!=null){msStockCheckVO.setStID(jsonObj.getInt("stID"));} if(jsonObj.containsKey("storeName") && jsonObj.getString("storeName")!=null){msStockCheckVO.setStoreName(jsonObj.getString("storeName"));} if(jsonObj.containsKey("onHand") && jsonObj.getString("onHand")!=null){msStockCheckVO.setOnHand(jsonObj.getInt("onHand"));} if(jsonObj.containsKey("onOrder") && jsonObj.getString("onOrder")!=null){msStockCheckVO.setOnOrder(jsonObj.getInt("onOrder"));} if(jsonObj.containsKey("daysOnOrder") && jsonObj.getString("daysOnOrder")!=null){msStockCheckVO.setDaysOnOrder(jsonObj.getInt("daysOnOrder"));} if(jsonObj.containsKey("onFactoryOrder") && jsonObj.getString("onFactoryOrder")!=null){msStockCheckVO.setOnFactoryOrder(jsonObj.getInt("onFactoryOrder"));} if(jsonObj.containsKey("daysOnFOrder") && jsonObj.getString("daysOnFOrder")!=null){msStockCheckVO.setDaysOnFOrder(jsonObj.getInt("daysOnFOrder"));} if(jsonObj.containsKey("onBackOrder") && jsonObj.getString("onBackOrder")!=null){msStockCheckVO.setOnBackOrder(jsonObj.getInt("onBackOrder"));} if(jsonObj.containsKey("daysOnBOrder") && jsonObj.getString("daysOnBOrder")!=null){msStockCheckVO.setDaysOnBOrder(jsonObj.getInt("daysOnBOrder"));} if(jsonObj.containsKey("ytdSales") && jsonObj.getString("ytdSales")!=null){msStockCheckVO.setYTDSales(jsonObj.getString("ytdSales"));} if(jsonObj.containsKey("lyrSales") && jsonObj.getString("lyrSales")!=null){msStockCheckVO.setLYRSales(jsonObj.getString("lyrSales"));} if(jsonObj.containsKey("minStock") && jsonObj.getString("minStock")!=null){msStockCheckVO.setMinStock(jsonObj.getInt("minStock"));} if(jsonObj.containsKey("maxStock") && jsonObj.getString("maxStock")!=null){msStockCheckVO.setMaxStock(jsonObj.getInt("maxStock"));} return msStockCheckVO; } public PricesOutVO getPickUpPrice(PricesInVO pricesInVO, String remoteIpAddress,Integer loc) { //http://10.5.28.35:8080/TAMSII/Servlets/pickupprice?cost=1&coreCost=1&loc=1&id=1&typeCD=A PricesOutVO pricesOutVO = null; String url = "http://" + remoteIpAddress + ":8080/TAMSII/Servlets/pickupprice"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("cost", pricesInVO.getCost().toString()), new NameValuePair("coreCost", pricesInVO.getCoreCost()==null?null:pricesInVO.getCoreCost().toString()), new NameValuePair("loc", loc.toString()), new NameValuePair("id", pricesInVO.getCustomerId().toString()), new NameValuePair("typeCD", pricesInVO.getCustomerTypeCD())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPickUpPrice remote call",httpGet.getQueryString(),remoteIpAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] outResponse = httpGet.getResponseBody(); String result = new String(outResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("pricesOutVO") && !jsonObject.getJSONObject("pricesOutVO").isNullObject()){ JSONObject pricesOutJson = jsonObject.getJSONObject("pricesOutVO"); long convMillSec = System.currentTimeMillis(); pricesOutVO = convertJSONToPricesOutVO(pricesOutJson); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToPricesOutVO",remoteIpAddress,pricesOutJson.toString(),convDuration); return pricesOutVO; } } else { logger.error("Server encountered an http error while authenticating " + httpGet.getStatusLine()); throw new HttpException(String.valueOf(httpGet.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { httpGet.releaseConnection(); } return pricesOutVO; } public String getFulfillmentBySalesOrderId(Integer id, String remoteIpAddress,Integer loc) { String url = "http://" + remoteIpAddress + ":8080/TAMSII/Servlets/poNumber"; logger.debug("getURL = " + url); String result = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("id", id.toString()), new NameValuePair("loc", loc.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getFulfillmentBySalesOrderId remote call",httpGet.getQueryString(),remoteIpAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] outResponse = httpGet.getResponseBody(); result = new String(outResponse); } else { logger.error("Server encountered an http error while authenticating " + httpGet.getStatusLine()); //throw new HttpException(String.valueOf(httpGet.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { httpGet.releaseConnection(); } return result; } public void sendNXPInterstoreUpdateSalesOrderRequestForPhoneRoom(InvoiceVO invoiceVO, String remoteStoreIP, boolean flag) { JSONObject req_json = new JSONObject(); try{ req_json = ConversionToVO.convertInvoiceVOToJson(invoiceVO); }catch(Exception e){ logger.error(("vo to json conversion exception, e")); } JSONObject obj = new JSONObject(); obj.put("invoiceDetails",req_json); obj.put("flag",flag); String json_string = obj.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/sendnxpupdatePR"; logger.debug("getURL = " + url); HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("send nxp interstore update for phone room Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making sendNXPInterstoreUpdateSalesOrderRequestForPhoneRoom remote call",json_string,remoteStoreIP, statusCode,callDuration); logger.info("Response from server is " + taapRequest.getStatusLine()); if (statusCode == HttpStatus.SC_OK) { logger.info("sendNXPInterstoreUpdateSalesOrderRequestForPhoneRoom success "); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } } public Vector getPrinterListPR(Integer loc, String type, String use, String remoteStoreIP, String ip) { Vector vector =new Vector(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/printerlist"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("type", type), new NameValuePair("use", use), new NameValuePair("ip",ip)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPrinterListPR remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jObj = JSONObject.fromObject(result); if (jObj.containsKey("printerList") && jObj.getJSONArray("printerList")!=null) { JSONArray jsonArr = jObj.getJSONArray("printerList"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { vector.add(j); } } } return vector; } } }else{ logger.error("Server encountered an http error while getting Printer List response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return vector; } public Integer getCustomerNumByID(Map params) { String remoteStoreIp = (String) params.get(SERVING_STORE_IP_ADDRESS); String getCustomerVOURL = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/custNameById"; logger.debug("getCustomerVOURL = " + getCustomerVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getCustomerVOURL); String custId = (String) params.get(CUSTID); Integer custNum = null; httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", (String) params.get(LOC)), new NameValuePair("custId",custId) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerNumByID remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { custNum = Integer.parseInt(result); } }else{ logger.error("Server encountered an http error while getting Customer Number response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return custNum; } public Vector getCustomerDeliveryTaxTables(Integer loc, short taxId, String remoteStoreIP) { Vector vector =new Vector(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/custdeliverytax"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("type", String.valueOf(taxId))}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerDeliveryTaxTables remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jObj = JSONObject.fromObject(result); if (jObj.containsKey("customerDeliveryTaxTables") && jObj.getJSONArray("customerDeliveryTaxTables")!=null) { JSONArray jsonArr = jObj.getJSONArray("customerDeliveryTaxTables"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { long convMillsec = System.currentTimeMillis(); vector.add(convertJsonToTaxTableVO(j)); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillsec); createAndLogConversionDataToAzure("Conversion of convertJsonToTaxTableVO",remoteStoreIP, j.toString(),convDuration); } } } return vector; } } }else{ logger.error("Server encountered an http error while customer delivery taxable response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting customer delivery taxable"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting customer delivery taxable"); } catch (Exception exception) { logger.error("Exception occured while getting customer delivery taxable"); } finally { httpGet.releaseConnection(); } return vector; } public boolean sendNOLOrderUpdateForPhoneRoom(SalesOrderVO vo, String remoteStoreIP) { JSONObject req_json = ConversionToVO.checkTimeStampFormat(vo); String json_string = req_json.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/sendnolupdatePR"; logger.debug("getURL = " + url); HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; boolean flag = false; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("send nol order pick update for phone room Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making sendNOLOrderUpdateForPhoneRoom remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = taapRequest.getResponseBody(); String result = new String(custVOResponse); if(result.equalsIgnoreCase("true")){ flag = true; } logger.info("sendNOLOrderUpdateForPhoneRoom success "); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return flag; } public OrderNotificationStatus sendOrderUpdateNotificationForPhoneRoom(OrderUpdateDetail orderUpdateDetail, String remoteStoreIP) { JSONObject req_json = ConversionToVO.convertOrderUpdateDetailToJSon(orderUpdateDetail); JSONObject obj = new JSONObject(); obj.put("orderUpdateDetails",req_json); String json_string = obj.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/sendorderupdatePR"; logger.debug("getURL = " + url); HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; OrderNotificationStatus status = null; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { logger.debug("send nol order pick update for phone room Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making sendOrderUpdateNotificationForPhoneRoom remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = taapRequest.getResponseBody(); String result = new String(custVOResponse); JSONObject orderNotObj = JSONObject.fromObject(result); long convMillSec = System.currentTimeMillis(); status = ConversionToVO.convertOrderNotificationStatusToJSon(orderNotObj); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillSec); createAndLogConversionDataToAzure("Conversion of convertOrderNotificationStatusToJSon",remoteStoreIP,orderNotObj.toString(),convDuration); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); //throw new HttpException(String.valueOf(taapRequest.getStatusLine())); } } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { taapRequest.releaseConnection(); } return status; } public CustomerDeliveryVO getCustomerDeliveryVOPR(Integer loc, String type, String id, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/custdelivery"; logger.debug("getURL = " + url); CustomerDeliveryVO customerDeliveryVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("type", type), new NameValuePair("id", id)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerDeliveryVOPR remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("customerDeliveryVO") && !jsonObject.getJSONObject("customerDeliveryVO").isNullObject()){ JSONObject customerDeliveryJson = jsonObject.getJSONObject("customerDeliveryVO"); long conMillSec = System.currentTimeMillis(); customerDeliveryVO = convertJSONToCustDeliveryVO(customerDeliveryJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToCustDeliveryVO ends",remoteStoreIP,customerDeliveryJson.toString(), convDuration); return customerDeliveryVO; } }else{ logger.error("Server encountered an http error while customer delivery response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting customer delivery response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting customer delivery response"); } catch (Exception exception) { logger.error("Exception occured while getting customer delivery response"); } finally { httpGet.releaseConnection(); } return customerDeliveryVO; } public static CustomerDeliveryVO convertJSONToCustDeliveryVO(JSONObject obj){ CustomerDeliveryVO vo = null; if(!obj.isNullObject() && !obj.isEmpty()){ vo=new CustomerDeliveryVO(); if(obj.containsKey("customerID")){ vo.setCustomerID(obj.getInt("customerID")); } if(obj.containsKey("loc")){ vo.setLOC(obj.getInt("loc")); } if(obj.containsKey("deliveryRefOptionCD")){ vo.setDeliveryRefOptionCD(obj.getString("deliveryRefOptionCD")); } if(obj.containsKey("deliveryOptionDescripion")){ vo.setDeliveryOptionDescripion(obj.getString("deliveryOptionDescripion")); } if(obj.containsKey("deliveryRouteCD")) { vo.setDeliveryRouteCD(obj.getString("deliveryRouteCD")); } if(obj.containsKey("deliveryPriorityID")){ vo.setDeliveryPriorityID(new Byte(obj.getString("deliveryPriorityID"))); } if(obj.containsKey("travelTimeCustomer")){ vo.setTravelTimeCustomer(new Short(obj.getString("travelTimeCustomer"))); } if(obj.containsKey("distanceToCustomer")){ vo.setDistanceToCustomer(new Short(obj.getString("distanceToCustomer"))); } if(obj.containsKey("directions")){ vo.setDirections(obj.getString("directions")); } if(obj.containsKey("minAmtFreeDelivery")){ vo.setMinAmtFreeDelivery(new BigDecimal(obj.getString("minAmtFreeDelivery"))); } if(obj.containsKey("deliveryCharge")){ vo.setDeliveryCharge(new BigDecimal(obj.getString("deliveryCharge"))); } } return vo; } public TerminalVO getTerminalVOPR(String ip, Integer loc, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/terminal"; logger.debug("getURL = " + url); TerminalVO terminalVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("ip", ip)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getTerminalVOPR remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("terminalVO") && !jsonObject.getJSONObject("terminalVO").isNullObject()){ JSONObject terminalJson = jsonObject.getJSONObject("terminalVO"); long conMillSec = System.currentTimeMillis(); terminalVO = convertJSONToTerminalVO(terminalJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToTerminalVO ends",remoteStoreIP,terminalJson.toString(), convDuration); return terminalVO; } }else{ logger.error("Server encountered an http error while terminal response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting terminal response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting terminal response"); } catch (Exception exception) { logger.error("Exception occured while getting terminal response"); } finally { httpGet.releaseConnection(); } return terminalVO; } public TerminalVO convertJSONToTerminalVO(JSONObject jsonObj){ TerminalVO terminalVO = new TerminalVO(); if(jsonObj.containsKey("beepOnAccessMessage") && jsonObj.getString("beepOnAccessMessage")!=null){terminalVO.setBeepOnAccessMessage(jsonObj.getBoolean("beepOnAccessMessage"));} if(jsonObj.containsKey("beepOnDivDcMessage") && jsonObj.getString("beepOnDivDcMessage")!=null){terminalVO.setBeepOnDivDcMessage(jsonObj.getBoolean("beepOnDivDcMessage"));} if(jsonObj.containsKey("beepOnNOLMessage") && jsonObj.getString("beepOnNOLMessage")!=null){terminalVO.setBeepOnNOLMessage(jsonObj.getBoolean("beepOnNOLMessage"));} if(jsonObj.containsKey("beepOnInterstoreMessage") && jsonObj.getString("beepOnInterstoreMessage")!=null){terminalVO.setBeepOnInterstoreMessage(jsonObj.getBoolean("beepOnInterstoreMessage"));} if(jsonObj.containsKey("barCodeScanner") && jsonObj.getString("barCodeScanner")!=null){terminalVO.setBarCodeScanner(jsonObj.getBoolean("barCodeScanner"));} if(jsonObj.containsKey("boxNumber") && jsonObj.getString("boxNumber")!=null){terminalVO.setBoxNumber(Byte.parseByte(jsonObj.getString("boxNumber")));} if(jsonObj.containsKey("cashDrawer") && jsonObj.getString("cashDrawer")!=null){terminalVO.setCashDrawer(jsonObj.getBoolean("cashDrawer"));} if(jsonObj.containsKey("cashInvoicePrinterID") && jsonObj.getString("cashInvoicePrinterID")!=null){terminalVO.setCashInvoicePrinterID(jsonObj.getInt("cashInvoicePrinterID"));} if(jsonObj.containsKey("chargeInvoicePrinterID") && jsonObj.getString("chargeInvoicePrinterID")!=null){terminalVO.setChargeInvoicePrinterID(jsonObj.getInt("chargeInvoicePrinterID"));} if(jsonObj.containsKey("modifiedByEmployeeID") && jsonObj.getString("modifiedByEmployeeID")!=null){terminalVO.setModifiedByEmployeeID(jsonObj.getInt("modifiedByEmployeeID"));} if(jsonObj.containsKey("lastModifiedDate") && jsonObj.getString("lastModifiedDate")!=null){terminalVO.setLastModifiedDate(ConvertStringToDate(jsonObj.getString("lastModifiedDate")));} if(jsonObj.containsKey("msdsPrinterID") && jsonObj.getString("msdsPrinterID")!=null){terminalVO.setMsdsPrinterID(jsonObj.getInt("msdsPrinterID"));} if(jsonObj.containsKey("portNumber") && jsonObj.getString("portNumber")!=null){terminalVO.setPortNumber(Short.parseShort(jsonObj.getString("portNumber")));} if(jsonObj.containsKey("refDeviceConnectionTypeID") && jsonObj.getString("refDeviceConnectionTypeID")!=null){terminalVO.setRefDeviceConnectionTypeID(Byte.parseByte(jsonObj.getString("refDeviceConnectionTypeID")));} if(jsonObj.containsKey("reportPrinterID") && jsonObj.getString("reportPrinterID")!=null){terminalVO.setReportPrinterID(jsonObj.getInt("reportPrinterID"));} if(jsonObj.containsKey("roaPrinterID") && jsonObj.getString("roaPrinterID")!=null){terminalVO.setROAPrinterID(jsonObj.getInt("roaPrinterID"));} if(jsonObj.containsKey("windowsPrinterID") && jsonObj.getString("windowsPrinterID")!=null){terminalVO.setWindowsPrinterID(jsonObj.getInt("windowsPrinterID"));} if(jsonObj.containsKey("paymentDeviceNumber") && jsonObj.getString("paymentDeviceNumber")!=null){terminalVO.setPaymentDeviceNumber(Byte.parseByte(jsonObj.getString("paymentDeviceNumber")));} if(jsonObj.containsKey("enableManualCCEntry") && jsonObj.getString("enableManualCCEntry")!=null){terminalVO.setEnableManulCCEntry(jsonObj.getBoolean("enableManualCCEntry"));} if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){terminalVO.setID(jsonObj.getInt("id"));} if(jsonObj.containsKey("loc") && jsonObj.getString("loc")!=null){terminalVO.setLoc(jsonObj.getInt("loc"));} if(jsonObj.containsKey("desc") && jsonObj.getString("desc")!=null){terminalVO.setDesc(jsonObj.getString("desc"));} if(jsonObj.containsKey("info") && jsonObj.getString("info")!=null){terminalVO.setInfo(jsonObj.getString("info"));} if(jsonObj.containsKey("ipAddress") && jsonObj.getString("ipAddress")!=null){terminalVO.setIPAddress(jsonObj.getString("ipAddress"));} return terminalVO; } public Integer getNextSalesOrderNumber(String remoteStoreIP, String miscIp,Integer employeeId, Integer loc, Object o) { Integer salesOrderNum = null; String getCustomerVOURL = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/nextSOnum"; logger.debug("getNextSalesOrderNumberURL = " + getCustomerVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getCustomerVOURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("ip", miscIp), new NameValuePair("loc",loc.toString()), new NameValuePair("empId",employeeId.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getNextSalesOrderNumber remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { salesOrderNum = Integer.parseInt(result); } }else{ logger.error("Server encountered an http error while getting Customer Number response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return salesOrderNum.intValue(); } public Integer createSalesOrder(SalesOrderVO salesOrderVO, String remoteStoreIP) { Integer salesOrderId =null; String getCustomerVOURL = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/createsalesorder"; logger.debug("createSalesOrderURL = " + getCustomerVOURL);; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(getCustomerVOURL); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("orderNum", salesOrderVO.getOrderNumber().toString()), new NameValuePair("loc",salesOrderVO.getLoc().toString()), new NameValuePair("custId",salesOrderVO.getCustomerId().toString()), new NameValuePair("date",String.valueOf(salesOrderVO.getOrderDate().getTime())), new NameValuePair("id",salesOrderVO.getModifiedByEmployeeId().toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making createSalesOrder remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); if(result!=null && result!="" && !result.isEmpty()) { salesOrderId = Integer.parseInt(result); } }else{ logger.error("Server encountered an http error while getting Customer Number response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return salesOrderId.intValue(); } public boolean getArProfilePrintStatements(String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/arprofilestatement"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getArProfilePrintStatements remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting AR profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting AR profile response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting AR profile response"); } catch (Exception exception) { logger.error("Exception occured while getting AR profile response"); } finally { httpGet.releaseConnection(); } return false; } public List getLoyaltyNonEligibleList(Integer loc, String remoteIpAddress) { String url = "http://" + remoteIpAddress + ":8080/TAMSII/Servlets/loyaltynoneligiblelist"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()) }); List nonEligibleIdList = null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getLoyaltyNonEligibleList remote call",httpGet.getQueryString(),remoteIpAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("napaRewardsNonEligibleList") && !jsonObject.getJSONArray("napaRewardsNonEligibleList").isEmpty()){ JSONArray jsonArray = jsonObject.getJSONArray("napaRewardsNonEligibleList"); nonEligibleIdList = new ArrayList(); Iterator itr2 = jsonArray.iterator(); while (itr2.hasNext()) { Integer id = (Integer) itr2.next(); nonEligibleIdList.add(id.byteValue()); } } } else{ logger.error("Server encountered an http error while getting napaRewardsNonEligibleList response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting napaRewardsNonEligibleList"); }catch (Exception exception) { logger.error("Exception occured while getting price napaRewardsNonEligibleList"); } finally { httpGet.releaseConnection(); } return nonEligibleIdList; } public boolean doSupersedesExist(String remoteStoreIP, String lineAbbrev, String partNumber, Integer loc) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/supersedesexist"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbr", lineAbbrev), new NameValuePair("part", partNumber), new NameValuePair("loc", loc.toString()) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making doSupersedesExist remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return false; } public BarcodeVO getBarcode(String barcode, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/barcode"; logger.debug("getURL = " + url); BarcodeVO barcodeVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("barcode", barcode)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getBarcode remote call",httpGet.getQueryString(),remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(!jsonObject.isNullObject()){ long conMillSec = System.currentTimeMillis(); barcodeVO = convertJSONToBarCodeVO(jsonObject); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToBarCodeVO ",remoteStoreIP,jsonObject.toString(), convDuration); return barcodeVO; } }else{ logger.error("Server encountered an http error while terminal response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting terminal response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting terminal response"); } catch (Exception exception) { logger.error("Exception occured while getting terminal response"); } finally { httpGet.releaseConnection(); } return barcodeVO; } private BarcodeVO convertJSONToBarCodeVO(JSONObject jsonObj) { BarcodeVO barCodeVO = new BarcodeVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){barCodeVO.setID(jsonObj.getInt("id"));} if(jsonObj.containsKey("barcode") && jsonObj.getString("barcode")!=null){barCodeVO.setBarcode(jsonObj.getString("barcode"));} if(jsonObj.containsKey("lineAbbrev") && jsonObj.getString("lineAbbrev")!=null){barCodeVO.setLineAbbrev(jsonObj.getString("lineAbbrev"));} if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null){barCodeVO.setPartNumber(jsonObj.getString("partNumber"));} if(jsonObj.containsKey("pkgQty") && jsonObj.getString("pkgQty")!=null){barCodeVO.setPkgQty(Short.valueOf(jsonObj.getString("pkgQty")));} if(jsonObj.containsKey("allowDVDUpdate") && jsonObj.getString("allowDVDUpdate")!=null){barCodeVO.setDVDUpdateAllowed(jsonObj.getBoolean("allowDVDUpdate"));} if(jsonObj.containsKey("modByEmployeeID") && jsonObj.getString("modByEmployeeID")!=null){barCodeVO.setModByEmployeeID(jsonObj.getInt("modByEmployeeID"));} if(jsonObj.containsKey("modByEmployeeLOC") && jsonObj.getString("modByEmployeeLOC")!=null){barCodeVO.setModByEmployeeLOC(jsonObj.getInt("modByEmployeeLOC"));} if(jsonObj.containsKey("updateFromCD") && jsonObj.getString("updateFromCD")!=null){barCodeVO.setUpdatedFromCD(jsonObj.getString("updateFromCD"));} if(jsonObj.containsKey("tmpBarcodeEntry") && jsonObj.getString("tmpBarcodeEntry")!=null){barCodeVO.setTmpBarcodeEntry(jsonObj.getString("tmpBarcodeEntry"));} return barCodeVO; } public BigDecimal getLowSuggestedPrice(String remoteStoreIP, InventoryVO inventoryVO) { BigDecimal lowsuggPrice =null; JSONObject req_json = inventoryVO.toJSONValue(); JSONObject inp_json = new JSONObject(); inp_json.put("inventoryVO",req_json); String json_string = inp_json.toString(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/lowsuggestedprice"; logger.debug("getLowSuggestedPrice url = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new PostMethod(url); StringRequestEntity reqEntity = null; try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } try { ((PostMethod) httpGet).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getLowSuggestedPrice remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] response = httpGet.getResponseBody(); String result = new String(response); if(result!=null && result!="" && !result.isEmpty()) { lowsuggPrice = convertStringToBigDecimal(result); return lowsuggPrice; } }else{ logger.error("Server encountered an http error while getting Customer Number response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return lowsuggPrice; } public boolean isCSGCoreInvoice(Integer partsBilledOnInvoiceID, Integer loc, String remoteIpAddress) { String url = "http://" + remoteIpAddress + ":8080/TAMSII/Servlets/coreinvoicecheck"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new PostMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("id", partsBilledOnInvoiceID.toString()), new NameValuePair("loc", loc.toString()) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isCSGCoreInvoice remote call", httpGet.getQueryString(), remoteIpAddress, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting isCSGCoreInvoice response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting isCSGCoreInvoice"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting isCSGCoreInvoice"); } catch (Exception exception) { logger.error("Exception occured while getting price isCSGCoreInvoice"); } finally { httpGet.releaseConnection(); } return false; } public CustomerCertificateVO getCustomerCertificateInfo(Integer location, Integer customerId, Integer certPartGroupId, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/customercertinfo"; logger.debug("getURL = " + url); CustomerCertificateVO customerCertificateVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("id", customerId.toString()), new NameValuePair("loc", location.toString()), new NameValuePair("groupId", certPartGroupId.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerCertificateInfo remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("customerCertVO") && !jsonObject.getJSONObject("customerCertVO").isNullObject()){ JSONObject custCertJson = jsonObject.getJSONObject("customerCertVO"); long conMillSec = System.currentTimeMillis(); customerCertificateVO = convertJSONToCustCertVO(custCertJson); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToCustCertVO ends",remoteStoreIP,custCertJson.toString(), convDuration); return customerCertificateVO; } }else{ logger.error("Server encountered an http error while terminal response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting terminal response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting terminal response"); } catch (Exception exception) { logger.error("Exception occured while getting terminal response"); } finally { httpGet.releaseConnection(); } return customerCertificateVO; } private CustomerCertificateVO convertJSONToCustCertVO(JSONObject jsonObj) { CustomerCertificateVO customerCertificateVO = new CustomerCertificateVO(); if(jsonObj.containsKey("certificationPartGroupId") && jsonObj.getString("certificationPartGroupId")!=null){customerCertificateVO.setCertificationPartGroupId(jsonObj.getInt("certificationPartGroupId"));} if(jsonObj.containsKey("technicianName") && jsonObj.getString("technicianName")!=null){customerCertificateVO.setTechnicianName(jsonObj.getString("technicianName"));} if(jsonObj.containsKey("certificateNumber") && jsonObj.getString("certificateNumber")!=null){customerCertificateVO.setCertificateNumber(jsonObj.getString("certificateNumber"));} if(jsonObj.containsKey("beginDate") && jsonObj.getString("beginDate")!=null){customerCertificateVO.setBeginDate(CovertToDateFr(jsonObj.getString("beginDate"),"YYYY-MM-dd"));} if(jsonObj.containsKey("endDate") && jsonObj.getString("endDate")!=null){customerCertificateVO.setEndDate(CovertToDateFr(jsonObj.getString("endDate"),"YYYY-MM-dd"));} if(jsonObj.containsKey("certificationCategory") && jsonObj.getString("certificationCategory")!=null){customerCertificateVO.setCertificationCategory(jsonObj.getString("certificationCategory"));} if(jsonObj.containsKey("certificationGroup") && jsonObj.getString("certificationGroup")!=null){customerCertificateVO.setCertificationGroup(jsonObj.getInt("certificationGroup"));} if(jsonObj.containsKey("description") && jsonObj.getString("description")!=null){customerCertificateVO.setDescription(jsonObj.getString("description"));} return customerCertificateVO; } public Boolean isReservedLine(String lineAbbrev, String remoteStoreIP, String loc) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/checklineabbrev"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbr", lineAbbrev), new NameValuePair("loc", loc) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isReservedLine remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting isReservedLine response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting isReservedLine"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting isReservedLine"); } catch (Exception exception) { logger.error("Exception occured while getting price isReservedLine"); } finally { httpGet.releaseConnection(); } return false; } public SupersedePartVO getSupersede(InventoryVO inventoryVO, String remoteStoreIP, CustomerVO customerVO,String lang) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/supersede"; logger.debug("getURL = " + url); SupersedePartVO supersedePartVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbrev", inventoryVO.getLineAbbrev()), new NameValuePair("loc", inventoryVO.getLOC().toString()), new NameValuePair("part", inventoryVO.getPartNumber()), new NameValuePair("custId", customerVO.getID().toString()), new NameValuePair("lang", lang)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getSupersede remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("supersedeVO") && !jsonObject.getJSONObject("supersedeVO").isNullObject()){ JSONObject ssjsonObject = jsonObject.getJSONObject("supersedeVO"); long conMillSec = System.currentTimeMillis(); supersedePartVO = convertJSONToSuperSedeVO(ssjsonObject); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToSuperSedeVO ends",remoteStoreIP,ssjsonObject.toString(), convDuration); return supersedePartVO; } }else{ logger.error("Server encountered an http error while terminal response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting terminal response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting terminal response"); } catch (Exception exception) { logger.error("Exception occured while getting terminal response"); } finally { httpGet.releaseConnection(); } return supersedePartVO; } private SupersedePartVO convertJSONToSuperSedeVO(JSONObject jsonObj) { SupersedePartVO supersedePartVO = new SupersedePartVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){supersedePartVO.setID(jsonObj.getInt("id"));} if(jsonObj.containsKey("loc") && jsonObj.getString("loc")!=null){supersedePartVO.setLOC(jsonObj.getInt("loc"));} if(jsonObj.containsKey("supersedeID") && jsonObj.getString("supersedeID")!=null){supersedePartVO.setSupersedeID(jsonObj.getInt("supersedeID"));} if(jsonObj.containsKey("refSupersedeTypeID") && jsonObj.getString("refSupersedeTypeID")!=null){supersedePartVO.setRefSupersedeTypeID(Byte.valueOf(jsonObj.getString("refSupersedeTypeID")));} if(jsonObj.containsKey("supersedingLineAbbrev") && jsonObj.getString("supersedingLineAbbrev")!=null){supersedePartVO.setSupersedingLineAbbrev(jsonObj.getString("supersedingLineAbbrev"));} if(jsonObj.containsKey("supersedingPartNumber") && jsonObj.getString("supersedingPartNumber")!=null){supersedePartVO.setSupersedingPartNumber(jsonObj.getString("supersedingPartNumber"));} if(jsonObj.containsKey("supersedingExpandedPartNumber") && jsonObj.getString("supersedingExpandedPartNumber")!=null){supersedePartVO.setSupersedingExpandedPartNumber(jsonObj.getString("supersedingExpandedPartNumber"));} if(jsonObj.containsKey("supersedingPartDescription") && jsonObj.getString("supersedingPartDescription")!=null){supersedePartVO.setSupersedingPartDescription(jsonObj.getString("supersedingPartDescription"));} if(jsonObj.containsKey("refTypeDescription") && jsonObj.getString("refTypeDescription")!=null){supersedePartVO.setRefTypeDescription(jsonObj.getString("refTypeDescription"));} if(jsonObj.containsKey("effectiveStartDate") && jsonObj.getString("effectiveStartDate")!=null){supersedePartVO.setEffectiveStartDate(ConvertStringToDate(jsonObj.getString("effectiveStartDate")));} if(jsonObj.containsKey("effectiveUntilDate") && jsonObj.getString("effectiveUntilDate")!=null){supersedePartVO.setEffectiveUntilDate(ConvertStringToDate(jsonObj.getString("effectiveUntilDate")));} if(jsonObj.containsKey("stockOnHand") && jsonObj.getString("stockOnHand")!=null){supersedePartVO.setStockOnHand(convertStringToBigDecimal(jsonObj.getString("stockOnHand")));} if(jsonObj.containsKey("price") && jsonObj.getString("price")!=null){supersedePartVO.setPrice(convertStringToBigDecimal(jsonObj.getString("price")));} if(jsonObj.containsKey("onOrder") && jsonObj.getString("onOrder")!=null){supersedePartVO.setOnOrder(Short.valueOf(jsonObj.getString("onOrder")));} if(jsonObj.containsKey("workInProgress") && jsonObj.getString("workInProgress")!=null){supersedePartVO.setWorkInProgress(convertStringToBigDecimal(jsonObj.getString("workInProgress")));} if(jsonObj.containsKey("minSaleQty") && jsonObj.getString("minSaleQty")!=null){supersedePartVO.setMinSaleQty(convertStringToBigDecimal(jsonObj.getString("minSaleQty")));} if(jsonObj.containsKey("maxStockQty") && jsonObj.getString("maxStockQty")!=null){supersedePartVO.setMaxStockQty(Short.valueOf(jsonObj.getString("maxStockQty")));} return supersedePartVO; } /** * getAllSupersede method is to load all the supersede details from the remote store * @param inventoryVO * @param remoteStoreIP * @param customerVO * @param lang * @return allSuperSedeVector */ public Vector getAllSupersede(InventoryVO inventoryVO, String remoteStoreIP, CustomerVO customerVO,String lang) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/supersede"; logger.debug("getURL = " + url); SupersedePartVO supersedePartVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); Vector allSuperSedeVector = new Vector(); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("lineAbrev", inventoryVO.getLineAbbrev()), new NameValuePair("loc", inventoryVO.getLOC().toString()), new NameValuePair("part", inventoryVO.getPartNumber()), new NameValuePair("custId", customerVO.getID().toString()), new NameValuePair("lang", lang), new NameValuePair("isReqAllSuperSede", "true")}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getAllSupersede remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] custVOResponse = httpGet.getResponseBody(); String result = new String(custVOResponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("supersedeVO") && !(jsonObject.getJSONArray("supersedeVO").size()<=0)){ JSONArray ssjsonArray = jsonObject.getJSONArray("supersedeVO"); for(int i=0;i<=ssjsonArray.size()-1;i++){ long convMillSec = System.currentTimeMillis(); allSuperSedeVector.add(convertJSONToSuperSedeVO((JSONObject) ssjsonArray.get(i))); long convMillSecEnd = System.currentTimeMillis(); long convDuration = (convMillSecEnd-convMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToSuperSedeVO ends",remoteStoreIP,((JSONObject) ssjsonArray.get(i)).toString(), convDuration); } return allSuperSedeVector; } }else{ logger.error("Server encountered an http error while terminal response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting terminal response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting terminal response"); } catch (Exception exception) { logger.error("Exception occured while getting terminal response"); } finally { httpGet.releaseConnection(); } return allSuperSedeVector; } //Check if GiftCard exists for the given part number in the remote store public Boolean isGiftCardPartNumber(String text, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/isgiftcardpart"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("text", text) }); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making isGiftCardPartNumber remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] resp = httpGet.getResponseBody(); String result = new String(resp); if(result!=null && result.equalsIgnoreCase("true")) return true; else return false; } else{ logger.error("Server encountered an http error while getting isGiftcardPartnumber response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting isGiftcardPartnumber "+httpConnection.getMessage()); } catch (IOException ioException) { logger.error("I/O Exception occured while getting isGiftcardPartnumber "+ioException.getMessage()); } catch (Exception exception) { logger.error("Exception occured while getting price isGiftcardPartnumber "+exception.getMessage()); } finally { httpGet.releaseConnection(); } return false; } //getBinRangeDetails for the given bin range in the remote store public BinRangeProfileVO getBinRangeDetails(String binRange, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getbinrange"; logger.debug("getURL = " + url); BinRangeProfileVO binRangeProfileVO = null; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("binRangeNum", binRange)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getBinRangeDetails remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] binRangevoresponse = httpGet.getResponseBody(); String result = new String(binRangevoresponse); JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject.containsKey("binRangeVO") && !jsonObject.getJSONObject("binRangeVO").isNullObject()){ JSONObject binjsonObject = jsonObject.getJSONObject("binRangeVO"); long conMillSec = System.currentTimeMillis(); binRangeProfileVO = convertJSONToBinRangeVO(binjsonObject); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToBinRangeVO ends",remoteStoreIP,binjsonObject.toString(), convDuration); return binRangeProfileVO; } }else{ logger.error("Server encountered an http error while binRangeVO response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting binRangeVO response "+httpConnection.getMessage()); } catch (IOException ioException) { logger.error("I/O Exception occured while getting binRangeVO response "+ioException.getMessage()); } catch (Exception exception) { logger.error("Exception occured while getting binRangeVO response "+exception.getMessage()); } finally { httpGet.releaseConnection(); } return binRangeProfileVO; } //Convert response json to BinRangeProfileVO private BinRangeProfileVO convertJSONToBinRangeVO(JSONObject jsonObj) { BinRangeProfileVO binRangeProfileVO = null; if(!jsonObj.isNullObject()){ binRangeProfileVO = new BinRangeProfileVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){binRangeProfileVO.setID(jsonObj.getInt("id"));} if(jsonObj.containsKey("binRangeNum") && jsonObj.getString("binRangeNum")!=null){binRangeProfileVO.setBinRangeNum(jsonObj.getString("binRangeNum"));} if(jsonObj.containsKey("description") && jsonObj.getString("description")!=null){binRangeProfileVO.setDescription(jsonObj.getString("description"));} if(jsonObj.containsKey("lineAbbrev") && jsonObj.getString("lineAbbrev")!=null){binRangeProfileVO.setLineAbbrev(jsonObj.getString("lineAbbrev"));} if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null){binRangeProfileVO.setPartNumber(jsonObj.getString("partNumber"));} } return binRangeProfileVO; } //Get PartLines for the given part number in the remote store public Vector getPartLines(String expandedPartNumber, String lineAbbrev,Integer location,Boolean inventoryOnly, String remoteStoreIP) { Vector v = new Vector(); String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getinventorylines"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); List values = new ArrayList(); values.add(new NameValuePair("part", expandedPartNumber)); values.add(new NameValuePair("loc", location.toString())); values.add(new NameValuePair("inventoryOnly", inventoryOnly.toString())); if(lineAbbrev!=null) values.add(new NameValuePair("line", lineAbbrev)); NameValuePair[] nvp = values.toArray(new NameValuePair[0]); httpGet.setQueryString(nvp); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPartLines remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] partLinesResponse = httpGet.getResponseBody(); String result = new String(partLinesResponse); if(result!=null && result!="" && !result.isEmpty()) { JSONObject jObj = JSONObject.fromObject(result); if (jObj.containsKey("inventoryLines") && jObj.getJSONArray("inventoryLines")!=null) { JSONArray jsonArr = jObj.getJSONArray("inventoryLines"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { BaseInventoryVO baseInventoryVO = new BaseInventoryVO(); long conMillSec = System.currentTimeMillis(); baseInventoryVO = convertJSONToBaseInventoryVO(j); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToBaseInventoryVO ends",remoteStoreIP,j.toString(), convDuration); v.add(baseInventoryVO); } } } return v; } } }else{ logger.error("Server encountered an http error while getting invoice profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax "+httpConnection.getMessage()); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax "+ioException.getMessage()); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax "+exception.getMessage()); } finally { httpGet.releaseConnection(); } return v; } //Convert json response to baseInventoryVO private BaseInventoryVO convertJSONToBaseInventoryVO(JSONObject jsonObj) { BaseInventoryVO biVO = null; if(!jsonObj.isNullObject()){ biVO = new BaseInventoryVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null){biVO.setId(jsonObj.getInt("id"));} if(jsonObj.containsKey("expandedPartNumber") && jsonObj.getString("expandedPartNumber")!=null){biVO.setExpandedPartNumber(jsonObj.getString("expandedPartNumber"));} if(jsonObj.containsKey("description") && jsonObj.getString("description")!=null){biVO.setDescription(jsonObj.getString("description"));} if(jsonObj.containsKey("lineAbbrev") && jsonObj.getString("lineAbbrev")!=null){biVO.setLineAbbrev(jsonObj.getString("lineAbbrev"));} if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null){biVO.setPartNumber(jsonObj.getString("partNumber"));} if(jsonObj.containsKey("CD") && jsonObj.getString("CD")!=null){biVO.setCD(jsonObj.getBoolean("CD"));} if(jsonObj.containsKey("groupCode") && jsonObj.getString("groupCode")!=null){biVO.setGroupCode(Short.valueOf(jsonObj.getString("groupCode")));} if(jsonObj.containsKey("sortNumber") && jsonObj.getString("sortNumber")!=null){biVO.setSortNumber(jsonObj.getInt("sortNumber"));} } return biVO; } public List getRemoteStoreRegulationPartDetails(String partNumber, String lineAbbrev, String remoteStoreIP) { List result = null; String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getRegulationRulePartDetails"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair(LINEABBR, lineAbbrev), new NameValuePair(PARTNUM, partNumber)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getRemoteStoreRegulationPartDetails remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { String response = new String(httpGet.getResponseBody()); if (response != null && !response.isEmpty()) { ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); long conMillSec = System.currentTimeMillis(); result = objectMapper.readValue(response.toString(), typeFactory.constructCollectionType(List.class, RegulationRulePartVO.class)); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of RegulationRulePartVO ends",remoteStoreIP,response.toString(), convDuration); } } else { logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return result; } public Boolean getRemoteStoreBlockSaleFlag(String remoteStoreIP) { Boolean result = null; String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getRemoteStoreBlockSaleFlag"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getRemoteStoreBlockSaleFlag remote call", "No Payload", remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { String response = new String(httpGet.getResponseBody()); if (response != null && !response.isEmpty()) { ObjectMapper objectMapper = new ObjectMapper(); TypeFactory typeFactory = objectMapper.getTypeFactory(); result = objectMapper.readValue(response.toString(), Boolean.class); } } else { logger.error("Server encountered an http error while getting invoice profile response "); throw new HttpException(); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting price information including tax"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting price information including tax"); } catch (Exception exception) { logger.error("Exception occured while getting price information including tax"); } finally { httpGet.releaseConnection(); } return result; } // To fetch onHand Quantity from Remote Store public List getOnHandForRemoteStore(List inventoryVO, String remoteStoreIP) { String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getOnHandQuantity"; logger.debug("url = " + url); HttpClient client = new HttpClient(); JSONArray req_json = convertInventoryVOToJSON(inventoryVO); String json_string = req_json.toString(); HttpMethod taapRequest = null; taapRequest = new PostMethod(url); StringRequestEntity reqEntity = null; int statusCode; List inventoryOnHandResponseVO = new ArrayList(); try{ reqEntity = new StringRequestEntity( json_string, "application/json", "UTF-8"); logger.debug("getOnHandQuantity Calling: " + url); ((PostMethod) taapRequest).setRequestEntity(reqEntity); long callMillSec = System.currentTimeMillis(); statusCode = client.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getOnHandForRemoteStore remote call",json_string,remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { String result = new String(taapRequest.getResponseBody()); JSONArray jsonArr = JSONArray.fromObject(result); for (int i = 0 ; i < jsonArr.size(); i++) { long conMillSec = System.currentTimeMillis(); inventoryOnHandResponseVO.add(convertJSONToInventoryOnHandResponseVO(jsonArr.getJSONObject(i))); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONToInventoryOnHandResponseVO ends",remoteStoreIP,jsonArr.getJSONObject(i).toString(), convDuration); } }else{ logger.error("Server encountered an http error while getting onHand Quantity"); } } catch (HttpException httpConnection) { logger.error("HttpException occurred while getting onHand Quantity"); } catch (IOException ioException) { logger.error("I/O Exception occurred while getting onHand Quantity"); } catch (Exception exception) { logger.error("Exception occurred while getting onHand Quantity"); } finally { taapRequest.releaseConnection(); } return inventoryOnHandResponseVO; } private JSONArray convertInventoryVOToJSON(List inventoryVO) { JSONArray request = new JSONArray(); if(inventoryVO!=null && !inventoryVO.isEmpty()){ for(InventoryVO inventory : inventoryVO){ JSONObject jsonObject = new JSONObject(); jsonObject.put("part",inventory.getPartNumber()); jsonObject.put("line",inventory.getLineAbbrev()); request.add(jsonObject); } } return request; } private InventoryOnHandResponseVO convertJSONToInventoryOnHandResponseVO(JSONObject jsonObj) { InventoryOnHandResponseVO inventoryOnHandVO = new InventoryOnHandResponseVO(); if(!jsonObj.isNullObject()){ if(jsonObj.containsKey("onHandQuantity") && jsonObj.getString("onHandQuantity")!=null){inventoryOnHandVO.setOnHandQuantity(jsonObj.getString("onHandQuantity"));} if(jsonObj.containsKey("lineAbbrev") && jsonObj.getString("lineAbbrev")!=null){inventoryOnHandVO.setLineAbbrev(jsonObj.getString("lineAbbrev"));} if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null){inventoryOnHandVO.setPartNumber(jsonObj.getString("partNumber"));} } return inventoryOnHandVO; } // To fetch Store managers, Asst managers and OSS keyholders from remote store public LinkedHashMap getManagers(String remoteStoreIp) { LinkedHashMap resultMap = new LinkedHashMap<>(); String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/getManagers"; logger.debug("URL: " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getManagers remote call","No Payload",remoteStoreIp, statusCode,callDuration); logger.debug("statusCode = " + statusCode); if (statusCode == HttpStatus.SC_OK) { final byte[] getManagersResponse = httpGet.getResponseBody(); String result = new String(getManagersResponse); if (result != null && result != "" && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject != null && jsonObject.containsKey("managersList")) { Object managersListValue = jsonObject.get("managersList"); if (managersListValue instanceof JSONObject){ JSONObject managersListObject = (JSONObject) managersListValue; //Iterate over the keys in managersListObject for (Object keyObj : managersListObject.keySet()) { String key = keyObj.toString(); String value = managersListObject.getString(key); resultMap.put(key, value); } return resultMap; } } else { logger.error("Server encountered an http error while getting managers response "); } } } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting managers response"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting managers response"); } catch (Exception exception) { logger.error("Exception occured while getting managers response"); } finally { httpGet.releaseConnection(); } return resultMap; } // To fetch password from remote store public String getManagerPassword(String employeeNum, String remoteStoreIP) { String managerPswd = null; String url = "http://" + remoteStoreIP + ":8080/TAMSII/Servlets/getManagerPassword"; logger.debug("getURL = " + url); HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("employeeNum", employeeNum)}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getManagerPassword remote call", httpGet.getQueryString(), remoteStoreIP, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] managerPswdResponse = httpGet.getResponseBody(); managerPswd = new String(managerPswdResponse); return managerPswd; } else{ logger.error("Server encountered an http error while getting manager password from remote store "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting manager password from remote store"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting manager password from remote store"); } catch (Exception exception) { logger.error("Exception occured while getting manager password from remote store"); } finally { httpGet.releaseConnection(); } return managerPswd; } //To fetch employee id from remote store with logged-in employee number in the current store public Integer getEmployeeIDUsingNum(String empNum, String loc, String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/getEmpId"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("empNum", empNum), new NameValuePair("loc", loc)}); Integer empId =null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getEmployeeIDUsingNum remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] empIdResponse = httpGet.getResponseBody(); String result = new String(empIdResponse); empId = result!=null?Integer.valueOf(result):null; return empId; } else{ logger.error("Server encountered an http error while getting employee response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting employee info"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting employee info"); } catch (Exception exception) { logger.error("Exception occured while getting employee info"); } finally { httpGet.releaseConnection(); } return empId; } //To fetch phone room profile using servlet public PhoneRoomProfileVO getPhoneRoomProfileInfo(String loc, String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/getPhoneRoomProfile"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc)}); PhoneRoomProfileVO phoneRoomProfileVO = new PhoneRoomProfileVO(); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getPhoneRoomProfileInfo remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] prProfileResponse = httpGet.getResponseBody(); String result = new String(prProfileResponse); if(result!=null && !result.equals("") && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject!=null && jsonObject.containsKey("PhoneRoomProfileVO") && !jsonObject.getJSONObject("PhoneRoomProfileVO").isNullObject()) { JSONObject prProfileJSON = jsonObject.getJSONObject("PhoneRoomProfileVO"); long conMillSec = System.currentTimeMillis(); phoneRoomProfileVO = convertJSONTOPRProfileVO(prProfileJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONTOPRProfileVO ends",remoteStoreIp,prProfileJSON.toString(), convDuration); } } } else{ logger.error("Server encountered an http error while getting phone room profile response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting phone room profile info"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting phone room profile info"); } catch (Exception exception) { logger.error("Exception occured while getting phone room profile info"); } finally { httpGet.releaseConnection(); } return phoneRoomProfileVO; } private PhoneRoomProfileVO convertJSONTOPRProfileVO(JSONObject prProfileJSON) { PhoneRoomProfileVO phoneRoomProfileVO = new PhoneRoomProfileVO(); if(prProfileJSON!=null && !prProfileJSON.isEmpty()){ if (prProfileJSON.containsKey("loc") && prProfileJSON.getString("loc")!=null) phoneRoomProfileVO.setLocation(prProfileJSON.getInt("loc")); if (prProfileJSON.containsKey("ccMgrPwd") && prProfileJSON.getString("ccMgrPwd")!=null) phoneRoomProfileVO.setCcMgrPassword(prProfileJSON.getString("ccMgrPwd")); if (prProfileJSON.containsKey("ccMgrPwdExpiryDate") && prProfileJSON.getString("ccMgrPwdExpiryDate")!=null) phoneRoomProfileVO.setCcMgrPasswordExpiryDate(ConvertStringToDate1(prProfileJSON.getString("ccMgrPwdExpiryDate"))); } return phoneRoomProfileVO; } public CustomerContactVO getCustomerAuthBuyerInfo(Integer loc, Integer customerID, String buyerName, String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/getAuthBuyerInfo"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", loc.toString()), new NameValuePair("custID",customerID.toString()), new NameValuePair("buyerName",buyerName)}); CustomerContactVO customerContactVO = null; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerAuthBuyerInfo remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] prProfileResponse = httpGet.getResponseBody(); String result = new String(prProfileResponse); if(result!=null && !result.equals("") && !result.isEmpty()){ JSONObject jsonObject = JSONObject.fromObject(result); if(jsonObject!=null && jsonObject.containsKey("CustomerContactVO") && !jsonObject.getJSONObject("CustomerContactVO").isNullObject()) { JSONObject authBuyerJSON = jsonObject.getJSONObject("CustomerContactVO"); long conMillSec = System.currentTimeMillis(); customerContactVO = convertJSONTOCustContactVO(authBuyerJSON); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONTOCustContactVO ends",remoteStoreIp,authBuyerJSON.toString(), convDuration); } } } else{ logger.error("Server encountered an http error while getting authorized buyer response "); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting authorized buyer info"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting authorized buyer info"); } catch (Exception exception) { logger.error("Exception occured while getting authorized buyer info"); } finally { httpGet.releaseConnection(); } return customerContactVO; } private CustomerContactVO convertJSONTOCustContactVO(JSONObject authBuyerJSON) { CustomerContactVO customerContactVO = null; if(authBuyerJSON!=null && !authBuyerJSON.isEmpty()) { customerContactVO = new CustomerContactVO(); if (authBuyerJSON.containsKey("ID") && authBuyerJSON.getString("ID") != null) { customerContactVO.setID(authBuyerJSON.getInt("ID")); } if (authBuyerJSON.containsKey("LOC") && authBuyerJSON.getString("LOC") != null) { customerContactVO.setLOC(authBuyerJSON.getInt("LOC")); } if (authBuyerJSON.containsKey("CustomerID") && authBuyerJSON.getString("CustomerID") != null) { customerContactVO.setCustomerID(authBuyerJSON.getInt("CustomerID")); } if (authBuyerJSON.containsKey("Name") && authBuyerJSON.getString("Name") != null) { customerContactVO.setName(authBuyerJSON.getString("Name")); } if (authBuyerJSON.containsKey("Title") && authBuyerJSON.getString("Title") != null) { customerContactVO.setTitle(authBuyerJSON.getString("Title")); } if (authBuyerJSON.containsKey("AddrLine1") && authBuyerJSON.getString("AddrLine1") != null) { customerContactVO.setAddrLine1(authBuyerJSON.getString("AddrLine1")); } if (authBuyerJSON.containsKey("Address2") && authBuyerJSON.getString("Address2") != null) { customerContactVO.setAddress2(authBuyerJSON.getString("Address2")); } if (authBuyerJSON.containsKey("Address3") && authBuyerJSON.getString("Address3") != null) { customerContactVO.setAddress3(authBuyerJSON.getString("Address3")); } if (authBuyerJSON.containsKey("Address4") && authBuyerJSON.getString("Address4") != null) { customerContactVO.setAddress4(authBuyerJSON.getString("Address4")); } if (authBuyerJSON.containsKey("City") && authBuyerJSON.getString("City") != null) { customerContactVO.setCity(authBuyerJSON.getString("City")); } if (authBuyerJSON.containsKey("State") && authBuyerJSON.getString("State") != null) { customerContactVO.setState(authBuyerJSON.getString("State")); } if (authBuyerJSON.containsKey("PostalCode") && authBuyerJSON.getString("PostalCode") != null) { customerContactVO.setPostalCode(authBuyerJSON.getString("PostalCode")); } if (authBuyerJSON.containsKey("Phone") && authBuyerJSON.getString("Phone") != null) { customerContactVO.setPhone(authBuyerJSON.getString("Phone")); } if (authBuyerJSON.containsKey("Extension") && authBuyerJSON.getString("Extension") != null) { customerContactVO.setExtension(authBuyerJSON.getString("Extension")); } if (authBuyerJSON.containsKey("CellPhone") && authBuyerJSON.getString("CellPhone") != null) { customerContactVO.setCellPhone(authBuyerJSON.getString("CellPhone")); } if (authBuyerJSON.containsKey("Pager") && authBuyerJSON.getString("Pager") != null) { customerContactVO.setPager(authBuyerJSON.getString("Pager")); } if (authBuyerJSON.containsKey("HomePhone") && authBuyerJSON.getString("HomePhone") != null) { customerContactVO.setHomePhone(authBuyerJSON.getString("HomePhone")); } if (authBuyerJSON.containsKey("FaxNumber") && authBuyerJSON.getString("FaxNumber") != null) { customerContactVO.setFaxNumber(authBuyerJSON.getString("FaxNumber")); } if (authBuyerJSON.containsKey("Email") && authBuyerJSON.getString("Email") != null) { customerContactVO.setEMail(authBuyerJSON.getString("Email")); } if (authBuyerJSON.containsKey("AuthorizedBuyer") && authBuyerJSON.getString("AuthorizedBuyer") != null) { customerContactVO.setAuthorizedBuyer(authBuyerJSON.getBoolean("AuthorizedBuyer")); } if (authBuyerJSON.containsKey("Note") && authBuyerJSON.getString("Note") != null) { customerContactVO.setNote(authBuyerJSON.getString("Note")); } if (authBuyerJSON.containsKey("countryCd") && authBuyerJSON.getString("countryCd") != null) { customerContactVO.setCountryCd(authBuyerJSON.getString("countryCd")); } } return customerContactVO; } public Vector getBuyoutByCustomer(Integer custId, Integer location,String remoteStoreIp) { Vector vector = new Vector(); String url = "http://"+remoteStoreIp+":8080/TAMSII/Servlets/getBuyoutByCustomer"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("loc", location.toString()), new NameValuePair("custId", custId.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getBuyoutByCustomer remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] buyOutVOResponse = httpGet.getResponseBody(); String result = new String(buyOutVOResponse); if(result!=null && !result.equals("") && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject != null && jsonObject.containsKey("buyouts")) { JSONArray jsonArr = jsonObject.getJSONArray("buyouts"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { BuyoutVO buyout = new BuyoutVO(); long conMillSec = System.currentTimeMillis(); buyout = convertJSONObjectToVector(j); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJsonToTaxTableVO ends",remoteStoreIp,j.toString(), convDuration); vector.add(buyout); } } } } } }else{ logger.error("Server encountered an http error while getting Buyout response"); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting Buyout Details"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting Buyout Details"); } catch (Exception exception) { logger.error("Exception occured while getting Buyout Details"); } finally { httpGet.releaseConnection(); } return vector; } public BuyoutVO convertJSONObjectToVector(JSONObject jsonObj){ BuyoutVO buyoutVO = new BuyoutVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("id"))){ buyoutVO.setID(Integer.valueOf(jsonObj.getString( "id"))); } if(jsonObj.containsKey("loc") && jsonObj.getString("loc")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("loc"))){ buyoutVO.setLOC(Integer.valueOf(jsonObj.getString( "loc"))); } if(jsonObj.containsKey("ponumber") && jsonObj.getString("ponumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("ponumber"))){ buyoutVO.setPONumber(jsonObj.getString("ponumber")); } if(jsonObj.containsKey("vendorValuePair") && !jsonObj.getJSONObject("vendorValuePair").isNullObject()) { IDValuePairVO idValuePairVO = new IDValuePairVO(); JSONObject j = jsonObj.getJSONObject("vendorValuePair"); if (j.containsKey("id") && j.getString("id")!=null && !NULL_VALUE.equalsIgnoreCase(j.getString("id"))) idValuePairVO.setID(j.getString("id")); if(j.containsKey("value") && j.getString("value")!=null && !NULL_VALUE.equalsIgnoreCase(j.getString("value"))) idValuePairVO.setValue(j.getString("value")); buyoutVO.setVendorValuePair(idValuePairVO); } if(jsonObj.containsKey("lineItemsOrdered") && jsonObj.getString("lineItemsOrdered")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("lineItemsOrdered"))){ buyoutVO.setLineItemsOrdered(jsonObj.getInt("lineItemsOrdered")); } if(jsonObj.containsKey("creationDate") && jsonObj.getString("creationDate")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("creationDate"))) { Date d = new Date(jsonObj.getLong("creationDate")); buyoutVO.setCreationDate(d); } return buyoutVO; } public Vector findBuyoutItemsByID(Integer buyoutID,Integer custId, Integer location,String remoteStoreIp) { Vector vector = new Vector(); String url = "http://"+remoteStoreIp+":8080/TAMSII/Servlets/getBuyoutItemsByID"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("buyoutID", buyoutID.toString()), new NameValuePair("loc", location.toString()), new NameValuePair("custID", custId.toString())}); try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making findBuyoutItemsByID remote call", httpGet.getQueryString(), remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] buyOutVOResponse = httpGet.getResponseBody(); String result = new String(buyOutVOResponse); if(result!=null && !result.equals("") && !result.isEmpty()) { JSONObject jsonObject = JSONObject.fromObject(result); if (jsonObject != null && jsonObject.containsKey("buyoutItemVO")) { JSONArray jsonArr = jsonObject.getJSONArray("buyoutItemVO"); if (!jsonArr.isEmpty()) { Iterator itr2 = jsonArr.iterator(); while (itr2.hasNext()) { JSONObject j = JSONObject.fromObject(itr2.next()); if (!j.isNullObject()) { BuyoutItemVO buyoutItemVO = new BuyoutItemVO(); long conMillSec = System.currentTimeMillis(); buyoutItemVO = convertJSONObjectToBuyoutVector(j); long conMillSecEnds = System.currentTimeMillis(); long convDuration = (conMillSecEnds-conMillSec); createAndLogConversionDataToAzure("Conversion of convertJSONObjectToBuyoutVector ends",remoteStoreIp,j.toString(), convDuration); vector.add(buyoutItemVO); } } } } } }else{ logger.error("Server encountered an http error while getting Buyout response"); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting BuyoutItem Details"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting BuyoutItem Details"); } catch (Exception exception) { logger.error("Exception occured while getting BuyoutItem Details"); } finally { httpGet.releaseConnection(); } return vector; } public BuyoutItemVO convertJSONObjectToBuyoutVector(JSONObject jsonObj){ BuyoutItemVO buyoutItemVO = new BuyoutItemVO(); if(jsonObj.containsKey("id") && jsonObj.getString("id")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("id"))){ buyoutItemVO.setID(Integer.valueOf(jsonObj.getString( "id"))); } if(jsonObj.containsKey("loc") && jsonObj.getString("loc")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("loc"))){ buyoutItemVO.setLOC(Integer.valueOf(jsonObj.getString( "loc"))); } if(jsonObj.containsKey("buyoutID") && jsonObj.getString("buyoutID")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("buyoutID"))){ buyoutItemVO.setBuyoutID(Integer.valueOf(jsonObj.getString( "buyoutID"))); } if(jsonObj.containsKey("depositInvoiceNumber") && jsonObj.getString("depositInvoiceNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("depositInvoiceNumber"))){ buyoutItemVO.setDepositInvoiceNumber(Integer.valueOf(jsonObj.getString("depositInvoiceNumber"))); } if(jsonObj.containsKey("lineAbbrev") && jsonObj.getString("lineAbbrev")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("lineAbbrev"))){ buyoutItemVO.setLineAbbrev(jsonObj.getString("lineAbbrev")); } if(jsonObj.containsKey("partNumber") && jsonObj.getString("partNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("partNumber"))){ buyoutItemVO.setPartNumber(jsonObj.getString("partNumber")); } if(jsonObj.containsKey("expandedPartNumber") && jsonObj.getString("expandedPartNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("expandedPartNumber"))){ buyoutItemVO.setExpandedPartNumber(jsonObj.getString("expandedPartNumber")); } if(jsonObj.containsKey("description") && jsonObj.getString("description")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("description"))){ buyoutItemVO.setDescription(jsonObj.getString("description")); } if(jsonObj.containsKey("buyoutItemTypeCD") && jsonObj.getString("buyoutItemTypeCD")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("buyoutItemTypeCD"))){ buyoutItemVO.setBuyoutItemTypeCD(jsonObj.getString("buyoutItemTypeCD")); } if(jsonObj.containsKey("buyoutItemStatusCD") && jsonObj.getString("buyoutItemStatusCD")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("buyoutItemStatusCD"))){ buyoutItemVO.setBuyoutItemStatusCD(jsonObj.getString("buyoutItemStatusCD")); } if(jsonObj.containsKey("customerOrderNumber") && jsonObj.getString("customerOrderNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("customerOrderNumber"))){ buyoutItemVO.setCustomerOrderNumber(jsonObj.getString("customerOrderNumber")); } if(jsonObj.containsKey("customerName") && jsonObj.getString("customerName")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("customerName"))){ buyoutItemVO.setCustomerName(jsonObj.getString("customerName")); } if(jsonObj.containsKey("newPONumber") && jsonObj.getString("newPONumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("newPONumber"))){ buyoutItemVO.setNewPONumber(jsonObj.getString("newPONumber")); } if(jsonObj.containsKey("customerPhoneNumber") && jsonObj.getString("customerPhoneNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("customerPhoneNumber"))){ buyoutItemVO.setCustomerPhoneNumber(jsonObj.getString("customerPhoneNumber")); } if(jsonObj.containsKey("sequence") && jsonObj.getString("sequence")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("sequence"))){ buyoutItemVO.setSequence(convertStringToBigDecimal(jsonObj.getString("sequence"))); } if(jsonObj.containsKey("unitCost") && jsonObj.getString("unitCost")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("unitCost")) ){ buyoutItemVO.setUnitCost(convertStringToBigDecimal(jsonObj.getString("unitCost"))); } if(jsonObj.containsKey("coreCost") && jsonObj.getString("coreCost")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("coreCost"))){ buyoutItemVO.setCoreCost(convertStringToBigDecimal(jsonObj.getString("coreCost"))); } if(jsonObj.containsKey("sequence") && jsonObj.getString("sequence")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("sequence"))){ buyoutItemVO.setSequence(convertStringToBigDecimal(jsonObj.getString("sequence"))); } if(jsonObj.containsKey("billedToInvoiceNumber") && jsonObj.getString("billedToInvoiceNumber")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedToInvoiceNumber"))){ buyoutItemVO.setBilledToInvoiceNumber(Integer.valueOf(jsonObj.getString( "billedToInvoiceNumber"))); } if(jsonObj.containsKey("billToCustomerID") && jsonObj.getString("billToCustomerID")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billToCustomerID"))){ buyoutItemVO.setBillToCustomerID(Integer.valueOf(jsonObj.getString( "billToCustomerID"))); } if(jsonObj.containsKey("billedUnitPrice") && jsonObj.getString("billedUnitPrice")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedUnitPrice"))){ buyoutItemVO.setBilledUnitPrice(convertStringToBigDecimal(jsonObj.getString("billedUnitPrice"))); } if(jsonObj.containsKey("GLAccount") && jsonObj.getString("GLAccount")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("GLAccount"))){ buyoutItemVO.setGLAccount(convertStringToBigDecimal(jsonObj.getString("GLAccount"))); } if(jsonObj.containsKey("billedUnitCost") && jsonObj.getString("billedUnitCost")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedUnitCost"))){ buyoutItemVO.setBilledUnitCost(convertStringToBigDecimal(jsonObj.getString("billedUnitCost"))); } if(jsonObj.containsKey("billedCorePrice") && jsonObj.getString("billedCorePrice")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedCorePrice"))){ buyoutItemVO.setBilledCorePrice(convertStringToBigDecimal(jsonObj.getString("billedCorePrice"))); } if(jsonObj.containsKey("billedCoreCost") && jsonObj.getString("billedCoreCost")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedCoreCost"))){ buyoutItemVO.setBilledCoreCost(convertStringToBigDecimal(jsonObj.getString("billedCoreCost"))); } if(jsonObj.containsKey("quantity")&& jsonObj.getString("quantity")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("quantity"))){ buyoutItemVO.setQuantity((short) jsonObj.getInt("quantity")); } if(jsonObj.containsKey("receivedQty")&& jsonObj.getString("receivedQty")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("receivedQty"))){ buyoutItemVO.setReceivedQty((short) jsonObj.getInt("receivedQty")); } if(jsonObj.containsKey("backOrderQty")&& jsonObj.getString("backOrderQty")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("backOrderQty"))){ buyoutItemVO.setBackOrderQty((short) jsonObj.getInt("backOrderQty")); } if(jsonObj.containsKey("billedToInvoiceDate") && jsonObj.getString("billedToInvoiceDate")!=null && !NULL_VALUE.equalsIgnoreCase(jsonObj.getString("billedToInvoiceDate"))) { Date d = new Date(jsonObj.getLong("billedToInvoiceDate")); buyoutItemVO.setBilledToInvoiceDate(d); } return buyoutItemVO; } public void callVLMService(String obj) { final Properties sysProp = ApplicationContext.getInstance().getSystemConfig() .getSystemConfiguration(SystemConfig.APPLICATION); String json_string = obj; String url = sysProp.getProperty(ServerPropConstants.VLM_ORDER_URL); logger.warn("getURL = " + url); HttpMethod taapRequest = null; HttpClient httpClient = new HttpClient(); taapRequest = new PostMethod(url); int statusCode; try { logger.debug("VLM Service Calling: " + url); taapRequest.addRequestHeader(sysProp.getProperty(ServerPropConstants.VLM_SUBSCRIPTION_KEY),sysProp.getProperty(ServerPropConstants.VLM_SUBSCRIPTION_KEY_VALUE)); taapRequest.addRequestHeader("Content-Type","application/json"); taapRequest.addRequestHeader("User-Agent","Tams Application"); ((PostMethod) taapRequest).setRequestBody(json_string); long callMillSec = System.currentTimeMillis(); statusCode = httpClient.executeMethod(taapRequest); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making callVLMService remote call",json_string,url, statusCode,callDuration); if (statusCode == HttpStatus.SC_CREATED) { logger.warn("Successfully created an order in VLM : " +json_string); } else { logger.error("Server encountered an http error while authenticating " + taapRequest.getStatusLine()); } } catch (HttpException httpConnection) { logger.error("HttpException occurred while creating an order in VLM"); } catch (IOException ioException) { logger.error("I/O Exception occurred while creating an order in VLM"); } catch (Exception exception) { logger.error("Exception occurred while creating an order in VLM"); }finally { taapRequest.releaseConnection(); } } public int getCustomerDeliveryPriorityTime(Integer deliveryPriorityID, Integer loc, String remoteStoreIp) { String url = "http://" + remoteStoreIp + ":8080/TAMSII/Servlets/getCustDeliveryPriority"; HttpClient client = new HttpClient(); HttpMethod httpGet = new GetMethod(url); httpGet.setQueryString(new NameValuePair[] { new NameValuePair("delPriorityID", deliveryPriorityID.toString()), new NameValuePair("loc", loc.toString())}); int delTime =0; try { long callMillSec = System.currentTimeMillis(); int statusCode = client.executeMethod(httpGet); long callMillSecEnds = System.currentTimeMillis(); long callDuration = (callMillSecEnds-callMillSec); createAndLogDataToAzure("Making getCustomerDeliveryPriorityTime remote call",httpGet.getQueryString(),remoteStoreIp, statusCode,callDuration); if (statusCode == HttpStatus.SC_OK) { final byte[] empIdResponse = httpGet.getResponseBody(); String result = new String(empIdResponse); delTime = result!=null?Integer.valueOf(result):0; return delTime; } else{ logger.error("Server encountered an http error while getting customer delivery time"); } } catch (HttpException httpConnection) { logger.error("HttpException occured while getting customer delivery time"); } catch (IOException ioException) { logger.error("I/O Exception occured while getting customer delivery time"); } catch (Exception exception) { logger.error("Exception occured while getting customer delivery time"); } finally { httpGet.releaseConnection(); } return delTime; } public void createAndLogDataToAzure(String message, String payload, String ipAddress, int code, long duration){ logger.warn("Inside createAndLogDataToAzure method :"); Object callCenterFlag = new LaunchDarklyRouter().retreiveFeatureFlagValue("TAMS_LOG_CALLCENTER_REMOTECALL_LOOKUP_USAGE", Boolean.class); Boolean callCenterMetricsEnabled = (callCenterFlag != null && ((String) callCenterFlag).equalsIgnoreCase("true")); if(callCenterMetricsEnabled.booleanValue()) { JSONObject object = new JSONObject(); object.put("RemoteCallPayload", payload); object.put("CallDuration", duration); SwingUtilities.invokeLater(() -> { try { ClientApplicationContext.getClientApplicationContext().getInvoiceDAO().sendMetricsToAzure(message, LogType.Status.REMOTECALL, object.toString(), ipAddress, code, LogType.Feature.CallCenterRemoteCall, ClientApplicationContext.getClientApplicationContext().getLocation()); } catch (ApplicationException e) { logger.error("Unable to write to Azure Log: Encountered Application Exception " + e.getMessage()); } }); } else { logger.warn("Logging is not enabled for Call Center Remote Calls "); } } public void createAndLogConversionDataToAzure(String message, String ipaddress, String payload, long duration) { logger.warn("Inside createAndLogConversionDataToAzure method :"); Object callCenterFlag = new LaunchDarklyRouter().retreiveFeatureFlagValue("TAMS_LOG_CALLCENTER_REMOTECALL_LOOKUP_USAGE", Boolean.class); Boolean callCenterMetricsEnabled = (callCenterFlag != null && ((String) callCenterFlag).equalsIgnoreCase("true")); if(callCenterMetricsEnabled.booleanValue()) { JSONObject object = new JSONObject(); object.put("ConversionPayload", payload); object.put("ConversionDuration", duration); SwingUtilities.invokeLater(() -> { try { ClientApplicationContext.getClientApplicationContext().getInvoiceDAO().sendMetricsToAzure(message, LogType.Status.CONVERSION, object.toString(), ipaddress, 0, LogType.Feature.RemoteCallConversion, ClientApplicationContext.getClientApplicationContext().getLocation()); } catch (ApplicationException e) { logger.error("Unable to write to Azure Log: Encountered Application Exception " + e.getMessage()); } }); } else { logger.warn("Logging is not enabled for Call Center Remote Calls "); } } }