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; }
public void setSrchResults(RELabelSetupSrchParams searchParams) throws Exception { Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; ArrayList<RELabelSetupSrchParams> searchResults = new ArrayList<RELabelSetupSrchParams>(); String labelFetchQry = "SELECT ID, SCREEN_ID,DESCRIPTION,JSP_NAME,VO_CLASS,HANDLER_CLASS," + "REMARKS,STATUS FROM SOFTWARE_SERVICES "; try { QueryFields fields = new QueryFields(); fields.put("SCREEN_ID", searchParams.getScrnId(), QueryConstants.LIKE_COND); fields.put("DESCRIPTION", searchParams.getDesc(), QueryConstants.LIKE_COND); fields.put("JSP_NAME", searchParams.getJspName(), QueryConstants.LIKE_COND); fields.put("VO_CLASS", searchParams.getVoClass(), QueryConstants.LIKE_COND); fields.put("HANDLER_CLASS", searchParams.getHandlerClass(), QueryConstants.DATE_TYPE); fields.put("REMARKS", searchParams.getRemarks(), QueryConstants.LIKE_COND); fields.put("STATUS", searchParams.getRemarks(), QueryConstants.LIKE_COND); String whereCond = QueryBuilderUtil.buildWhereCond(fields); String finalQry = labelFetchQry; if (!TagLibStringUtility.isNullEmpty(whereCond)) { finalQry = finalQry + " WHERE " + whereCond; } finalQry = finalQry + "ORDER BY SCREEN_ID DESC"; con = TagLibConnectionUtil.getConnection(); searchParams.totalRecords = QueryBuilderUtil.getTotalRowCount(finalQry, con); String pagedQry = QueryBuilderUtil.getPaginationQry( finalQry, searchParams.startNumber, searchParams.endNumber); pstmt = con.prepareStatement(pagedQry); rs = pstmt.executeQuery(); while (rs.next()) { RELabelSetupSrchParams labelSetup = new RELabelSetupSrchParams(); labelSetup.setId(rs.getLong("ID")); labelSetup.setScrnId(rs.getString("SCREEN_ID")); labelSetup.setDesc(rs.getString("DESCRIPTION")); labelSetup.setJspName(rs.getString("JSP_NAME")); labelSetup.setVoClass(rs.getString("VO_CLASS")); labelSetup.setHandlerClass(rs.getString("HANDLER_CLASS")); labelSetup.setRemarks(rs.getString("REMARKS")); labelSetup.setStatus(rs.getString("STATUS")); searchResults.add(labelSetup); } searchParams.setSearchResults(searchResults); } catch (Exception e) { e.printStackTrace(); } finally { TagLibConnectionUtil.closePreparedStatement(pstmt, rs); TagLibConnectionUtil.closeConnection(con); } }
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; }