AbstractDatabasePlatform implements IDatabasePlatform { @Override public Map<String, String> parseQualifiedTableName(String tableName) { Map<String, String> tableNameParts = new LinkedHashMap<String, String>(); if (StringUtils.isEmpty(tableName)) { return tableNameParts; } String[] initialSplit = tableName.split(Pattern.quote(getDatabaseInfo().getCatalogSeparator())); if (initialSplit.length == 0) { initialSplit = new String[] { tableName }; } List<String> nameComponents = new ArrayList<String>(); for (String part : initialSplit) { String[] subParts = part.split(Pattern.quote(getDatabaseInfo().getSchemaSeparator())); if (subParts.length == 0) { subParts = new String[] { part }; } for (String subPart : subParts) { if (!StringUtils.isEmpty(subPart)) { nameComponents.add(subPart); } } } if (nameComponents.size() >= 3) { tableNameParts.put("catalog", nameComponents.get(0)); tableNameParts.put("schema", nameComponents.get(1)); tableNameParts.put("table", nameComponents.get(2)); } else if (nameComponents.size() == 2) { tableNameParts.put("schema", nameComponents.get(0)); tableNameParts.put("table", nameComponents.get(1)); } else { tableNameParts.put("table", nameComponents.get(0)); } return tableNameParts; } AbstractDatabasePlatform(SqlTemplateSettings settings); DatabaseInfo getDatabaseInfo(); abstract ISqlTemplate getSqlTemplate(); abstract ISqlTemplate getSqlTemplateDirty(); DmlStatement createDmlStatement(DmlType dmlType, Table table, String textColumnExpression); DmlStatement createDmlStatement(DmlType dmlType, String catalogName, String schemaName, String tableName, Column[] keys,
            Column[] columns, boolean[] nullKeyValues, String textColumnExpression); DmlStatement createDmlStatement(DmlType dmlType, String catalogName, String schemaName, String tableName, Column[] keys,
            Column[] columns, boolean[] nullKeyValues, String textColumnExpression, boolean namedParameters); IDdlReader getDdlReader(); IDdlBuilder getDdlBuilder(); void setClearCacheModelTimeoutInMs(long clearCacheModelTimeoutInMs); long getClearCacheModelTimeoutInMs(); void dropTables(boolean continueOnError, Table... tables); void dropDatabase(Database database, boolean continueOnError); void createTables(boolean dropTablesFirst, boolean continueOnError, Table... tables); void createDatabase(Database targetDatabase, boolean dropTablesFirst, boolean continueOnError); void alterDatabase(Database desiredDatabase, boolean continueOnError, IAlterDatabaseInterceptor[] interceptors); void alterDatabase(Database desiredDatabase, boolean continueOnError); void alterTables(boolean continueOnError, Table... desiredTables); void alterTables(boolean continueOnError, IAlterDatabaseInterceptor[] interceptors, Table... desiredTables); Database readDatabase(String catalog, String schema, String[] tableTypes); Database readFromDatabase(Table... tables); Table readTableFromDatabase(String catalogName, String schemaName, String tableName); void resetCachedTableModel(); Table getTableFromCache(String tableName, boolean forceReread); Table getTableFromCache(String catalogName, String schemaName, String tableName, boolean forceReread); Object[] getObjectValues(BinaryEncoding encoding, Table table, String[] columnNames, String[] values); Object[] getObjectValues(BinaryEncoding encoding, Table table, String[] columnNames, String[] values, boolean useVariableDates,
            boolean fitToColumn); Object[] getObjectValues(BinaryEncoding encoding, String[] values, Column[] orderedMetaData); Object[] getObjectValues(BinaryEncoding encoding, String[] values, Column[] orderedMetaData, boolean useVariableDates,
            boolean fitToColumn); String[] getStringValues(BinaryEncoding encoding, Column[] metaData, Row row, boolean useVariableDates, boolean indexByPosition); String getCsvStringValue(BinaryEncoding encoding, Column[] metaData, Row row, boolean[] isColumnPositionUsingTemplate); Map<String, String> getSqlScriptReplacementTokens(); String scrubSql(String sql); java.util.Date parseDate(int type, String value, boolean useVariableDates); @Override Map<String, String> parseQualifiedTableName(String tableName); Table makeAllColumnsPrimaryKeys(Table table); boolean isLob(int type); boolean isClob(int type); boolean isBlob(int type); List<Column> getLobColumns(Table table); void setMetadataIgnoreCase(boolean metadataIgnoreCase); boolean isMetadataIgnoreCase(); boolean isStoresLowerCaseIdentifiers(); boolean isStoresMixedCaseQuotedIdentifiers(); boolean isStoresUpperCaseIdentifiers(); Database readDatabaseFromXml(String filePath, boolean alterCaseToMatchDatabaseDefaultCase); void prefixDatabase(String prefix, Database targetTables); void alterCaseToMatchDatabaseDefaultCase(Database database); String[] alterCaseToMatchDatabaseDefaultCase(String[] values); String alterCaseToMatchDatabaseDefaultCase(String value); void alterCaseToMatchDatabaseDefaultCase(Table... tables); void alterCaseToMatchDatabaseDefaultCase(Table table); Database readDatabaseFromXml(InputStream is, boolean alterCaseToMatchDatabaseDefaultCase); boolean canColumnBeUsedInWhereClause(Column column); java.util.Date parseTimestamp(int type, String value); TimeZone getTimeZone(String value); @Override void makePlatformSpecific(Database database); List<PermissionResult> checkSymTablePermissions(PermissionType... permissionTypes); boolean isUseMultiThreadSyncTriggers(); @Override boolean supportsTransactions(); @Override boolean supportsMultiThreadedTransactions(); long getEstimatedRowCount(Table table); String getTruncateSql(Table table); String getDeleteSql(Table table); static final String REQUIRED_FIELD_NULL_SUBSTITUTE; static final String ZERO_DATE_STRING; }
