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:edu.ku.brc.specify.conversion.GenericDBConversion.java

/**
 * //  w w w  .j a va  2s . c o  m
 */
public void convertLocality() {
    int errorsToShow = BasicSQLUtils.SHOW_ALL;
    log.debug("Preparing to convert localities");
    // Ignore these field names from new table schema when mapping IDs

    setIdentityInsertOFFCommandForSQLServer(newDBConn, "collectionobject",
            BasicSQLUtils.myDestinationServerType);
    setIdentityInsertONCommandForSQLServer(newDBConn, "locality", BasicSQLUtils.myDestinationServerType);
    deleteAllRecordsFromTable("locality", BasicSQLUtils.myDestinationServerType);

    Hashtable<String, String> newToOldColMap = new Hashtable<String, String>();
    newToOldColMap.put("Visibility", "GroupPermittedToView");

    String[] fieldsToIgnore = new String[] { "GML", "NamedPlaceExtent", "GeoRefAccuracyUnits", "GeoRefDetRef",
            "GeoRefDetDate", "GeoRefDetBy", "NoGeoRefBecause", "GeoRefRemarks", "GeoRefVerificationStatus",
            "NationalParkName", "VisibilitySetBy", "GeoRefDetByID", "Drainage", // TODO make sure this is right, meg added due to conversion non-mapping errors????
            "Island", // TODO make sure this is right, meg added due to conversion non-mapping errors????
            "IslandGroup", // TODO make sure this is right, meg added due to conversion non-mapping errors????
            "WaterBody", // TODO make sure this is right, meg added due to conversion non-mapping errors????
            "Version", "CreatedByAgentID", "CollectionMemberID", "ShortName", "DisciplineID", "GUID", "GML",
            "SrcLatLongUnit", "Visibility", "VisibilitySetByID",
            // Special String
            "LocalityName", "NamedPlace", "RelationToNamedPlace", "SGRStatus", "PaleoContextID", "Text3",
            "Text4", "Text5", "VerbatimLatitude", "VerbatimLongitude" };

    setFieldsToIgnoreWhenMappingNames(fieldsToIgnore);

    errorsToShow &= ~BasicSQLUtils.SHOW_NULL_FK; // Turn off this error for LocalityID
    errorsToShow &= ~BasicSQLUtils.SHOW_NAME_MAPPING_ERROR; //Assuming new sp6 fields do not have sp5 equivalent
    setShowErrors(errorsToShow);

    TableWriter tblWriter = convLogger.getWriter("Locality.html", "Localities");
    setTblWriter(tblWriter);
    IdHashMapper.setTblWriter(tblWriter);

    Map<String, String> mappedFields = createFieldNameMap(
            new String[] { "ModifiedByAgentID", "LastEditedBy", });

    String sql = "SELECT locality.*,g.* FROM locality LEFT JOIN geography g on locality.GeographyID = g.GeographyID WHERE locality.GeographyID IS NOT NULL";

    if (copyTable(oldDBConn, newDBConn, sql, "locality", "locality", mappedFields, null,
            BasicSQLUtils.mySourceServerType, BasicSQLUtils.myDestinationServerType)) {
        log.info("Locality/Geography copied ok.");
    } else {
        log.error("Copying locality/geography (fields) to new Locality");
    }

    setFieldsToIgnoreWhenMappingNames(fieldsToIgnore);

    sql = "SELECT * FROM locality WHERE locality.GeographyID IS NULL";

    if (copyTable(oldDBConn, newDBConn, sql, "locality", "locality", mappedFields, null,
            BasicSQLUtils.mySourceServerType, BasicSQLUtils.myDestinationServerType)) {
        log.info("Locality/Geography copied ok.");
    } else {
        log.error("Copying locality/geography (fields) to new Locality");
    }

    frame.setProcess(0, BasicSQLUtils.getCountAsInt("SELECT COUNT(*) FROM locality"));

    PreparedStatement pStmt = null;
    Statement stmt = null;
    sql = "SELECT LocalityID, LocalityName, NamedPlace, RelationToNamedPlace, Remarks FROM locality ORDER BY LocalityID";
    try {
        IdMapperIFace locMapper = idMapperMgr.get("locality_LocalityID");
        pStmt = newDBConn.prepareStatement(
                "UPDATE locality SET LocalityName=?, NamedPlace=?, RelationToNamedPlace=?, Remarks=? WHERE LocalityID=?");
        stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);

        ResultSet rs = stmt.executeQuery(sql);
        int cnt = 0;
        while (rs.next()) {
            int oldId = rs.getInt(1);
            Integer newId = locMapper.get(oldId);
            if (newId != null) {
                pStmt.setString(1, rs.getString(2));
                pStmt.setString(2, rs.getString(3));
                pStmt.setString(3, rs.getString(4));
                pStmt.setString(4, rs.getString(5));
                pStmt.setInt(5, newId);

                pStmt.execute();

                /*if (!pStmt.execute())
                {
                if ()
                String msg = "Error Updating OldId ["+rs.getInt(1)+"] NewId ["+newId+"]";
                log.error(msg);
                tblWriter.logErrors(Integer.toString(rs.getInt(1)), msg);
                }*/

            } else {
                String msg = "No Mapping for OldId [" + rs.getInt(1) + "]";
                log.error(msg);
                tblWriter.logErrors(Integer.toString(rs.getInt(1)), msg);
            }
            cnt++;
            if (cnt % 500 == 0) {
                frame.setProcess(cnt);
            }
        }

        frame.setProcess(cnt);

    } catch (Exception ex) {
        log.error(ex);
        tblWriter.logErrors("Exception", ex.toString());
    } finally {
        try {
            if (stmt != null)
                stmt.close();
            if (pStmt != null)
                pStmt.close();

        } catch (SQLException ex) {

        }
    }

    convertLocalityExtraInfo("localitydetail", false);
    convertLocalityExtraInfo("geocoorddetail", true);

    setFieldsToIgnoreWhenMappingNames(null);
    setIdentityInsertOFFCommandForSQLServer(newDBConn, "locality", BasicSQLUtils.myDestinationServerType);

    setTblWriter(null);
    IdHashMapper.setTblWriter(null);
}

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

