Example usage for java.sql ResultSet CONCUR_READ_ONLY

List of usage examples for java.sql ResultSet CONCUR_READ_ONLY

Introduction

In this page you can find the example usage for java.sql ResultSet CONCUR_READ_ONLY.

Prototype

int CONCUR_READ_ONLY

To view the source code for java.sql ResultSet CONCUR_READ_ONLY.

Click Source Link

Document

The constant indicating the concurrency mode for a ResultSet object that may NOT be updated.

Usage

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java

public MSSBamAtomDefBuff[] readDerivedByVAccSecIdx(MSSBamAuthorization Authorization,
        Short ViewAccessSecurityId) {
    final String S_ProcName = "readDerivedByVAccSecIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }// w  w w  .  j a  v  a 2  s  .c  o  m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    try {
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE "
                + ((ViewAccessSecurityId == null) ? "val.ViewAccessSecurityId is null "
                        : "val.ViewAccessSecurityId = " + ViewAccessSecurityId.toString() + " ");
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
    ArrayList<MSSBamAtomDefBuff> resultList = new ArrayList<MSSBamAtomDefBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("ATM")) {
            MSSBamAtomDefBuff[] subList = readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLB")) {
            MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLB")) {
            MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLB")) {
            MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLN")) {
            MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLN")) {
            MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLN")) {
            MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DAT")) {
            MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDAT")) {
            MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDAT")) {
            MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DBL")) {
            MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDBL")) {
            MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDBL")) {
            MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NUM")) {
            MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNUM")) {
            MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNUM")) {
            MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("FLT")) {
            MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TFLT")) {
            MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SFLT")) {
            MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I16")) {
            MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI16")) {
            MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI16")) {
            MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ENM")) {
            MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TENM")) {
            MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SENM")) {
            MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G16")) {
            MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG16")) {
            MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG16")) {
            MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U16")) {
            MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU16")) {
            MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU16")) {
            MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I32")) {
            MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI32")) {
            MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI32")) {
            MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G32")) {
            MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG32")) {
            MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG32")) {
            MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U32")) {
            MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU32")) {
            MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU32")) {
            MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I64")) {
            MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI64")) {
            MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI64")) {
            MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G64")) {
            MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG64")) {
            MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG64")) {
            MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U64")) {
            MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU64")) {
            MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU64")) {
            MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("UUID")) {
            MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TUUI")) {
            MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SUUI")) {
            MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("IDGU")) {
            MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TGUU")) {
            MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SGUU")) {
            MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMT")) {
            MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTK")) {
            MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTK")) {
            MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMS")) {
            MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTS")) {
            MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTS")) {
            MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STR")) {
            MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSTR")) {
            MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SSTR")) {
            MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZDY")) {
            MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZDY")) {
            MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZDY")) {
            MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZTM")) {
            MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZTM")) {
            MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZTM")) {
            MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZSP")) {
            MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZST")) {
            MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZST")) {
            MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TXT")) {
            MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTXT")) {
            MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STXT")) {
            MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TIM")) {
            MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTIM")) {
            MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STIM")) {
            MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSP")) {
            MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTSM")) {
            MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STSM")) {
            MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp()
                    .readBuffByVAccSecIdx(Authorization, ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TKN")) {
            MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTOK")) {
            MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STOK")) {
            MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByVAccSecIdx(Authorization,
                    ViewAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    return (resultList.toArray(new MSSBamAtomDefBuff[0]));

}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Moves the cursor for this <code>CachedRowSetImpl</code> object
 * to the insert row.  The current row in the rowset is remembered
 * while the cursor is on the insert row.
 * <P>//from ww w.  ja  va2s.  c o  m
 * The insert row is a special row associated with an updatable
 * rowset.  It is essentially a buffer where a new row may
 * be constructed by calling the appropriate <code>updateXXX</code>
 * methods to assign a value to each column in the row.  A complete
 * row must be constructed; that is, every column that is not nullable
 * must be assigned a value.  In order for the new row to become part
 * of this rowset, the method <code>insertRow</code> must be called
 * before the cursor is moved back to the rowset.
 * <P>
 * Only certain methods may be invoked while the cursor is on the insert
 * row; many methods throw an exception if they are called while the
 * cursor is there.  In addition to the <code>updateXXX</code>
 * and <code>insertRow</code> methods, only the <code>getXXX</code> methods
 * may be called when the cursor is on the insert row.  A <code>getXXX</code>
 * method should be called on a column only after an <code>updateXXX</code>
 * method has been called on that column; otherwise, the value returned is
 * undetermined.
 *
 * @throws SQLException if this <code>CachedRowSetImpl</code> object is
 *            <code>ResultSet.CONCUR_READ_ONLY</code>
 */
public void moveToInsertRow() throws SQLException {
    if (getConcurrency() == ResultSet.CONCUR_READ_ONLY) {
        throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.movetoins").toString());
    }
    if (insertRow == null) {
        if (RowSetMD == null)
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.movetoins1").toString());
        int numCols = RowSetMD.getColumnCount();
        if (numCols > 0) {
            insertRow = new InsertRow(numCols);
        } else {
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.movetoins2").toString());
        }
    }
    onInsertRow = true;
    // %%% setCurrentRow called in BaseRow

    currentRow = cursorPos;
    cursorPos = -1;

    insertRow.initInsertRow();
}

From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * Converts all the Determinations.// ww w  .j  a  va 2s.  com
 * @return true if no errors
 */
public boolean convertDeterminationRecords() {
    TableWriter tblWriter = convLogger.getWriter("convertDeterminations.html", "Determinations");

    setIdentityInsertONCommandForSQLServer(newDBConn, "determination", BasicSQLUtils.myDestinationServerType);

    deleteAllRecordsFromTable(newDBConn, "determination", BasicSQLUtils.myDestinationServerType); // automatically closes the connection

    if (getNumRecords(oldDBConn, "determination") == 0) {
        return true;
    }

    TimeLogger timeLogger = new TimeLogger();

    String oldDetermination_Current = "Current";
    String oldDetermination_Date = "Date";

    /*if (BasicSQLUtils.mySourceServerType == BasicSQLUtils.SERVERTYPE.MySQL)
    {
    oldDetermination_Date     = "Date1";
    oldDetermination_Current = "IsCurrent";
    }*/

    Map<String, String> colNewToOldMap = createFieldNameMap(
            new String[] { "CollectionObjectID", "BiologicalObjectID", // meg is this right?
                    "IsCurrent", oldDetermination_Current, "DeterminedDate", oldDetermination_Date, // want to change  over to DateField TODO Meg!!!
                    "TaxonID", "TaxonNameID" });

    try {
        Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);

        List<String> oldFieldNames = new ArrayList<String>();

        StringBuilder sql = new StringBuilder("SELECT ");
        List<String> names = getFieldNamesFromSchema(oldDBConn, "determination");

        sql.append(buildSelectFieldList(names, "determination"));
        oldFieldNames.addAll(names);

        sql.append(
                ", cc.CatalogSeriesID AS CatSeriesID FROM determination Inner Join collectionobjectcatalog AS cc ON determination.BiologicalObjectID = cc.CollectionObjectCatalogID");

        log.info(sql);

        if (BasicSQLUtils.mySourceServerType == BasicSQLUtils.SERVERTYPE.MS_SQLServer) {
            log.debug("FIXING select statement to run against SQL Server.......");
            log.debug("old string: " + sql.toString());
            String currentSQL = sql.toString();
            currentSQL = currentSQL.replaceAll("Current", "[" + "Current" + "]");
            log.debug("new string: " + currentSQL);
            sql = new StringBuilder(currentSQL);

        }

        oldFieldNames.add("CatSeriesID");

        log.info(sql);
        List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, "determination");

        log.info("Number of Fields in New Determination " + newFieldMetaData.size());
        String sqlStr = sql.toString();

        Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>();
        int inx = 1;
        for (String name : oldFieldNames) {
            oldNameIndex.put(name, inx++);
        }

        String tableName = "determination";

        //int isCurrentInx = oldNameIndex.get(oldDetermination_Current) + 1;

        log.info(sqlStr);
        System.err.println(sqlStr);
        ResultSet rs = stmt.executeQuery(sqlStr);

        if (hasFrame) {
            if (rs.last()) {
                setProcess(0, rs.getRow());
                rs.first();

            } else {
                rs.close();
                stmt.close();
                return true;
            }
        } else {
            if (!rs.first()) {
                rs.close();
                stmt.close();
                return true;
            }
        }

        PartialDateConv partialDateConv = new PartialDateConv();

        IdMapperIFace detIdMapper = IdMapperMgr.getInstance().get("determination", "DeterminationID");
        IdMapperIFace colObjIdMapper = idMapperMgr.get("collectionobjectcatalog", "CollectionObjectCatalogID");
        IdMapperIFace colObjCatIdMapper = idMapperMgr.get("collectionobject", "CollectionObjectID");

        Integer catSeriesIdInx = oldNameIndex.get("CatSeriesID");
        Integer oldRecIDInx = oldNameIndex.get("DeterminationID");
        int lastEditedByInx = oldNameIndex.get("LastEditedBy");
        Integer detDateInx = oldNameIndex.get("Date");

        System.err.println("catSeriesIdInx: " + catSeriesIdInx);

        HashMap<String, Integer> nameToInxHash = new HashMap<String, Integer>();
        StringBuffer fieldList = new StringBuffer();
        StringBuilder insertQuesDB = new StringBuilder();
        for (int i = 0; i < newFieldMetaData.size(); i++) {
            if (i > 0) {
                fieldList.append(',');
                insertQuesDB.append(',');
            }

            String newFieldName = newFieldMetaData.get(i).getName();
            fieldList.append(newFieldName);
            insertQuesDB.append('?');
            nameToInxHash.put(newFieldName, (i + 1));
            System.out.println(newFieldName + " " + (i + 1));
        }

        String insertStmtStr = "INSERT INTO determination (" + fieldList + ") VALUES ("
                + insertQuesDB.toString() + ')';
        log.debug(insertStmtStr);
        PreparedStatement pStmt = newDBConn.prepareStatement(insertStmtStr);

        int count = 0;
        do {
            partialDateConv.nullAll();

            String lastEditedBy = rs.getString(lastEditedByInx);

            Integer catSeriesId = rs.getInt(catSeriesIdInx);
            if (catSeriesId != null && rs.wasNull()) {
                String msg = String.format(
                        "Error - The Determination had a null CatalogSeries DeterminationID %d; it's CollectionObjectID: %d",
                        rs.getInt(1), rs.getInt(6));
                log.error(msg);
                tblWriter.logError(msg);

                //if (rs.next())
                //{
                continue;
                //}
                //break;
            }

            Vector<Integer> collectionIdList = catSeriesToNewCollectionID.get(catSeriesId);
            if (collectionIdList == null) {
                //Integer colObjId = rs.getInt(idIndex);
                throw new RuntimeException("There are no Collections mapped to CatSeriesId[" + catSeriesId
                        + "] (converting Determinations)");
            }

            if (collectionIdList.size() > 1) {
                UIRegistry.showError(
                        "There are multiple Collections assigned to the same CatalogSeries and we can't handle that right now.");
            }

            Integer collectionId = collectionIdList.get(0);
            if (collectionId == null) {
                throw new RuntimeException("CollectionId is null when mapped from CatSeriesId");
            }

            this.curCollectionID = collectionId;

            boolean isError = false;

            for (int i = 0; i < newFieldMetaData.size(); i++) {

                String newFieldName = newFieldMetaData.get(i).getName();
                int fldInx = nameToInxHash.get(newFieldName);

                if (i == 0) {
                    Integer recId = rs.getInt(oldRecIDInx);
                    Integer newId = detIdMapper.get(recId);
                    if (newId != null) {
                        pStmt.setInt(fldInx, newId);

                    } else {
                        String msg = String.format("Error - Unable to map old id %d to new Id", recId);
                        log.error(msg);
                        tblWriter.logError(msg);
                        isError = true;
                        continue;
                    }

                } else if (newFieldName.equals("Version")) // User/Security changes
                {
                    pStmt.setInt(fldInx, 0);

                } else if (newFieldName.equals("DeterminedDate")) {
                    //System.out.println("["+rs.getObject(detDateInx)+"]");

                    if (partialDateConv.getDateStr() == null) {
                        getPartialDate(rs.getObject(detDateInx), partialDateConv);
                    }

                    if (!partialDateConv.isNull()) {
                        int len = partialDateConv.getDateStr().length();
                        if (len == 12) {
                            String tsStr = partialDateConv.getDateStr().length() == 12
                                    ? partialDateConv.getDateStr().substring(1, 11)
                                    : partialDateConv.getDateStr();
                            pStmt.setString(fldInx, tsStr);

                        } else {
                            if (!partialDateConv.getDateStr().equals("NULL"))
                                log.error("Determined Date was in error[" + partialDateConv.getDateStr() + "]");
                            pStmt.setObject(fldInx, null);
                        }
                    } else {
                        pStmt.setObject(fldInx, null);
                    }

                    /*
                     if (partialDateConv.getDateStr() == null)
                    {
                    getPartialDate(rs.getObject(detDateInx), partialDateConv);
                    }
                    if (isNotEmpty(partialDateConv.getDateStr()))
                    {
                    try
                    {
                        Date tsDate = sdf.parse(partialDateConv.getDateStr());
                        pStmt.setTimestamp(fldInx, new Timestamp(tsDate.getTime()));
                                
                    } catch (ParseException e)
                    {
                        e.printStackTrace();
                        pStmt.setObject(fldInx, null);
                    }
                    } else
                    {
                    pStmt.setObject(fldInx, null);
                    }
                     */

                } else if (newFieldName.equals("DeterminedDatePrecision")) {
                    if (partialDateConv.getDateStr() == null) {
                        getPartialDate(rs.getObject(detDateInx), partialDateConv);
                    }

                    if (partialDateConv.getPartial() != null) {
                        if (partialDateConv.getPartial().length() > 1) {
                            pStmt.setInt(fldInx, 1);
                        } else {
                            pStmt.setInt(fldInx, Integer.parseInt(partialDateConv.getPartial()));
                        }
                    } else {
                        pStmt.setInt(fldInx, 1);
                    }

                } else if (newFieldName.equals("CreatedByAgentID")) // User/Security changes
                {
                    Integer agentId = getCreatorAgentId(null);
                    pStmt.setInt(fldInx, agentId);

                } else if (newFieldName.equals("ModifiedByAgentID")) // User/Security changes
                {
                    Integer agentId = getModifiedByAgentId(lastEditedBy);
                    pStmt.setInt(fldInx, agentId);

                } else if (newFieldName.equals("Qualifier") || newFieldName.equals("SubSpQualifier")
                        || newFieldName.equals("VarQualifier") || newFieldName.equals("Addendum")
                        || newFieldName.equals("AlternateName") || newFieldName.equals("NameUsage")
                        || newFieldName.equals("GUID") || newFieldName.equals("PreferredTaxonID")) {
                    pStmt.setObject(fldInx, null);

                } else if (newFieldName.equals("CollectionMemberID")) // User/Security changes
                {
                    pStmt.setInt(fldInx, getCollectionMemberId());

                } else {
                    Integer index = null;
                    String oldMappedColName = colNewToOldMap.get(newFieldName);
                    if (oldMappedColName != null) {
                        index = oldNameIndex.get(oldMappedColName);

                    } else {
                        index = oldNameIndex.get(newFieldName);
                        oldMappedColName = newFieldName;
                    }

                    Object data;
                    if (index == null) {
                        String msg = "convertDeterminationRecords - Couldn't find new field name["
                                + newFieldName + "] in old field name in index Map";
                        log.warn(msg);
                        //                            stmt.close();
                        //                            tblWriter.logError(msg);
                        //                            throw new RuntimeException(msg);
                        data = null;
                    } else {
                        data = rs.getObject(index);
                    }

                    if (data != null) {
                        int idInx = newFieldName.lastIndexOf("ID");
                        if (idMapperMgr != null && idInx > -1) {
                            Integer oldId = (Integer) data;
                            IdMapperIFace idMapper;

                            if (oldMappedColName.equals("BiologicalObjectID")) {
                                data = colObjIdMapper.get(oldId);
                                if (data == null) {
                                    data = colObjCatIdMapper.get(oldId);
                                }

                            } else {
                                idMapper = idMapperMgr.get(tableName, oldMappedColName);
                                if (idMapper != null) {
                                    data = idMapper.get(oldId);
                                } else {
                                    String msg = "No Map for [" + tableName + "][" + oldMappedColName + "]";
                                    log.error(msg);
                                    tblWriter.logError(msg);
                                    isError = true;
                                    break;
                                }
                            }

                            if (data == null) {
                                String msg = "The determination with recordID[" + rs.getInt(oldRecIDInx)
                                        + "] could not find a mapping for record ID[" + oldId
                                        + "] for Old Field[" + oldMappedColName + "]";
                                log.debug(msg);
                                tblWriter.logError(msg);

                                tblWriter.log(ConvertVerifier.dumpSQL(oldDBConn,
                                        "SELECT * FROM determination WHERE DeterminationId = "
                                                + rs.getInt(oldRecIDInx)));

                                if (isValueRequired(tableName, newFieldName)) {
                                    msg = "For table[" + tableName + "] the field [" + newFieldName
                                            + "] is null and can't be. Old value[" + oldId + "]";
                                    log.error(msg);
                                    tblWriter.logError(msg);
                                }
                                isError = true;
                                break;
                            }
                        }
                    }
                    //fixTimestamps(newFieldName, newFieldMetaData.get(i).getType(), data, str);
                    FieldMetaData fldMetaData = newFieldMetaData.get(i);
                    if (fldMetaData == null) {
                        String msg = "For table[" + tableName + "] the field [" + newFieldName
                                + "] FieldMeataDate was null for index[" + i + "]";
                        log.error(msg);
                        tblWriter.logError(msg);

                    } else {
                        //System.out.println(fldMetaData.getName()+"  "+fldMetaData.getSqlType()+"  "+fldMetaData.getType());
                        BasicSQLUtils.setData(pStmt, newFieldMetaData.get(i).getSqlType(), fldInx, data);
                    }
                }
            }

            if (hasFrame) {
                if (count % 500 == 0) {
                    setProcess(count);
                }

            } else {
                if (count % 2000 == 0) {
                    log.info("Determination Records: " + count);
                }
            }

            if (!isError) {
                try {
                    if (pStmt.executeUpdate() != 1) {
                        log.error("Count:  " + count);
                        log.error("Error inserting record.");
                    }

                } catch (SQLException e) {
                    log.error("Count:  " + count);
                    e.printStackTrace();
                    log.error(e);
                    rs.close();
                    stmt.close();
                    showError(e.toString());
                    throw new RuntimeException(e);
                }
            }

            count++;
            // if (count > 10) break;
        } while (rs.next());

        pStmt.close();

        if (hasFrame) {
            setProcess(count);
        } else {
            log.info("Processed Determination " + count + " records.");
        }
        rs.close();

        stmt.close();

        tblWriter.log(String.format("Determination Processing Time: %s", timeLogger.end()));

        tblWriter.close();

    } catch (SQLException e) {
        e.printStackTrace();
        log.error(e);
        throw new RuntimeException(e);
    }

    setIdentityInsertOFFCommandForSQLServer(newDBConn, "determination", BasicSQLUtils.myDestinationServerType);

    return true;
}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java

public MSSBamAtomDefBuff[] readDerivedByVAccFreqIdx(MSSBamAuthorization Authorization,
        Short ViewAccessFrequencyId) {
    final String S_ProcName = "readDerivedByVAccFreqIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }//from   w  w w  .  j av a 2s  .  c  o m
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    try {
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE "
                + ((ViewAccessFrequencyId == null) ? "val.ViewAccessFrequencyId is null "
                        : "val.ViewAccessFrequencyId = " + ViewAccessFrequencyId.toString() + " ");
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
    ArrayList<MSSBamAtomDefBuff> resultList = new ArrayList<MSSBamAtomDefBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("ATM")) {
            MSSBamAtomDefBuff[] subList = readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLB")) {
            MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLB")) {
            MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLB")) {
            MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLN")) {
            MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLN")) {
            MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLN")) {
            MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DAT")) {
            MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDAT")) {
            MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDAT")) {
            MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DBL")) {
            MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDBL")) {
            MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDBL")) {
            MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NUM")) {
            MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNUM")) {
            MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNUM")) {
            MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("FLT")) {
            MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TFLT")) {
            MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SFLT")) {
            MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I16")) {
            MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI16")) {
            MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI16")) {
            MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ENM")) {
            MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TENM")) {
            MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SENM")) {
            MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G16")) {
            MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG16")) {
            MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG16")) {
            MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U16")) {
            MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU16")) {
            MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU16")) {
            MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I32")) {
            MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI32")) {
            MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI32")) {
            MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G32")) {
            MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG32")) {
            MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG32")) {
            MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U32")) {
            MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU32")) {
            MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU32")) {
            MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I64")) {
            MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI64")) {
            MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI64")) {
            MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G64")) {
            MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG64")) {
            MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG64")) {
            MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U64")) {
            MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU64")) {
            MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU64")) {
            MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("UUID")) {
            MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TUUI")) {
            MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SUUI")) {
            MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("IDGU")) {
            MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TGUU")) {
            MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SGUU")) {
            MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMT")) {
            MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTK")) {
            MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTK")) {
            MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMS")) {
            MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTS")) {
            MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTS")) {
            MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STR")) {
            MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSTR")) {
            MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SSTR")) {
            MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZDY")) {
            MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZDY")) {
            MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZDY")) {
            MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZTM")) {
            MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZTM")) {
            MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZTM")) {
            MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZSP")) {
            MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZST")) {
            MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZST")) {
            MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TXT")) {
            MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTXT")) {
            MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STXT")) {
            MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TIM")) {
            MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTIM")) {
            MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STIM")) {
            MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSP")) {
            MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTSM")) {
            MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STSM")) {
            MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp()
                    .readBuffByVAccFreqIdx(Authorization, ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TKN")) {
            MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTOK")) {
            MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STOK")) {
            MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByVAccFreqIdx(Authorization,
                    ViewAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    return (resultList.toArray(new MSSBamAtomDefBuff[0]));

}

From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * Converts all the CollectionObject and CollectionObjectCatalog Records into the new schema
 * CollectionObject table. All "logical" records are moved to the CollectionObject table and all
 * "physical" records are moved to the Preparation table.
 * @return true if no errors/* w ww  . j  a  v a2s. c  om*/
 */
@SuppressWarnings("cast")
public boolean convertCollectionObjects(final boolean useNumericCatNumbers, final boolean usePrefix) {
    final String ZEROES = "000000000";

    UIFieldFormatterIFace formatter0 = UIFieldFormatterMgr.getInstance().getFormatter("CatalogNumber");
    log.debug(formatter0);

    UIFieldFormatterIFace formatter = UIFieldFormatterMgr.getInstance().getFormatter("CatalogNumberNumeric");
    log.debug(formatter);

    DisciplineType dt;
    Discipline discipline = (Discipline) AppContextMgr.getInstance().getClassObject(Discipline.class);
    if (discipline != null) {
        System.out.println("discipline.getType()[" + discipline.getType() + "]");
        dt = DisciplineType.getDiscipline(discipline.getType());
    } else {
        Vector<Object[]> list = query(newDBConn, "SELECT Type FROM discipline");
        String typeStr = (String) list.get(0)[0];
        System.out.println("typeStr[" + typeStr + "]");
        dt = DisciplineType.getDiscipline(typeStr);
    }

    Pair<Integer, Boolean> objTypePair = dispToObjTypeHash.get(dt.getDisciplineType());
    if (objTypePair == null) {
        System.out.println("objTypePair is null dt[" + dt.getName() + "][" + dt.getTitle() + "]");

        for (STD_DISCIPLINES key : dispToObjTypeHash.keySet()) {
            Pair<Integer, Boolean> p = dispToObjTypeHash.get(key);
            System.out.println("[" + key + "] [" + p.first + "][" + p.second + "]");
        }

    } else if (objTypePair.first == null) {
        System.out.println("objTypePair.first is null dt[" + dt + "]");

        for (STD_DISCIPLINES key : dispToObjTypeHash.keySet()) {
            Pair<Integer, Boolean> p = dispToObjTypeHash.get(key);
            System.out.println("[" + key + "] [" + p.first + "][" + p.second + "]");
        }

    }
    //int objTypeId  = objTypePair.first;
    //boolean isEmbedded = objTypePair.second;

    idMapperMgr.dumpKeys();
    IdHashMapper colObjTaxonMapper = (IdHashMapper) idMapperMgr.get("ColObjCatToTaxonType".toLowerCase());
    IdHashMapper colObjAttrMapper = (IdHashMapper) idMapperMgr
            .get("biologicalobjectattributes_BiologicalObjectAttributesID");
    IdHashMapper colObjMapper = (IdHashMapper) idMapperMgr
            .get("collectionobjectcatalog_CollectionObjectCatalogID");

    colObjTaxonMapper.setShowLogErrors(false); // NOTE: TURN THIS ON FOR DEBUGGING or running new Databases through it
    colObjAttrMapper.setShowLogErrors(false);

    //IdHashMapper stratMapper    = (IdHashMapper)idMapperMgr.get("stratigraphy_StratigraphyID");
    //IdHashMapper stratGTPMapper = (IdHashMapper)idMapperMgr.get("stratigraphy_GeologicTimePeriodID");

    String[] fieldsToSkip = { "ContainerID", "ContainerItemID", "AltCatalogNumber", "GUID", "ContainerOwnerID",
            "RepositoryAgreementID", "GroupPermittedToView", // this may change when converting Specify 5.x
            "CollectionObjectID", "VisibilitySetBy", "ContainerOwnerID", "InventoryDate", "ObjectCondition",
            "Notifications", "ProjectNumber", "Restrictions", "YesNo3", "YesNo4", "YesNo5", "YesNo6",
            "FieldNotebookPageID", "ColObjAttributesID", "DNASequenceID", "AppraisalID", "TotalValue",
            "Description", "SGRStatus", "OCR", "ReservedText", "Text3" };

    HashSet<String> fieldsToSkipHash = new HashSet<String>();
    for (String fName : fieldsToSkip) {
        fieldsToSkipHash.add(fName);
    }

    TableWriter tblWriter = convLogger.getWriter("convertCollectionObjects.html", "Collection Objects");

    String msg = "colObjTaxonMapper: " + colObjTaxonMapper.size();
    log.info(msg);
    tblWriter.log(msg);

    setIdentityInsertONCommandForSQLServer(newDBConn, "collectionobject",
            BasicSQLUtils.myDestinationServerType);

    deleteAllRecordsFromTable(newDBConn, "collectionobject", BasicSQLUtils.myDestinationServerType); // automatically closes the connection

    TreeSet<String> badSubNumberCatNumsSet = new TreeSet<String>();

    TimeLogger timeLogger = new TimeLogger();

    try {
        Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        StringBuilder str = new StringBuilder();

        List<String> oldFieldNames = new ArrayList<String>();

        StringBuilder sql = new StringBuilder("select ");
        List<String> names = getFieldNamesFromSchema(oldDBConn, "collectionobject");

        sql.append(buildSelectFieldList(names, "collectionobject"));
        sql.append(", ");
        oldFieldNames.addAll(names);

        names = getFieldNamesFromSchema(oldDBConn, "collectionobjectcatalog");
        sql.append(buildSelectFieldList(names, "collectionobjectcatalog"));
        oldFieldNames.addAll(names);

        String fromClause = " FROM collectionobject Inner Join collectionobjectcatalog ON "
                + "collectionobject.CollectionObjectID = collectionobjectcatalog.CollectionObjectCatalogID "
                + "WHERE (collectionobject.DerivedFromID IS NULL) AND collectionobjectcatalog.CollectionObjectCatalogID = ";
        sql.append(fromClause);

        log.info(sql);
        String sqlStr = sql.toString();

        List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, "collectionobject");

        log.info("Number of Fields in New CollectionObject " + newFieldMetaData.size());

        Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>();
        int inx = 1;
        log.info("---- Old Names ----");
        for (String name : oldFieldNames) {
            log.info("[" + name + "][" + inx + "]");
            oldNameIndex.put(name, inx++);
        }

        log.info("---- New Names ----");
        for (FieldMetaData fmd : newFieldMetaData) {
            log.info("[" + fmd.getName() + "]");
        }
        String tableName = "collectionobject";

        Statement newStmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        newStmt.setFetchSize(Integer.MIN_VALUE);
        ResultSet rsLooping = newStmt.executeQuery(
                "SELECT OldID, NewID FROM collectionobjectcatalog_CollectionObjectCatalogID ORDER BY OldID");

        if (hasFrame) {
            if (rsLooping.last()) {
                setProcess(0, rsLooping.getRow());
                rsLooping.first();

            } else {
                rsLooping.close();
                stmt.close();
                return true;
            }
        } else {
            if (!rsLooping.first()) {
                rsLooping.close();
                stmt.close();
                return true;
            }
        }

        int boaCnt = BasicSQLUtils.getCountAsInt(oldDBConn, "SELECT COUNT(*) FROM biologicalobjectattributes"); // ZZZ

        PartialDateConv partialDateConv = new PartialDateConv();

        Statement stmt2 = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt2.setFetchSize(Integer.MIN_VALUE);

        int catNumInx = oldNameIndex.get("CatalogNumber");
        int catDateInx = oldNameIndex.get("CatalogedDate");
        int catSeriesIdInx = oldNameIndex.get("CatalogSeriesID");
        int lastEditedByInx = oldNameIndex.get("LastEditedBy");

        /*int     grpPrmtViewInx    = -1;
        Integer grpPrmtViewInxObj = oldNameIndex.get("GroupPermittedToView");
        if (grpPrmtViewInxObj != null)
        {
        grpPrmtViewInx = grpPrmtViewInxObj + 1;
        }*/

        Hashtable<Integer, CollectionInfo> oldCatSeriesIDToCollInfo = new Hashtable<Integer, CollectionInfo>();
        for (CollectionInfo ci : collectionInfoShortList) {
            if (ci.getCatSeriesId() != null) {
                oldCatSeriesIDToCollInfo.put(ci.getCatSeriesId(), ci);
            }
        }

        String insertStmtStr = null;

        /*String catIdTaxIdStrBase = "SELECT cc.CollectionObjectCatalogID, cc.CatalogSeriesID, ct.TaxonomyTypeID "
                                + "FROM collectionobjectcatalog AS cc "
                                + "Inner Join collectionobject AS co ON cc.CollectionObjectCatalogID = co.CollectionObjectID "
                                + "Inner Join collectiontaxonomytypes as ct ON co.CollectionObjectTypeID = ct.BiologicalObjectTypeID "
                                + "where cc.CollectionObjectCatalogID = ";*/

        int colObjAttrsNotMapped = 0;
        int count = 0;
        boolean skipRecord = false;
        do {
            String catSQL = sqlStr + rsLooping.getInt(1);
            //log.debug(catSQL);
            ResultSet rs = stmt.executeQuery(catSQL);
            if (!rs.next()) {
                log.error("Couldn't find CO with old  id[" + rsLooping.getInt(1) + "] " + catSQL);
                continue;
            }

            partialDateConv.nullAll();

            skipRecord = false;

            CollectionInfo collInfo = oldCatSeriesIDToCollInfo.get(rs.getInt(catSeriesIdInx));

            /*String catIdTaxIdStr = catIdTaxIdStrBase + rs.getInt(1);
            //log.info(catIdTaxIdStr);
                    
            ResultSet rs2 = stmt2.executeQuery(catIdTaxIdStr);
            if (!rs2.next())
            {
            log.info("QUERY failed to return results:\n"+catIdTaxIdStr+"\n");
            continue;
            }
            Integer catalogSeriesID = rs2.getInt(2);
            Integer taxonomyTypeID  = rs2.getInt(3);
            Integer newCatSeriesId  = collectionHash.get(catalogSeriesID + "_" + taxonomyTypeID);
            String  prefix          = prefixHash.get(catalogSeriesID + "_" + taxonomyTypeID);
            rs2.close();
                    
            if (newCatSeriesId == null)
            {
            msg = "Can't find " + catalogSeriesID + "_" + taxonomyTypeID;
            log.info(msg);
            tblWriter.logError(msg);
            continue;
            }*/

            /*if (false)
            {
            String stratGTPIdStr = "SELECT co.CollectionObjectID, ce.CollectingEventID, s.StratigraphyID, g.GeologicTimePeriodID FROM collectionobject co " +
                "LEFT JOIN collectingevent ce ON co.CollectingEventID = ce.CollectingEventID  " +
                "LEFT JOIN stratigraphy s ON ce.CollectingEventID = s.StratigraphyID  " +
                "LEFT JOIN geologictimeperiod g ON s.GeologicTimePeriodID = g.GeologicTimePeriodID  " +
                "WHERE co.CollectionObjectID  = " + rs.getInt(1);
            log.info(stratGTPIdStr);
            rs2 = stmt2.executeQuery(stratGTPIdStr);
                    
            Integer coId = null;
            Integer ceId = null;
            Integer stId = null;
            Integer gtpId = null;
            if (rs2.next())
            {
                coId = rs2.getInt(1);
                ceId = rs2.getInt(2);
                stId = rs2.getInt(3);
                gtpId = rs2.getInt(4);
            }
            rs2.close();
            }*/

            String catalogNumber = null;
            String colObjId = null;

            str.setLength(0);

            if (insertStmtStr == null) {
                StringBuffer fieldList = new StringBuffer();
                fieldList.append("( ");
                for (int i = 0; i < newFieldMetaData.size(); i++) {
                    if ((i > 0) && (i < newFieldMetaData.size())) {
                        fieldList.append(", ");
                    }
                    String newFieldName = newFieldMetaData.get(i).getName();
                    fieldList.append(newFieldName + " ");
                }
                fieldList.append(")");
                insertStmtStr = "INSERT INTO collectionobject " + fieldList + "  VALUES (";
            }
            str.append(insertStmtStr);

            for (int i = 0; i < newFieldMetaData.size(); i++) {
                if (i > 0) {
                    str.append(", ");
                }

                String newFieldName = newFieldMetaData.get(i).getName();

                if (i == 0) {
                    Integer oldColObjId = rs.getInt(1);
                    Integer newColObjId = colObjMapper.get(oldColObjId);

                    if (newColObjId == null) {
                        msg = "Couldn't find new ColObj Id for old [" + oldColObjId + "]";
                        tblWriter.logError(msg);
                        showError(msg);
                        throw new RuntimeException(msg);
                    }

                    colObjId = getStrValue(newColObjId);
                    if (contains(colObjId, '.')) {
                        String msgStr = String.format("CatalogNumber '%d' contains a decimal point.", colObjId);
                        log.debug(msgStr);
                        tblWriter.logError(msgStr);
                        skipRecord = true;
                        break;
                    }
                    str.append(colObjId);

                    if (useNumericCatNumbers) {
                        catalogNumber = rs.getString(catNumInx);

                        if (catalogNumber != null) {
                            int catNumInt = (int) Math.abs(rs.getDouble(catNumInx));
                            catalogNumber = Integer.toString(catNumInt);

                            if (catalogNumber.length() > 0 && catalogNumber.length() < ZEROES.length()) {
                                catalogNumber = "\"" + ZEROES.substring(catalogNumber.length()) + catalogNumber
                                        + "\"";

                            } else if (catalogNumber.length() > ZEROES.length()) {
                                showError(
                                        "Catalog Number[" + catalogNumber + "] is too long for formatter of 9");
                            }

                        } else {
                            String mssg = "Empty catalog number.";
                            log.debug(mssg);
                            //showError(msg);
                            tblWriter.logError(mssg);
                        }

                    } else {
                        String prefix = collInfo.getCatSeriesPrefix();

                        float catNum = rs.getFloat(catNumInx);
                        catalogNumber = "\"" + (usePrefix && isNotEmpty(prefix) ? (prefix + "-") : "")
                                + String.format("%9.0f", catNum).trim() + "\"";
                    }

                    int subNumber = rs.getInt(oldNameIndex.get("SubNumber"));
                    if (subNumber < 0 || rs.wasNull()) {
                        badSubNumberCatNumsSet.add(catalogNumber);

                        skipRecord = true;
                        //msg = "Collection Object is being skipped because SubNumber is less than zero CatalogNumber["+ catalogNumber + "]";
                        //log.error(msg);
                        //tblWriter.logError(msg);
                        //showError(msg);
                        break;
                    }

                } else if (fieldsToSkipHash.contains(newFieldName)) {
                    str.append("NULL");

                } else if (newFieldName.equals("CollectionID")) // User/Security changes
                {
                    str.append(collInfo.getCollectionId());

                } else if (newFieldName.equals("Version")) // User/Security changes
                {
                    str.append("0");

                } else if (newFieldName.equals("CreatedByAgentID")) // User/Security changes
                {
                    str.append(getCreatorAgentId(null));

                } else if (newFieldName.equals("ModifiedByAgentID")) // User/Security changes
                {
                    String lastEditedByStr = rs.getString(lastEditedByInx);
                    str.append(getModifiedByAgentId(lastEditedByStr));

                } else if (newFieldName.equals("CollectionMemberID")) // User/Security changes
                {
                    str.append(collInfo.getCollectionId());

                } else if (newFieldName.equals("PaleoContextID")) {
                    str.append("NULL");// newCatSeriesId);

                } else if (newFieldName.equals("CollectionObjectAttributeID")) // User/Security changes
                {
                    Object idObj = rs.getObject(1);
                    if (idObj != null) {
                        Integer coId = rs.getInt(1);
                        Integer newId = colObjAttrMapper.get(coId);
                        if (newId != null) {
                            str.append(getStrValue(newId));
                        } else {
                            if (boaCnt > 0)
                                colObjAttrsNotMapped++;
                            str.append("NULL");
                        }
                    } else {
                        str.append("NULL");
                    }

                } else if (newFieldName.equals("CatalogedDate")) {
                    if (partialDateConv.getDateStr() == null) {
                        getPartialDate(rs.getObject(catDateInx), partialDateConv);
                    }
                    str.append(partialDateConv.getDateStr());

                } else if (newFieldName.equals("CatalogedDatePrecision")) {
                    if (partialDateConv.getDateStr() == null) {
                        getPartialDate(rs.getObject(catDateInx), partialDateConv);
                    }
                    str.append(partialDateConv.getPartial());

                } else if (newFieldName.equals("CatalogedDateVerbatim")) {
                    if (partialDateConv.getDateStr() == null) {
                        getPartialDate(rs.getObject(catDateInx), partialDateConv);
                    }
                    str.append(partialDateConv.getVerbatim());

                } else if (newFieldName.equals("Availability")) {
                    str.append("NULL");

                } else if (newFieldName.equals("CatalogNumber")) {
                    str.append(catalogNumber);

                } else if (newFieldName.equals("Visibility")) // User/Security changes
                {
                    //str.append(grpPrmtViewInx > -1 ? rs.getObject(grpPrmtViewInx) : "NULL");
                    str.append("0");

                } else if (newFieldName.equals("VisibilitySetByID")) // User/Security changes
                {
                    str.append("NULL");

                } else if (newFieldName.equals("CountAmt")) {
                    Integer index = oldNameIndex.get("Count1");
                    if (index == null) {
                        index = oldNameIndex.get("Count");
                    }
                    Object countObj = rs.getObject(index);
                    if (countObj != null) {
                        str.append(getStrValue(countObj, newFieldMetaData.get(i).getType()));
                    } else {
                        str.append("NULL");
                    }

                } else {
                    Integer index = oldNameIndex.get(newFieldName);
                    Object data;
                    if (index == null) {
                        msg = "convertCollectionObjects - Couldn't find new field name[" + newFieldName
                                + "] in old field name in index Map";
                        log.warn(msg);
                        //                            tblWriter.logError(msg);
                        //                            showError(msg);
                        data = null;
                        // for (String key : oldNameIndex.keySet())
                        // {
                        // log.info("["+key+"]["+oldNameIndex.get(key)+"]");
                        // }
                        //stmt.close();
                        //throw new RuntimeException(msg);
                    } else {

                        data = rs.getObject(index);
                    }
                    if (data != null) {
                        int idInx = newFieldName.lastIndexOf("ID");
                        if (idMapperMgr != null && idInx > -1) {
                            IdMapperIFace idMapper = idMapperMgr.get(tableName, newFieldName);
                            if (idMapper != null) {
                                Integer origValue = rs.getInt(index);
                                data = idMapper.get(origValue);
                                if (data == null) {
                                    msg = "No value [" + origValue + "] in map  [" + tableName + "]["
                                            + newFieldName + "]";
                                    log.error(msg);
                                    tblWriter.logError(msg);
                                    //showError(msg);
                                }
                            } else {
                                msg = "No Map for [" + tableName + "][" + newFieldName + "]";
                                log.error(msg);
                                tblWriter.logError(msg);
                                //showError(msg);
                            }
                        }
                    }
                    str.append(getStrValue(data, newFieldMetaData.get(i).getType()));
                }
            }

            if (!skipRecord) {
                str.append(")");
                // log.info("\n"+str.toString());
                if (hasFrame) {
                    if (count % 500 == 0) {
                        setProcess(count);
                    }
                    if (count % 5000 == 0) {
                        log.info("CollectionObject Records: " + count);
                    }

                } else {
                    if (count % 2000 == 0) {
                        log.info("CollectionObject Records: " + count);
                    }
                }

                try {
                    Statement updateStatement = newDBConn.createStatement();
                    if (BasicSQLUtils.myDestinationServerType != BasicSQLUtils.SERVERTYPE.MS_SQLServer) {
                        removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType);
                    }
                    // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0");
                    //if (count < 50) System.err.println(str.toString());

                    updateStatement.executeUpdate(str.toString());
                    updateStatement.clearBatch();
                    updateStatement.close();
                    updateStatement = null;

                } catch (SQLException e) {
                    log.error("Count: " + count);
                    log.error("Key: [" + colObjId + "][" + catalogNumber + "]");
                    log.error("SQL: " + str.toString());
                    e.printStackTrace();
                    log.error(e);
                    showError(e.getMessage());
                    rs.close();
                    stmt.close();
                    throw new RuntimeException(e);
                }

                count++;
            } else {
                tblWriter.logError("Skipping - CatNo:" + catalogNumber);
            }
            // if (count > 10) break;

            rs.close();

        } while (rsLooping.next());

        /*if (boaCnt > 0)
        {
        msg = "CollectionObjectAttributes not mapped: " + colObjAttrsNotMapped + " out of "+boaCnt;
        log.info(msg);
        tblWriter.logError(msg);
        }*/

        stmt2.close();

        if (hasFrame) {
            setProcess(count);
        } else {
            log.info("Processed CollectionObject " + count + " records.");
        }

        tblWriter.log(String.format("Collection Objects Processing Time: %s", timeLogger.end()));

        tblWriter.log("Processed CollectionObject " + count + " records.");
        rsLooping.close();
        newStmt.close();
        stmt.close();

        tblWriter.append(
                "<br><br><b>Catalog Numbers rejected because the SubNumber was NULL or less than Zero</b><br>");
        tblWriter.startTable();
        tblWriter.logHdr("Catalog Number");
        for (String catNum : badSubNumberCatNumsSet) {
            tblWriter.log(catNum);
        }
        tblWriter.endTable();

    } catch (SQLException e) {
        setIdentityInsertOFFCommandForSQLServer(newDBConn, "collectionobject",
                BasicSQLUtils.myDestinationServerType);
        e.printStackTrace();
        log.error(e);
        tblWriter.logError(e.getMessage());
        showError(e.getMessage());
        throw new RuntimeException(e);

    } finally {
        tblWriter.close();
    }
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "collectionobject",
            BasicSQLUtils.myDestinationServerType);

    return true;
}

