com.continuent.tungsten.replicator.filter
Class RenameDefinitions

java.lang.Object
  extended by com.continuent.tungsten.replicator.filter.RenameDefinitions

public class RenameDefinitions
extends java.lang.Object

Definitions of requests to rename schemas, tables and columns.

Version:
1.0
Author:
Linas Virbalas

Constructor Summary
RenameDefinitions(java.lang.String definitionFile)
           
 
Method Summary
 java.lang.String getDefinitionsFile()
          Returns rename definitions file name used.
 java.lang.String getNewColumnName(java.lang.String schema, java.lang.String table, java.lang.String column)
          Gets new name for the column.
 java.lang.String getNewSchemaName(java.lang.String schema, java.lang.String table)
          Gets new name for the schema.
 java.lang.String getNewTableName(java.lang.String schema, java.lang.String table)
          Gets new name for the table.
 void parseFile()
          Parses rename definition file, validates format and populates lookup structures.
 boolean shouldRenameColumn(java.lang.String schema, java.lang.String table)
          Check whether specific schema and table has requests to rename columns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenameDefinitions

public RenameDefinitions(java.lang.String definitionFile)
Method Detail

getDefinitionsFile

public java.lang.String getDefinitionsFile()
Returns rename definitions file name used.


parseFile

public void parseFile()
               throws java.io.IOException,
                      ReplicatorException
Parses rename definition file, validates format and populates lookup structures.

Throws:
ReplicatorException - On format issues.
java.io.IOException

shouldRenameColumn

public boolean shouldRenameColumn(java.lang.String schema,
                                  java.lang.String table)
Check whether specific schema and table has requests to rename columns. Checks for asterisk matches too:
schema.table
*.table
schema.*
*.*

Returns:
true, if columns are in need for renaming.

getNewColumnName

public java.lang.String getNewColumnName(java.lang.String schema,
                                         java.lang.String table,
                                         java.lang.String column)
Gets new name for the column. Search for rename definition done in the following order:
1. schema.table
2. schema.*
3. *.table
4. *.*

Returns:
Renamed column name or null if no rename definition found.

getNewTableName

public java.lang.String getNewTableName(java.lang.String schema,
                                        java.lang.String table)
Gets new name for the table. Search for rename definition done in the following order of preference:
1. schema.table
2. *.table

Returns:
Renamed table name or null if no rename definition found.

getNewSchemaName

public java.lang.String getNewSchemaName(java.lang.String schema,
                                         java.lang.String table)
Gets new name for the schema. Search for rename definition done in the following order of preference:
1. schema.table
2. schema.*

Returns:
Renamed table name or null if no rename definition found.