/**
 * @param treeDef//from www .  jav a  2  s.  com
 * @throws SQLException
 */
public void convertGeography(final GeographyTreeDef treeDef, final String dispName, final boolean firstTime)
        throws SQLException {
    TableWriter tblWriter = convLogger.getWriter("Geography" + (dispName != null ? dispName : "") + ".html",
            "Geography");
    setTblWriter(tblWriter);

    IdHashMapper.setTblWriter(tblWriter);

    if (firstTime) {
        // empty out any pre-existing records
        deleteAllRecordsFromTable(newDBConn, "geography", BasicSQLUtils.myDestinationServerType);
    }

    IdTableMapper geoIdMapper = (IdTableMapper) IdMapperMgr.getInstance().get("geography", "GeographyID");
    if (geoIdMapper == null) {
        // create an ID mapper for the geography table (mainly for use in converting localities)
        geoIdMapper = IdMapperMgr.getInstance().addTableMapper("geography", "GeographyID");
    } else {
        geoIdMapper.clearRecords();
    }

    Hashtable<Integer, Geography> oldIdToGeoMap = new Hashtable<Integer, Geography>();

    // get a Hibernate session for saving the new records
    Session localSession = HibernateUtil.getCurrentSession();
    HibernateUtil.beginTransaction();

    // get all of the old records
    String sql = "SELECT GeographyID,ContinentOrOcean,Country,State,County,LastEditedBy FROM geography";
    Statement statement = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);
    statement.setFetchSize(Integer.MIN_VALUE);

    ResultSet oldGeoRecords = statement.executeQuery(sql);

    fixGeography("ContinentOrOcean");
    fixGeography("Country");
    fixGeography("State");
    fixGeography("County");

    if (hasFrame) {
        if (oldGeoRecords.last()) {
            setProcess(0, oldGeoRecords.getRow());
            oldGeoRecords.first();
        }
    } else {
        oldGeoRecords.first();
    }

    // setup the root Geography record (planet Earth)
    Geography planetEarth = new Geography();
    planetEarth.initialize();
    planetEarth.setName("Earth");
    planetEarth.setCommonName("Earth");
    planetEarth.setRankId(0);
    planetEarth.setDefinition(treeDef);
    for (GeographyTreeDefItem defItem : treeDef.getTreeDefItems()) {
        if (defItem.getRankId() == 0) {
            planetEarth.setDefinitionItem(defItem);
            break;
        }
    }
    GeographyTreeDefItem defItem = treeDef.getDefItemByRank(0);
    planetEarth.setDefinitionItem(defItem);

    int counter = 0;
    // for each old record, convert the record
    do {
        if (counter % 500 == 0) {
            if (hasFrame) {
                setProcess(counter);

            } else {
                log.info("Converted " + counter + " geography records");
            }
        }

        // grab the important data fields from the old record
        int oldId = oldGeoRecords.getInt(1);
        String cont = fixSize(tblWriter, oldId, "continent", oldGeoRecords.getString(2), 64);
        String country = fixSize(tblWriter, oldId, "country", oldGeoRecords.getString(3), 64);
        String state = fixSize(tblWriter, oldId, "state", oldGeoRecords.getString(4), 64);
        String county = fixSize(tblWriter, oldId, "county", oldGeoRecords.getString(5), 64);
        String lastEditedBy = oldGeoRecords.getString(6);

        Integer agtId = getCreatorAgentId(lastEditedBy);
        Agent createdByAgent = getCreatedByAgent(localSession, agtId);
        Agent modifiedByAgent = getAgentObj(localSession, getCurAgentModifierID());

        /*cont    = isNotEmpty(county)  && cont.equals("null")    ? null : cont;
        country = isNotEmpty(country) && country.equals("null") ? null : country;
        state   = isNotEmpty(state)   && state.equals("null")   ? null : state;
        county  = isNotEmpty(county)  && county.equals("null")  ? null : county;
        */

        if (isEmpty(cont) && isEmpty(country) && isEmpty(state) && isEmpty(county)) {
            //String msg = "For Record Id["+oldId+"] Continent, Country, State and County are all null.";
            //log.error(msg);
            //tblWriter.logError(msg);

            cont = "Undefined";
            country = "Undefined";
            state = "Undefined";
            county = "Undefined";

        } else if (isEmpty(cont) && isEmpty(country) && isEmpty(state)) {
            //String msg = "For Record Id["+oldId+"] Continent, Country and State are all null.";
            //log.error(msg);
            //tblWriter.logError(msg);

            cont = "Undefined";
            country = "Undefined";
            state = "Undefined";

        } else if (isEmpty(cont) && isEmpty(country)) {
            //String msg = "For Record Id["+oldId+"] Country is null.";
            //log.error(msg);
            //tblWriter.logError(msg);

            cont = "Undefined";
            country = "Undefined";

        } else if (isEmpty(cont)) {
            //String msg = "For Record Id["+oldId+"] Country is null.";
            //log.error(msg);
            //tblWriter.logError(msg);

            cont = "Undefined";
        }

        // create a new Geography object from the old data
        List<Geography> newGeos = convertOldGeoRecord(cont, country, state, county, createdByAgent,
                modifiedByAgent, planetEarth);
        if (newGeos.size() > 0) {
            Geography lowestLevel = newGeos.get(newGeos.size() - 1);

            oldIdToGeoMap.put(oldId, lowestLevel);
        }

        counter++;

    } while (oldGeoRecords.next());

    if (hasFrame) {
        setProcess(counter);

    } else {
        log.info("Converted " + counter + " geography records");
    }

    TreeHelper.fixFullnameForNodeAndDescendants(planetEarth);
    planetEarth.setNodeNumber(1);
    fixNodeNumbersFromRoot(planetEarth);

    localSession.save(planetEarth);

    HibernateUtil.commitTransaction();
    log.info("Converted " + counter + " geography records");

    if (shouldCreateMapTables) {
        // add all of the ID mappings
        for (Integer oldId : oldIdToGeoMap.keySet()) {
            Geography geo = oldIdToGeoMap.get(oldId);
            geoIdMapper.put(oldId, geo.getId());
        }
    }

    if (firstTime) {
        // set up Geography foreign key mapping for locality
        idMapperMgr.mapForeignKey("Locality", "GeographyID", "Geography", "GeographyID");
    }
}

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