From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * @return//from  www. j a v a 2s  .com
 */
public boolean convertLoanPreparations() {
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "determination", BasicSQLUtils.myDestinationServerType);
    setIdentityInsertONCommandForSQLServer(newDBConn, "loanpreparation", BasicSQLUtils.myDestinationServerType);

    deleteAllRecordsFromTable(newDBConn, "loanpreparation", BasicSQLUtils.myDestinationServerType); // automatically closes the connection

    if (getNumRecords(oldDBConn, "loanphysicalobject") == 0) {
        setIdentityInsertOFFCommandForSQLServer(newDBConn, "loanpreparation",
                BasicSQLUtils.myDestinationServerType);
        return true;
    }

    Integer recCount = getCount(oldDBConn, "SELECT count(*) FROM loan WHERE Category = 0 ORDER BY LoanID");
    if (recCount == null || recCount == 0) {
        return true;
    }

    TableWriter tblWriter = convLogger.getWriter("convertLoanPreparations.html", "Loan Preparations");

    IdTableMapper loanPrepsMapper = (IdTableMapper) IdMapperMgr.getInstance().get("loanphysicalobject",
            "LoanPhysicalObjectID");
    if (loanPrepsMapper == null) {
        String msg = "LoanPrepsMapper not found. (This was a fatal error).";
        tblWriter.logError(msg);
        log.error(msg);
        return false;
    }

    TimeLogger timeLogger = new TimeLogger();

    try {
        Map<String, String> colNewToOldMap = createFieldNameMap(
                new String[] { "PreparationID", "PhysicalObjectID", });

        Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        StringBuilder str = new StringBuilder();

        List<String> oldFieldNames = new ArrayList<String>();

        StringBuilder sql = new StringBuilder("SELECT ");
        List<String> names = getFieldNamesFromSchema(oldDBConn, "loanphysicalobject");

        sql.append(buildSelectFieldList(names, "loanphysicalobject"));
        oldFieldNames.addAll(names);

        sql.append(
                " FROM loanphysicalobject INNER JOIN loan ON loanphysicalobject.LoanID = loan.LoanID WHERE loan.Category = 0");

        log.info(sql);

        List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, "loanpreparation");

        log.info("Number of Fields in New loanpreparation " + newFieldMetaData.size());
        String sqlStr = sql.toString();

        Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>();
        int inx = 1;
        for (String name : oldFieldNames) {
            oldNameIndex.put(name, inx++);
        }

        String tableName = "loanphysicalobject";

        int loanPhysIdIndex = oldNameIndex.get("LoanPhysicalObjectID");
        int quantityIndex = oldNameIndex.get("Quantity");
        int quantityRetIndex = oldNameIndex.get("QuantityReturned");
        int quantityResIndex = oldNameIndex.get("QuantityResolved");
        int lastEditedByInx = oldNameIndex.get("LastEditedBy");

        log.info(sqlStr);
        ResultSet rs = stmt.executeQuery(sqlStr);

        if (hasFrame) {
            if (rs.last()) {
                setProcess(0, rs.getRow());
                rs.first();

            } else {
                rs.close();
                stmt.close();
                return true;
            }
        } else {
            if (!rs.first()) {
                rs.close();
                stmt.close();
                return true;
            }
        }

        String insertStmtStr = null;

        int count = 0;
        do {
            boolean skipInsert = false;

            int quantity = getIntValue(rs, quantityIndex);
            int quantityResolved = getIntValue(rs, quantityResIndex);
            int quantityReturned = getIntValue(rs, quantityRetIndex);
            Boolean isResolved = quantityReturned == quantity || quantityResolved == quantity;
            String lastEditedBy = rs.getString(lastEditedByInx);

            str.setLength(0);

            if (insertStmtStr == null) {
                StringBuffer fieldList = new StringBuffer();
                fieldList.append("( ");
                for (int i = 0; i < newFieldMetaData.size(); i++) {
                    if ((i > 0) && (i < newFieldMetaData.size())) {
                        fieldList.append(", ");
                    }
                    String newFieldName = newFieldMetaData.get(i).getName();
                    fieldList.append(newFieldName + " ");
                }
                fieldList.append(")");
                insertStmtStr = "INSERT INTO loanpreparation " + fieldList + " VALUES (";
            }

            str.append(insertStmtStr);

            /*int    loanPhysId = rs.getInt(loanPhysIdIndex);
            String loanNumber = BasicSQLUtils.querySingleObj(oldDBConn, "SELECT LoanNumber FROM loan l INNER JOIN loanphysicalobject lp ON l.LoanID = lp.LoanID WHERE LoanPhysicalObjectID = "+loanPhysId);
            if (loanNumber != null && loanNumber.equals("25"))
            {
            debug = true;
            System.out.println("-------------------------------------\n"+loanPhysId);
            }*/

            for (int i = 0; i < newFieldMetaData.size(); i++) {
                if (i > 0)
                    str.append(", ");

                String newFieldName = newFieldMetaData.get(i).getName();

                if (i == 0) {
                    Integer oldId = rs.getInt(loanPhysIdIndex);
                    Integer newID = loanPrepsMapper.get(oldId);
                    if (newID != null) {
                        str.append(getStrValue(newID));
                    } else {
                        String msg = String.format(
                                "loanPhysIdIndex: %d; Old Id: %d could be mapped to a new ID. (This was a fatal error).",
                                loanPhysIdIndex, oldId);
                        tblWriter.logError(msg);
                        log.error(msg);
                        return false;
                    }

                } else if (newFieldName.equals("ReceivedComments")) {
                    str.append("NULL");

                } else if (newFieldName.equals("IsResolved")) {
                    str.append(getStrValue(isResolved));

                } else if (newFieldName.equalsIgnoreCase("Version")) {
                    str.append("0");

                } else if (newFieldName.equalsIgnoreCase("DisciplineID")) {
                    str.append(getDisciplineId());

                } else if (newFieldName.equalsIgnoreCase("ModifiedByAgentID")) {
                    str.append(getModifiedByAgentId(lastEditedBy));

                } else if (newFieldName.equalsIgnoreCase("CreatedByAgentID")) {
                    str.append(getCreatorAgentId(null));

                } else {
                    Integer index = null;
                    String oldMappedColName = colNewToOldMap.get(newFieldName);
                    if (oldMappedColName != null) {
                        index = oldNameIndex.get(oldMappedColName);

                    } else {
                        index = oldNameIndex.get(newFieldName);
                        oldMappedColName = newFieldName;
                    }

                    Object data;
                    if (index == null) {
                        String msg = "convertLoanPreparations - Couldn't find new field name[" + newFieldName
                                + "] in old field name in index Map";
                        log.warn(msg);
                        //                            stmt.close();
                        //                            tblWriter.logError(msg);
                        //                            showError(msg);
                        //                            throw new RuntimeException(msg);
                        data = null;
                    } else {
                        data = rs.getObject(index);
                    }
                    if (data != null) {
                        int idInx = newFieldName.lastIndexOf("ID");
                        if (idMapperMgr != null && idInx > -1) {
                            IdMapperIFace idMapper = idMapperMgr.get(tableName, oldMappedColName);
                            if (idMapper != null) {
                                Integer oldId = rs.getInt(index);
                                data = idMapper.get(oldId);
                                if (data == null) {
                                    String msg = "No Map ID for [" + tableName + "][" + oldMappedColName
                                            + "] for ID[" + oldId + "]";
                                    log.error(msg);
                                    tblWriter.logError(msg);
                                    skipInsert = true;
                                }
                            } else {
                                String msg = "No Map for [" + tableName + "][" + oldMappedColName + "]";
                                log.error(msg);
                                tblWriter.logError(msg);
                                skipInsert = true;
                            }
                        }
                    }
                    str.append(getStrValue(data, newFieldMetaData.get(i).getType()));
                }
            }
            str.append(")");

            if (hasFrame) {
                if (count % 500 == 0) {
                    setProcess(count);
                }

            } else {
                if (count % 2000 == 0) {
                    log.info("LoanPreparation Records: " + count);
                }
            }

            try {
                if (!skipInsert) {
                    Statement updateStatement = newDBConn.createStatement();
                    if (BasicSQLUtils.myDestinationServerType != BasicSQLUtils.SERVERTYPE.MS_SQLServer) {
                        removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType);
                    }
                    // log.debug("executring: " + str.toString());
                    // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0");
                    updateStatement.executeUpdate(str.toString());
                    updateStatement.clearBatch();
                    updateStatement.close();
                    updateStatement = null;
                }

            } catch (SQLException e) {
                log.error("Count: " + count);
                e.printStackTrace();
                log.error(e);
                rs.close();
                stmt.close();
                throw new RuntimeException(e);
            }

            count++;
            // if (count > 10) break;
        } while (rs.next());

        if (hasFrame) {
            setProcess(count);
            log.info("Processed LoanPreparation " + count + " records.");
        } else {
            log.info("Processed LoanPreparation " + count + " records.");
        }
        rs.close();

        stmt.close();

    } catch (SQLException e) {
        e.printStackTrace();
        log.error(e);
        setIdentityInsertOFFCommandForSQLServer(newDBConn, "LoanPreparation",
                BasicSQLUtils.myDestinationServerType);
        throw new RuntimeException(e);
    }
    log.info("Done processing LoanPhysicalObject");
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "LoanPreparation",
            BasicSQLUtils.myDestinationServerType);

    //tblWriter.log(String.format("Loan Preps Processing Time: %s", timeLogger.end()));
    tblWriter.close();

    return true;

}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java

