Java tutorial
// Description: Java 7 PostgreSQL Jdbc DbIO implementation for AccountConfig. /* * MSS Code Factory Accounting Business Application Model * * Copyright (c) 2014 Mark Sobkow * * This program is available as free software under the GNU GPL v3, or * under a commercial license from Mark Sobkow. For commercial licensing * details, please contact msobkow@sasktel.net. * * Under the terms of the GPL: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * This source code incorporates modified modules originally licensed * under the Apache 2.0 license by MSS Code Factory including CFSecurity * (net-sourceforge-msscodefactory-2.0-cfsecurity.xml), * CFInternet (net-sourceforge-msscodefactory-2.0-cfinternet.xml), and * CFCrm 2.0 (net-sourceforge-msscodefactory-2.0-cfcrm.xml), with all of the * required models being available as part of the MSS Code Factory 1.11 * distribution source and install zips. * * You can download installations of MSS Code Factory 1.11 from * http://msscodefactory.sourceforge.net/ * * *********************************************************************** * * Code manufactured by MSS Code Factory */ package net.sourceforge.msscodefactory.cfacc.v2_0.CFAccPgSql; import java.math.*; import java.sql.*; import java.text.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_11.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.*; /* * CFAccPgSqlAccountConfigTable PostgreSQL Jdbc DbIO implementation * for AccountConfig. */ public class CFAccPgSqlAccountConfigTable implements ICFAccAccountConfigTable { private CFAccPgSqlSchema schema; protected PreparedStatement stmtReadBuffByPKey = null; protected PreparedStatement stmtReadBuffAll = null; protected PreparedStatement stmtLockBuffByPKey = null; protected PreparedStatement stmtCreateByPKey = null; protected PreparedStatement stmtUpdateByPKey = null; protected PreparedStatement stmtDeleteByPKey = null; protected PreparedStatement stmtReadAllBuff = null; protected PreparedStatement stmtReadBuffByIdIdx = null; protected PreparedStatement stmtReadBuffByTenantIdx = null; protected PreparedStatement stmtReadBuffByDefCcyIdx = null; protected PreparedStatement stmtReadBuffByCustCtcLstIdx = null; protected PreparedStatement stmtReadBuffByEmpCtcLstIdx = null; protected PreparedStatement stmtReadBuffByVendCtcLstIdx = null; protected PreparedStatement stmtDeleteByIdIdx = null; protected PreparedStatement stmtDeleteByTenantIdx = null; protected PreparedStatement stmtDeleteByDefCcyIdx = null; protected PreparedStatement stmtDeleteByCustCtcLstIdx = null; protected PreparedStatement stmtDeleteByEmpCtcLstIdx = null; protected PreparedStatement stmtDeleteByVendCtcLstIdx = null; public CFAccPgSqlAccountConfigTable(CFAccPgSqlSchema argSchema) { schema = argSchema; } public void createAccountConfig(CFAccAuthorization Authorization, CFAccAccountConfigBuff Buff) { final String S_ProcName = "createAccountConfig"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); short DefaultCurrencyId = Buff.getRequiredDefaultCurrencyId(); Long CustContactListTenantId = Buff.getOptionalCustContactListTenantId(); Long CustContactListId = Buff.getOptionalCustContactListId(); Long EmpContactListTenantId = Buff.getOptionalEmpContactListTenantId(); Long EmpContactListId = Buff.getOptionalEmpContactListId(); Long VendContactListTenantId = Buff.getOptionalVendContactListTenantId(); Long VendContactListId = Buff.getOptionalVendContactListId(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_create_acct_cfg( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtCreateByPKey == null) { stmtCreateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtCreateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtCreateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtCreateByPKey.setString(argIdx++, "ACFG"); stmtCreateByPKey.setLong(argIdx++, TenantId); stmtCreateByPKey.setShort(argIdx++, DefaultCurrencyId); if (CustContactListTenantId != null) { stmtCreateByPKey.setLong(argIdx++, CustContactListTenantId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (CustContactListId != null) { stmtCreateByPKey.setLong(argIdx++, CustContactListId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (EmpContactListTenantId != null) { stmtCreateByPKey.setLong(argIdx++, EmpContactListTenantId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (EmpContactListId != null) { stmtCreateByPKey.setLong(argIdx++, EmpContactListId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (VendContactListTenantId != null) { stmtCreateByPKey.setLong(argIdx++, VendContactListTenantId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (VendContactListId != null) { stmtCreateByPKey.setLong(argIdx++, VendContactListId.longValue()); } else { stmtCreateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtCreateByPKey.executeQuery(); if (resultSet.next()) { CFAccAccountConfigBuff createdBuff = unpackAccountConfigResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredTenantId(createdBuff.getRequiredTenantId()); Buff.setRequiredDefaultCurrencyId(createdBuff.getRequiredDefaultCurrencyId()); Buff.setOptionalCustContactListTenantId(createdBuff.getOptionalCustContactListTenantId()); Buff.setOptionalCustContactListId(createdBuff.getOptionalCustContactListId()); Buff.setOptionalEmpContactListTenantId(createdBuff.getOptionalEmpContactListTenantId()); Buff.setOptionalEmpContactListId(createdBuff.getOptionalEmpContactListId()); Buff.setOptionalVendContactListTenantId(createdBuff.getOptionalVendContactListTenantId()); Buff.setOptionalVendContactListId(createdBuff.getOptionalVendContactListId()); Buff.setRequiredRevision(createdBuff.getRequiredRevision()); Buff.setCreatedByUserId(createdBuff.getCreatedByUserId()); Buff.setCreatedAt(createdBuff.getCreatedAt()); Buff.setUpdatedByUserId(createdBuff.getUpdatedByUserId()); Buff.setUpdatedAt(createdBuff.getUpdatedAt()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public String S_sqlSelectAccountConfigDistinctClassCode = null; public String getSqlSelectAccountConfigDistinctClassCode() { if (S_sqlSelectAccountConfigDistinctClassCode == null) { S_sqlSelectAccountConfigDistinctClassCode = "SELECT " + "DISTINCT acfg.ClassCode " + "FROM " + schema.getLowerSchemaDbName() + ".acct_cfg AS acfg "; } return (S_sqlSelectAccountConfigDistinctClassCode); } public String S_sqlSelectAccountConfigBuff = null; public String getSqlSelectAccountConfigBuff() { if (S_sqlSelectAccountConfigBuff == null) { S_sqlSelectAccountConfigBuff = "SELECT " + "acfg.TenantId, " + "acfg.DefCcyId, " + "acfg.CstCtcLstTntId, " + "acfg.CstCtcLstId, " + "acfg.EmpCtcLstTntId, " + "acfg.EmpCtcLstId, " + "acfg.VendCtcLstTntId, " + "acfg.VendCtcLstId, " + "acfg.Revision " + "FROM " + schema.getLowerSchemaDbName() + ".acct_cfg AS acfg "; } return (S_sqlSelectAccountConfigBuff); } protected CFAccAccountConfigBuff unpackAccountConfigResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackAccountConfigResultSetToBuff"; int idxcol = 1; CFAccAccountConfigBuff buff = schema.getFactoryAccountConfig().newBuff(); { String colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedByUserId(null); } else { buff.setCreatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setCreatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setCreatedAt(null); } else { buff.setCreatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedByUserId(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedByUserId(null); } else { buff.setUpdatedByUserId(UUID.fromString(colString)); } idxcol++; colString = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setUpdatedAt(null); } else if ((colString == null) || (colString.length() <= 0)) { buff.setUpdatedAt(null); } else { buff.setUpdatedAt(CFAccPgSqlSchema.convertTimestampString(colString)); } idxcol++; } buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredDefaultCurrencyId(resultSet.getShort(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalCustContactListTenantId(null); } else { buff.setOptionalCustContactListTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalCustContactListId(null); } else { buff.setOptionalCustContactListId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalEmpContactListTenantId(null); } else { buff.setOptionalEmpContactListTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalEmpContactListId(null); } else { buff.setOptionalEmpContactListId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalVendContactListTenantId(null); } else { buff.setOptionalVendContactListTenantId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalVendContactListId(null); } else { buff.setOptionalVendContactListId(colVal); } } idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); } public CFAccAccountConfigBuff readDerived(CFAccAuthorization Authorization, CFAccAccountConfigPKey PKey) { final String S_ProcName = "readDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff buff; buff = readBuff(Authorization, PKey); return (buff); } public CFAccAccountConfigBuff lockDerived(CFAccAuthorization Authorization, CFAccAccountConfigPKey PKey) { final String S_ProcName = "lockDerived"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff buff; buff = lockBuff(Authorization, PKey); return (buff); } public CFAccAccountConfigBuff[] readAllDerived(CFAccAuthorization Authorization) { final String S_ProcName = "readAllDerived"; CFAccAccountConfigBuff[] buffArray; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buffArray = readAllBuff(Authorization); return (buffArray); } public CFAccAccountConfigBuff readDerivedByIdIdx(CFAccAuthorization Authorization, long TenantId) { final String S_ProcName = "CFAccPgSqlAccountConfigTable.readDerivedByIdIdx() "; CFAccAccountConfigBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByIdIdx(Authorization, TenantId); return (buff); } public CFAccAccountConfigBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff[] buffList = readBuffByTenantIdx(Authorization, TenantId); return (buffList); } public CFAccAccountConfigBuff[] readDerivedByDefCcyIdx(CFAccAuthorization Authorization, short DefaultCurrencyId) { final String S_ProcName = "readDerivedByDefCcyIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff[] buffList = readBuffByDefCcyIdx(Authorization, DefaultCurrencyId); return (buffList); } public CFAccAccountConfigBuff[] readDerivedByCustCtcLstIdx(CFAccAuthorization Authorization, Long CustContactListTenantId, Long CustContactListId) { final String S_ProcName = "readDerivedByCustCtcLstIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff[] buffList = readBuffByCustCtcLstIdx(Authorization, CustContactListTenantId, CustContactListId); return (buffList); } public CFAccAccountConfigBuff[] readDerivedByEmpCtcLstIdx(CFAccAuthorization Authorization, Long EmpContactListTenantId, Long EmpContactListId) { final String S_ProcName = "readDerivedByEmpCtcLstIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff[] buffList = readBuffByEmpCtcLstIdx(Authorization, EmpContactListTenantId, EmpContactListId); return (buffList); } public CFAccAccountConfigBuff[] readDerivedByVendCtcLstIdx(CFAccAuthorization Authorization, Long VendContactListTenantId, Long VendContactListId) { final String S_ProcName = "readDerivedByVendCtcLstIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } CFAccAccountConfigBuff[] buffList = readBuffByVendCtcLstIdx(Authorization, VendContactListTenantId, VendContactListId); return (buffList); } public CFAccAccountConfigBuff readBuff(CFAccAuthorization Authorization, CFAccAccountConfigPKey PKey) { final String S_ProcName = "readBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long TenantId = PKey.getRequiredTenantId(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByPKey == null) { stmtReadBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByPKey.setLong(argIdx++, TenantId); resultSet = stmtReadBuffByPKey.executeQuery(); if (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff lockBuff(CFAccAuthorization Authorization, CFAccAccountConfigPKey PKey) { final String S_ProcName = "lockBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long TenantId = PKey.getRequiredTenantId(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_lock_acct_cfg( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtLockBuffByPKey == null) { stmtLockBuffByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtLockBuffByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtLockBuffByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtLockBuffByPKey.setLong(argIdx++, TenantId); resultSet = stmtLockBuffByPKey.executeQuery(); if (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readAllBuff(CFAccAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_all( ?, ?, ?, ?, ? )"; if (stmtReadAllBuff == null) { stmtReadAllBuff = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadAllBuff.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadAllBuff.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); resultSet = stmtReadAllBuff.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff readBuffByIdIdx(CFAccAuthorization Authorization, long TenantId) { final String S_ProcName = "readBuffByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByIdIdx == null) { stmtReadBuffByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByIdIdx.setLong(argIdx++, TenantId); resultSet = stmtReadBuffByIdIdx.executeQuery(); if (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readBuffByTenantIdx(CFAccAuthorization Authorization, long TenantId) { final String S_ProcName = "readBuffByTenantIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByTenantIdx == null) { stmtReadBuffByTenantIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByTenantIdx.setLong(argIdx++, TenantId); resultSet = stmtReadBuffByTenantIdx.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readBuffByDefCcyIdx(CFAccAuthorization Authorization, short DefaultCurrencyId) { final String S_ProcName = "readBuffByDefCcyIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_defccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " )"; if (stmtReadBuffByDefCcyIdx == null) { stmtReadBuffByDefCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDefCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByDefCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtReadBuffByDefCcyIdx.setShort(argIdx++, DefaultCurrencyId); resultSet = stmtReadBuffByDefCcyIdx.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readBuffByCustCtcLstIdx(CFAccAuthorization Authorization, Long CustContactListTenantId, Long CustContactListId) { final String S_ProcName = "readBuffByCustCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_custctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByCustCtcLstIdx == null) { stmtReadBuffByCustCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCustCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByCustCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (CustContactListTenantId != null) { stmtReadBuffByCustCtcLstIdx.setLong(argIdx++, CustContactListTenantId.longValue()); } else { stmtReadBuffByCustCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (CustContactListId != null) { stmtReadBuffByCustCtcLstIdx.setLong(argIdx++, CustContactListId.longValue()); } else { stmtReadBuffByCustCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtReadBuffByCustCtcLstIdx.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readBuffByEmpCtcLstIdx(CFAccAuthorization Authorization, Long EmpContactListTenantId, Long EmpContactListId) { final String S_ProcName = "readBuffByEmpCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_empctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByEmpCtcLstIdx == null) { stmtReadBuffByEmpCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByEmpCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByEmpCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (EmpContactListTenantId != null) { stmtReadBuffByEmpCtcLstIdx.setLong(argIdx++, EmpContactListTenantId.longValue()); } else { stmtReadBuffByEmpCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (EmpContactListId != null) { stmtReadBuffByEmpCtcLstIdx.setLong(argIdx++, EmpContactListId.longValue()); } else { stmtReadBuffByEmpCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtReadBuffByEmpCtcLstIdx.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public CFAccAccountConfigBuff[] readBuffByVendCtcLstIdx(CFAccAuthorization Authorization, Long VendContactListTenantId, Long VendContactListId) { final String S_ProcName = "readBuffByVendCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT * FROM " + schema.getLowerSchemaDbName() + ".sp_read_acct_cfg_by_vendctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )"; if (stmtReadBuffByVendCtcLstIdx == null) { stmtReadBuffByVendCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtReadBuffByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByVendCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtReadBuffByVendCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtReadBuffByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtReadBuffByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (VendContactListTenantId != null) { stmtReadBuffByVendCtcLstIdx.setLong(argIdx++, VendContactListTenantId.longValue()); } else { stmtReadBuffByVendCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (VendContactListId != null) { stmtReadBuffByVendCtcLstIdx.setLong(argIdx++, VendContactListId.longValue()); } else { stmtReadBuffByVendCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtReadBuffByVendCtcLstIdx.executeQuery(); List<CFAccAccountConfigBuff> buffList = new LinkedList<CFAccAccountConfigBuff>(); while (resultSet.next()) { CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); buffList.add(buff); } int idx = 0; CFAccAccountConfigBuff[] retBuff = new CFAccAccountConfigBuff[buffList.size()]; Iterator<CFAccAccountConfigBuff> iter = buffList.iterator(); while (iter.hasNext()) { retBuff[idx++] = iter.next(); } return (retBuff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void updateAccountConfig(CFAccAuthorization Authorization, CFAccAccountConfigBuff Buff) { final String S_ProcName = "updateAccountConfig"; ResultSet resultSet = null; try { long TenantId = Buff.getRequiredTenantId(); short DefaultCurrencyId = Buff.getRequiredDefaultCurrencyId(); Long CustContactListTenantId = Buff.getOptionalCustContactListTenantId(); Long CustContactListId = Buff.getOptionalCustContactListId(); Long EmpContactListTenantId = Buff.getOptionalEmpContactListTenantId(); Long EmpContactListId = Buff.getOptionalEmpContactListId(); Long VendContactListTenantId = Buff.getOptionalVendContactListTenantId(); Long VendContactListId = Buff.getOptionalVendContactListId(); int Revision = Buff.getRequiredRevision(); Connection cnx = schema.getCnx(); String sql = "select * from " + schema.getLowerSchemaDbName() + ".sp_update_acct_cfg( ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + ", " + "?" + " )"; if (stmtUpdateByPKey == null) { stmtUpdateByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtUpdateByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtUpdateByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtUpdateByPKey.setString(argIdx++, "ACFG"); stmtUpdateByPKey.setLong(argIdx++, TenantId); stmtUpdateByPKey.setShort(argIdx++, DefaultCurrencyId); if (CustContactListTenantId != null) { stmtUpdateByPKey.setLong(argIdx++, CustContactListTenantId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (CustContactListId != null) { stmtUpdateByPKey.setLong(argIdx++, CustContactListId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (EmpContactListTenantId != null) { stmtUpdateByPKey.setLong(argIdx++, EmpContactListTenantId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (EmpContactListId != null) { stmtUpdateByPKey.setLong(argIdx++, EmpContactListId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (VendContactListTenantId != null) { stmtUpdateByPKey.setLong(argIdx++, VendContactListTenantId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } if (VendContactListId != null) { stmtUpdateByPKey.setLong(argIdx++, VendContactListId.longValue()); } else { stmtUpdateByPKey.setNull(argIdx++, java.sql.Types.BIGINT); } stmtUpdateByPKey.setInt(argIdx++, Revision); resultSet = stmtUpdateByPKey.executeQuery(); if (resultSet.next()) { CFAccAccountConfigBuff updatedBuff = unpackAccountConfigResultSetToBuff(resultSet); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } Buff.setRequiredDefaultCurrencyId(updatedBuff.getRequiredDefaultCurrencyId()); Buff.setOptionalCustContactListTenantId(updatedBuff.getOptionalCustContactListTenantId()); Buff.setOptionalCustContactListId(updatedBuff.getOptionalCustContactListId()); Buff.setOptionalEmpContactListTenantId(updatedBuff.getOptionalEmpContactListTenantId()); Buff.setOptionalEmpContactListId(updatedBuff.getOptionalEmpContactListId()); Buff.setOptionalVendContactListTenantId(updatedBuff.getOptionalVendContactListTenantId()); Buff.setOptionalVendContactListId(updatedBuff.getOptionalVendContactListId()); Buff.setRequiredRevision(updatedBuff.getRequiredRevision()); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected a single-record response, " + resultSet.getRow() + " rows selected"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfig(CFAccAuthorization Authorization, CFAccAccountConfigBuff Buff) { final String S_ProcName = "deleteAccountConfig"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); long TenantId = Buff.getRequiredTenantId(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByPKey == null) { stmtDeleteByPKey = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByPKey.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByPKey.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByPKey.setLong(argIdx++, TenantId); stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision()); ; resultSet = stmtDeleteByPKey.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByIdIdx(CFAccAuthorization Authorization, long argTenantId) { final String S_ProcName = "deleteAccountConfigByIdIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_ididx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByIdIdx == null) { stmtDeleteByIdIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByIdIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByIdIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByIdIdx.setLong(argIdx++, argTenantId); resultSet = stmtDeleteByIdIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByIdIdx(CFAccAuthorization Authorization, CFAccAccountConfigPKey argKey) { deleteAccountConfigByIdIdx(Authorization, argKey.getRequiredTenantId()); } public void deleteAccountConfigByTenantIdx(CFAccAuthorization Authorization, long argTenantId) { final String S_ProcName = "deleteAccountConfigByTenantIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_tenantidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByTenantIdx == null) { stmtDeleteByTenantIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByTenantIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByTenantIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByTenantIdx.setLong(argIdx++, argTenantId); resultSet = stmtDeleteByTenantIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByTenantIdx(CFAccAuthorization Authorization, CFAccAccountConfigByTenantIdxKey argKey) { deleteAccountConfigByTenantIdx(Authorization, argKey.getRequiredTenantId()); } public void deleteAccountConfigByDefCcyIdx(CFAccAuthorization Authorization, short argDefaultCurrencyId) { final String S_ProcName = "deleteAccountConfigByDefCcyIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_defccyidx( ?, ?, ?, ?, ?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByDefCcyIdx == null) { stmtDeleteByDefCcyIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDefCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByDefCcyIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByDefCcyIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); stmtDeleteByDefCcyIdx.setShort(argIdx++, argDefaultCurrencyId); resultSet = stmtDeleteByDefCcyIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByDefCcyIdx(CFAccAuthorization Authorization, CFAccAccountConfigByDefCcyIdxKey argKey) { deleteAccountConfigByDefCcyIdx(Authorization, argKey.getRequiredDefaultCurrencyId()); } public void deleteAccountConfigByCustCtcLstIdx(CFAccAuthorization Authorization, Long argCustContactListTenantId, Long argCustContactListId) { final String S_ProcName = "deleteAccountConfigByCustCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_custctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByCustCtcLstIdx == null) { stmtDeleteByCustCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCustCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByCustCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByCustCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argCustContactListTenantId != null) { stmtDeleteByCustCtcLstIdx.setLong(argIdx++, argCustContactListTenantId.longValue()); } else { stmtDeleteByCustCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (argCustContactListId != null) { stmtDeleteByCustCtcLstIdx.setLong(argIdx++, argCustContactListId.longValue()); } else { stmtDeleteByCustCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtDeleteByCustCtcLstIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByCustCtcLstIdx(CFAccAuthorization Authorization, CFAccAccountConfigByCustCtcLstIdxKey argKey) { deleteAccountConfigByCustCtcLstIdx(Authorization, argKey.getOptionalCustContactListTenantId(), argKey.getOptionalCustContactListId()); } public void deleteAccountConfigByEmpCtcLstIdx(CFAccAuthorization Authorization, Long argEmpContactListTenantId, Long argEmpContactListId) { final String S_ProcName = "deleteAccountConfigByEmpCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_empctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByEmpCtcLstIdx == null) { stmtDeleteByEmpCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByEmpCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByEmpCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByEmpCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argEmpContactListTenantId != null) { stmtDeleteByEmpCtcLstIdx.setLong(argIdx++, argEmpContactListTenantId.longValue()); } else { stmtDeleteByEmpCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (argEmpContactListId != null) { stmtDeleteByEmpCtcLstIdx.setLong(argIdx++, argEmpContactListId.longValue()); } else { stmtDeleteByEmpCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtDeleteByEmpCtcLstIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByEmpCtcLstIdx(CFAccAuthorization Authorization, CFAccAccountConfigByEmpCtcLstIdxKey argKey) { deleteAccountConfigByEmpCtcLstIdx(Authorization, argKey.getOptionalEmpContactListTenantId(), argKey.getOptionalEmpContactListId()); } public void deleteAccountConfigByVendCtcLstIdx(CFAccAuthorization Authorization, Long argVendContactListTenantId, Long argVendContactListId) { final String S_ProcName = "deleteAccountConfigByVendCtcLstIdx"; ResultSet resultSet = null; try { Connection cnx = schema.getCnx(); String sql = "SELECT " + schema.getLowerSchemaDbName() + ".sp_delete_acct_cfg_by_vendctclstidx( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " ) as DeletedFlag"; if (stmtDeleteByVendCtcLstIdx == null) { stmtDeleteByVendCtcLstIdx = cnx.prepareStatement(sql); } int argIdx = 1; stmtDeleteByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByVendCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString()); stmtDeleteByVendCtcLstIdx.setString(argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString()); stmtDeleteByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId()); stmtDeleteByVendCtcLstIdx.setLong(argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId()); if (argVendContactListTenantId != null) { stmtDeleteByVendCtcLstIdx.setLong(argIdx++, argVendContactListTenantId.longValue()); } else { stmtDeleteByVendCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } if (argVendContactListId != null) { stmtDeleteByVendCtcLstIdx.setLong(argIdx++, argVendContactListId.longValue()); } else { stmtDeleteByVendCtcLstIdx.setNull(argIdx++, java.sql.Types.BIGINT); } resultSet = stmtDeleteByVendCtcLstIdx.executeQuery(); if (resultSet.next()) { boolean deleteFlag = resultSet.getBoolean(1); if (resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response"); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 record result set to be returned by delete, not 0 rows"); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } finally { if (resultSet != null) { try { resultSet.close(); } catch (SQLException e) { } resultSet = null; } } } public void deleteAccountConfigByVendCtcLstIdx(CFAccAuthorization Authorization, CFAccAccountConfigByVendCtcLstIdxKey argKey) { deleteAccountConfigByVendCtcLstIdx(Authorization, argKey.getOptionalVendContactListTenantId(), argKey.getOptionalVendContactListId()); } public CFAccCursor openAccountConfigCursorAll(CFAccAuthorization Authorization) { String sql = getSqlSelectAccountConfigBuff() + ((schema.isSystemUser(Authorization)) ? "" : (" WHERE acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public CFAccCursor openAccountConfigCursorByTenantIdx(CFAccAuthorization Authorization, long TenantId) { String sql = getSqlSelectAccountConfigBuff() + "WHERE " + "acfg.TenantId = " + Long.toString(TenantId) + " " + ((schema.isSystemUser(Authorization)) ? "" : (" AND acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public CFAccCursor openAccountConfigCursorByDefCcyIdx(CFAccAuthorization Authorization, short DefaultCurrencyId) { String sql = getSqlSelectAccountConfigBuff() + "WHERE " + "acfg.DefCcyId = " + Short.toString(DefaultCurrencyId) + " " + ((schema.isSystemUser(Authorization)) ? "" : (" AND acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public CFAccCursor openAccountConfigCursorByCustCtcLstIdx(CFAccAuthorization Authorization, Long CustContactListTenantId, Long CustContactListId) { String sql = getSqlSelectAccountConfigBuff() + "WHERE " + ((CustContactListTenantId == null) ? "acfg.CstCtcLstTntId is null " : "acfg.CstCtcLstTntId = " + CustContactListTenantId.toString() + " ") + "AND " + ((CustContactListId == null) ? "acfg.CstCtcLstId is null " : "acfg.CstCtcLstId = " + CustContactListId.toString() + " ") + ((schema.isSystemUser(Authorization)) ? "" : (" AND acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public CFAccCursor openAccountConfigCursorByEmpCtcLstIdx(CFAccAuthorization Authorization, Long EmpContactListTenantId, Long EmpContactListId) { String sql = getSqlSelectAccountConfigBuff() + "WHERE " + ((EmpContactListTenantId == null) ? "acfg.EmpCtcLstTntId is null " : "acfg.EmpCtcLstTntId = " + EmpContactListTenantId.toString() + " ") + "AND " + ((EmpContactListId == null) ? "acfg.EmpCtcLstId is null " : "acfg.EmpCtcLstId = " + EmpContactListId.toString() + " ") + ((schema.isSystemUser(Authorization)) ? "" : (" AND acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public CFAccCursor openAccountConfigCursorByVendCtcLstIdx(CFAccAuthorization Authorization, Long VendContactListTenantId, Long VendContactListId) { String sql = getSqlSelectAccountConfigBuff() + "WHERE " + ((VendContactListTenantId == null) ? "acfg.VendCtcLstTntId is null " : "acfg.VendCtcLstTntId = " + VendContactListTenantId.toString() + " ") + "AND " + ((VendContactListId == null) ? "acfg.VendCtcLstId is null " : "acfg.VendCtcLstId = " + VendContactListId.toString() + " ") + ((schema.isSystemUser(Authorization)) ? "" : (" AND acfg.TenantId = " + Authorization.getSecTenantId())) + "ORDER BY " + "acfg.TenantId ASC"; CFAccCursor cursor = new CFAccPgSqlCursor(Authorization, schema, sql); return (cursor); } public void closeAccountConfigCursor(CFAccCursor Cursor) { try { Cursor.getResultSet().close(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeAccountConfigCursor", e); } } public CFAccAccountConfigBuff nextAccountConfigCursor(CFAccCursor Cursor) { final String S_ProcName = "nextAccountConfigCursor"; try { ResultSet resultSet = Cursor.getResultSet(); if (!resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "No more results available"); } CFAccAccountConfigBuff buff = unpackAccountConfigResultSetToBuff(resultSet); return (buff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public CFAccAccountConfigBuff prevAccountConfigCursor(CFAccCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; CFAccAccountConfigBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextAccountConfigCursor(Cursor); } return (buff); } public CFAccAccountConfigBuff firstAccountConfigCursor(CFAccCursor Cursor) { int targetRowIdx = 1; CFAccAccountConfigBuff buff = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { buff = nextAccountConfigCursor(Cursor); } return (buff); } public CFAccAccountConfigBuff lastAccountConfigCursor(CFAccCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastAccountConfigCursor"); } public CFAccAccountConfigBuff nthAccountConfigCursor(CFAccCursor Cursor, int Idx) { int targetRowIdx = Idx; CFAccAccountConfigBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextAccountConfigCursor(Cursor); } return (buff); } /** * Release the prepared statements. * <p> * When the schema changes connections, the prepared statements * have to be released because they contain connection-specific * information for most databases. */ public void releasePreparedStatements() { final String S_ProcName = "releasePreparedStatements"; S_sqlSelectAccountConfigDistinctClassCode = null; S_sqlSelectAccountConfigBuff = null; if (stmtReadBuffByPKey != null) { try { stmtReadBuffByPKey.close(); } catch (SQLException e) { } stmtReadBuffByPKey = null; } if (stmtReadBuffAll != null) { try { stmtReadBuffAll.close(); } catch (SQLException e) { } stmtReadBuffAll = null; } if (stmtLockBuffByPKey != null) { try { stmtLockBuffByPKey.close(); } catch (SQLException e) { } stmtLockBuffByPKey = null; } if (stmtCreateByPKey != null) { try { stmtCreateByPKey.close(); } catch (SQLException e) { } stmtCreateByPKey = null; } if (stmtUpdateByPKey != null) { try { stmtUpdateByPKey.close(); } catch (SQLException e) { } stmtUpdateByPKey = null; } if (stmtDeleteByPKey != null) { try { stmtDeleteByPKey.close(); } catch (SQLException e) { } stmtDeleteByPKey = null; } if (stmtDeleteByIdIdx != null) { try { stmtDeleteByIdIdx.close(); } catch (SQLException e) { } stmtDeleteByIdIdx = null; } if (stmtDeleteByTenantIdx != null) { try { stmtDeleteByTenantIdx.close(); } catch (SQLException e) { } stmtDeleteByTenantIdx = null; } if (stmtDeleteByDefCcyIdx != null) { try { stmtDeleteByDefCcyIdx.close(); } catch (SQLException e) { } stmtDeleteByDefCcyIdx = null; } if (stmtDeleteByCustCtcLstIdx != null) { try { stmtDeleteByCustCtcLstIdx.close(); } catch (SQLException e) { } stmtDeleteByCustCtcLstIdx = null; } if (stmtDeleteByEmpCtcLstIdx != null) { try { stmtDeleteByEmpCtcLstIdx.close(); } catch (SQLException e) { } stmtDeleteByEmpCtcLstIdx = null; } if (stmtDeleteByVendCtcLstIdx != null) { try { stmtDeleteByVendCtcLstIdx.close(); } catch (SQLException e) { } stmtDeleteByVendCtcLstIdx = null; } if (stmtReadAllBuff != null) { try { stmtReadAllBuff.close(); } catch (SQLException e) { } stmtReadAllBuff = null; } if (stmtReadBuffByIdIdx != null) { try { stmtReadBuffByIdIdx.close(); } catch (SQLException e) { } stmtReadBuffByIdIdx = null; } if (stmtReadBuffByTenantIdx != null) { try { stmtReadBuffByTenantIdx.close(); } catch (SQLException e) { } stmtReadBuffByTenantIdx = null; } if (stmtReadBuffByDefCcyIdx != null) { try { stmtReadBuffByDefCcyIdx.close(); } catch (SQLException e) { } stmtReadBuffByDefCcyIdx = null; } if (stmtReadBuffByCustCtcLstIdx != null) { try { stmtReadBuffByCustCtcLstIdx.close(); } catch (SQLException e) { } stmtReadBuffByCustCtcLstIdx = null; } if (stmtReadBuffByEmpCtcLstIdx != null) { try { stmtReadBuffByEmpCtcLstIdx.close(); } catch (SQLException e) { } stmtReadBuffByEmpCtcLstIdx = null; } if (stmtReadBuffByVendCtcLstIdx != null) { try { stmtReadBuffByVendCtcLstIdx.close(); } catch (SQLException e) { } stmtReadBuffByVendCtcLstIdx = null; } } }