/**
 * @param treeDef/*w w  w  .  j  a  va2  s  .  c om*/
 * @throws SQLException
 */
public void convertLithoStratGeneral(final LithoStratTreeDef treeDef, final LithoStrat earth,
        final TableWriter tblWriter, final String srcTableName) throws SQLException {
    Statement stmt = null;
    ResultSet rs = null;
    String s = "";
    try {
        // get a Hibernate session for saving the new records
        Session localSession = HibernateUtil.getCurrentSession();
        HibernateUtil.beginTransaction();

        int count = BasicSQLUtils.getCountAsInt(oldDBConn, "SELECT COUNT(*) FROM " + srcTableName);
        if (count < 1)
            return;

        if (hasFrame) {
            setProcess(0, count);
        }

        // create an ID mapper for the geography table (mainly for use in converting localities)
        IdHashMapper lithoStratIdMapper = IdMapperMgr.getInstance().addHashMapper("stratigraphy_StratigraphyID",
                true);
        if (lithoStratIdMapper == null) {
            UIRegistry.showError("The lithoStratIdMapper was null.");
            return;
        }

        IdMapperIFace gtpIdMapper = IdMapperMgr.getInstance().get("geologictimeperiod", "GeologicTimePeriodID");

        IdMapperIFace ceMapper = IdMapperMgr.getInstance().get("collectingevent", "CollectingEventID");
        if (ceMapper == null) {
            ceMapper = IdMapperMgr.getInstance().addTableMapper("collectingevent", "CollectingEventID", null,
                    false);
        }
        String sql = String.format(
                "SELECT s.StratigraphyID, s.SuperGroup, s.Group, s.Formation, s.Member, s.Bed, Remarks, "
                        + "Text1, Text2, Number1, Number2, YesNo1, YesNo2, GeologicTimePeriodID FROM %s s "
                        + "ORDER BY s.StratigraphyID",
                srcTableName);

        stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        rs = stmt.executeQuery(sql);

        Map<Integer, Pair<Integer, Integer>> stratHash = new HashMap<Integer, Pair<Integer, Integer>>();

        int stratsWithNoGTP = 0;
        int stratsWithNoMappedGTP = 0;
        int missingCEMapping = 0;

        int lithoCnt = 0;

        int counter = 0;
        // for each old record, convert the record
        while (rs.next()) {
            if (counter % 500 == 0) {
                if (hasFrame) {
                    setProcess(counter);

                } else {
                    log.info("Converted " + counter + " Stratigraphy records");
                }
            }

            // grab the important data fields from the old record
            int oldStratId = rs.getInt(1); // This is a one-to-one with CollectingEvent
            String superGroup = rs.getString(2);
            String lithoGroup = rs.getString(3);
            String formation = rs.getString(4);
            String member = rs.getString(5);
            String bed = rs.getString(6);
            String remarks = escapeStringLiterals(rs.getString(7));
            String text1 = escapeStringLiterals(rs.getString(8));
            String text2 = escapeStringLiterals(rs.getString(9));
            Double number1 = rs.getObject(10) != null ? rs.getDouble(10) : null;
            Double number2 = rs.getObject(11) != null ? rs.getDouble(11) : null;
            Boolean yesNo1 = rs.getObject(12) != null ? rs.getBoolean(12) : null;
            Boolean yesNo2 = rs.getObject(13) != null ? rs.getBoolean(13) : null;
            Integer oldGTPId = rs.getObject(14) != null ? rs.getInt(14) : null;

            // Check to see if there is any Litho information OR an GTP Id
            // If both are missing then skip the record.
            boolean hasLithoFields = isNotEmpty(superGroup) || isNotEmpty(lithoGroup) || isNotEmpty(formation)
                    || isNotEmpty(member);
            if (!hasLithoFields && oldGTPId == null) {
                continue;
            }

            Integer gtpId = null;
            if (oldGTPId != null) {
                gtpId = gtpIdMapper.get(oldGTPId);
                if (gtpId == null) {
                    tblWriter.logError("Old GTPID[" + gtpId
                            + "] in the Strat record could not be mapped for Old StratID[" + oldStratId + "]");
                    stratsWithNoMappedGTP++;
                }
            } else {
                stratsWithNoGTP++;
            }

            // There may not be any Litho information to add to the LithoStrat tree, 
            // but it did have GTP Information if we got here
            Integer lithoStratID = null;
            if (hasLithoFields) {
                // create a new Geography object from the old data
                LithoStrat[] newStrats = convertOldStratRecord(superGroup, lithoGroup, formation, member, bed,
                        remarks, text1, text2, number1, number2, yesNo1, yesNo2, earth, localSession);

                LithoStrat newStrat = getLastLithoStrat(newStrats);
                counter++;
                lithoCnt += newStrats.length;

                // Map Old LithoStrat ID to the new Tree Id
                //System.out.println(oldStratId + " " + newStrat.getLithoStratId());
                if (newStrat != null) {
                    lithoStratID = newStrat.getLithoStratId();
                    lithoStratIdMapper.put(oldStratId, newStrat.getLithoStratId());
                } else {
                    String msg = String.format("Strat Fields were all null for oldID", oldStratId);
                    tblWriter.logError(msg);
                    log.error(msg);
                    missingCEMapping++;
                }
            }
            if (lithoStratID != null || gtpId != null) {
                Integer newCEId = ceMapper.get(oldStratId);
                if (newCEId == null) {
                    String msg = String.format("No CE mapping for Old StratId %d, when they are a one-to-one.",
                            oldStratId);
                    tblWriter.logError(msg);
                    log.error(msg);
                    missingCEMapping++;
                } else {
                    stratHash.put(newCEId, new Pair<Integer, Integer>(gtpId, lithoStratID));
                }
            }
        }
        stmt.close();

        System.out.println("lithoCnt: " + lithoCnt);

        if (hasFrame) {
            setProcess(counter);
        } else {
            log.info("Converted " + counter + " Stratigraphy records");
        }

        TreeHelper.fixFullnameForNodeAndDescendants(earth);
        earth.setNodeNumber(1);
        fixNodeNumbersFromRoot(earth);

        HibernateUtil.commitTransaction();
        log.info("Converted " + counter + " Stratigraphy records");

        rs.close();

        Statement updateStatement = newDBConn.createStatement();

        int ceCnt = BasicSQLUtils.getCountAsInt(oldDBConn,
                "SELECT Count(CollectingEventID) FROM collectingevent");
        int stratCnt = BasicSQLUtils.getCountAsInt(oldDBConn,
                String.format("SELECT Count(CollectingEventID) FROM collectingevent "
                        + "INNER JOIN %s ON CollectingEventID = StratigraphyID", srcTableName));

        String msg = String.format("There are %d CE->Strat and %d CEs. The diff is %d", stratCnt, ceCnt,
                (ceCnt - stratCnt));
        tblWriter.log(msg);
        log.debug(msg);

        // Create a PaleoContext for each ColObj
        stmt = newDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);

        int processCnt = BasicSQLUtils
                .getCountAsInt("SELECT COUNT(*) FROM collectionobject WHERE CollectingEventID IS NOT NULL");
        if (frame != null) {
            frame.setDesc("Converting PaleoContext...");
            frame.setProcess(0, processCnt);
        }

        TreeSet<Integer> missingStratIds = new TreeSet<Integer>();

        int missingStrat = 0;
        int missingGTP = 0;
        int coUpdateCnt = 0;
        int cnt = 0;
        sql = "SELECT CollectionObjectID, CollectingEventID FROM collectionobject WHERE CollectingEventID IS NOT NULL ORDER BY CollectionObjectID";
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            int coId = rs.getInt(1); // New CO Id
            Integer ceId = rs.getInt(2); // New CE Id

            Pair<Integer, Integer> strat = stratHash.get(ceId);
            Integer newLithoId = null;
            Integer gtpId = null;
            if (strat != null) {
                gtpId = strat.getFirst();
                newLithoId = strat.getSecond();
            }

            if (newLithoId == null) {
                missingStrat++;
                missingStratIds.add(ceId);
                if (gtpId == null)
                    continue;
            }

            try {
                String updateStr = "INSERT INTO paleocontext (TimestampCreated, TimestampModified, DisciplineID, Version, CreatedByAgentID, ModifiedByAgentID, LithoStratID, ChronosStratID) "
                        + "VALUES ('" + nowStr + "','" + nowStr + "'," + getDisciplineId() + ", 0, "
                        + getCreatorAgentId(null) + "," + getModifiedByAgentId(null) + ","
                        + (newLithoId != null ? newLithoId : "NULL") + "," + (gtpId != null ? gtpId : "NULL")
                        + ")";
                updateStatement.executeUpdate(updateStr, Statement.RETURN_GENERATED_KEYS);

                Integer paleoContextID = getInsertedId(updateStatement);
                if (paleoContextID == null) {
                    throw new RuntimeException("Couldn't get the Agent's inserted ID");
                }

                String sqlUpdate = "UPDATE collectionobject SET PaleoContextID=" + paleoContextID
                        + " WHERE CollectionObjectID = " + coId;
                updateStatement.executeUpdate(sqlUpdate);
                coUpdateCnt++;
            } catch (SQLException e) {
                e.printStackTrace();
                log.error(e);
                showError(e.getMessage());
                throw new RuntimeException(e);
            }
            processCnt++;
            if (frame != null && cnt % 100 == 0)
                frame.setProcess(cnt);
        }
        rs.close();
        stmt.close();

        if (frame != null)
            frame.setProcess(processCnt);

        msg = String.format("There are %d unmappable Strat Records and %d unmappable GTP records.",
                missingStrat, missingGTP);
        tblWriter.log(msg);
        log.debug(msg);

        msg = String.format("There are %d CO records updated.", coUpdateCnt);
        tblWriter.log(msg);
        log.debug(msg);
        updateStatement.close();

        msg = String.format("No CE mapping for Old StratId Count: %d", missingCEMapping);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Strats with No GTP Count: %d", stratsWithNoGTP);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Strats with missing Mapping to GTP Count: %d", stratsWithNoMappedGTP);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Number of Old StratIds mapped to a new Strat ID Count: %d",
                lithoStratIdMapper.size());
        tblWriter.logError(msg);
        log.error(msg);

        StringBuilder sb = new StringBuilder();
        sb.append("Missing New Strat: ");
        if (missingStratIds.size() == 0)
            sb.append("None");

        for (Integer id : missingStratIds) {
            sb.append(String.format("%d, ", id));
        }
        tblWriter.logError(sb.toString());
        log.error(sb.toString());

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

    // Now in this Step we Add the PaleoContext to the Collecting Events

}

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

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