public MSSBamAtomDefBuff[] readDerivedByEAccSecIdx(MSSBamAuthorization Authorization,
        Short EditAccessSecurityId) {
    final String S_ProcName = "readDerivedByEAccSecIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from  w  ww .ja v a  2 s. c  o m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    try {
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE "
                + ((EditAccessSecurityId == null) ? "val.EditAccessSecurityId is null "
                        : "val.EditAccessSecurityId = " + EditAccessSecurityId.toString() + " ");
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
    ArrayList<MSSBamAtomDefBuff> resultList = new ArrayList<MSSBamAtomDefBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("ATM")) {
            MSSBamAtomDefBuff[] subList = readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLB")) {
            MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLB")) {
            MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLB")) {
            MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLN")) {
            MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLN")) {
            MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLN")) {
            MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DAT")) {
            MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDAT")) {
            MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDAT")) {
            MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DBL")) {
            MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDBL")) {
            MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDBL")) {
            MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NUM")) {
            MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNUM")) {
            MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNUM")) {
            MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("FLT")) {
            MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TFLT")) {
            MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SFLT")) {
            MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I16")) {
            MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI16")) {
            MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI16")) {
            MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ENM")) {
            MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TENM")) {
            MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SENM")) {
            MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G16")) {
            MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG16")) {
            MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG16")) {
            MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U16")) {
            MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU16")) {
            MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU16")) {
            MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I32")) {
            MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI32")) {
            MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI32")) {
            MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G32")) {
            MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG32")) {
            MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG32")) {
            MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U32")) {
            MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU32")) {
            MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU32")) {
            MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I64")) {
            MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI64")) {
            MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI64")) {
            MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G64")) {
            MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG64")) {
            MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG64")) {
            MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U64")) {
            MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU64")) {
            MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU64")) {
            MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("UUID")) {
            MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TUUI")) {
            MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SUUI")) {
            MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("IDGU")) {
            MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TGUU")) {
            MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SGUU")) {
            MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMT")) {
            MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTK")) {
            MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTK")) {
            MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMS")) {
            MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTS")) {
            MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTS")) {
            MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STR")) {
            MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSTR")) {
            MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SSTR")) {
            MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZDY")) {
            MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZDY")) {
            MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZDY")) {
            MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZTM")) {
            MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZTM")) {
            MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZTM")) {
            MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZSP")) {
            MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZST")) {
            MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZST")) {
            MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TXT")) {
            MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTXT")) {
            MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STXT")) {
            MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TIM")) {
            MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTIM")) {
            MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STIM")) {
            MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSP")) {
            MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTSM")) {
            MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STSM")) {
            MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp()
                    .readBuffByEAccSecIdx(Authorization, EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TKN")) {
            MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTOK")) {
            MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STOK")) {
            MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByEAccSecIdx(Authorization,
                    EditAccessSecurityId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    return (resultList.toArray(new MSSBamAtomDefBuff[0]));

}

From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * Converts all the LoanPhysicalObjects.
 * @return true if no errors//from   ww w.ja v  a2s .c om
 */
public boolean convertGiftPreparations() {
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "determination", BasicSQLUtils.myDestinationServerType);
    setIdentityInsertONCommandForSQLServer(newDBConn, "giftpreparation", BasicSQLUtils.myDestinationServerType);

    deleteAllRecordsFromTable(newDBConn, "giftpreparation", BasicSQLUtils.myDestinationServerType); // automatically closes the connection

    if (getNumRecords(oldDBConn, "loanphysicalobject") == 0) {
        setIdentityInsertOFFCommandForSQLServer(newDBConn, "giftpreparation",
                BasicSQLUtils.myDestinationServerType);
        return true;
    }

    Integer recCount = getCount(oldDBConn, "SELECT count(*) FROM loan WHERE Category = 1 ORDER BY LoanID");
    if (recCount == null || recCount == 0) {
        return true;
    }

    // This mapping is used by Gifts
    IdMapperIFace giftsIdMapper = IdMapperMgr.getInstance().get("gift", "GiftID");
    //if (shouldCreateMapTables)
    //{
    //   giftsIdMapper.mapAllIdsWithSQL();
    //}

    // This mapping is used by Gifts Preps

    IdMapperIFace giftPrepsIdMapper = IdMapperMgr.getInstance().get("giftphysicalobject", "id");

    TableWriter tblWriter = convLogger.getWriter("convertGiftPreparations.html", "Gift Preparations");
    TimeLogger timeLogger = new TimeLogger();

    try {
        Map<String, String> colNewToOldMap = createFieldNameMap(
                new String[] { "PreparationID", "PhysicalObjectID" });

        Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        StringBuilder str = new StringBuilder();

        List<String> oldFieldNames = new ArrayList<String>();

        StringBuilder sql = new StringBuilder("SELECT ");
        List<String> names = getFieldNamesFromSchema(oldDBConn, "loanphysicalobject");

        sql.append(buildSelectFieldList(names, "loanphysicalobject"));
        oldFieldNames.addAll(names);

        sql.append(
                " FROM loanphysicalobject INNER JOIN loan ON loanphysicalobject.LoanID = loan.LoanID WHERE loan.Category = 1 ORDER BY loanphysicalobject.LoanPhysicalObjectID");

        log.info(sql);

        List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, "giftpreparation");

        log.info("Number of Fields in New giftpreparation " + newFieldMetaData.size());
        String sqlStr = sql.toString();

        colNewToOldMap.put("GiftID", "LoanID");

        Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>();
        int inx = 1;
        for (String name : oldFieldNames) {
            oldNameIndex.put(name, inx++);
        }

        String tableName = "loanphysicalobject";

        //int quantityIndex   = oldNameIndex.get("Quantity");
        int lastEditedByInx = oldNameIndex.get("LastEditedBy");
        int loanPhysIdIndex = oldNameIndex.get("LoanPhysicalObjectID");

        log.info(sqlStr);
        ResultSet rs = stmt.executeQuery(sqlStr);

        if (hasFrame) {
            if (rs.last()) {
                setProcess(0, rs.getRow());
                rs.first();

            } else {
                rs.close();
                stmt.close();
                return true;
            }
        } else {
            if (!rs.first()) {
                rs.close();
                stmt.close();
                return true;
            }
        }

        String insertStmtStr = null;

        int count = 0;
        do {
            //int quantity         = getIntValue(rs, quantityIndex);
            String lastEditedBy = rs.getString(lastEditedByInx);

            str.setLength(0);

            if (insertStmtStr == null) {
                StringBuffer fieldList = new StringBuffer();
                fieldList.append("( ");
                for (int i = 0; i < newFieldMetaData.size(); i++) {
                    if ((i > 0) && (i < newFieldMetaData.size())) {
                        fieldList.append(", ");
                    }
                    String newFieldName = newFieldMetaData.get(i).getName();
                    fieldList.append(newFieldName + " ");
                }
                fieldList.append(")");
                insertStmtStr = "INSERT INTO giftpreparation " + fieldList + " VALUES (";
            }
            str.append(insertStmtStr);

            for (int i = 0; i < newFieldMetaData.size(); i++) {
                if (i > 0)
                    str.append(", ");

                String newFieldName = newFieldMetaData.get(i).getName();

                if (i == 0) {
                    Integer oldId = rs.getInt(loanPhysIdIndex);
                    Integer newID = giftPrepsIdMapper.get(oldId);
                    if (newID != null) {
                        str.append(getStrValue(newID));
                    } else {
                        String msg = String.format(
                                "loanPhysIdIndex: %d; Old Id: %d could be mapped to a new ID. (This was a fatal error).",
                                loanPhysIdIndex, oldId);
                        tblWriter.logError(msg);
                        log.error(msg);
                        return false;
                    }

                } else if (newFieldName.equals("ReceivedComments")) {
                    str.append("NULL");

                } else if (newFieldName.equalsIgnoreCase("Version")) {
                    str.append("0");

                } else if (newFieldName.equalsIgnoreCase("DisciplineID")) {
                    str.append(getDisciplineId());

                } else if (newFieldName.equalsIgnoreCase("ModifiedByAgentID")) {
                    str.append(getModifiedByAgentId(lastEditedBy));

                } else if (newFieldName.equalsIgnoreCase("CreatedByAgentID")) {
                    str.append(getCreatorAgentId(null));

                } else {
                    Integer index = null;
                    String oldMappedColName = colNewToOldMap.get(newFieldName);
                    if (oldMappedColName != null) {
                        index = oldNameIndex.get(oldMappedColName);

                    } else {
                        index = oldNameIndex.get(newFieldName);
                        oldMappedColName = newFieldName;
                    }

                    Object data;

                    if (index == null) {
                        String msg = "convertGiftPreparations - Couldn't find new field name[" + newFieldName
                                + "] in old field name in index Map";
                        log.warn(msg);
                        //                            stmt.close();
                        //                            tblWriter.logError(msg);
                        //                            showError(msg);
                        //                            throw new RuntimeException(msg);
                        data = null;
                    } else {
                        data = rs.getObject(index);
                    }
                    if (data != null) {
                        if (newFieldName.equalsIgnoreCase("GiftID")) {
                            data = giftsIdMapper.get((Integer) data);

                        } else {
                            int idInx = newFieldName.lastIndexOf("ID");
                            if (idMapperMgr != null && idInx > -1) {
                                IdMapperIFace idMapper = idMapperMgr.get(tableName, oldMappedColName);
                                if (idMapper != null) {
                                    Integer oldId = rs.getInt(index);
                                    data = idMapper.get(oldId);
                                    if (data == null) {
                                        String msg = "No Map ID for [" + tableName + "][" + oldMappedColName
                                                + "] for ID[" + oldId + "]";
                                        log.error(msg);
                                        tblWriter.logError(msg);
                                    }
                                } else {
                                    String msg = "No Map for [" + tableName + "][" + oldMappedColName + "]";
                                    log.error(msg);
                                    tblWriter.logError(msg);
                                }
                            }
                        }
                    }
                    str.append(getStrValue(data, newFieldMetaData.get(i).getType()));
                }
            }
            str.append(")");

            if (hasFrame) {
                if (count % 500 == 0) {
                    setProcess(count);
                }

            } else {
                if (count % 2000 == 0) {
                    log.info("LoanPreparation Records: " + count);
                }
            }

            try {
                Statement updateStatement = newDBConn.createStatement();
                if (BasicSQLUtils.myDestinationServerType != BasicSQLUtils.SERVERTYPE.MS_SQLServer) {
                    removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType);
                }
                // log.debug("executring: " + str.toString());
                // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0");
                updateStatement.executeUpdate(str.toString());
                updateStatement.clearBatch();
                updateStatement.close();
                updateStatement = null;

            } catch (SQLException e) {
                log.error("Count: " + count);
                e.printStackTrace();
                log.error(e);
                rs.close();
                stmt.close();
                throw new RuntimeException(e);
            }

            count++;
            // if (count > 10) break;
        } while (rs.next());

        if (hasFrame) {
            setProcess(count);
            log.info("Processed LoanPreparation " + count + " records.");
        } else {
            log.info("Processed LoanPreparation " + count + " records.");
        }
        rs.close();
        stmt.close();

        tblWriter.log(String.format("Determinations Processing Time: %s", timeLogger.end()));

    } catch (SQLException e) {
        e.printStackTrace();
        log.error(e);
        setIdentityInsertOFFCommandForSQLServer(newDBConn, "LoanPreparation",
                BasicSQLUtils.myDestinationServerType);
        throw new RuntimeException(e);
    }
    log.info("Done processing LoanPhysicalObject");
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "LoanPreparation",
            BasicSQLUtils.myDestinationServerType);

    tblWriter.close();
    return true;

}

From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * @param tableName//from   w  w  w  .java 2  s.  c  o  m
 */
protected void convertLocalityExtraInfo(final String tableName, final boolean isGeoCoordDetail) {
    removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType);

    String capName = capitalize(tableName);
    TableWriter tblWriter = convLogger.getWriter(capName + ".html", capName);
    setTblWriter(tblWriter);
    IdHashMapper.setTblWriter(tblWriter);

    setDesc("Converting " + capName);

    List<String> localityDetailNamesTmp = getFieldNamesFromSchema(newDBConn, tableName);

    List<String> localityDetailNames = new ArrayList<String>();
    Hashtable<String, Boolean> nameHash = new Hashtable<String, Boolean>();

    for (String fieldName : localityDetailNamesTmp) {
        localityDetailNames.add(fieldName);
        nameHash.put(fieldName, true);
        System.out.println("[" + fieldName + "]");
    }

    String fieldList = buildSelectFieldList(localityDetailNames, null);
    log.info(fieldList);

    IdMapperIFace locIdMapper = idMapperMgr.get("locality", "LocalityID");
    IdMapperIFace agtIdMapper = idMapperMgr.get("agent", "AgentID");

    Statement updateStatement = null;
    try {
        updateStatement = newDBConn.createStatement();

        Hashtable<String, Boolean> usedFieldHash = new Hashtable<String, Boolean>();

        Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        Integer countRows = getCount(
                "select count(LocalityID) from locality,geography where locality.GeographyID = geography.GeographyID");
        if (countRows != null) {
            frame.setProcess(0, countRows);
        }

        ResultSet rs = stmt.executeQuery(
                "select locality.*,geography.* from locality LEFT JOIN geography on locality.GeographyID = geography.GeographyID ");

        StringBuilder colSQL = new StringBuilder();
        StringBuilder valuesSQL = new StringBuilder();

        int rows = 0;
        while (rs.next()) {
            usedFieldHash.clear();
            valuesSQL.setLength(0);

            boolean hasData = false;
            ResultSetMetaData metaData = rs.getMetaData();
            int cols = metaData.getColumnCount();
            for (int i = 1; i <= cols; i++) {
                String colName = metaData.getColumnName(i); // Old Column Name

                if (colName.equals("GeoRefDetBy")) {
                    colName = "AgentID";
                }

                if ((nameHash.get(colName) == null || usedFieldHash.get(colName) != null)
                        && !colName.startsWith("Range")) {
                    if (rows == 0) {
                        log.debug("Skipping[" + colName + "]");
                    }
                    continue;
                }

                usedFieldHash.put(colName, true);

                if (rows == 0) {
                    System.err.println("[" + colName + "]");

                    if (colName.equals("Range")) {
                        if (!isGeoCoordDetail) {
                            if (colSQL.length() > 0)
                                colSQL.append(",");
                            colSQL.append("RangeDesc");
                        }

                    } else if (isGeoCoordDetail) {
                        if (!colName.equals("RangeDirection")) {
                            if (colSQL.length() > 0)
                                colSQL.append(",");
                            colSQL.append(colName);
                        }

                    } else {
                        if (colSQL.length() > 0)
                            colSQL.append(",");
                        colSQL.append(colName);
                    }
                }

                String value;
                if (colName.equals("LocalityID")) {
                    Integer oldId = rs.getInt(i);
                    Integer newId = locIdMapper.get(oldId);
                    if (newId != null) {
                        value = Integer.toString(newId);
                    } else {
                        String msg = "Couldn't map LocalityId oldId[" + rs.getInt(i) + "]";
                        log.error(msg);
                        tblWriter.logError(msg);
                        value = "NULL";
                    }

                } else if (isGeoCoordDetail && colName.equals("GeoRefDetDate")) {
                    Integer dateInt = rs.getInt(i);
                    value = getStrValue(dateInt, "date");

                } else if (colName.startsWith("YesNo")) {
                    Integer bool = rs.getInt(i);
                    if (bool == null) {
                        value = "NULL";

                    } else if (bool == 0) {
                        value = "0";
                    } else {
                        value = "1";
                    }
                } else if (isGeoCoordDetail && colName.equals("AgentID")) {
                    Integer agentID = (Integer) rs.getObject(i);
                    if (agentID != null) {
                        Integer newID = agtIdMapper.get(agentID);
                        if (newID != null) {
                            value = newID.toString();
                        } else {
                            String msg = "Couldn't map GeoRefDetBY (Agent) oldId[" + agentID + "]";
                            log.error(msg);
                            tblWriter.logError(msg);
                            value = "NULL";
                        }
                    } else {
                        value = "NULL";
                    }

                } else if (colName.equals("Range") || colName.equals("RangeDirection")) {
                    if (!isGeoCoordDetail) {
                        String range = rs.getString(i);
                        range = escapeStringLiterals(range);
                        if (range != null) {
                            hasData = true;
                            value = "'" + range + "'";
                        } else {
                            value = "NULL";
                        }
                    } else {
                        value = null;
                    }
                } else {
                    Object obj = rs.getObject(i);
                    if (obj != null && !colName.equals("TimestampCreated")
                            && !colName.equals("TimestampModified")) {
                        hasData = true;
                    }
                    /*if (obj instanceof String)
                    {
                    String str = (String)obj;
                    int inx = str.indexOf('\'');
                    if (inx > -1)
                    {
                        obj = escapeStringLiterals(str);
                    }
                    }*/
                    value = getStrValue(obj);
                }
                // log.debug(colName+" ["+value+"]");

                if (value != null) {
                    if (valuesSQL.length() > 0) {
                        valuesSQL.append(",");
                    }
                    valuesSQL.append(value);
                }
            }

            if (hasData) {
                String insertSQL = "INSERT INTO " + tableName + " (" + colSQL.toString()
                        + ", Version, CreatedByAgentID, ModifiedByAgentID) " + " VALUES(" + valuesSQL.toString()
                        + ", 0, " + getCreatorAgentId(null) + "," + getModifiedByAgentId(null) + ")";

                /*if (true)
                {
                log.info(insertSQL);
                }*/
                try {
                    updateStatement.executeUpdate(insertSQL);
                    updateStatement.clearBatch();

                } catch (Exception ex) {
                    System.out.println("isGeoCoordDetail: " + isGeoCoordDetail);
                    System.out.println(insertSQL);
                    ex.printStackTrace();
                }
            }
            rows++;
            if (rows % 500 == 0) {
                frame.setProcess(rows);
            }
        }

        rs.close();
        stmt.close();

    } catch (Exception ex) {
        ex.printStackTrace();

    } finally {
        try {
            updateStatement.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

}

From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java

public MSSBamAtomDefBuff[] readDerivedByEAccFreqIdx(MSSBamAuthorization Authorization,
        Short EditAccessFrequencyId) {
    final String S_ProcName = "readDerivedByEAccFreqIdx";
    if (!schema.isTransactionOpen()) {
        throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName,
                "Transaction not open");
    }/*from ww  w.  j ava  2 s.c  o  m*/
    ArrayList<String> classCodeList = new ArrayList<String>();
    String classCode;
    try {
        Connection cnx = schema.getCnx();
        String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE "
                + ((EditAccessFrequencyId == null) ? "val.EditAccessFrequencyId is null "
                        : "val.EditAccessFrequencyId = " + EditAccessFrequencyId.toString() + " ");
        Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        ResultSet resultSet = stmt.executeQuery(sql);
        while (resultSet.next()) {
            classCode = resultSet.getString(1);
            classCodeList.add(classCode);
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
    ArrayList<MSSBamAtomDefBuff> resultList = new ArrayList<MSSBamAtomDefBuff>();
    ListIterator<String> classCodeIter = classCodeList.listIterator();
    while (classCodeIter.hasNext()) {
        classCode = classCodeIter.next();
        if (classCode.equals("ATM")) {
            MSSBamAtomDefBuff[] subList = readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLB")) {
            MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLB")) {
            MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLB")) {
            MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("BLN")) {
            MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TBLN")) {
            MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SBLN")) {
            MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DAT")) {
            MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDAT")) {
            MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDAT")) {
            MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("DBL")) {
            MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TDBL")) {
            MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SDBL")) {
            MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NUM")) {
            MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNUM")) {
            MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNUM")) {
            MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("FLT")) {
            MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TFLT")) {
            MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SFLT")) {
            MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I16")) {
            MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI16")) {
            MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI16")) {
            MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ENM")) {
            MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TENM")) {
            MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SENM")) {
            MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G16")) {
            MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG16")) {
            MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG16")) {
            MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U16")) {
            MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU16")) {
            MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU16")) {
            MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I32")) {
            MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI32")) {
            MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI32")) {
            MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G32")) {
            MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG32")) {
            MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG32")) {
            MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U32")) {
            MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU32")) {
            MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU32")) {
            MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("I64")) {
            MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TI64")) {
            MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SI64")) {
            MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("G64")) {
            MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TG64")) {
            MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SG64")) {
            MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("U64")) {
            MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TU64")) {
            MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SU64")) {
            MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("UUID")) {
            MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TUUI")) {
            MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SUUI")) {
            MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("IDGU")) {
            MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TGUU")) {
            MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SGUU")) {
            MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMT")) {
            MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTK")) {
            MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTK")) {
            MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("NMS")) {
            MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TNTS")) {
            MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SNTS")) {
            MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STR")) {
            MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSTR")) {
            MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SSTR")) {
            MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZDY")) {
            MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZDY")) {
            MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZDY")) {
            MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZTM")) {
            MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZTM")) {
            MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZTM")) {
            MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("ZSP")) {
            MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TZST")) {
            MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("SZST")) {
            MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TXT")) {
            MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTXT")) {
            MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STXT")) {
            MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TIM")) {
            MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTIM")) {
            MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STIM")) {
            MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TSP")) {
            MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTSM")) {
            MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STSM")) {
            MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp()
                    .readBuffByEAccFreqIdx(Authorization, EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TKN")) {
            MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("TTOK")) {
            MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else if (classCode.equals("STOK")) {
            MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByEAccFreqIdx(Authorization,
                    EditAccessFrequencyId);
            for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) {
                resultList.add(subList[subListIdx]);
            }
        } else {
            throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName,
                    "Did not expect ClassCode \"" + classCode + "\"");
        }
    }
    return (resultList.toArray(new MSSBamAtomDefBuff[0]));

}