public boolean isValidParty(PartyLovVO partyLovVO) throws Exception {
   boolean validParty = false;
   Connection connection = null;
   StringBuilder finalQry = new StringBuilder();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   QueryFields fields = null;
   String whereCond = "";
   try {
     fields = new QueryFields();
     fields.put("BP.DCS_STATUS", "1");
     fields.put("PR.DCS_CODE", partyLovVO.getPartyRole());
     fields.put("BP.DCS_CODE", partyLovVO.getPartyId());
     if (!StringUtility.isNullEmpty(partyLovVO.getRelatedParty())) {
       fields.put("BP.DCS_CODE", partyLovVO.getRelatedParty());
       fields.put("PR.DCS_CODE", partyLovVO.getRelationShipType());
     }
     whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
     finalQry.append(PartyLovQueries.validatePartyIdQry).append(whereCond);
     connection = getConnection();
     pstmt = connection.prepareStatement(finalQry.toString());
     rs = pstmt.executeQuery();
     if (rs.next()) {
       if (rs.getInt(1) > 0) {
         validParty = true;
       } else {
         validParty = false;
       }
     }
   } finally {
     ConnectionUtil.closeConnection(connection, pstmt, rs);
   }
   return validParty;
 }
 // @@20060706 for Adv. Search Functionlality
 // @@ Added by Smitha V for PR-PR-ET-1410 on  02-Apr-07
 public String getRecordForTransit(List data) {
   StringBuffer sb = new StringBuffer();
   if (data.size() <= 0) {
     return "[\"No Results Found\"],";
   }
   Iterator itr = data.iterator();
   ETLOCATIONAdvVO locationVO = null;
   while (itr.hasNext()) {
     locationVO = (ETLOCATIONAdvVO) itr.next();
     sb.append("[")
         .append("\"" + locationVO.getLocId() + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getLocName()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getCountryId()) + "\",")
         .append("],");
   }
   return sb.toString();
 }
 public String[] createUpdateETBooking(ETBookingServiceVO objETBookingServiceVO) {
   logger.info("createUpdateETBooking Entered");
   Connection connection = null;
   String intBookingHeaderId = null;
   String intPackDtlId = null;
   String intPoAndInvDtlId = null;
   String intContainerDtlId = null;
   String intcontStuffDtlId = null;
   String[] bookingStatus = new String[3];
   JournalEntryDAO objJournalEntryDAO = null;
   ArrayList<String> journalIdArrayList = null;
   try {
     connection = dataSource.getConnection();
     intBookingHeaderId =
         ETIntegrationDAO.insertETBookingHeaderDetails(connection, objETBookingServiceVO);
     if (intBookingHeaderId != null) {
       objETBookingServiceVO.setIntBookingHeaderId(intBookingHeaderId);
       intPackDtlId = ETIntegrationDAO.insertETPackDetails(connection, objETBookingServiceVO);
       intPoAndInvDtlId =
           ETIntegrationDAO.insertETPoAndInvDetails(connection, objETBookingServiceVO);
       intContainerDtlId =
           ETIntegrationDAO.insertETSContainerDtl(connection, objETBookingServiceVO);
       intcontStuffDtlId =
           ETIntegrationDAO.insertETSContStuffDtl(connection, objETBookingServiceVO);
       if (!"".equals(StringUtility.noNull(objETBookingServiceVO.getShipmentMode())))
         bookingStatus =
             ETIntegrationDAO.validateAndCreateETBooking(
                 connection, intBookingHeaderId, objETBookingServiceVO.getShipmentMode());
       if (bookingStatus != null && bookingStatus.length > 0)
         logger.info("Booking Status.." + bookingStatus[0]);
       if (bookingStatus != null && bookingStatus.length > 1)
         logger.info("Booking Id.." + bookingStatus[1]);
       if (bookingStatus != null && bookingStatus.length > 2)
         logger.info("Booking Status from DB.." + bookingStatus[2]);
       /*if(bookingStatus != null && bookingStatus.length > 1){
       	try{
       		objJournalEntryDAO=new JournalEntryDAO();
       		journalIdArrayList=objJournalEntryDAO.getJournalId(bookingStatus[1]);
       		objJournalEntryDAO.pushJournalsToQueue(journalIdArrayList);
       	}catch(Exception ex){
       		logger.error("Exception in createUpdateETBooking While Pushing Jounal Entries to Queue..",ex);
       		ex.printStackTrace();
       	}
       }*/
     }
     logger.info("createUpdateETBooking Exit");
   } catch (Exception ex) {
     ex.printStackTrace();
     sessionContext.setRollbackOnly();
     throw new EJBException(ex.getMessage());
   } finally {
     ConnectionUtil.closeConnection(connection);
   }
   return bookingStatus;
 }
 public void doReqResDataPreRequisite(HttpServletRequest request) throws Exception {
   byte[] fileContent = null;
   String documentName = null;
   File mFile = null;
   BufferedInputStream br = null;
   String docFormat = null;
   try {
     documentName = httpRequest.getParameter("fileName");
     System.out.println("DocumentName-->" + documentName);
     docFormat = StringUtility.noNull(httpRequest.getParameter("docFormat")).trim();
     request.setAttribute("defaultFormat", "txt");
     if (!StringUtility.isNullEmpty(documentName)) {
       httpSession.setAttribute("documentName", documentName);
       mFile = new File(documentName);
       if (mFile.exists()) {
         if (docFormat.equals(Constants.INT_DATA_TYPE_XML)
             || docFormat.equals(Constants.INT_DATA_TYPE_STRING)) {
           if (docFormat.equals(Constants.INT_DATA_TYPE_XML)) {
             request.setAttribute("defaultFormat", docFormat);
           } else {
             request.setAttribute("defaultFormat", "txt");
           }
           br = new BufferedInputStream(new FileInputStream(mFile));
           fileContent = new byte[(int) mFile.length()];
           br.read(fileContent);
         } else if (docFormat.equals(Constants.INT_DATA_TYPE_VO)) {
           String objStr = InterfaceLogger.serializationObjToStr(documentName);
           fileContent = objStr.getBytes();
         }
       } else {
         fileContent = new String("File not found").getBytes();
       }
       httpSession.setAttribute("baosView", fileContent);
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     fileContent = null;
     if (br != null) br.close();
   }
 }
 public String[] invoicingDetails(String partyId, String relationShipType) throws Exception {
   String[] invoicingBranchDept = new String[2];
   try {
     invoicingBranchDept[0] = getRelatedParty(partyId, relationShipType);
     if (!"".equals(StringUtility.noNull(invoicingBranchDept[0]))) {
       invoicingBranchDept[1] = getAssociatedDept(invoicingBranchDept[0], true);
     } else {
       invoicingBranchDept[1] = "";
     }
   } finally {
   }
   return invoicingBranchDept;
 }
 @SuppressWarnings("unchecked")
 public void doTransJournalReProcess(HttpServletRequest request)
     throws FoursoftException, Exception {
   String selectedJrnalIds = null;
   JournalEntryVO srchParams = null;
   try {
     selectedJrnalIds = StringUtility.noNull(request.getParameter("selectedJrnalIds"));
     JournalEntryDAO.pushETJIdsQueue(CollectionUtils.commaSepartedStrToList(selectedJrnalIds));
     navigationParams.setSuccessMessage("Reprocess request intiated sucessfully.");
     srchParams = (JournalEntryVO) httpRequest.getAttribute("JournalEntryVO");
     if (srchParams != null) {
       srchParams.setSelectedJrnalIds(null);
     }
   } finally {
     selectedJrnalIds = null;
   }
 }
 // @@ added by Nagaraj on 20060706 for Adv. Search functionality
 public String getRecords(List data, ESupplyGlobalParameters loginbean) {
   StringBuffer sb = new StringBuffer();
   if (data.size() <= 0) {
     return "[\"No Results Found\"],";
   }
   Iterator itr = data.iterator();
   ETLOCATIONAdvVO locationVO = null;
   String dateFormat = loginbean.getUserPreferences().getDateFormat();
   while (itr.hasNext()) {
     locationVO = (ETLOCATIONAdvVO) itr.next();
     sb.append("[")
         .append("\"" + locationVO.getLocId() + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getLocName()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getZipCode()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getCityName()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getCountryId()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getMode()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getSectorId()) + "\",")
         .append("\"" + StringUtility.noNull(locationVO.getZoneId()) + "\",")
         .append("],");
   }
   return sb.toString();
 }
 public String isValidNickName(PartyLovVO partyLovVO) {
   Statement st = null;
   Connection connection = null;
   ResultSet rs = null;
   String ret = "Invalid";
   String partyRole = partyLovVO.getPartyRole();
   String visiblePartyId = partyLovVO.getPartyNickName();
   String hiddenPartyId = partyLovVO.getPartyId();
   try {
     boolean partyMatch =
         visiblePartyId.equalsIgnoreCase(getNickNameInNickNameMode(hiddenPartyId));
     if (!partyMatch) {
       hiddenPartyId = "";
       partyLovVO.setPartyId("");
     }
     if (!isValidParty(partyLovVO) || StringUtility.isNullEmpty(hiddenPartyId)) {
       boolean temp = false;
       if (!StringUtility.isNullEmpty(hiddenPartyId) && partyMatch) {
         temp = isValidParty(partyLovVO);
         if (!temp && ("*PU_LOCN".equals(partyRole) || "*DEL_LOCN".equals(partyRole))) {
           if ("*PU_LOCN".equals(partyRole)) {
             partyLovVO.setPartyRole("*SHIPPER");
           } else {
             partyLovVO.setPartyRole("*CONSIGNEE");
           }
           temp = isValidParty(partyLovVO);
         }
       }
       if (!temp) {
         connection = getConnection();
         st =
             connection.createStatement(
                 ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
         rs =
             st.executeQuery(
                 "SELECT DCS_CODE FROM ET_BUSINESS_PARTY WHERE DCS_NICK_NAME='"
                     + visiblePartyId
                     + "' AND DCS_PARTY_TYPE LIKE '%"
                     + partyRole
                     + "%'");
         int count = 0;
         if (rs.next()) {
           rs.last();
           count = rs.getRow();
           rs.beforeFirst();
         }
         if (count == 0) {
           ret = "InValidNickName";
         } else if (count == 1) {
           if (rs.first()) {
             partyLovVO.setPartyId(rs.getString("DCS_CODE"));
             temp = isValidParty(partyLovVO);
             if (!temp && ("*PU_LOCN".equals(partyRole) || "*DEL_LOCN".equals(partyRole))) {
               if ("*PU_LOCN".equals(partyRole)) {
                 partyLovVO.setPartyRole("*SHIPPER");
               } else {
                 partyLovVO.setPartyRole("*CONSIGNEE");
               }
               temp = isValidParty(partyLovVO);
             }
             if (temp) {
               ret = partyLovVO.getPartyId();
             }
           } else {
           }
         } else {
           ret = "Duplicate";
         }
       } else {
         ret = hiddenPartyId;
       }
     } else {
       ret = hiddenPartyId;
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     ConnectionUtil.closeConnection(connection, st, rs);
   }
   return ret;
 }
 public String loadAJAXData(PartyLovVO lovAttributes, ESupplyGlobalParameters loginBean)
     throws Exception {
   StringBuilder finalQry = new StringBuilder();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   String xmlString = "";
   String userDisplaySeparator = "-";
   String partyNickName = "";
   String partyId = "";
   String partyName = "";
   String userDisplay = null;
   String toolTip = null;
   Connection connection = null;
   String whereCond = "";
   try {
     QueryFields fields = new QueryFields();
     if (ETPartyLovConstants.typeAheadLevel1.equals(lovAttributes.getTypeAheadLevel())
         || ETPartyLovConstants.typeAheadLevel3.equals(lovAttributes.getTypeAheadLevel())) {
       finalQry.append("SELECT ");
       finalQry.append(" USER_DISPLAY,");
       finalQry.append(" TOOL_TIP,");
       finalQry.append(" DCS_CODE,");
       finalQry.append(" DCS_NICK_NAME,");
       finalQry.append(" DCS_PARTY_NAME ");
       finalQry.append(" FROM (" + PartyLovQueries.loadAjaxQuery_LEVEl1);
       fields.put("BP.DCS_NICK_NAME", lovAttributes.getPartyNickName(), QueryConstants.LIKE_COND);
       fields.put("BP.DCS_STATUS", "1");
       fields.put("PR.DCS_CODE", lovAttributes.getPartyRole());
       if (!StringUtility.isNullEmpty(lovAttributes.getRelatedParty())) {
         fields.put("BP.DCS_CODE", lovAttributes.getRelatedParty());
         fields.put("PR.DCS_CODE", lovAttributes.getRelationShipType());
       }
       whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
       whereCond +=
           " ORDER BY "
               + lovAttributes.getSearchMode()
               + " ) WHERE ROWNUM<="
               + lovAttributes.getDisplayRows();
       finalQry.append(whereCond);
       connection = getConnection();
       pstmt = connection.prepareStatement(finalQry.toString());
       rs = pstmt.executeQuery();
       xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
       xmlString += "<partyData>";
       while (rs.next()) {
         partyNickName = StringUtility.noNull(rs.getString("DCS_NICK_NAME"));
         partyId = StringUtility.noNull(rs.getString("DCS_CODE"));
         partyName = StringUtility.noNull(rs.getString("DCS_PARTY_NAME"));
         userDisplay = StringUtility.noNull(rs.getString("USER_DISPLAY"));
         toolTip = StringUtility.noNull(rs.getString("TOOL_TIP"));
         xmlString += "<row>";
         if (ETPartyLovConstants.typeAheadLevel1.equals(lovAttributes.getTypeAheadLevel())) {
           xmlString += "<userdisplay>" + userDisplay + "</userdisplay>";
         } else if (ETPartyLovConstants.typeAheadLevel3.equals(
             lovAttributes.getTypeAheadLevel())) {
           xmlString +=
               "<userdisplay>" + userDisplay + userDisplaySeparator + partyName + "</userdisplay>";
         }
         xmlString += "<tooltip>" + toolTip + "</tooltip>";
         if ("NickNameMode".equals(loginBean.getPartyMode())) {
           xmlString += "<partynickname>" + partyNickName + "</partynickname>";
         } else {
           xmlString += "<partynickname>" + partyId + "</partynickname>";
         }
         xmlString += "<partycode>" + partyId + "</partycode>";
         xmlString += "<partyName>" + partyName + "</partyName>";
         xmlString += "</row>";
       }
       xmlString = xmlString + "</partyData>";
     } else if (ETPartyLovConstants.typeAheadLevel2.equals(lovAttributes.getTypeAheadLevel())
         || ETPartyLovConstants.typeAheadLevel4.equals(lovAttributes.getTypeAheadLevel())) {
       finalQry.append("SELECT ");
       finalQry.append(" USER_DISPLAY,");
       finalQry.append(" TOOL_TIP,");
       finalQry.append(" DCS_CODE,");
       finalQry.append(" DCS_NICK_NAME,");
       finalQry.append(" DCS_PARTY_NAME,");
       finalQry.append(" DCS_ADDRESS_NAME,");
       finalQry.append(" DCS_ADDRESS_NAME2,");
       finalQry.append(" DCS_BUILDING_NAME,");
       finalQry.append(" DCS_STREET_NAME,");
       finalQry.append(" DCS_CITY_TOWN,");
       finalQry.append(" DCS_PHONE_NO,");
       finalQry.append(" DCS_FAX,");
       finalQry.append(" DCS_COUNTRY_STATE_CODE,");
       finalQry.append(" DCS_POS_CODE,");
       finalQry.append(" DCS_COUNTRY_CODE,");
       finalQry.append(" DCS_FORMATTED_ADDRESS");
       finalQry.append(" FROM (" + PartyLovQueries.loadAjaxQuery_LEVEl2);
       fields.put("BP.DCS_NICK_NAME", lovAttributes.getPartyNickName(), QueryConstants.LIKE_COND);
       fields.put("BP.DCS_STATUS", "1");
       fields.put("PR.DCS_CODE", lovAttributes.getPartyRole());
       if (!StringUtility.isNullEmpty(lovAttributes.getRelatedParty())) {
         fields.put("BP.DCS_CODE", lovAttributes.getRelatedParty());
         fields.put("PR.DCS_CODE", lovAttributes.getRelationShipType());
       }
       whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
       whereCond +=
           " ORDER BY "
               + lovAttributes.getSearchMode()
               + " ) WHERE ROWNUM<="
               + lovAttributes.getDisplayRows();
       finalQry.append(whereCond);
       connection = getConnection();
       pstmt = connection.prepareStatement(finalQry.toString());
       rs = pstmt.executeQuery();
       xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
       xmlString += "<partyData>";
       while (rs.next()) {
         partyNickName = StringUtility.noNull(rs.getString("DCS_NICK_NAME"));
         partyId = StringUtility.noNull(rs.getString("DCS_CODE"));
         partyName = StringUtility.noNull(rs.getString("DCS_PARTY_NAME"));
         userDisplay = StringUtility.noNull(rs.getString("USER_DISPLAY"));
         toolTip = StringUtility.noNull(rs.getString("TOOL_TIP"));
         xmlString += "<row>";
         xmlString += "<userdisplay>" + userDisplay + "</userdisplay>";
         xmlString += "<tooltip>" + toolTip + "</tooltip>";
         if ("NickNameMode".equals(loginBean.getPartyMode())) {
           xmlString += "<partynickname>" + partyNickName + "</partynickname>";
         } else {
           xmlString += "<partynickname>" + partyId + "</partynickname>";
         }
         xmlString += "<partycode>" + partyId + "</partycode>";
         xmlString += "<partyName>" + partyName + "</partyName>";
         xmlString += "<addressname1>" + rs.getString("DCS_ADDRESS_NAME") + "</addressname1>";
         xmlString += "<addressname2>" + rs.getString("DCS_ADDRESS_NAME2") + "</addressname2>";
         xmlString += "<buildingname>" + rs.getString("DCS_BUILDING_NAME") + "</buildingname>";
         xmlString += "<streetname>" + rs.getString("DCS_STREET_NAME") + "</streetname>";
         xmlString += "<citytown>" + rs.getString("DCS_CITY_TOWN") + "</citytown>";
         xmlString += "<phoneno>" + rs.getString("DCS_PHONE_NO") + "</phoneno>";
         xmlString += "<fax>" + rs.getString("DCS_FAX") + "</fax>";
         xmlString +=
             "<countrystate>" + rs.getString("DCS_COUNTRY_STATE_CODE") + "</countrystate>";
         xmlString += "<poscode>" + rs.getString("DCS_POS_CODE") + "</poscode>";
         xmlString += "<countrycode>" + rs.getString("DCS_COUNTRY_CODE") + "</countrycode>";
         xmlString +=
             "<formatedaddress>" + rs.getString("DCS_FORMATTED_ADDRESS") + "</formatedaddress>";
         xmlString += "</row>";
       }
       xmlString = xmlString + "</partyData>";
     }
   } catch (Exception e) {
     e.printStackTrace();
     throw e;
   } finally {
     ConnectionUtil.closeResultSet(rs);
     ConnectionUtil.closePreparedStatement(pstmt);
     ConnectionUtil.closeConnection(connection);
   }
   return xmlString;
 }
 public String loadConsigneeOnBlurAjaxData(
     PartyLovVO lovAttributes, ESupplyGlobalParameters loginBean, String xmlString)
     throws Exception {
   StringBuilder finalQry = new StringBuilder();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   String invoiceBranch = null;
   Connection connection = null;
   String whereCond = "";
   String invoiceDept = null;
   String collectParty = null;
   String stParty = null;
   String collectCon = null;
   String stCon = null;
   String collectType = null;
   String onBlurSeq = null;
   String[] onBlurSeqAry = null;
   try {
     QueryFields fields = new QueryFields();
     finalQry.append(PartyLovQueries.loadConsigneeOnBlurAjaxQry);
     fields.put("BP.DCS_STATUS", "1");
     fields.put("PR.DCS_CODE", lovAttributes.getPartyRole());
     fields.put("BP.DCS_CODE", lovAttributes.getPartyId());
     whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
     finalQry.append(whereCond);
     connection = getConnection();
     pstmt = connection.prepareStatement(finalQry.toString());
     rs = pstmt.executeQuery();
     if (rs.next()) {
       onBlurSeq = lovAttributes.getOnBlurSeq();
       invoiceBranch = StringUtility.noNull(rs.getString("INVOICE_BRANCH"));
       invoiceDept = StringUtility.noNull(rs.getString("INVOICE_DEPT"));
       collectParty = StringUtility.noNull(rs.getString("COLLECT_PARTY"));
       stParty = StringUtility.noNull(rs.getString("ST_PARTY"));
       collectCon = StringUtility.noNull(rs.getString("COLLECT_CON"));
       stCon = StringUtility.noNull(rs.getString("ST_CON"));
       if (!StringUtility.isNullEmpty(onBlurSeq)) {
         onBlurSeqAry = onBlurSeq.split(",");
       }
       if (onBlurSeqAry != null && onBlurSeqAry.length > 0) {
         for (String onBlurFinalSeq : onBlurSeqAry) {
           if ("1".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             xmlString += "<invoicebranch>" + invoiceBranch + "</invoicebranch>";
             xmlString += "<invoicedept>" + invoiceDept + "</invoicedept>";
           }
           if ("2".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             if (!"0".equals(collectCon) && !"1".equals(collectCon)) {
               collectType =
                   "1".equals(stCon) ? "Export" : ("2".equals(stCon) ? "Import" : "Both");
             } else if (collectParty != "0" && "1" != collectParty) {
               collectType =
                   "1".equals(stParty) ? "Export" : ("2".equals(stParty) ? "Import" : "Both");
             }
             xmlString += "<collectshipment>" + collectType + "</collectshipment>";
           }
         }
       }
     }
   } finally {
     ConnectionUtil.closeConnection(connection, pstmt, rs);
   }
   return xmlString;
 }
 public String loadCustomerOnBlurAjaxData(
     PartyLovVO lovAttributes, ESupplyGlobalParameters loginBean, String xmlString)
     throws Exception {
   StringBuilder finalQry = new StringBuilder();
   PreparedStatement pstmt = null;
   ResultSet rs = null;
   String invoiceBranch = null;
   String partyId = "";
   Connection connection = null;
   String whereCond = "";
   String invoiceDept = null;
   String tradeTerms = "NoTradeTerm";
   boolean ro = false;
   String creditLimit = null;
   String collectParty = null;
   String stParty = null;
   String collectCon = null;
   String stCon = null;
   String csr = null;
   String salesPersonId = null;
   String salesPersonIdNickName = null;
   String collectType = null;
   String onBlurSeq = null;
   String[] onBlurSeqAry = null;
   try {
     QueryFields fields = new QueryFields();
     finalQry.append(PartyLovQueries.loadCustomerOnBlurAjaxQry);
     fields.put("BP.DCS_STATUS", "1");
     fields.put("PR.DCS_CODE", lovAttributes.getPartyRole());
     fields.put("BP.DCS_CODE", lovAttributes.getPartyId());
     whereCond = " AND " + QueryBuilderUtil.buildWhereCond(fields);
     finalQry.append(whereCond);
     connection = getConnection();
     pstmt = connection.prepareStatement(finalQry.toString());
     rs = pstmt.executeQuery();
     if (rs.next()) {
       onBlurSeq = lovAttributes.getOnBlurSeq();
       partyId = StringUtility.noNull(rs.getString("DCS_CODE"));
       invoiceBranch = StringUtility.noNull(rs.getString("INVOICE_BRANCH"));
       invoiceDept = StringUtility.noNull(rs.getString("INVOICE_DEPT"));
       tradeTerms = StringUtility.noNull(rs.getString("TRADE_TERMS"));
       creditLimit = StringUtility.noNull(rs.getString("CREDIT_LIMIT"));
       collectParty = StringUtility.noNull(rs.getString("COLLECT_PARTY"));
       stParty = StringUtility.noNull(rs.getString("ST_PARTY"));
       collectCon = StringUtility.noNull(rs.getString("COLLECT_CON"));
       stCon = StringUtility.noNull(rs.getString("ST_CON"));
       csr = StringUtility.noNull(rs.getString("CSR"));
       salesPersonId = StringUtility.noNull(rs.getString("SALESPERSONID"));
       salesPersonIdNickName = StringUtility.noNull(rs.getString("SALESPERSONIDNICKNAME"));
       if (!StringUtility.isNullEmpty(onBlurSeq)) {
         onBlurSeqAry = onBlurSeq.split(",");
       }
       if (onBlurSeqAry != null && onBlurSeqAry.length > 0) {
         for (String onBlurFinalSeq : onBlurSeqAry) {
           if ("1".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             xmlString += "<invoicebranch>" + invoiceBranch + "</invoicebranch>";
             xmlString += "<invoicedept>" + invoiceDept + "</invoicedept>";
           }
           if ("2".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             ro = StringUtility.noNull(rs.getString("RO")).equals("1") ? true : false;
             xmlString += "<tradeterm>" + tradeTerms + "</tradeterm>";
             xmlString += "<ro>" + ro + "</ro>";
           }
           if ("3".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             if (!"0".equals(collectCon) && !"1".equals(collectCon)) {
               collectType =
                   "1".equals(stCon) ? "Export" : ("2".equals(stCon) ? "Import" : "Both");
             } else if (collectParty != "0" && "1" != collectParty) {
               collectType =
                   "1".equals(stParty) ? "Export" : ("2".equals(stParty) ? "Import" : "Both");
             }
             xmlString += "<collectshipment>" + collectType + "</collectshipment>";
           }
           if ("4".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             xmlString += "<creditlimit>" + creditLimit + "</creditlimit>";
           }
           if ("5".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             String[] csrTeam = csr.split(",");
             String csrXmlString = "";
             if (!StringUtility.isNullEmpty(csrTeam)) {
               if ("csrAETeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 0) {
                 csrXmlString = csrTeam[0];
               } else if ("csrAITeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 1) {
                 csrXmlString = csrTeam[1];
               } else if ("csrOETeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 2) {
                 csrXmlString = csrTeam[2];
               } else if ("csrOITeam".equals(lovAttributes.getCsrType()) && csrTeam.length > 3) {
                 csrXmlString = csrTeam[3];
               } else {
                 if (csrTeam.length > 4) {
                   csrXmlString = csrTeam[4];
                 }
               }
             }
             xmlString += "<csr>" + csrXmlString + "</csr>";
           }
           if ("6".equals(onBlurFinalSeq) || "0".equals(onBlurFinalSeq)) {
             String[] salesPerson =
                 getDefaultSalespersonForCustomer(partyId, loginBean.getTerminalId());
             salesPersonId = !StringUtility.isNullEmpty(salesPerson) ? salesPerson[0] : "";
             salesPersonIdNickName = !StringUtility.isNullEmpty(salesPerson) ? salesPerson[1] : "";
             xmlString += "<salespersonid>" + salesPersonId + "</salespersonid>";
             xmlString +=
                 "<salespersonidnickname>" + salesPersonIdNickName + "</salespersonidnickname>";
           }
         }
       }
     }
   } finally {
     ConnectionUtil.closeConnection(connection, pstmt, rs);
   }
   return xmlString;
 }
 public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   EAChequeFuntionalityMaintenanceController mainControllerObj;
   mainControllerObj = new EAChequeFuntionalityMaintenanceController();
   if (request.getParameter("chequeIssueReport") != null) {
     String batchNo = request.getParameter("batchNo");
     StringTokenizer splitBatchNo = new StringTokenizer(batchNo, ",");
     String[] batchNoArray = new String[splitBatchNo.countTokens()];
     int i = 0;
     while (splitBatchNo.hasMoreTokens()) {
       batchNoArray[i++] = new String(splitBatchNo.nextToken());
     }
     ESupplyGlobalParameters loginBean =
         (ESupplyGlobalParameters) request.getSession(true).getAttribute("loginbean");
     EAChequeFunctionalityDAO chequeDAO = new EAChequeFunctionalityDAO();
     String report = chequeDAO.retrieveChequeIssueReport(batchNoArray, loginBean.getLocalTime());
     response.setContentType("Application/txt");
     response.setHeader("Content-Disposition", "attachment; filename=" + batchNo + ".txt");
     OutputStream outStream = response.getOutputStream();
     java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream();
     baos.write(report.getBytes());
     baos.writeTo(outStream);
     baos.close();
     outStream.flush();
     outStream.close();
   } else if (request.getParameter("fetchNextOpenCheque") != null) {
     String chequeNo = "";
     String stockId = "";
     String chequeCurrency = "";
     Logger.info(FILE_NAME, "fetchNextOpenCheque");
     HashMap chequeMap = new HashMap();
     if (!"".equals(StringUtility.noNull(request.getParameter("searchCompanyId"))))
       chequeMap.put("companyId", StringUtility.noNull(request.getParameter("searchCompanyId")));
     if (!"".equals(StringUtility.noNull(request.getParameter("searchTerminalId"))))
       chequeMap.put("terminalId", StringUtility.noNull(request.getParameter("searchTerminalId")));
     if (!"".equals(StringUtility.noNull(request.getParameter("searchAccountCode"))))
       chequeMap.put(
           "accountCode", StringUtility.noNull(request.getParameter("searchAccountCode")));
     if (!"".equals(StringUtility.noNull(request.getParameter("searchChequeStatus"))))
       chequeMap.put(
           "chequeStatus", StringUtility.noNull(request.getParameter("searchChequeStatus")));
     // Added by AMIT On 02DEC
     if (!"".equals(StringUtility.noNull(request.getParameter("searchAccountName"))))
       chequeMap.put(
           "accountName", StringUtility.noNull(request.getParameter("searchAccountName")));
     chequeMap.put("singleCheque", "Y");
     // @@ Added by Siva  S for CR_2097
     if (!"".equals(StringUtility.noNull(request.getParameter("reservedCheques")))) {
       chequeMap.put(
           "reservedCheques", StringUtility.noNull(request.getParameter("reservedCheques")));
     }
     // @@ for CR_2097
     try {
       ArrayList result =
           new EAChequeFunctionalityAdvDAO().getResult(chequeMap, "SearchOpenCheque");
       if (result != null && result.size() > 0) {
         HashMap chequeDetail = (HashMap) result.get(0);
         stockId = (String) chequeDetail.get("stockId");
         chequeNo = (String) chequeDetail.get("chequeNo");
         chequeCurrency = (String) chequeDetail.get("chequeCurrency");
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     StringBuffer chequeXML = new StringBuffer("<cheque>");
     chequeXML.append("<stockId>" + stockId + "</stockId>");
     chequeXML.append("<chequeNo>" + chequeNo + "</chequeNo>");
     chequeXML.append("<chequeCurrency>" + chequeCurrency + "</chequeCurrency>");
     chequeXML.append("</cheque>");
     response.setContentType("text/xml");
     PrintWriter out = response.getWriter();
     out.write(chequeXML.toString());
     out.close();
   } else mainControllerObj.handleRequest(request, response);
 }
 /**
  * Actually runs the query and puts the returned table model on the request as attribute
  * 'tableModel'.
  *
  * @param request
  * @param criteria
  * @throws ServletException
  */
 protected void runQuery(HttpServletRequest request, DefaultListFormBackingObject backingObject)
     throws ServletException {
   IdTableModel tm = null;
   ObjectQueryCommand command = createQueryCommand(request, backingObject);
   SearchFormCriteria criteria = (SearchFormCriteria) backingObject.getDataObject();
   // FOR RETERIVING SEARCH CRITERIA WRITTEN BY SUBHASH CHANDRASHAKER.V START
   String searchCriteriaFunctionCode =
       (String) request.getSession().getAttribute("searchCriteriaFunctionCode");
   if (request.getSession().getAttribute("searchCriteriaObject") != null
       && searchCriteriaFunctionCode != null
       && searchCriteriaFunctionCode.equals(getFunctionCode())) {
     criteria = (SearchFormCriteria) request.getSession().getAttribute("searchCriteriaObject");
     backingObject.setDataObject(criteria);
     request.getSession().removeAttribute("searchCriteriaObject");
     request.getSession().removeAttribute("searchCriteriaFunctionCode");
   } else if (searchCriteriaFunctionCode != null
       && !searchCriteriaFunctionCode.equals(getFunctionCode())) {
     request.getSession().removeAttribute("searchCriteriaObject");
     request.getSession().removeAttribute("searchCriteriaFunctionCode");
   }
   // FOR RETERIVING SEARCH CRITERIA WRITTEN BY SUBHASH CHANDRASHAKER.V END
   if (criteria.getParentInfo() != null) {
     command.setParentInfo(criteria.getParentInfo());
   }
   /*
    * If we have criteria, then add them to the command.
    */
   if (criteria.getCriteria() != null && criteria.getCriteria().size() > 0) {
     Iterator i = criteria.getCriteria().values().iterator();
     while (i.hasNext()) {
       ObjectQueryCommandFilterCriterion crit = (ObjectQueryCommandFilterCriterion) i.next();
       if (crit.getValue()
           != null) { // the validator resets all empty strings to null, so we don't have to check
                      // here
         // Modified by SIVAPRASAD for single quotes handling
         if (crit.getAttributeName() != null && crit.getAttributeName().equals("code")) {
           command.addFilterCriterion(
               crit.getAttributeName(),
               crit.getOperator(),
               StringUtility.escapeCharsSQLQuery(((String) crit.getValue()).toUpperCase()));
         } else {
           command.addFilterCriterion(
               crit.getAttributeName(),
               crit.getOperator(),
               StringUtility.escapeCharsSQLQuery((String) crit.getValue()));
         }
       }
     }
   }
   /*PAGINATION RELATED CODE STARTS*/
   String currentPageNumber = backingObject.getPageNumber();
   if (currentPageNumber != null
       && !"".equals(currentPageNumber)
       && backingObject.getTotalPages() != null
       && !"".equals(backingObject.getTotalPages())) {
     int oldTotal = Integer.parseInt(backingObject.getTotalPages());
     int selectedPage = Integer.parseInt(currentPageNumber);
     if (selectedPage > oldTotal) currentPageNumber = backingObject.getTotalPages();
   }
   String pageOperation = backingObject.getPageOperation();
   if ((currentPageNumber == null)
       || ("").equals(currentPageNumber)
       || (Integer.parseInt(currentPageNumber) <= 0)
           && (pageOperation == null || ("").equals(pageOperation))) {
     currentPageNumber = "1";
   } else {
     // check the Operation requested
     if (Constants.PAGE_FIRST.equals(pageOperation)) {
       currentPageNumber = "1";
       backingObject.setPageOffset(null);
     } else if (Constants.PAGE_PREVIOUS.equals(pageOperation)) {
       int tempCount = (Integer.parseInt(currentPageNumber));
       if (tempCount >= 1) {
         currentPageNumber = Integer.toString(tempCount - 1);
         if (tempCount == 2
             && backingObject.getPageOffset() != null
             && Integer.parseInt(backingObject.getPageOffset()) > 0) {
           backingObject.setPageOffset(null);
         }
       }
     } else if (Constants.PAGE_NEXT.equals(pageOperation)) {
       currentPageNumber = Integer.toString((Integer.parseInt(currentPageNumber)) + 1);
     } else if (Constants.PAGE_LAST.equals(pageOperation)) {
       currentPageNumber = Integer.toString(Integer.parseInt(backingObject.getTotalPages()));
     } else if (Constants.PAGE_CLICK_ENTER.equals(pageOperation)) {
       // Modified by SIVAPRASAD to display the first page when 0 is entered in the page number
       if (currentPageNumber.equals("0")) currentPageNumber = "1";
       else currentPageNumber = currentPageNumber;
     }
     // added above condition for pagenation for WPBN Issue 67620
   }
   setPositionToValues(request, backingObject, command);
   // enable pagination
   command.setPaginationEnabled(backingObject.isPaginationEnabled());
   command.setCurrentPageNum(Integer.parseInt(currentPageNumber));
   //     	if (backingObject.getSelectedEntityId() != null) {
   //     		command.setPositionToEntity(backingObject.getSelectedEntityId());
   //     	}
   String defaultFetchSize = backingObject.getPageSize();
   // set the Fetch Size
   try {
     //	Modified by Yogesh for Auto Grid Functionality
     //			Modified by Kiran sajja for WPBN ISSUE ID 98681
     if (defaultFetchSize != null && !("").equals(defaultFetchSize)) {
       int defaultFetchSizeInt = Integer.parseInt(defaultFetchSize);
       command.setPageSize(defaultFetchSizeInt);
     } else {
       command.setPageSize(getDefaultAutoSize()); // set the default fetch size to 10
       backingObject.setPageNumber("" + getDefaultAutoSize());
     }
   } catch (NumberFormatException ex) {
     command.setPageSize(getDefaultAutoSize()); // set the default fetch size to 10
     backingObject.setPageSize("" + getDefaultAutoSize());
   }
   // modified by lokesh for issue 159432
   request.setAttribute("defaultAutoSize", getDefaultAutoSize() + "");
   // setup page offset (if required)
   if (backingObject.getPageOffset() != null) {
     if (backingObject.getPageSize().equals(backingObject.getPageOffsetForPageSize())) {
       command.setPageOffset(Integer.parseInt(backingObject.getPageOffset()));
     } else {
       // page size has changed, recalc the offset and page
       int rowPosition = 0;
       int pageOffset = Integer.parseInt(backingObject.getPageOffset());
       if (pageOffset != 0) {
         rowPosition =
             pageOffset
                 + ((Integer.parseInt(backingObject.getPageNumber()) - 2)
                     * Integer.parseInt(backingObject.getPageOffsetForPageSize()));
         pageOffset = rowPosition % command.getPageSize();
         command.setPageOffset(pageOffset);
         command.setCurrentPageNum(((rowPosition - pageOffset) / command.getPageSize()) + 2);
       }
     }
   }
   // work out if we have a pagination-related change
   boolean paginationChange = false;
   // page changed
   if (backingObject.getPageNumber() != null && backingObject.getTableModel() != null) {
     int requestedPageNumber = Integer.parseInt(backingObject.getPageNumber());
     if (requestedPageNumber != backingObject.getTableModel().getPageNumber()) {
       paginationChange = true;
     }
   }
   if (backingObject.getPageSize() != null && backingObject.getPageOffsetForPageSize() != null) {
     if (!backingObject.getPageSize().equals(backingObject.getPageOffsetForPageSize())) {
       paginationChange = true;
     }
   }
   if (backingObject.getPageOperation() != null && !"".equals(backingObject.getPageOperation())) {
     paginationChange = true;
   }
   // if the pagination has not changed, reset to the first page because we're doing a search
   if (!paginationChange) {
     command.setCurrentPageNum(1);
     backingObject.setPageNumber("1");
     command.setPageOffset(0);
     backingObject.setPageOffset("0");
   }
   try {
     command.setCurrentPageNum(Integer.parseInt(currentPageNumber));
   } catch (NumberFormatException e) {
     command.setCurrentPageNum(1);
   }
   /* PAGINATION RELATED CODE CONTINUES */
   tm = retrieveQueryResults(command);
   /* PAGINATION RELATED CODE CONTINUED */
   // CALCULATE THE TOTAL PAGE COUNT
   Object[][] data = tm.getData();
   if (data.length > 0) {
     int totalPages = 1;
     if ((tm.getTotalRowCount() > command.getPageSize()) || tm.getPageOffset() != 0) {
       int totalRows = tm.getTotalRowCount();
       int offset = tm.getPageOffset();
       int overhang = (totalRows - offset) % command.getPageSize();
       // normal pages in the set
       totalPages = 0;
       // if we overhang, e.g. 15 rows on page size 10, then add extra page
       if (offset > 0) totalPages += 1;
       if (overhang > 0) totalPages += 1;
       totalPages += (totalRows - (offset + overhang)) / command.getPageSize();
     }
     command.setTotalPageCount(totalPages);
     // commented for pagenation for WPBN Issue 67620
     // currentPageNumber = Integer.toString(tm.getPageNumber());
   } else {
     request.setAttribute(
         "successmessage", ResourceUtils.getLiteral("norecordsfound", getUserLocale(request)));
     command.setTotalPageCount(1);
     currentPageNumber = "1";
   }
   // set the new Total Page Count
   backingObject.setTotalPages(Integer.toString(command.getTotalPageCount()));
   // set the new Page Number
   backingObject.setPageNumber(currentPageNumber);
   // set the defaultFetchSize
   backingObject.setPageSize(Integer.toString(command.getPageSize()));
   // set the page offset (for position to)
   backingObject.setPageOffset(Integer.toString(tm.getPageOffset()));
   backingObject.setPageOffsetForPageSize(backingObject.getPageSize());
   // reset for the next query
   backingObject.setPageOperation(null);
   /*PAGINATION RELATED CODE ENDS*/
   request.setAttribute("tableModel", tm);
   backingObject.setTableModel(tm);
   TableLayoutDescriptor layoutDescriptor = new TableLayoutDescriptor(tm);
   setTableLayout(layoutDescriptor, tm, backingObject, request);
   ((DefaultListFormBackingObject) backingObject).setTableLayout(layoutDescriptor);
   request.setAttribute("tableColumnHeadings", getColumnHeadings(getUserLocale(request)));
   // Added By vara for Issue Id: 88316 to retain the customized grid column width
   String tableColumnString = request.getParameter("tableColumnSize");
   String tableColumnSize[] = setColumnSize();
   if (tableColumnString != null && tableColumnString != "" && !tableColumnString.equals("")) {
     tableColumnSize = tableColumnString.split(",");
   }
   request.setAttribute("tableColumnSize", tableColumnSize);
   // End
   backingObject.setDisplayTab(Constants.ACTION_LIST);
   request.setAttribute(Constants.REQUEST_FORM_ACTION_FIELD, Constants.ACTION_LIST);
   // make sure the view knows what URL to access to maintain an instance
   request.setAttribute(Constants.REQUEST_MAINTAINER_URL, getMaintainerUrl());
 }