/**
 * @param treeDef//from w  w  w. j a v  a  2s.c om
 * @throws SQLException
 */
public void convertLithoStratCustom(final LithoStratTreeDef treeDef, final LithoStrat earth,
        final TableWriter tblWriter, final String srcTableName, final boolean doMapGTPIds) throws SQLException {
    Statement stmt = null;
    ResultSet rs = null;
    String s = "";
    try {
        // get a Hibernate session for saving the new records
        Session localSession = HibernateUtil.getCurrentSession();
        HibernateUtil.beginTransaction();

        int count = BasicSQLUtils.getCountAsInt(oldDBConn, "SELECT COUNT(*) FROM " + srcTableName);
        if (count < 1)
            return;

        if (hasFrame) {
            setProcess(0, count);
        }

        // create an ID mapper for the geography table (mainly for use in converting localities)
        IdHashMapper lithoStratIdMapper = IdMapperMgr.getInstance().addHashMapper("stratigraphy_StratigraphyID",
                true);
        if (lithoStratIdMapper == null) {
            UIRegistry.showError("The lithoStratIdMapper was null.");
            return;
        }

        IdTableMapper gtpIdMapper = IdMapperMgr.getInstance().addTableMapper("geologictimeperiod",
                "GeologicTimePeriodID", null, false);
        if (doMapGTPIds) {
            gtpIdMapper.clearRecords();
            gtpIdMapper.mapAllIds();
        }

        Hashtable<Integer, Integer> stratGTPIdHash = new Hashtable<Integer, Integer>();
        //Hashtable<Integer, Integer> newCEIdToNewStratIdHash = new Hashtable<Integer, Integer>();

        // stratigraphy2 goes here.
        IdHashMapper newCEIdToNewStratIdHash = IdMapperMgr.getInstance()
                .addHashMapper("stratigraphy_StratigraphyID_2", true);
        newCEIdToNewStratIdHash.setShowLogErrors(false);

        IdMapperIFace ceMapper = IdMapperMgr.getInstance().get("collectingevent", "CollectingEventID");
        if (ceMapper == null) {
            ceMapper = IdMapperMgr.getInstance().addTableMapper("collectingevent", "CollectingEventID", null,
                    false);
        }
        // get all of the old records
        //            String sql  = String.format("SELECT s.StratigraphyID, s.SuperGroup, s.Group, s.Formation, s.Member, s.Bed, Remarks, " +
        //                                      "Text1, Text2, Number1, Number2, YesNo1, YesNo2, GeologicTimePeriodID FROM %s s " +
        //                                       "WHERE s.SuperGroup IS NOT NULL OR s.Group IS NOT NULL OR s.Formation IS NOT NULL OR " +
        //                                       "s.Member IS NOT NULL OR s.Bed IS NOT NULL ORDER BY s.StratigraphyID", srcTableName);
        String sql = String.format(
                "SELECT s.StratigraphyID, s.SuperGroup, s.Group, s.Formation, s.Member, s.Bed, Remarks, "
                        + "Text1, Text2, Number1, Number2, YesNo1, YesNo2, GeologicTimePeriodID FROM %s s "
                        + "ORDER BY s.StratigraphyID",
                srcTableName);

        stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);
        rs = stmt.executeQuery(sql);

        int stratsWithNoGTP = 0;
        int stratsWithNoMappedGTP = 0;
        int missingCEMapping = 0;

        int lithoCnt = 0;

        int counter = 0;
        // for each old record, convert the record
        while (rs.next()) {
            if (counter % 500 == 0) {
                if (hasFrame) {
                    setProcess(counter);

                } else {
                    log.info("Converted " + counter + " Stratigraphy records");
                }
            }

            // grab the important data fields from the old record
            int oldStratId = rs.getInt(1); // This is a one-to-one with CollectingEvent
            String superGroup = rs.getString(2);
            String lithoGroup = rs.getString(3);
            String formation = rs.getString(4);
            String member = rs.getString(5);
            String bed = rs.getString(6);
            String remarks = escapeStringLiterals(rs.getString(7));
            String text1 = escapeStringLiterals(rs.getString(8));
            String text2 = escapeStringLiterals(rs.getString(9));
            Double number1 = rs.getObject(10) != null ? rs.getDouble(10) : null;
            Double number2 = rs.getObject(11) != null ? rs.getDouble(11) : null;
            Boolean yesNo1 = rs.getObject(12) != null ? rs.getBoolean(12) : null;
            Boolean yesNo2 = rs.getObject(13) != null ? rs.getBoolean(13) : null;
            Integer oldGTPId = rs.getObject(14) != null ? rs.getInt(14) : null;

            // Check to see if there is any Litho information OR an GTP Id
            // If both are missing then skip the record.
            boolean hasLithoFields = isNotEmpty(superGroup) || isNotEmpty(lithoGroup) || isNotEmpty(formation)
                    || isNotEmpty(member);
            if (!hasLithoFields && oldGTPId == null) {
                continue;
            }

            Integer gtpId = null;
            if (doMapGTPIds) {
                if (oldGTPId != null) {
                    gtpId = oldGTPId;
                }
            } else {
                gtpId = oldStratId;
            }

            if (gtpId != null) {
                gtpId = gtpIdMapper.get(gtpId);
                if (gtpId == null) {
                    tblWriter.logError("Old GTPID[" + gtpId
                            + "] in the Strat record could not be mapped for Old StratID[" + oldStratId + "]");
                    stratsWithNoMappedGTP++;
                }
            } else {
                stratsWithNoGTP++;
            }

            // There may not be any Litho information to add to the LithoStrat tree, 
            // but it did have GTP Information if we got here
            if (hasLithoFields) {
                // create a new Geography object from the old data
                LithoStrat[] newStrats = convertOldStratRecord(superGroup, lithoGroup, formation, member, bed,
                        remarks, text1, text2, number1, number2, yesNo1, yesNo2, earth, localSession);

                LithoStrat newStrat = getLastLithoStrat(newStrats);
                counter++;
                lithoCnt += newStrats.length;

                // Map Old LithoStrat ID to the new Tree Id
                //System.out.println(oldStratId + " " + newStrat.getLithoStratId());
                if (newStrat != null) {
                    lithoStratIdMapper.put(oldStratId, newStrat.getLithoStratId());

                    // Convert Old CEId (StratID) to new CEId, then map the new CEId -> new StratId
                    Integer newCEId = ceMapper.get(oldStratId);
                    if (newCEId != null) {
                        newCEIdToNewStratIdHash.put(newCEId, newStrat.getLithoStratId());
                    } else {
                        String msg = String.format(
                                "No CE mapping for Old StratId %d, when they are a one-to-one.", oldStratId);
                        tblWriter.logError(msg);
                        log.error(msg);
                        missingCEMapping++;
                    }

                    // Map the New StratId to the new GTP Id
                    if (gtpId != null && stratGTPIdHash.get(newStrat.getLithoStratId()) == null) {
                        stratGTPIdHash.put(newStrat.getLithoStratId(), gtpId); // new ID to new ID
                    }
                } else {
                    String msg = String.format("Strat Fields were all null for oldID", oldStratId);
                    tblWriter.logError(msg);
                    log.error(msg);
                    missingCEMapping++;
                }
            }
        }
        stmt.close();

        System.out.println("lithoCnt: " + lithoCnt);

        if (hasFrame) {
            setProcess(counter);

        } else {
            log.info("Converted " + counter + " Stratigraphy records");
        }

        TreeHelper.fixFullnameForNodeAndDescendants(earth);
        earth.setNodeNumber(1);
        fixNodeNumbersFromRoot(earth);

        HibernateUtil.commitTransaction();
        log.info("Converted " + counter + " Stratigraphy records");

        rs.close();

        Statement updateStatement = newDBConn.createStatement();

        //Hashtable<Integer, Integer> ceToPCHash = new Hashtable<Integer, Integer>();

        int ceCnt = BasicSQLUtils.getCountAsInt(oldDBConn,
                "SELECT Count(CollectingEventID) FROM collectingevent");
        int stratCnt = BasicSQLUtils.getCountAsInt(oldDBConn,
                String.format("SELECT Count(CollectingEventID) FROM collectingevent "
                        + "INNER JOIN %s ON CollectingEventID = StratigraphyID", srcTableName));

        String msg = String.format("There are %d CE->Strat and %d CEs. The diff is %d", stratCnt, ceCnt,
                (ceCnt - stratCnt));
        tblWriter.log(msg);
        log.debug(msg);

        // Create a PaleoContext for each ColObj
        stmt = newDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);

        int processCnt = BasicSQLUtils
                .getCountAsInt("SELECT COUNT(*) FROM collectionobject WHERE CollectingEventID IS NOT NULL");
        if (frame != null) {
            frame.setDesc("Converting PaleoContext...");
            frame.setProcess(0, processCnt);
        }

        TreeSet<Integer> missingStratIds = new TreeSet<Integer>();

        int missingStrat = 0;
        int missingGTP = 0;
        int coUpdateCnt = 0;
        int cnt = 0;
        sql = "SELECT CollectionObjectID, CollectingEventID FROM collectionobject WHERE CollectingEventID IS NOT NULL ORDER BY CollectionObjectID";
        rs = stmt.executeQuery(sql);
        while (rs.next()) {
            int coId = rs.getInt(1); // New CO Id
            Integer ceId = rs.getInt(2); // New CE Id

            // Use the new CE ID to get the new Strat Id
            Integer newLithoId = newCEIdToNewStratIdHash.get(ceId);
            Integer gtpId = null;

            if (newLithoId == null) {
                missingStrat++;
                missingStratIds.add(ceId);

                Integer oldStratID = ceMapper.reverseGet(ceId);
                if (oldStratID != null) {
                    sql = "SELECT GeologicTimePeriodID FROM stratigraphy WHERE StratigraphyID = " + oldStratID;
                    Integer oldGTPId = BasicSQLUtils.getCount(oldDBConn, sql);
                    if (oldGTPId != null) {
                        gtpId = gtpIdMapper.get(oldGTPId);
                    }
                }
                if (gtpId == null)
                    continue;
            }

            // Use the new StratID to get the new GTP Id (ChronosStratigraphy)
            if (gtpId == null) {
                gtpId = stratGTPIdHash.get(newLithoId);
                if (gtpId == null) {
                    missingGTP++;
                    if (newLithoId == null)
                        continue;
                }
            }

            try {
                String updateStr = "INSERT INTO paleocontext (TimestampCreated, TimestampModified, DisciplineID, Version, CreatedByAgentID, ModifiedByAgentID, LithoStratID, ChronosStratID) "
                        + "VALUES ('" + nowStr + "','" + nowStr + "'," + getDisciplineId() + ", 0, "
                        + getCreatorAgentId(null) + "," + getModifiedByAgentId(null) + ","
                        + (newLithoId != null ? newLithoId : "NULL") + "," + (gtpId != null ? gtpId : "NULL")
                        + ")";
                updateStatement.executeUpdate(updateStr, Statement.RETURN_GENERATED_KEYS);

                Integer paleoContextID = getInsertedId(updateStatement);
                if (paleoContextID == null) {
                    throw new RuntimeException("Couldn't get the Agent's inserted ID");
                }

                String sqlUpdate = "UPDATE collectionobject SET PaleoContextID=" + paleoContextID
                        + " WHERE CollectionObjectID = " + coId;
                updateStatement.executeUpdate(sqlUpdate);
                coUpdateCnt++;

            } catch (SQLException e) {
                e.printStackTrace();
                log.error(e);
                showError(e.getMessage());
                throw new RuntimeException(e);
            }
            processCnt++;
            if (frame != null && cnt % 100 == 0)
                frame.setProcess(cnt);

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

        if (frame != null)
            frame.setProcess(processCnt);

        msg = String.format("There are %d unmappable Strat Records and %d unmappable GTP records.",
                missingStrat, missingGTP);
        tblWriter.log(msg);
        log.debug(msg);

        msg = String.format("There are %d CO records updated.", coUpdateCnt);
        tblWriter.log(msg);
        log.debug(msg);
        updateStatement.close();

        msg = String.format("No CE mapping for Old StratId Count: %d", missingCEMapping);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Strats with No GTP Count: %d", stratsWithNoGTP);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Strats with missing Mapping to GTP Count: %d", stratsWithNoMappedGTP);
        tblWriter.logError(msg);
        log.error(msg);

        msg = String.format("Number of Old StratIds mapped to a new Strat ID Count: %d",
                lithoStratIdMapper.size());
        tblWriter.logError(msg);
        log.error(msg);

        StringBuilder sb = new StringBuilder();
        sb.append("Missing New Strat: ");
        if (missingStratIds.size() == 0)
            sb.append("None");

        for (Integer id : missingStratIds) {
            sb.append(String.format("%d, ", id));
        }
        tblWriter.logError(sb.toString());
        log.error(sb.toString());

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

    // Now in this Step we Add the PaleoContext to the Collecting Events

}

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