@Test public void testParseQualifiedTableName() { assertEquals("SIMPLE_TABLE_NAME", testDatabasePlatform.parseQualifiedTableName("SIMPLE_TABLE_NAME").get("table")); assertEquals(1, testDatabasePlatform.parseQualifiedTableName("SIMPLE_TABLE_NAME").size()); assertEquals("\"QUOTED_TABLE_NAME\"", testDatabasePlatform.parseQualifiedTableName("\"QUOTED_TABLE_NAME\"").get("table")); assertEquals(1, testDatabasePlatform.parseQualifiedTableName("\"QUOTED_TABLE_NAME\"").size()); assertEquals("TABLE", testDatabasePlatform.parseQualifiedTableName("SCHEMA.TABLE").get("table")); assertEquals("SCHEMA", testDatabasePlatform.parseQualifiedTableName("SCHEMA.TABLE").get("schema")); assertEquals(2, testDatabasePlatform.parseQualifiedTableName("SCHEMA.TABLE").size()); assertEquals("CATALOG", testDatabasePlatform.parseQualifiedTableName("CATALOG.SCHEMA.TABLE").get("catalog")); assertEquals("TABLE", testDatabasePlatform.parseQualifiedTableName("CATALOG.SCHEMA.TABLE").get("table")); assertEquals("SCHEMA", testDatabasePlatform.parseQualifiedTableName("CATALOG.SCHEMA.TABLE").get("schema")); assertEquals(3, testDatabasePlatform.parseQualifiedTableName("CATALOG.SCHEMA.TABLE").size()); assertEquals("\"CATALOG\"", testDatabasePlatform.parseQualifiedTableName("\"CATALOG\".\"SCHEMA\".\"TABLE\"").get("catalog")); assertEquals("\"TABLE\"", testDatabasePlatform.parseQualifiedTableName("\"CATALOG\".\"SCHEMA\".\"TABLE\"").get("table")); assertEquals("\"SCHEMA\"", testDatabasePlatform.parseQualifiedTableName("\"CATALOG\".\"SCHEMA\".\"TABLE\"").get("schema")); assertEquals(3, testDatabasePlatform.parseQualifiedTableName("\"CATALOG\".\"SCHEMA\".\"TABLE\"").size()); }