private boolean checkDatabaseForTable(String templateName, String tableName) { TemplateDatabaseDescription templateDatabaseDescription = templateNameToDatabaseDescriptionMap.get(templateName); MyUtils.checkStatusProgram(templateDatabaseDescription != null); List<String> tableList = templateDatabaseDescription.getTableList(); return MartConfiguratorUtils.containsIgnoreCase(tableList, tableName); }
public void fetchTableColumnMap(String templateName) throws TechnicalException { String databaseName = getDatabaseName(templateName); MyUtils.checkStatusProgram(null != databaseName); try { Map<String, List<String>> tableColumnMap = null; TemplateDatabaseDescription templateDatabaseDescription = templateNameToDatabaseDescriptionMap.get(templateName); MyUtils.checkStatusProgram(templateDatabaseDescription != null); String tableColumnMapContentSerialFilePathAndName = this.transformationsGeneralSerialFolderPathAndName + TABLE_COLUMN_LIST_SERIAL_FILE_PREFIX + databaseName; if (new File(tableColumnMapContentSerialFilePathAndName).exists()) { tableColumnMap = (Map<String, List<String>>) MyUtils.readSerializedObject(tableColumnMapContentSerialFilePathAndName); System.out.println("Using serial, quick check: " + tableColumnMap.size()); } else { System.out.println( "No serial at " + tableColumnMapContentSerialFilePathAndName + " , connecting..."); connect(databaseName); tableColumnMap = new HashMap<String, List<String>>(); List<String> tableList = templateDatabaseDescription.getTableList(); int table = 0; for (String tableName : tableList) { System.out.print( "tableName = " + tableName + ", " + (table + 1) + "/" + tableList.size()); // Prepare list of descriptions this.preparedStatementField = this.connection.prepareStatement("desc " + tableName); ResultSet resultSet = this.preparedStatementField.executeQuery(); List<String> columnList = new ArrayList<String>(); resultSet.beforeFirst(); while (resultSet.next()) { columnList.add(resultSet.getString(1)); } tableColumnMap.put(tableName, columnList); this.preparedStatementField.close(); resultSet.close(); System.out.println(", " + columnList.size()); table++; } disconnect(); MyUtils.writeSerializedObject(tableColumnMap, tableColumnMapContentSerialFilePathAndName); } templateDatabaseDescription.setTableColumnMap(tableColumnMap); } catch (SQLException e) { throw new TechnicalException(e); } }