/**
 * Walks the old GTP records and creates a GTP tree def and items based on the ranks and rank
 * names found in the old records// ww  w  . j a va 2s  . co  m
 * 
 * @return the new tree def
 * @throws SQLException on any error while contacting the old database
 */
public GeologicTimePeriodTreeDef convertGTPDefAndItems(final boolean isPaleo) throws SQLException {
    deleteAllRecordsFromTable("geologictimeperiodtreedef", BasicSQLUtils.myDestinationServerType);
    deleteAllRecordsFromTable("geologictimeperiodtreedefitem", BasicSQLUtils.myDestinationServerType);
    log.info("Inferring geologic time period definition from old records");
    int count = 0;

    // get all of the old records
    String sql = "SELECT RankCode, RankName from geologictimeperiod";
    Statement statement = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);
    statement.setFetchSize(Integer.MIN_VALUE);

    ResultSet oldGtpRecords = statement.executeQuery(sql);

    Session localSession = HibernateUtil.getCurrentSession();
    HibernateUtil.beginTransaction();

    GeologicTimePeriodTreeDef def = new GeologicTimePeriodTreeDef();
    def.initialize();
    def.setName("Inferred Geologic Time Period Definition");
    def.setRemarks("");
    def.setFullNameDirection(TreeDefIface.REVERSE);
    localSession.save(def);

    Vector<GeologicTimePeriodTreeDefItem> newItems = new Vector<GeologicTimePeriodTreeDefItem>();

    GeologicTimePeriodTreeDefItem rootItem = addGtpDefItem(0, "Time Root", def);
    rootItem.setIsEnforced(true);
    rootItem.setIsInFullName(false);
    rootItem.setFullNameSeparator(", ");
    localSession.save(rootItem);
    newItems.add(rootItem);
    ++count;

    if (isPaleo) {
        while (oldGtpRecords.next()) {
            // we're modifying the rank since the originals were 1,2,3,...
            // to make them 100, 200, 300, ... (more like the other trees)
            Integer rankCode = oldGtpRecords.getInt(1) * 100;
            String rankName = oldGtpRecords.getString(2);
            GeologicTimePeriodTreeDefItem newItem = addGtpDefItem(rankCode, rankName, def);
            if (newItem != null) {
                newItem.setFullNameSeparator(", ");
                localSession.save(newItem);
                newItems.add(newItem);
            }
            if (++count % 1000 == 0) {
                log.info(count + " geologic time period records processed");
            }
        }
    }

    // sort the vector to put them in parent/child order
    Comparator<GeologicTimePeriodTreeDefItem> itemComparator = new Comparator<GeologicTimePeriodTreeDefItem>() {
        public int compare(GeologicTimePeriodTreeDefItem o1, GeologicTimePeriodTreeDefItem o2) {
            return o1.getRankId().compareTo(o2.getRankId());
        }
    };
    Collections.sort(newItems, itemComparator);

    // set the parent/child pointers
    for (int i = 0; i < newItems.size() - 1; ++i) {
        GeologicTimePeriodTreeDefItem parent = newItems.get(i);
        GeologicTimePeriodTreeDefItem child = newItems.get(i + 1);
        parent.setChild(child);
        child.setParent(parent);
    }

    HibernateUtil.commitTransaction();

    log.info("Finished inferring GTP tree definition and items");
    return def;
}

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

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

