List of usage examples for java.sql ResultSet CONCUR_READ_ONLY
int CONCUR_READ_ONLY
To view the source code for java.sql ResultSet CONCUR_READ_ONLY.
Click Source Link
ResultSet
object that may NOT be updated. From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AnyObjTable.java
public MSSBamAnyObjBuff[] readDerivedByAuthorIdx(MSSBamAuthorization Authorization, Long AuthorId) { final String S_ProcName = "readDerivedByAuthorIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*ww w. j av a 2 s. c o m*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectAnyObjDistinctClassCode + "WHERE " + ((AuthorId == null) ? "anyo.AuthorId is null " : "anyo.AuthorId = " + AuthorId.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<MSSBamAnyObjBuff> resultList = new ArrayList<MSSBamAnyObjBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("ANYO")) { MSSBamAnyObjBuff[] subList = readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SCP")) { MSSBamScopeBuff[] subList = schema.getTableScope().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DICT")) { MSSBamDictionaryBuff[] subList = schema.getTableDictionary().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("RMD")) { MSSBamMSSBamBuff[] subList = schema.getTableMSSBam().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BDM")) { MSSBamBaseDomainBuff[] subList = schema.getTableBaseDomain().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DOM")) { MSSBamDomainBuff[] subList = schema.getTableDomain().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("LENT")) { MSSBamLegalEntityBuff[] subList = schema.getTableLegalEntity().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("COM")) { MSSBamCompanyBuff[] subList = schema.getTableCompany().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("USR")) { MSSBamUserBuff[] subList = schema.getTableUser().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("PRJ")) { MSSBamProjectBuff[] subList = schema.getTableProject().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("VER")) { MSSBamVersionBuff[] subList = schema.getTableVersion().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MJV")) { MSSBamMajorVersionBuff[] subList = schema.getTableMajorVersion().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("MNV")) { MSSBamMinorVersionBuff[] subList = schema.getTableMinorVersion().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TLD")) { MSSBamTLDBuff[] subList = schema.getTableTLD().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("IDX")) { MSSBamIndexBuff[] subList = schema.getTableIndex().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("REL")) { MSSBamRelationBuff[] subList = schema.getTableRelation().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SCH")) { MSSBamSchemaDefBuff[] subList = schema.getTableSchemaDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBL")) { MSSBamTableBuff[] subList = schema.getTableTable().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("VAL")) { MSSBamValueBuff[] subList = schema.getTableValue().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ATM")) { MSSBamAtomDefBuff[] subList = schema.getTableAtomDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLB")) { MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLB")) { MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLB")) { MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLN")) { MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLN")) { MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLN")) { MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DAT")) { MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDAT")) { MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDAT")) { MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DBL")) { MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDBL")) { MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDBL")) { MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NUM")) { MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNUM")) { MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNUM")) { MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("FLT")) { MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TFLT")) { MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SFLT")) { MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I16")) { MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI16")) { MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI16")) { MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ENM")) { MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TENM")) { MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SENM")) { MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G16")) { MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG16")) { MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG16")) { MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U16")) { MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU16")) { MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU16")) { MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I32")) { MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI32")) { MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI32")) { MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G32")) { MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG32")) { MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG32")) { MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U32")) { MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU32")) { MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU32")) { MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I64")) { MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI64")) { MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI64")) { MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G64")) { MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG64")) { MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG64")) { MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U64")) { MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU64")) { MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU64")) { MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("UUID")) { MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TUUI")) { MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SUUI")) { MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("IDGU")) { MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TGUU")) { MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SGUU")) { MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMT")) { MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTK")) { MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTK")) { MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMS")) { MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTS")) { MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTS")) { MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STR")) { MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSTR")) { MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SSTR")) { MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZDY")) { MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZDY")) { MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZDY")) { MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZTM")) { MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZTM")) { MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZTM")) { MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZSP")) { MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZST")) { MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZST")) { MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TXT")) { MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTXT")) { MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STXT")) { MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TIM")) { MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTIM")) { MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STIM")) { MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSP")) { MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTSM")) { MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STSM")) { MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp() .readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TKN")) { MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTOK")) { MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STOK")) { MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBC")) { MSSBamTableColBuff[] subList = schema.getTableTableCol().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("LIC")) { MSSBamLicenseBuff[] subList = schema.getTableLicense().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("CHN")) { MSSBamChainBuff[] subList = schema.getTableChain().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("RLC")) { MSSBamRelationColBuff[] subList = schema.getTableRelationCol().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ETG")) { MSSBamEnumTagBuff[] subList = schema.getTableEnumTag().readBuffByAuthorIdx(Authorization, AuthorId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("IXC")) { MSSBamIndexColBuff[] subList = schema.getTableIndexCol().readBuffByAuthorIdx(Authorization, AuthorId); 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 MSSBamAnyObjBuff[0])); }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java
public MSSBamAtomDefBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamPg8AtomDefTable.readDerivedByUNameIdx() "; MSSBamAtomDefBuff buff;/*ww w. jav a 2 s.co m*/ if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { classCode = resultSet.getString(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (classCode.equals("ATM")) { buff = readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("BLB")) { buff = schema.getTableBlobDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBLB")) { buff = schema.getTableTableBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SBLB")) { buff = schema.getTableSchemaBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("BLN")) { buff = schema.getTableBoolDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBLN")) { buff = schema.getTableTableBool().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SBLN")) { buff = schema.getTableSchemaBool().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DAT")) { buff = schema.getTableDateDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TDAT")) { buff = schema.getTableTableDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SDAT")) { buff = schema.getTableSchemaDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DBL")) { buff = schema.getTableDoubleDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TDBL")) { buff = schema.getTableTableDouble().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SDBL")) { buff = schema.getTableSchemaDouble().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NUM")) { buff = schema.getTableNumberDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNUM")) { buff = schema.getTableTableNumber().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNUM")) { buff = schema.getTableSchemaNumber().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("FLT")) { buff = schema.getTableFloatDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TFLT")) { buff = schema.getTableTableFloat().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SFLT")) { buff = schema.getTableSchemaFloat().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I16")) { buff = schema.getTableInt16Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI16")) { buff = schema.getTableTableInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI16")) { buff = schema.getTableSchemaInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ENM")) { buff = schema.getTableEnumDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TENM")) { buff = schema.getTableTableEnum().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SENM")) { buff = schema.getTableSchemaEnum().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G16")) { buff = schema.getTableId16GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG16")) { buff = schema.getTableTableId16Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG16")) { buff = schema.getTableSchemaId16Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U16")) { buff = schema.getTableUInt16Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU16")) { buff = schema.getTableTableUInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU16")) { buff = schema.getTableSchemaUInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I32")) { buff = schema.getTableInt32Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI32")) { buff = schema.getTableTableInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI32")) { buff = schema.getTableSchemaInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G32")) { buff = schema.getTableId32GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG32")) { buff = schema.getTableTableId32Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG32")) { buff = schema.getTableSchemaId32Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U32")) { buff = schema.getTableUInt32Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU32")) { buff = schema.getTableTableUInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU32")) { buff = schema.getTableSchemaUInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I64")) { buff = schema.getTableInt64Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI64")) { buff = schema.getTableTableInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI64")) { buff = schema.getTableSchemaInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G64")) { buff = schema.getTableId64GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG64")) { buff = schema.getTableTableId64Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG64")) { buff = schema.getTableSchemaId64Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U64")) { buff = schema.getTableUInt64Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU64")) { buff = schema.getTableTableUInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU64")) { buff = schema.getTableSchemaUInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("UUID")) { buff = schema.getTableUuidDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TUUI")) { buff = schema.getTableTableUuid().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SUUI")) { buff = schema.getTableSchemaUuid().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("IDGU")) { buff = schema.getTableUuidGenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TGUU")) { buff = schema.getTableTableUuidGen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SGUU")) { buff = schema.getTableSchemaUuidGen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NMT")) { buff = schema.getTableNmTokenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNTK")) { buff = schema.getTableTableNmToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNTK")) { buff = schema.getTableSchemaNmToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NMS")) { buff = schema.getTableNmTokensDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNTS")) { buff = schema.getTableTableNmTokens().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNTS")) { buff = schema.getTableSchemaNmTokens().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STR")) { buff = schema.getTableStringDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TSTR")) { buff = schema.getTableTableString().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SSTR")) { buff = schema.getTableSchemaString().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZDY")) { buff = schema.getTableTZDateDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZDY")) { buff = schema.getTableTableTZDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZDY")) { buff = schema.getTableSchemaTZDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZTM")) { buff = schema.getTableTZTimeDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZTM")) { buff = schema.getTableTableTZTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZTM")) { buff = schema.getTableSchemaTZTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZSP")) { buff = schema.getTableTZTimestampDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZST")) { buff = schema.getTableTableTZTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZST")) { buff = schema.getTableSchemaTZTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TXT")) { buff = schema.getTableTextDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTXT")) { buff = schema.getTableTableText().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STXT")) { buff = schema.getTableSchemaText().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TIM")) { buff = schema.getTableTimeDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTIM")) { buff = schema.getTableTableTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STIM")) { buff = schema.getTableSchemaTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TSP")) { buff = schema.getTableTimestampDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTSM")) { buff = schema.getTableTableTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STSM")) { buff = schema.getTableSchemaTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TKN")) { buff = schema.getTableTokenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTOK")) { buff = schema.getTableTableToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STOK")) { buff = schema.getTableSchemaToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } return (buff); }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Looks up all the current Permit Types and uses them, instead of the usystable *///from w ww .j a v a 2 s .com @SuppressWarnings("unchecked") public void createPermitTypePickList() { /* * try { Statement stmt = oldDBConn.createStatement(); String sqlStr = "select count(Type) * from (select distinct Type from permit where Type is not null) as t"; * * log.info(sqlStr); * * boolean useField = false; ResultSet rs = stmt.executeQuery(sqlStr); } catch (SQLException * e) { e.printStackTrace(); log.error(e); } */ Session localSession = HibernateUtil.getCurrentSession(); PickList pl = new PickList(); pl.initialize(); Set<PickListItemIFace> items = pl.getItems(); try { pl.setName("Permit"); pl.setSizeLimit(-1); HibernateUtil.beginTransaction(); localSession.saveOrUpdate(pl); HibernateUtil.commitTransaction(); } catch (Exception ex) { log.error("******* " + ex); HibernateUtil.rollbackTransaction(); throw new RuntimeException("Couldn't create PickList for [Permit]"); } try { Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); String sqlStr = "select distinct Type from permit where Type is not null"; log.info(sqlStr); ResultSet rs = stmt.executeQuery(sqlStr); // check for no records which is OK if (!rs.first()) { return; } int count = 0; do { String typeStr = rs.getString(1); if (typeStr != null) { log.info("Permit Type[" + typeStr + "]"); PickListItem pli = new PickListItem(); pli.initialize(); pli.setTitle(typeStr); pli.setValue(typeStr); pli.setTimestampCreated(now); items.add(pli); pli.setPickList(pl); count++; } } while (rs.next()); log.info("Processed Permit Types " + count + " records."); HibernateUtil.beginTransaction(); localSession.saveOrUpdate(pl); HibernateUtil.commitTransaction(); } catch (SQLException e) { e.printStackTrace(); log.error(e); throw new RuntimeException(e); } }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java
public MSSBamAtomDefBuff[] readDerivedByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) { final String S_ProcName = "readDerivedByVContIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w ww .jav a2 s .c o m*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " "; 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 = readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLB")) { MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLB")) { MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLB")) { MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLN")) { MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLN")) { MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLN")) { MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DAT")) { MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDAT")) { MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDAT")) { MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DBL")) { MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDBL")) { MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDBL")) { MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NUM")) { MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNUM")) { MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNUM")) { MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("FLT")) { MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TFLT")) { MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SFLT")) { MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I16")) { MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI16")) { MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI16")) { MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ENM")) { MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TENM")) { MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SENM")) { MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G16")) { MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG16")) { MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG16")) { MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U16")) { MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU16")) { MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU16")) { MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I32")) { MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI32")) { MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI32")) { MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G32")) { MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG32")) { MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG32")) { MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U32")) { MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU32")) { MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU32")) { MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I64")) { MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI64")) { MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI64")) { MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G64")) { MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG64")) { MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG64")) { MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U64")) { MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU64")) { MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU64")) { MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("UUID")) { MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TUUI")) { MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SUUI")) { MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("IDGU")) { MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TGUU")) { MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SGUU")) { MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMT")) { MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTK")) { MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTK")) { MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMS")) { MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTS")) { MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTS")) { MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STR")) { MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSTR")) { MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SSTR")) { MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZDY")) { MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZDY")) { MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZDY")) { MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZTM")) { MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZTM")) { MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZTM")) { MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZSP")) { MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZST")) { MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZST")) { MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TXT")) { MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTXT")) { MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STXT")) { MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TIM")) { MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTIM")) { MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STIM")) { MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSP")) { MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTSM")) { MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STSM")) { MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp() .readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TKN")) { MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTOK")) { MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STOK")) { MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } return (resultList.toArray(new MSSBamAtomDefBuff[0])); }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Converts an old USYS table to a PickList. * @param usysTableName old table name/*w w w . j a v a2s . co m*/ * @param pickListName new pciklist name * @return true on success, false on failure */ @SuppressWarnings("unchecked") public boolean convertUSYSToPicklist(final Session localSession, final Collection collection, final String usysTableName, final String pickListName) { List<FieldMetaData> fieldMetaData = getFieldMetaDataFromSchema(oldDBConn, usysTableName); int ifaceInx = -1; int dataInx = -1; int fieldSetInx = -1; int i = 0; for (FieldMetaData md : fieldMetaData) { if (ifaceInx == -1 && md.getName().equals("InterfaceID")) { ifaceInx = i + 1; } else if (fieldSetInx == -1 && md.getName().equals("FieldSetSubTypeID")) { fieldSetInx = i + 1; } else if (dataInx == -1 && md.getType().toLowerCase().indexOf("varchar") > -1) { dataInx = i + 1; } i++; } if (ifaceInx == -1 || dataInx == -1 || fieldSetInx == -1) { throw new RuntimeException("Couldn't decypher USYS table ifaceInx[" + ifaceInx + "] dataInx[" + dataInx + "] fieldSetInx[" + fieldSetInx + "]"); } PickList pl = new PickList(); pl.initialize(); try { pl.setName(pickListName); if (pickListName.equals("PrepType")) { pl.setReadOnly(true); pl.setSizeLimit(-1); pl.setIsSystem(true); pl.setTableName("preptype"); pl.setType((byte) 1); } else { pl.setReadOnly(false); pl.setSizeLimit(-1); } pl.setCollection(collection); collection.getPickLists().add(pl); Transaction trans = localSession.beginTransaction(); localSession.saveOrUpdate(pl); localSession.saveOrUpdate(collection); trans.commit(); localSession.flush(); } catch (Exception ex) { log.error("******* " + ex); HibernateUtil.rollbackTransaction(); throw new RuntimeException("Couldn't create PickList for [" + usysTableName + "]"); } try { Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); String sqlStr = "select * from " + usysTableName + " where InterfaceID is not null"; log.info(sqlStr); boolean useField = false; ResultSet rs = stmt.executeQuery(sqlStr); // check for no records which is OK if (!rs.first()) { return true; } do { Object fieldObj = rs.getObject(fieldSetInx); if (fieldObj != null) { useField = true; break; } } while (rs.next()); Hashtable<String, String> values = new Hashtable<String, String>(); //log.info("Using FieldSetSubTypeID " + useField); rs.first(); int count = 0; do { if (!useField || rs.getObject(fieldSetInx) != null) { String val = rs.getString(dataInx); String lowerStr = val.toLowerCase(); if (values.get(lowerStr) == null) { //log.info("[" + val + "]"); pl.addItem(val, val); values.put(lowerStr, val); count++; } else { log.info("Discarding duplicate picklist value[" + val + "]"); } } } while (rs.next()); log.info("Processed " + usysTableName + " " + count + " records."); Transaction trans = localSession.beginTransaction(); localSession.saveOrUpdate(pl); trans.commit(); localSession.flush(); return true; } catch (SQLException e) { e.printStackTrace(); log.error(e); throw new RuntimeException(e); } }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AnyObjTable.java
public MSSBamAnyObjBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamPg8AnyObjTable.readDerivedByUNameIdx() "; MSSBamAnyObjBuff buff;/*from w ww . j a v a 2 s .c o m*/ if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectAnyObjDistinctClassCode + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { classCode = resultSet.getString(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (classCode.equals("ANYO")) { buff = readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SCP")) { buff = schema.getTableScope().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DICT")) { buff = schema.getTableDictionary().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("RMD")) { buff = schema.getTableMSSBam().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("BDM")) { buff = schema.getTableBaseDomain().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DOM")) { buff = schema.getTableDomain().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("LENT")) { buff = schema.getTableLegalEntity().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("COM")) { buff = schema.getTableCompany().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("USR")) { buff = schema.getTableUser().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("PRJ")) { buff = schema.getTableProject().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("VER")) { buff = schema.getTableVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("MJV")) { buff = schema.getTableMajorVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("MNV")) { buff = schema.getTableMinorVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TLD")) { buff = schema.getTableTLD().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("IDX")) { buff = schema.getTableIndex().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("REL")) { buff = schema.getTableRelation().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SCH")) { buff = schema.getTableSchemaDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBL")) { buff = schema.getTableTable().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("VAL")) { buff = schema.getTableValue().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ATM")) { buff = schema.getTableAtomDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("BLB")) { buff = schema.getTableBlobDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBLB")) { buff = schema.getTableTableBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SBLB")) { buff = schema.getTableSchemaBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("BLN")) { buff = schema.getTableBoolDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBLN")) { buff = schema.getTableTableBool().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SBLN")) { buff = schema.getTableSchemaBool().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DAT")) { buff = schema.getTableDateDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TDAT")) { buff = schema.getTableTableDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SDAT")) { buff = schema.getTableSchemaDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DBL")) { buff = schema.getTableDoubleDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TDBL")) { buff = schema.getTableTableDouble().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SDBL")) { buff = schema.getTableSchemaDouble().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NUM")) { buff = schema.getTableNumberDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNUM")) { buff = schema.getTableTableNumber().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNUM")) { buff = schema.getTableSchemaNumber().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("FLT")) { buff = schema.getTableFloatDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TFLT")) { buff = schema.getTableTableFloat().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SFLT")) { buff = schema.getTableSchemaFloat().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I16")) { buff = schema.getTableInt16Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI16")) { buff = schema.getTableTableInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI16")) { buff = schema.getTableSchemaInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ENM")) { buff = schema.getTableEnumDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TENM")) { buff = schema.getTableTableEnum().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SENM")) { buff = schema.getTableSchemaEnum().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G16")) { buff = schema.getTableId16GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG16")) { buff = schema.getTableTableId16Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG16")) { buff = schema.getTableSchemaId16Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U16")) { buff = schema.getTableUInt16Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU16")) { buff = schema.getTableTableUInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU16")) { buff = schema.getTableSchemaUInt16().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I32")) { buff = schema.getTableInt32Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI32")) { buff = schema.getTableTableInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI32")) { buff = schema.getTableSchemaInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G32")) { buff = schema.getTableId32GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG32")) { buff = schema.getTableTableId32Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG32")) { buff = schema.getTableSchemaId32Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U32")) { buff = schema.getTableUInt32Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU32")) { buff = schema.getTableTableUInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU32")) { buff = schema.getTableSchemaUInt32().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("I64")) { buff = schema.getTableInt64Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TI64")) { buff = schema.getTableTableInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SI64")) { buff = schema.getTableSchemaInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("G64")) { buff = schema.getTableId64GenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TG64")) { buff = schema.getTableTableId64Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SG64")) { buff = schema.getTableSchemaId64Gen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("U64")) { buff = schema.getTableUInt64Def().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TU64")) { buff = schema.getTableTableUInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SU64")) { buff = schema.getTableSchemaUInt64().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("UUID")) { buff = schema.getTableUuidDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TUUI")) { buff = schema.getTableTableUuid().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SUUI")) { buff = schema.getTableSchemaUuid().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("IDGU")) { buff = schema.getTableUuidGenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TGUU")) { buff = schema.getTableTableUuidGen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SGUU")) { buff = schema.getTableSchemaUuidGen().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NMT")) { buff = schema.getTableNmTokenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNTK")) { buff = schema.getTableTableNmToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNTK")) { buff = schema.getTableSchemaNmToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("NMS")) { buff = schema.getTableNmTokensDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TNTS")) { buff = schema.getTableTableNmTokens().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SNTS")) { buff = schema.getTableSchemaNmTokens().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STR")) { buff = schema.getTableStringDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TSTR")) { buff = schema.getTableTableString().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SSTR")) { buff = schema.getTableSchemaString().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZDY")) { buff = schema.getTableTZDateDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZDY")) { buff = schema.getTableTableTZDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZDY")) { buff = schema.getTableSchemaTZDate().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZTM")) { buff = schema.getTableTZTimeDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZTM")) { buff = schema.getTableTableTZTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZTM")) { buff = schema.getTableSchemaTZTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ZSP")) { buff = schema.getTableTZTimestampDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TZST")) { buff = schema.getTableTableTZTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SZST")) { buff = schema.getTableSchemaTZTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TXT")) { buff = schema.getTableTextDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTXT")) { buff = schema.getTableTableText().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STXT")) { buff = schema.getTableSchemaText().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TIM")) { buff = schema.getTableTimeDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTIM")) { buff = schema.getTableTableTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STIM")) { buff = schema.getTableSchemaTime().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TSP")) { buff = schema.getTableTimestampDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTSM")) { buff = schema.getTableTableTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STSM")) { buff = schema.getTableSchemaTimestamp().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TKN")) { buff = schema.getTableTokenDef().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TTOK")) { buff = schema.getTableTableToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("STOK")) { buff = schema.getTableSchemaToken().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBC")) { buff = schema.getTableTableCol().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("LIC")) { buff = schema.getTableLicense().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("CHN")) { buff = schema.getTableChain().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("RLC")) { buff = schema.getTableRelationCol().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("ETG")) { buff = schema.getTableEnumTag().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("IXC")) { buff = schema.getTableIndexCol().readBuffByUNameIdx(Authorization, ScopeId, Name); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } return (buff); }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Convert all the biological attributes to Collection Object Attributes. Each old record may * end up being multiple records in the new schema. This will first figure out which columns in * the old schema were used and only map those columns to the new database.<br> * <br>// ww w . j ava 2s . c o m * It also will use the old name if there is not mapping for it. The old name is converted from * lower/upper case to be space separated where each part of the name starts with a capital * letter. * * @param discipline the Discipline * @param colToNameMap a mape for old names to new names * @param typeMap a map for changing the type of the data (meaning an old value may be a boolean * stored in a float) * @return true for success */ public boolean convertBiologicalAttrs(final Discipline discipline, @SuppressWarnings("unused") final Map<String, String> colToNameMap, final Map<String, Short> typeMap) { AttributeIFace.FieldType[] attrTypes = { AttributeIFace.FieldType.IntegerType, AttributeIFace.FieldType.FloatType, AttributeIFace.FieldType.DoubleType, AttributeIFace.FieldType.BooleanType, AttributeIFace.FieldType.StringType, // AttributeIFace.FieldType.MemoType }; Session localSession = HibernateUtil.getCurrentSession(); deleteAllRecordsFromTable(newDBConn, "collectionobjectattr", BasicSQLUtils.myDestinationServerType); deleteAllRecordsFromTable(newDBConn, "attributedef", BasicSQLUtils.myDestinationServerType); try { Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); // grab the field and their type from the old schema List<FieldMetaData> oldFieldMetaData = new ArrayList<FieldMetaData>(); Map<String, FieldMetaData> oldFieldMetaDataMap = getFieldMetaDataFromSchemaHash(oldDBConn, "biologicalobjectattributes"); // create maps to figure which columns where used List<String> columnsInUse = new ArrayList<String>(); Map<String, AttributeDef> attrDefs = new Hashtable<String, AttributeDef>(); List<Integer> counts = new ArrayList<Integer>(); int totalCount = 0; for (FieldMetaData md : oldFieldMetaData) { // Skip these fields if (md.getName().indexOf("ID") == -1 && md.getName().indexOf("Timestamp") == -1 && md.getName().indexOf("LastEditedBy") == -1) { oldFieldMetaDataMap.put(md.getName(), md); // add to map for later // log.info(convertColumnName(md.getName())+" "+ md.getType()); String sqlStr = "select count(" + md.getName() + ") from biologicalobjectattributes where " + md.getName() + " is not null"; ResultSet rs = stmt.executeQuery(sqlStr); if (rs.first() && rs.getInt(1) > 0) { int rowCount = rs.getInt(1); totalCount += rowCount; counts.add(rowCount); log.info(md.getName() + " has " + rowCount + " rows of values"); columnsInUse.add(md.getName()); AttributeDef attrDef = new AttributeDef(); String newName = convertColumnName(md.getName()); attrDef.setFieldName(newName); log.debug("mapping[" + newName + "][" + md.getName() + "]"); // newNameToOldNameMap.put(newName, md.getName()); short dataType = -1; if (typeMap != null) { Short type = typeMap.get(md.getName()); if (type == null) { dataType = type; } } if (dataType == -1) { dataType = getDataType(md.getName(), md.getType()).getType(); } attrDef.setDataType(dataType); attrDef.setDiscipline(discipline); attrDef.setTableType(GenericDBConversion.TableType.CollectionObject.getType()); attrDef.setTimestampCreated(now); attrDefs.put(md.getName(), attrDef); try { HibernateUtil.beginTransaction(); localSession.save(attrDef); HibernateUtil.commitTransaction(); } catch (Exception e) { log.error("******* " + e); HibernateUtil.rollbackTransaction(); throw new RuntimeException(e); } } rs.close(); } } // for log.info("Total Number of Attrs: " + totalCount); // Now that we know which columns are being used we can start the conversion process log.info("biologicalobjectattributes columns in use: " + columnsInUse.size()); if (columnsInUse.size() > 0) { int inx = 0; StringBuilder str = new StringBuilder("select BiologicalObjectAttributesID"); for (String name : columnsInUse) { str.append(", "); str.append(name); inx++; } str.append(" from biologicalobjectattributes order by BiologicalObjectAttributesID"); log.info("sql: " + str.toString()); ResultSet rs = stmt.executeQuery(str.toString()); int[] countVerify = new int[counts.size()]; for (int i = 0; i < countVerify.length; i++) { countVerify[i] = 0; } boolean useHibernate = false; StringBuilder strBufInner = new StringBuilder(); int recordCount = 0; while (rs.next()) { if (useHibernate) { Criteria criteria = localSession.createCriteria(CollectionObject.class); criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY); criteria.add(Restrictions.eq("collectionObjectId", rs.getInt(1))); List<?> list = criteria.list(); if (list.size() == 0) { log.error("**** Can't find the CollectionObject " + rs.getInt(1)); } else { CollectionObject colObj = (CollectionObject) list.get(0); inx = 2; // skip the first column (the ID) for (String name : columnsInUse) { AttributeDef attrDef = attrDefs.get(name); // the needed // AttributeDef by name FieldMetaData md = oldFieldMetaDataMap.get(name); // Create the new Collection Object Attribute CollectionObjectAttr colObjAttr = new CollectionObjectAttr(); colObjAttr.setCollectionObject(colObj); colObjAttr.setDefinition(attrDef); colObjAttr.setTimestampCreated(now); // String oldName = newNameToOldNameMap.get(attrDef.getFieldName()); // log.debug("["+attrDef.getFieldName()+"]["+oldName+"]"); // log.debug(inx+" "+attrTypes[attrDef.getDataType()]+" // "+md.getName()+" "+md.getType()); setData(rs, inx, attrTypes[attrDef.getDataType()], md, colObjAttr); HibernateUtil.beginTransaction(); localSession.save(colObjAttr); HibernateUtil.commitTransaction(); inx++; if (recordCount % 2000 == 0) { log.info("CollectionObjectAttr Records Processed: " + recordCount); } recordCount++; } // for // log.info("Done - CollectionObjectAttr Records Processed: // "+recordCount); } } else { inx = 2; // skip the first column (the ID) for (String name : columnsInUse) { AttributeDef attrDef = attrDefs.get(name); // the needed AttributeDef // by name FieldMetaData md = oldFieldMetaDataMap.get(name); if (rs.getObject(inx) != null) { Integer newRecId = (Integer) getMappedId(rs.getInt(1), "biologicalobjectattributes", "BiologicalObjectAttributesID"); Object data = getData(rs, inx, attrTypes[attrDef.getDataType()], md); boolean isStr = data instanceof String; countVerify[inx - 2]++; strBufInner.setLength(0); strBufInner.append("INSERT INTO collectionobjectattr VALUES ("); strBufInner.append("NULL");// Integer.toString(recordCount)); strBufInner.append(","); strBufInner.append(getStrValue(isStr ? data : null)); strBufInner.append(","); strBufInner.append(getStrValue(isStr ? null : data)); strBufInner.append(","); strBufInner.append(getStrValue(now)); strBufInner.append(","); strBufInner.append(getStrValue(now)); strBufInner.append(","); strBufInner.append(newRecId.intValue()); strBufInner.append(","); strBufInner.append(getStrValue(attrDef.getAttributeDefId())); strBufInner.append(")"); try { Statement updateStatement = newDBConn.createStatement(); // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0"); removeForeignKeyConstraints(newDBConn, BasicSQLUtils.myDestinationServerType); if (false) { log.debug(strBufInner.toString()); } updateStatement.executeUpdate(strBufInner.toString()); updateStatement.clearBatch(); updateStatement.close(); updateStatement = null; } catch (SQLException e) { log.error(strBufInner.toString()); log.error("Count: " + recordCount); e.printStackTrace(); log.error(e); throw new RuntimeException(e); } if (recordCount % 2000 == 0) { log.info("CollectionObjectAttr Records Processed: " + recordCount); } recordCount++; } inx++; } // for } // if } // while rs.close(); stmt.close(); log.info("Count Verification:"); for (int i = 0; i < counts.size(); i++) { log.info(columnsInUse.get(i) + " [" + counts.get(i) + "][" + countVerify[i] + "] " + (counts.get(i) - countVerify[i])); } } } catch (SQLException e) { e.printStackTrace(); log.error(e); throw new RuntimeException(e); } return true; }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AtomDefTable.java
public MSSBamAtomDefBuff[] readDerivedByDataScopeIdx(MSSBamAuthorization Authorization, Short DataScopeId) { final String S_ProcName = "readDerivedByDataScopeIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/*from w ww . j a v a2 s .co m*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectAtomDefDistinctClassCode + "WHERE " + ((DataScopeId == null) ? "val.DataScopeId is null " : "val.DataScopeId = " + DataScopeId.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 = readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLB")) { MSSBamBlobDefBuff[] subList = schema.getTableBlobDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLB")) { MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLB")) { MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("BLN")) { MSSBamBoolDefBuff[] subList = schema.getTableBoolDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLN")) { MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLN")) { MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DAT")) { MSSBamDateDefBuff[] subList = schema.getTableDateDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDAT")) { MSSBamTableDateBuff[] subList = schema.getTableTableDate().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDAT")) { MSSBamSchemaDateBuff[] subList = schema.getTableSchemaDate().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("DBL")) { MSSBamDoubleDefBuff[] subList = schema.getTableDoubleDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TDBL")) { MSSBamTableDoubleBuff[] subList = schema.getTableTableDouble().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SDBL")) { MSSBamSchemaDoubleBuff[] subList = schema.getTableSchemaDouble() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NUM")) { MSSBamNumberDefBuff[] subList = schema.getTableNumberDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNUM")) { MSSBamTableNumberBuff[] subList = schema.getTableTableNumber().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNUM")) { MSSBamSchemaNumberBuff[] subList = schema.getTableSchemaNumber() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("FLT")) { MSSBamFloatDefBuff[] subList = schema.getTableFloatDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TFLT")) { MSSBamTableFloatBuff[] subList = schema.getTableTableFloat().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SFLT")) { MSSBamSchemaFloatBuff[] subList = schema.getTableSchemaFloat().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I16")) { MSSBamInt16DefBuff[] subList = schema.getTableInt16Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI16")) { MSSBamTableInt16Buff[] subList = schema.getTableTableInt16().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI16")) { MSSBamSchemaInt16Buff[] subList = schema.getTableSchemaInt16().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ENM")) { MSSBamEnumDefBuff[] subList = schema.getTableEnumDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TENM")) { MSSBamTableEnumBuff[] subList = schema.getTableTableEnum().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SENM")) { MSSBamSchemaEnumBuff[] subList = schema.getTableSchemaEnum().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G16")) { MSSBamId16GenDefBuff[] subList = schema.getTableId16GenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG16")) { MSSBamTableId16GenBuff[] subList = schema.getTableTableId16Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG16")) { MSSBamSchemaId16GenBuff[] subList = schema.getTableSchemaId16Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U16")) { MSSBamUInt16DefBuff[] subList = schema.getTableUInt16Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU16")) { MSSBamTableUInt16Buff[] subList = schema.getTableTableUInt16().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU16")) { MSSBamSchemaUInt16Buff[] subList = schema.getTableSchemaUInt16() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I32")) { MSSBamInt32DefBuff[] subList = schema.getTableInt32Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI32")) { MSSBamTableInt32Buff[] subList = schema.getTableTableInt32().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI32")) { MSSBamSchemaInt32Buff[] subList = schema.getTableSchemaInt32().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G32")) { MSSBamId32GenDefBuff[] subList = schema.getTableId32GenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG32")) { MSSBamTableId32GenBuff[] subList = schema.getTableTableId32Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG32")) { MSSBamSchemaId32GenBuff[] subList = schema.getTableSchemaId32Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U32")) { MSSBamUInt32DefBuff[] subList = schema.getTableUInt32Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU32")) { MSSBamTableUInt32Buff[] subList = schema.getTableTableUInt32().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU32")) { MSSBamSchemaUInt32Buff[] subList = schema.getTableSchemaUInt32() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("I64")) { MSSBamInt64DefBuff[] subList = schema.getTableInt64Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TI64")) { MSSBamTableInt64Buff[] subList = schema.getTableTableInt64().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SI64")) { MSSBamSchemaInt64Buff[] subList = schema.getTableSchemaInt64().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("G64")) { MSSBamId64GenDefBuff[] subList = schema.getTableId64GenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TG64")) { MSSBamTableId64GenBuff[] subList = schema.getTableTableId64Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SG64")) { MSSBamSchemaId64GenBuff[] subList = schema.getTableSchemaId64Gen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("U64")) { MSSBamUInt64DefBuff[] subList = schema.getTableUInt64Def().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TU64")) { MSSBamTableUInt64Buff[] subList = schema.getTableTableUInt64().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SU64")) { MSSBamSchemaUInt64Buff[] subList = schema.getTableSchemaUInt64() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("UUID")) { MSSBamUuidDefBuff[] subList = schema.getTableUuidDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TUUI")) { MSSBamTableUuidBuff[] subList = schema.getTableTableUuid().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SUUI")) { MSSBamSchemaUuidBuff[] subList = schema.getTableSchemaUuid().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("IDGU")) { MSSBamUuidGenDefBuff[] subList = schema.getTableUuidGenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TGUU")) { MSSBamTableUuidGenBuff[] subList = schema.getTableTableUuidGen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SGUU")) { MSSBamSchemaUuidGenBuff[] subList = schema.getTableSchemaUuidGen() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMT")) { MSSBamNmTokenDefBuff[] subList = schema.getTableNmTokenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTK")) { MSSBamTableNmTokenBuff[] subList = schema.getTableTableNmToken() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTK")) { MSSBamSchemaNmTokenBuff[] subList = schema.getTableSchemaNmToken() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("NMS")) { MSSBamNmTokensDefBuff[] subList = schema.getTableNmTokensDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TNTS")) { MSSBamTableNmTokensBuff[] subList = schema.getTableTableNmTokens() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SNTS")) { MSSBamSchemaNmTokensBuff[] subList = schema.getTableSchemaNmTokens() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STR")) { MSSBamStringDefBuff[] subList = schema.getTableStringDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSTR")) { MSSBamTableStringBuff[] subList = schema.getTableTableString().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SSTR")) { MSSBamSchemaStringBuff[] subList = schema.getTableSchemaString() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZDY")) { MSSBamTZDateDefBuff[] subList = schema.getTableTZDateDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZDY")) { MSSBamTableTZDateBuff[] subList = schema.getTableTableTZDate().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZDY")) { MSSBamSchemaTZDateBuff[] subList = schema.getTableSchemaTZDate() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZTM")) { MSSBamTZTimeDefBuff[] subList = schema.getTableTZTimeDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZTM")) { MSSBamTableTZTimeBuff[] subList = schema.getTableTableTZTime().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZTM")) { MSSBamSchemaTZTimeBuff[] subList = schema.getTableSchemaTZTime() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("ZSP")) { MSSBamTZTimestampDefBuff[] subList = schema.getTableTZTimestampDef() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TZST")) { MSSBamTableTZTimestampBuff[] subList = schema.getTableTableTZTimestamp() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SZST")) { MSSBamSchemaTZTimestampBuff[] subList = schema.getTableSchemaTZTimestamp() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TXT")) { MSSBamTextDefBuff[] subList = schema.getTableTextDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTXT")) { MSSBamTableTextBuff[] subList = schema.getTableTableText().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STXT")) { MSSBamSchemaTextBuff[] subList = schema.getTableSchemaText().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TIM")) { MSSBamTimeDefBuff[] subList = schema.getTableTimeDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTIM")) { MSSBamTableTimeBuff[] subList = schema.getTableTableTime().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STIM")) { MSSBamSchemaTimeBuff[] subList = schema.getTableSchemaTime().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TSP")) { MSSBamTimestampDefBuff[] subList = schema.getTableTimestampDef() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTSM")) { MSSBamTableTimestampBuff[] subList = schema.getTableTableTimestamp() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STSM")) { MSSBamSchemaTimestampBuff[] subList = schema.getTableSchemaTimestamp() .readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TKN")) { MSSBamTokenDefBuff[] subList = schema.getTableTokenDef().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TTOK")) { MSSBamTableTokenBuff[] subList = schema.getTableTableToken().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("STOK")) { MSSBamSchemaTokenBuff[] subList = schema.getTableSchemaToken().readBuffByDataScopeIdx(Authorization, DataScopeId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } return (resultList.toArray(new MSSBamAtomDefBuff[0])); }
From source file:edu.ku.brc.specify.conversion.GenericDBConversion.java
/** * Converts all the CollectionObject Physical records and CollectionObjectCatalog Records into * the new schema Preparation table.//w w w. j av a 2s. co m * @return true if no errors */ public boolean convertLoanRecords(final boolean doingGifts) { String newTableName = doingGifts ? "gift" : "loan"; setIdentityInsertONCommandForSQLServer(newDBConn, newTableName, BasicSQLUtils.myDestinationServerType); deleteAllRecordsFromTable(newDBConn, newTableName, BasicSQLUtils.myDestinationServerType); // automatically closes the connection if (getNumRecords(oldDBConn, "loan") == 0) { return true; } String[] ignoredFields = { "SpecialConditions", "AddressOfRecordID", "DateReceived", "ReceivedComments", "PurposeOfLoan", "OverdueNotiSetDate", "IsFinancialResponsibility", "Version", "CreatedByAgentID", "IsFinancialResponsibility", "SrcTaxonomy", "SrcGeography", "CollectionMemberID", "PurposeOfGift", "IsFinancialResponsibility", "SpecialConditions", "ReceivedComments", "AddressOfRecordID" }; Hashtable<String, Boolean> fieldToSkip = new Hashtable<String, Boolean>(); for (String nm : ignoredFields) { fieldToSkip.put(nm, true); } IdTableMapper loanIdMapper = (IdTableMapper) idMapperMgr.get(newTableName, doingGifts ? "GiftID" : "LoanID"); try { Statement stmt = oldDBConn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); stmt.setFetchSize(Integer.MIN_VALUE); StringBuilder str = new StringBuilder(); List<String> oldFieldNames = getFieldNamesFromSchema(oldDBConn, "loan"); StringBuilder sql = new StringBuilder("SELECT "); sql.append(buildSelectFieldList(oldFieldNames, "loan")); sql.append(" FROM loan WHERE loan.Category = "); sql.append(doingGifts ? "1" : "0"); sql.append(" ORDER BY loan.LoanID"); log.info(sql); List<FieldMetaData> newFieldMetaData = getFieldMetaDataFromSchema(newDBConn, newTableName); log.info("Number of Fields in New " + newTableName + " " + newFieldMetaData.size()); String sqlStr = sql.toString(); if (doingGifts && loanIdMapper == null) { StringBuilder mapSQL = new StringBuilder("SELECT LoanID FROM loan WHERE loan.Category = "); mapSQL.append(doingGifts ? "1" : "0"); mapSQL.append(" ORDER BY loan.LoanID"); log.info(mapSQL.toString()); BasicSQLUtils.deleteAllRecordsFromTable(oldDBConn, "gift_GiftID", BasicSQLUtils.myDestinationServerType); loanIdMapper = new IdTableMapper(newTableName, "GiftID", mapSQL.toString(), false, false); idMapperMgr.addMapper(loanIdMapper); loanIdMapper.mapAllIdsWithSQL(); } Map<String, Integer> oldNameIndex = new Hashtable<String, Integer>(); int inx = 1; for (String name : oldFieldNames) { oldNameIndex.put(name, inx++); } Map<String, String> colNewToOldMap = doingGifts ? createFieldNameMap(new String[] { "GiftNumber", "LoanNumber", "GiftDate", "LoanDate", "IsCurrent", "Current", "IsClosed", "Closed" }) : createFieldNameMap(new String[] { "IsCurrent", "Current", "IsClosed", "Closed", }); log.info(sqlStr); ResultSet rs = stmt.executeQuery(sqlStr); if (hasFrame) { if (rs.last()) { setProcess(0, rs.getRow()); rs.first(); } else { rs.close(); stmt.close(); return true; } } else { if (!rs.first()) { rs.close(); stmt.close(); return true; } } PartialDateConv partialDateConv = new PartialDateConv(); int lastEditedByInx = oldNameIndex.get("LastEditedBy"); int count = 0; do { partialDateConv.nullAll(); str.setLength(0); StringBuffer fieldList = new StringBuffer(); fieldList.append("( "); for (int i = 0; i < newFieldMetaData.size(); i++) { if ((i > 0) && (i < newFieldMetaData.size())) { fieldList.append(", "); } String newFieldName = newFieldMetaData.get(i).getName(); fieldList.append(newFieldName); } fieldList.append(")"); str.append("INSERT INTO " + newTableName + " " + fieldList + " VALUES ("); for (int i = 0; i < newFieldMetaData.size(); i++) { if (i > 0) { str.append(", "); } String newFieldName = newFieldMetaData.get(i).getName(); if (i == 0) { Integer oldID = rs.getInt(1); Integer newID = loanIdMapper.get(oldID); if (newID != null) { str.append(getStrValue(newID)); } else { log.error(newTableName + " Old/New ID problem [" + oldID + "][" + newID + "]"); } } else if (newFieldName.equals("Version")) // User/Security changes { str.append("0"); } else if (newFieldName.equals("CreatedByAgentID")) // User/Security changes { str.append(getCreatorAgentId(null)); } else if (newFieldName.equals("ModifiedByAgentID")) // User/Security changes { String lastEditedByStr = rs.getString(lastEditedByInx); str.append(getModifiedByAgentId(lastEditedByStr)); } else if (fieldToSkip.get(newFieldName) != null) { str.append("NULL"); } else if (newFieldName.equals("DisciplineID")) // User/Security changes { str.append(curDisciplineID); } else if (newFieldName.equals("DivisionID")) // User/Security changes { str.append(curDivisionID); } else { Integer index = null; String oldMappedColName = colNewToOldMap.get(newFieldName); if (oldMappedColName != null) { index = oldNameIndex.get(oldMappedColName); } else { index = oldNameIndex.get(newFieldName); oldMappedColName = newFieldName; } Object data; if (index == null) { String msg = "convertLoanRecords - Couldn't find new field name[" + newFieldName + "] in old field name in index Map"; log.warn(msg); // stmt.close(); // throw new RuntimeException(msg); data = null; } else { data = rs.getObject(index); } if (data != null) { int idInx = newFieldName.lastIndexOf("ID"); if (idMapperMgr != null && idInx > -1) { IdMapperIFace idMapper = idMapperMgr.get("loan", oldMappedColName); if (idMapper != null) { data = idMapper.get(rs.getInt(index)); } else { log.error("No Map for [" + "loan" + "][" + oldMappedColName + "]"); } } } // hack for ??bug?? found in Sp5 that inserted null values in // timestampmodified field of determination table? BasicSQLUtils.fixTimestamps(newFieldName, newFieldMetaData.get(i).getType(), data, str); } } str.append(")"); if (hasFrame) { if (count % 500 == 0) { setProcess(count); } } else { if (count % 2000 == 0) { log.info("Loan/Gifts Records: " + count); } } try { //log.debug(str.toString()); Statement updateStatement = newDBConn.createStatement(); // updateStatement.executeUpdate("SET FOREIGN_KEY_CHECKS = 0"); updateStatement.executeUpdate(str.toString()); updateStatement.clearBatch(); updateStatement.close(); updateStatement = null; } catch (SQLException e) { log.error("Count: " + count); log.error("Exception on insert: " + str.toString()); e.printStackTrace(); log.error(e); rs.close(); stmt.close(); throw new RuntimeException(e); } count++; // if (count > 10) break; } while (rs.next()); if (hasFrame) { setProcess(count); } else { log.info("Processed Loan/Gift " + count + " records."); } rs.close(); stmt.close(); } catch (SQLException e) { e.printStackTrace(); log.error(e); throw new RuntimeException(e); } setIdentityInsertOFFCommandForSQLServer(newDBConn, "determination", BasicSQLUtils.myDestinationServerType); return true; }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8AnyObjTable.java
public MSSBamAnyObjBuff readBuff(MSSBamAuthorization Authorization, MSSBamAnyObjPKey PKey) { final String S_ProcName = "readBuff"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w ww . j av a 2s . c o m try { Connection cnx = schema.getCnx(); long Id = PKey.getRequiredId(); String sql = S_sqlSelectAnyObjBuff + "WHERE " + "anyo.Id = " + Long.toString(Id) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { MSSBamAnyObjBuff buff = unpackAnyObjResultSetToBuff(resultSet); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } return (buff); } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } }