Java tutorial
// Description: Java 6 PostgreSQL Jdbc DbIO implementation for SchemaDouble. /* * MSS Code Factory 1.10 * * Copyright (c) 2012 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/>. * * *********************************************************************** * * Code manufactured * by MSS Code Factory version 1.9.3294 * * $Revision: 26 $ */ package net.sourceforge.msscodefactory.v1_10.MSSBamPg8; import java.math.*; import java.sql.*; import java.text.*; import java.util.*; import net.sourceforge.msscodefactory.cflib.v1_9.CFLib.*; import org.apache.commons.codec.binary.Base64; import net.sourceforge.msscodefactory.v1_10.MSSBam.*; /* * MSSBamPg8SchemaDoubleTable PostgreSQL Jdbc DbIO implementation * for SchemaDouble. * * Data redaction is the responsibility of another layer. The raw database * interface returns everything regardless of whether the end user is * authorized to see the data. A redaction layer replaces protected/redacted * buffs with default values. They should not be included in client-side * filter sets, and the network redaction layer should actually eliminate them * before transmitting data to the client. The client should never see * redacted data in order to comply with data privacy regulations in Canada * and the US. */ public class MSSBamPg8SchemaDoubleTable implements IMSSBamSchemaDoubleTable { private MSSBamPg8Schema schema; public MSSBamPg8SchemaDoubleTable(MSSBamPg8Schema argSchema) { schema = argSchema; } public void createSchemaDouble(MSSBamAuthorization Authorization, MSSBamSchemaDoubleBuff Buff) { final String S_ProcName = "createSchemaDouble "; try { Connection cnx = schema.getCnx(); long Id = Buff.getRequiredId(); long ContainerId = Buff.getRequiredContainerId(); String sql = "INSERT INTO mssbam110.schema_double( " + "id, " + "containerid" + " )" + "VALUES ( " + Id + ", " + ContainerId + " )"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); int rowsAffected = stmt.executeUpdate(sql); if (rowsAffected != 1) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 row to be affected by insert, not " + rowsAffected); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public final static String S_sqlSelectSchemaDoubleDistinctClassCode = "SELECT " + "DISTINCT anyo.ClassCode " + "FROM mssbam110.any_obj AS anyo " + "INNER JOIN mssbam110.scope scp ON " + "scp.Id = anyo.Id " + "INNER JOIN mssbam110.valuedef val ON " + "val.Id = anyo.Id " + "INNER JOIN mssbam110.atom_def atm ON " + "atm.Id = anyo.Id " + "INNER JOIN mssbam110.double_def dbl ON " + "dbl.Id = anyo.Id " + "INNER JOIN mssbam110.schema_double sdbl ON " + "sdbl.Id = anyo.Id "; public final static String S_sqlSelectSchemaDoubleBuff = "SELECT " + "anyo.ClassCode, " + "anyo.Id, " + "anyo.TenantId, " + "anyo.ScopeId, " + "anyo.Name, " + "anyo.short_name, " + "anyo.Label, " + "anyo.short_descr, " + "anyo.descr, " + "anyo.AuthorId, " + "val.ValueContainerId, " + "val.IsNullable, " + "val.GenerateId, " + "val.DataScopeId, " + "val.ViewAccessSecurityId, " + "val.EditAccessSecurityId, " + "val.ViewAccessFrequencyId, " + "val.EditAccessFrequencyId, " + "val.PrevId, " + "val.NextId, " + "atm.DbName, " + "dbl.InitVal, " + "dbl.DefVal, " + "dbl.MinVal, " + "dbl.MaxVal, " + "dbl.NullValue, " + "dbl.UnknownVal, " + "sdbl.ContainerId, " + "anyo.Revision " + "FROM mssbam110.any_obj AS anyo " + "INNER JOIN mssbam110.scope scp ON " + "scp.Id = anyo.Id " + "INNER JOIN mssbam110.valuedef val ON " + "val.Id = anyo.Id " + "INNER JOIN mssbam110.atom_def atm ON " + "atm.Id = anyo.Id " + "INNER JOIN mssbam110.double_def dbl ON " + "dbl.Id = anyo.Id " + "INNER JOIN mssbam110.schema_double sdbl ON " + "sdbl.Id = anyo.Id "; protected MSSBamSchemaDoubleBuff unpackSchemaDoubleResultSetToBuff(ResultSet resultSet) throws SQLException { final String S_ProcName = "unpackSchemaDoubleResultSetToBuff"; int idxcol = 1; String classCode = resultSet.getString(idxcol); idxcol++; MSSBamSchemaDoubleBuff buff; if (classCode.equals("SDBL")) { buff = schema.getFactorySchemaDouble().newBuff(); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Unrecognized class code \"" + classCode + "\""); } buff.setRequiredId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredTenantId(resultSet.getLong(idxcol)); idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalScopeId(null); } else { buff.setOptionalScopeId(colVal); } } idxcol++; buff.setRequiredName(resultSet.getString(idxcol)); idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalShortName(null); } else { buff.setOptionalShortName(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalLabel(null); } else { buff.setOptionalLabel(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalShortDescription(null); } else { buff.setOptionalShortDescription(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalDescription(null); } else { buff.setOptionalDescription(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalAuthorId(null); } else { buff.setOptionalAuthorId(colVal); } } idxcol++; buff.setRequiredValueContainerId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredIsNullable(resultSet.getBoolean(idxcol)); idxcol++; { boolean colVal = resultSet.getBoolean(idxcol); if (resultSet.wasNull()) { buff.setOptionalGenerateId(null); } else { buff.setOptionalGenerateId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalDataScopeId(null); } else { buff.setOptionalDataScopeId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalViewAccessSecurityId(null); } else { buff.setOptionalViewAccessSecurityId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalEditAccessSecurityId(null); } else { buff.setOptionalEditAccessSecurityId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalViewAccessFrequencyId(null); } else { buff.setOptionalViewAccessFrequencyId(colVal); } } idxcol++; { short colVal = resultSet.getShort(idxcol); if (resultSet.wasNull()) { buff.setOptionalEditAccessFrequencyId(null); } else { buff.setOptionalEditAccessFrequencyId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalPrevId(null); } else { buff.setOptionalPrevId(colVal); } } idxcol++; { long colVal = resultSet.getLong(idxcol); if (resultSet.wasNull()) { buff.setOptionalNextId(null); } else { buff.setOptionalNextId(colVal); } } idxcol++; { String colVal = resultSet.getString(idxcol); if (resultSet.wasNull()) { buff.setOptionalDbName(null); } else { buff.setOptionalDbName(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalInitValue(null); } else { buff.setOptionalInitValue(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalDefaultValue(null); } else { buff.setOptionalDefaultValue(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalMinValue(null); } else { buff.setOptionalMinValue(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalMaxValue(null); } else { buff.setOptionalMaxValue(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalNullValue(null); } else { buff.setOptionalNullValue(colVal); } } idxcol++; { double colVal = resultSet.getDouble(idxcol); if (resultSet.wasNull()) { buff.setOptionalUnknownValue(null); } else { buff.setOptionalUnknownValue(colVal); } } idxcol++; buff.setRequiredContainerId(resultSet.getLong(idxcol)); idxcol++; buff.setRequiredRevision(resultSet.getInt(idxcol)); return (buff); } public MSSBamSchemaDoubleBuff readDerived(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "readDerived()"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff buff; long Id = PKey.getRequiredId(); buff = readBuff(Authorization, PKey); return (buff); } public MSSBamSchemaDoubleBuff[] readAllDerived(MSSBamAuthorization Authorization) { final String S_ProcName = "readAllDerived"; MSSBamSchemaDoubleBuff[] buffArray; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buffArray = readAllBuff(Authorization); return (buffArray); } public MSSBamSchemaDoubleBuff readDerivedByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "MSSBamPg8SchemaDoubleTable.readDerivedByIdIdx() "; MSSBamSchemaDoubleBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByIdIdx(Authorization, Id); return (buff); } public MSSBamSchemaDoubleBuff[] readDerivedByTenantIdx(MSSBamAuthorization Authorization, long TenantId) { final String S_ProcName = "readDerivedByTenantIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByTenantIdx(Authorization, TenantId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) { final String S_ProcName = "readDerivedByScopeIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByScopeIdx(Authorization, ScopeId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "readDerivedByAuthorIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByAuthorIdx(Authorization, AuthorId); return (buffList); } public MSSBamSchemaDoubleBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamPg8SchemaDoubleTable.readDerivedByUNameIdx() "; MSSBamSchemaDoubleBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } buff = readBuffByUNameIdx(Authorization, ScopeId, Name); return (buff); } public MSSBamSchemaDoubleBuff[] readDerivedByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) { final String S_ProcName = "readDerivedByVContIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByVContIdx(Authorization, ValueContainerId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { final String S_ProcName = "readDerivedByDataScopeIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByDataScopeIdx(Authorization, DataScopeId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) { final String S_ProcName = "readDerivedByVAccSecIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) { final String S_ProcName = "readDerivedByVAccFreqIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) { final String S_ProcName = "readDerivedByEAccSecIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByEAccSecIdx(Authorization, EditAccessSecurityId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) { final String S_ProcName = "readDerivedByEAccFreqIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) { final String S_ProcName = "readDerivedByPrevIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByPrevIdx(Authorization, PrevId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByNextIdx(MSSBamAuthorization Authorization, Long NextId) { final String S_ProcName = "readDerivedByNextIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByNextIdx(Authorization, NextId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByContPrevIdx(MSSBamAuthorization Authorization, long ValueContainerId, Long PrevId) { final String S_ProcName = "readDerivedByContPrevIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByContPrevIdx(Authorization, ValueContainerId, PrevId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByContNextIdx(MSSBamAuthorization Authorization, long ValueContainerId, Long NextId) { final String S_ProcName = "readDerivedByContNextIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByContNextIdx(Authorization, ValueContainerId, NextId); return (buffList); } public MSSBamSchemaDoubleBuff[] readDerivedByContainerIdx(MSSBamAuthorization Authorization, long ContainerId) { final String S_ProcName = "readDerivedByContainerIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } MSSBamSchemaDoubleBuff[] buffList = readBuffByContainerIdx(Authorization, ContainerId); return (buffList); } public MSSBamSchemaDoubleBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "readBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "anyo.Id = " + Long.toString(Id) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readAllBuff(MSSBamAuthorization Authorization) { final String S_ProcName = "readAllBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "anyo.ClassCode = 'SDBL' " + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff readBuffByIdIdx(MSSBamAuthorization Authorization, long Id) { final String S_ProcName = "readBuffByIdIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "anyo.Id = " + Long.toString(Id) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByTenantIdx(MSSBamAuthorization Authorization, long TenantId) { final String S_ProcName = "readBuffByTenantIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "anyo.TenantId = " + Long.toString(TenantId) + " " + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByScopeIdx(MSSBamAuthorization Authorization, Long ScopeId) { final String S_ProcName = "readBuffByScopeIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "readBuffByAuthorIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((AuthorId == null) ? "anyo.AuthorId is null " : "anyo.AuthorId = " + AuthorId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff readBuffByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "readBuffByUNameIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) { final String S_ProcName = "readBuffByVContIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " " + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { final String S_ProcName = "readBuffByDataScopeIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((DataScopeId == null) ? "val.DataScopeId is null " : "val.DataScopeId = " + DataScopeId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByVAccSecIdx(MSSBamAuthorization Authorization, Short ViewAccessSecurityId) { final String S_ProcName = "readBuffByVAccSecIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((ViewAccessSecurityId == null) ? "val.ViewAccessSecurityId is null " : "val.ViewAccessSecurityId = " + ViewAccessSecurityId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByVAccFreqIdx(MSSBamAuthorization Authorization, Short ViewAccessFrequencyId) { final String S_ProcName = "readBuffByVAccFreqIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((ViewAccessFrequencyId == null) ? "val.ViewAccessFrequencyId is null " : "val.ViewAccessFrequencyId = " + ViewAccessFrequencyId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByEAccSecIdx(MSSBamAuthorization Authorization, Short EditAccessSecurityId) { final String S_ProcName = "readBuffByEAccSecIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((EditAccessSecurityId == null) ? "val.EditAccessSecurityId is null " : "val.EditAccessSecurityId = " + EditAccessSecurityId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByEAccFreqIdx(MSSBamAuthorization Authorization, Short EditAccessFrequencyId) { final String S_ProcName = "readBuffByEAccFreqIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((EditAccessFrequencyId == null) ? "val.EditAccessFrequencyId is null " : "val.EditAccessFrequencyId = " + EditAccessFrequencyId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByPrevIdx(MSSBamAuthorization Authorization, Long PrevId) { final String S_ProcName = "readBuffByPrevIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((PrevId == null) ? "val.PrevId is null " : "val.PrevId = " + PrevId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByNextIdx(MSSBamAuthorization Authorization, Long NextId) { final String S_ProcName = "readBuffByNextIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + ((NextId == null) ? "val.NextId is null " : "val.NextId = " + NextId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByContPrevIdx(MSSBamAuthorization Authorization, long ValueContainerId, Long PrevId) { final String S_ProcName = "readBuffByContPrevIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " " + "AND " + ((PrevId == null) ? "val.PrevId is null " : "val.PrevId = " + PrevId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByContNextIdx(MSSBamAuthorization Authorization, long ValueContainerId, Long NextId) { final String S_ProcName = "readBuffByContNextIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " " + "AND " + ((NextId == null) ? "val.NextId is null " : "val.NextId = " + NextId.toString() + " ") + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff[] readBuffByContainerIdx(MSSBamAuthorization Authorization, long ContainerId) { final String S_ProcName = "readBuffByContainerIdx"; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectSchemaDoubleBuff + "WHERE " + "sdbl.ContainerId = " + Long.toString(ContainerId) + " " + "ORDER BY " + "anyo.Id ASC"; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); List<MSSBamSchemaDoubleBuff> buffList = new ArrayList<MSSBamSchemaDoubleBuff>(); while (resultSet.next()) { MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); buffList.add(buff); } return (buffList.toArray(new MSSBamSchemaDoubleBuff[0])); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public void updateSchemaDouble(MSSBamAuthorization Authorization, MSSBamSchemaDoubleBuff Buff) { final String S_ProcName = "updateSchemaDouble"; try { Connection cnx = schema.getCnx(); long Id = Buff.getRequiredId(); long ContainerId = Buff.getRequiredContainerId(); String sql = "UPDATE mssbam110.schema_double " + "SET " + "Id = " + MSSBamPg8Schema.getInt64String(Id) + ", " + "ContainerId = " + MSSBamPg8Schema.getInt64String(ContainerId) + " " + "WHERE " + "Id = " + Long.toString(Id) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); int rowsAffected = stmt.executeUpdate(sql); if (rowsAffected != 1) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 row to be affected by update, not " + rowsAffected); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public void deleteSchemaDouble(MSSBamAuthorization Authorization, MSSBamSchemaDoubleBuff Buff) { final String S_ProcName = "deleteSchemaDouble"; try { Connection cnx = schema.getCnx(); long Id = Buff.getRequiredId(); long ContainerId = Buff.getRequiredContainerId(); String sql = "DELETE FROM mssbam110.schema_double " + "WHERE " + "Id = " + Long.toString(Id) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); int rowsAffected = stmt.executeUpdate(sql); if (rowsAffected != 1) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Expected 1 row to be affected by delete, not " + rowsAffected); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamCursor openSchemaDoubleCursorAll(MSSBamAuthorization Authorization) { String sql = "SELECT " + "anyo.ClassCode, " + "sdbl.Id, " + "sdbl.ContainerId, " + "sdbl.Revision " + "FROM mssbam110.schema_double AS sdbl " + "INNER JOIN mssbam110.any_obj anyo ON " + "sdbl.Id = anyo.Id " + "ORDER BY " + "anyo.Id ASC"; MSSBamCursor cursor = new MSSBamPg8Cursor(Authorization, schema, sql); return (cursor); } public MSSBamCursor openSchemaDoubleCursorByContainerIdx(MSSBamAuthorization Authorization, long ContainerId) { String sql = "SELECT " + "anyo.ClassCode, " + "sdbl.Id, " + "sdbl.ContainerId, " + "sdbl.Revision " + "FROM mssbam110.schema_double AS sdbl " + "INNER JOIN mssbam110.any_obj anyo ON " + "sdbl.Id = anyo.Id " + "WHERE " + "sdbl.ContainerId = " + Long.toString(ContainerId) + " " + "ORDER BY " + "sdbl.Id ASC"; MSSBamCursor cursor = new MSSBamPg8Cursor(Authorization, schema, sql); return (cursor); } public void closeSchemaDoubleCursor(MSSBamCursor Cursor) { try { Cursor.getResultSet().close(); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), "closeSchemaDoubleCursor", e); } } public MSSBamSchemaDoubleBuff nextSchemaDoubleCursor(MSSBamCursor Cursor) { final String S_ProcName = "nextSchemaDoubleCursor"; try { ResultSet resultSet = Cursor.getResultSet(); if (!resultSet.next()) { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "No more results available"); } MSSBamSchemaDoubleBuff buff = unpackSchemaDoubleResultSetToBuff(resultSet); return (buff); } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } } public MSSBamSchemaDoubleBuff prevSchemaDoubleCursor(MSSBamCursor Cursor) { int targetRowIdx = (Cursor.getRowIdx() > 1) ? Cursor.getRowIdx() - 1 : 1; MSSBamSchemaDoubleBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSchemaDoubleCursor(Cursor); } return (buff); } public MSSBamSchemaDoubleBuff firstSchemaDoubleCursor(MSSBamCursor Cursor) { int targetRowIdx = 1; MSSBamSchemaDoubleBuff buff = null; Cursor.reset(); while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSchemaDoubleCursor(Cursor); } return (buff); } public MSSBamSchemaDoubleBuff lastSchemaDoubleCursor(MSSBamCursor Cursor) { throw CFLib.getDefaultExceptionFactory().newNotImplementedYetException(getClass(), "lastSchemaDoubleCursor"); } public MSSBamSchemaDoubleBuff nthSchemaDoubleCursor(MSSBamCursor Cursor, int Idx) { int targetRowIdx = Idx; MSSBamSchemaDoubleBuff buff = null; if (Cursor.getRowIdx() >= targetRowIdx) { Cursor.reset(); } while (Cursor.getRowIdx() < targetRowIdx) { buff = nextSchemaDoubleCursor(Cursor); } return (buff); } }