/**
 * @param tblWriter/*from  ww w.  j ava  2  s .  c  om*/
 * @param treeDef
 * @param isPaleo
 * @throws SQLException
 */
public void convertGTP(final TableWriter tblWriter, final GeologicTimePeriodTreeDef treeDef,
        final boolean isPaleo) throws SQLException {
    deleteAllRecordsFromTable("geologictimeperiod", BasicSQLUtils.myDestinationServerType);

    log.info("Converting old geologic time period records");
    int count = 0;

    // create an ID mapper for the geologictimeperiod table
    IdTableMapper gtpIdMapper = IdMapperMgr.getInstance().addTableMapper("geologictimeperiod",
            "GeologicTimePeriodID");
    Hashtable<Integer, GeologicTimePeriod> oldIdToGTPMap = new Hashtable<Integer, GeologicTimePeriod>();

    //        String    sql = "SELECT g.GeologicTimePeriodID,g.RankCode,g.Name,g.Standard,g.Remarks,g.TimestampModified,g.TimestampCreated,p1.Age as Upper," +
    //                     "p1.AgeUncertainty as UpperUncertainty,p2.Age as Lower,p2.AgeUncertainty as LowerUncertainty FROM geologictimeperiod g, " +
    //                     "geologictimeboundary p1, geologictimeboundary p2 WHERE g.UpperBoundaryID=p1.GeologicTimeBoundaryID AND " +
    //                     "g.LowerBoundaryID=p2.GeologicTimeBoundaryID ORDER BY Lower DESC, RankCode";
    String sql = "SELECT g.GeologicTimePeriodID,g.RankCode,g.Name,g.Standard,g.Remarks,g.TimestampModified,g.TimestampCreated,gb1.Age as Upper,"
            + "gb1.AgeUncertainty as UpperUncertainty,gb2.Age as Lower,gb2.AgeUncertainty as LowerUncertainty FROM geologictimeperiod g "
            + "LEFT OUTER JOIN geologictimeboundary gb1 ON g.UpperBoundaryID = gb1.GeologicTimeBoundaryID "
            + "LEFT OUTER JOIN geologictimeboundary gb2 ON g.LowerBoundaryID = gb2.GeologicTimeBoundaryID "
            + "ORDER BY Lower DESC, RankCode";
    Statement statement = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
            ResultSet.CONCUR_READ_ONLY);
    statement.setFetchSize(Integer.MIN_VALUE);
    ResultSet rs = statement.executeQuery(sql);

    Session localSession = HibernateUtil.getCurrentSession();
    HibernateUtil.beginTransaction();

    Vector<GeologicTimePeriod> newItems = new Vector<GeologicTimePeriod>();

    GeologicTimePeriod allTime = new GeologicTimePeriod();
    allTime.initialize();
    allTime.setDefinition(treeDef);
    GeologicTimePeriodTreeDefItem rootDefItem = treeDef.getDefItemByRank(0);
    allTime.setDefinitionItem(rootDefItem);
    allTime.setRankId(0);
    allTime.setName("Time");
    allTime.setFullName("Time");
    allTime.setStartPeriod(100000f);
    allTime.setEndPeriod(0f);
    allTime.setEndUncertainty(0f);
    allTime.setTimestampCreated(now);
    ++count;
    newItems.add(allTime);

    ArrayList<GeologicTimePeriod> needsPlaceHolderList = new ArrayList<GeologicTimePeriod>();

    boolean needsTbl = true;

    if (isPaleo) {
        while (rs.next()) {
            Integer id = rs.getInt(1);
            Integer rank = rs.getInt(2) * 100;
            String name = rs.getString(3);
            String std = rs.getString(4);
            String rem = rs.getString(5);
            Date modTDate = rs.getDate(6);
            Date creTDate = rs.getDate(7);
            Timestamp modT = (modTDate != null) ? new Timestamp(modTDate.getTime()) : null;
            Timestamp creT = (creTDate != null) ? new Timestamp(creTDate.getTime()) : null;
            Float upper = (Float) rs.getObject(8);
            Float uError = (Float) rs.getObject(9);
            Float lower = (Float) rs.getObject(10);
            Float lError = (Float) rs.getObject(11);

            if (isEmpty(name)) {
                if (needsTbl) {
                    tblWriter.startTable();
                    tblWriter.logHdr("ID", "Rank Name", "Name", "Reason");
                    needsTbl = false;
                }
                tblWriter.log(id.toString(), rank.toString(), name, "Name is null, Name set to 'XXXX'");
                log.error("The Name is empty (or null) for GTP ID[" + id + "]  Rank[" + rank + "]");
                name = "XXXX";
            }

            if (modT == null && creT == null) {
                creT = now;
                modT = now;

            } else if (modT == null && creT != null) {
                modT = new Timestamp(creT.getTime());

            } else if (modT != null && creT == null) {
                creT = new Timestamp(modT.getTime());
            }
            // else (neither are null, so do nothing)

            GeologicTimePeriodTreeDefItem defItem = rank != null ? treeDef.getDefItemByRank(rank) : null;

            GeologicTimePeriod gtp = new GeologicTimePeriod();
            gtp.initialize();
            gtp.setName(name);
            gtp.setFullName(name);
            gtp.setDefinitionItem(defItem);
            gtp.setRankId(rank);
            gtp.setDefinition(treeDef);
            gtp.setStartPeriod(lower);
            gtp.setStartUncertainty(lError);
            gtp.setEndPeriod(upper);
            gtp.setEndUncertainty(uError);
            gtp.setStandard(std);
            gtp.setRemarks(rem);
            gtp.setTimestampCreated(creT);
            gtp.setTimestampModified(modT);

            if (lower == null || upper == null || rank == null) {
                needsPlaceHolderList.add(gtp);
                log.debug("PlaceHold Old ID: " + id);
            } else {
                newItems.add(gtp);
            }

            oldIdToGTPMap.put(id, gtp);

            if (++count % 500 == 0) {
                log.info(count + " geologic time period records converted");
            }
        }

        // now we need to fix the parent/pointers
        for (int i = 0; i < newItems.size(); ++i) {
            GeologicTimePeriod gtp = newItems.get(i);
            for (int j = 0; j < newItems.size(); ++j) {
                GeologicTimePeriod child = newItems.get(j);
                if (isParentChildPair(gtp, child)) {
                    gtp.addChild(child);
                }
            }
        }

        if (needsPlaceHolderList.size() > 0) {
            int rank = 100;
            for (GeologicTimePeriodTreeDefItem di : treeDef.getTreeDefItems()) {
                System.out.println(di.getName() + " -> " + di.getRankId());
            }
            GeologicTimePeriodTreeDefItem defItem = treeDef.getDefItemByRank(rank);

            GeologicTimePeriod gtp = new GeologicTimePeriod();
            gtp.initialize();
            gtp.setName("Placeholder");
            gtp.setFullName("Placeholder");
            gtp.setDefinitionItem(defItem);
            gtp.setRankId(rank);
            gtp.setDefinition(treeDef);
            gtp.setStartPeriod(0.0f);
            gtp.setStartUncertainty(0.0f);
            gtp.setEndPeriod(0.0f);
            gtp.setEndUncertainty(0.0f);
            gtp.setStandard(null);
            gtp.setRemarks(null);
            gtp.setTimestampCreated(now);
            gtp.setTimestampModified(now);
            allTime.addChild(gtp);

            rank = 200;
            defItem = treeDef.getDefItemByRank(rank);

            for (GeologicTimePeriod gtpPH : needsPlaceHolderList) {
                gtpPH.setDefinition(treeDef);
                gtpPH.setDefinitionItem(defItem);
                gtpPH.setRankId(rank);
                gtpPH.setStartPeriod(0.0f);
                gtpPH.setStartUncertainty(0.0f);
                gtpPH.setEndPeriod(0.0f);
                gtpPH.setEndUncertainty(0.0f);
                gtp.addChild(gtpPH);
            }
        }

        TreeHelper.fixFullnameForNodeAndDescendants(allTime);
    }

    // fix node number, child node number stuff
    allTime.setNodeNumber(1);
    fixNodeNumbersFromRoot(allTime);
    localSession.save(allTime);

    HibernateUtil.commitTransaction();

    if (shouldCreateMapTables) {
        // add all of the ID mappings
        for (Integer oldId : oldIdToGTPMap.keySet()) {
            if (oldId != null) {
                GeologicTimePeriod gtp = oldIdToGTPMap.get(oldId);
                if (gtp != null) {
                    if (gtp.getId() != null) {
                        gtpIdMapper.put(oldId, gtp.getId());
                    } else {
                        log.debug("GTP id is null: " + gtp.getName());
                    }
                } else {
                    log.debug("GTP missing in hash for Old ID: " + oldId);
                }
            } else {
                log.debug("Old ID in Hash is null: " + oldId);
            }
        }
    }

    // set up geologictimeperiod foreign key mapping for stratigraphy
    IdMapperMgr.getInstance().mapForeignKey("Stratigraphy", "GeologicTimePeriodID", "GeologicTimePeriod",
            "GeologicTimePeriodID");

    log.info(count + " geologic time period records converted");

    if (!needsTbl) {
        tblWriter.endTable();
    }
}

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

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

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

}