com.ptc.windchill.esi.migrate
Class MigratorService

java.lang.Object
  extended bycom.ptc.windchill.esi.migrate.MigratorService

public class MigratorService
extends Object

Utility class that provides basic migration services. These methods are meant only to be used server-side.


Field Summary
private static PrintWriter log
           
 
Constructor Summary
MigratorService()
           
 
Method Summary
static void freeResources(ResultSet rs)
          Releases the resources used by the supplied ResultSet.
static void freeResources(Statement statement)
          Releases the resources used by the supplied Statement.
static Connection getConnection()
          Returns a JDBC connection to the Windchill database.
protected static PrintWriter getLog()
          Obtains the log in which information and errors can be recorded related to the migration processing.
static String getLogFileName()
          Obtains the name of the log file used to record the details related to the migration processing.
static Persistable getObject(ObjectIdentifier objectId)
          Returns the Persistable represented by the supplied object identifier.
static ObjectIdentifier getObjectId(String className, long id)
          Creates an ObjectIdentifier instance from the supplied class name and identity.
static PersistentObjectManager getPOM()
          Returns a PersistentObjectManager for the Windchill database.
static Persistable getRoleAObject(ResultSet rs)
          Returns the Persistable represented by the Role A relationship contained in the supplied ResultSet.
static ObjectIdentifier getRoleAObjectId(ResultSet rs)
          Extracts the ObjectIdentifier for the Role A relationship contained in the supplied ResultSet.
static Persistable getRoleBObject(ResultSet rs)
          Returns the Persistable represented by the Role B relationship contained in the supplied ResultSet.
static ObjectIdentifier getRoleBObjectId(ResultSet rs)
          Extracts the ObjectIdentifier for the Role B relationship contained in the supplied ResultSet.
static TimeZone getTimeZone()
          Returns the time zone used by Windchill.
static String getUserName()
          Returns the name of the user currently logged into Windchill.
static boolean hasTable(String tableName)
          Determines if a table exists in the Windchill database for the supplied name.
static void log(Exception e)
          Logs the supplied exception.
static void log(String msg)
          Logs the supplied message.
static void log(String msg, Exception e)
          Logs the supplied message and exception.
static ResultSet query(String sql)
          Executes the supplied SQL query on the Windchill database, returning the query's resultset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static PrintWriter log
Constructor Detail

MigratorService

public MigratorService()
Method Detail

getConnection

public static Connection getConnection()
                                throws WTException
Returns a JDBC connection to the Windchill database.

Returns:
a JDBC connection
Throws:
WTException

getPOM

public static PersistentObjectManager getPOM()
                                      throws WTException
Returns a PersistentObjectManager for the Windchill database.

Returns:
a PersistentObjectManager
Throws:
WTException

getUserName

public static String getUserName()
Returns the name of the user currently logged into Windchill.

Returns:
the name of the current user
Throws:
WTException

getTimeZone

public static TimeZone getTimeZone()
Returns the time zone used by Windchill.

Returns:
the time zone

hasTable

public static boolean hasTable(String tableName)
                        throws WTException
Determines if a table exists in the Windchill database for the supplied name.

Parameters:
tableName - - the name of the table to locate
Returns:
true if the table exists; otherwise, false
Throws:
WTException

query

public static ResultSet query(String sql)
                       throws WTException
Executes the supplied SQL query on the Windchill database, returning the query's resultset.

Parameters:
sql - - the SQL query to execute
Returns:
the query's resultset
Throws:
WTException

freeResources

public static void freeResources(ResultSet rs)
Releases the resources used by the supplied ResultSet.

Parameters:
rs - - the ResultSet, may be null

freeResources

public static void freeResources(Statement statement)
Releases the resources used by the supplied Statement.

Parameters:
statement - - the Statement, may be null

getObjectId

public static ObjectIdentifier getObjectId(String className,
                                           long id)
                                    throws WTException
Creates an ObjectIdentifier instance from the supplied class name and identity.

Parameters:
className - - the class name of the object
id - - the identity of the object
Returns:
the newly created ObjectIdentifier
Throws:
WTException

getObject

public static Persistable getObject(ObjectIdentifier objectId)
                             throws WTException
Returns the Persistable represented by the supplied object identifier.

Parameters:
objectId - - the object identifier
Returns:
the Persistable represented by the object identifier
Throws:
WTException

getRoleAObjectId

public static ObjectIdentifier getRoleAObjectId(ResultSet rs)
                                         throws WTException
Extracts the ObjectIdentifier for the Role A relationship contained in the supplied ResultSet. The supplied ResultSet must be positioned on a valid row that contains the necessary role columns.

Parameters:
rs - - the ResultSet that contains the role columns
Returns:
the ObjectIdentifier stored for the role
Throws:
WTException

getRoleBObjectId

public static ObjectIdentifier getRoleBObjectId(ResultSet rs)
                                         throws WTException
Extracts the ObjectIdentifier for the Role B relationship contained in the supplied ResultSet. The supplied ResultSet must be positioned on a valid row that contains the necessary role columns.

Parameters:
rs - - the ResultSet that contains the role columns
Returns:
the ObjectIdentifier stored for the role
Throws:
WTException

getRoleAObject

public static Persistable getRoleAObject(ResultSet rs)
                                  throws WTException
Returns the Persistable represented by the Role A relationship contained in the supplied ResultSet. The supplied ResultSet must be positioned on a valid row that contains the necessary role columns.

Parameters:
rs - - the ResultSet that contains the role columns
Returns:
the Persistable represented by the role
Throws:
WTException

getRoleBObject

public static Persistable getRoleBObject(ResultSet rs)
                                  throws WTException
Returns the Persistable represented by the Role B relationship contained in the supplied ResultSet. The supplied ResultSet must be positioned on a valid row that contains the necessary role columns.

Parameters:
rs - - the ResultSet that contains the role columns
Returns:
the Persistable represented by the role
Throws:
WTException

log

public static void log(String msg)
Logs the supplied message.

Parameters:
msg - - the message to log

log

public static void log(Exception e)
Logs the supplied exception.

Parameters:
e - - the exception to log

log

public static void log(String msg,
                       Exception e)
Logs the supplied message and exception.

Parameters:
msg - - the message to log
e - - the exception to log

getLog

protected static PrintWriter getLog()
Obtains the log in which information and errors can be recorded related to the migration processing.

Returns:
a log that can be used to record migration details

getLogFileName

public static String getLogFileName()
                             throws IOException
Obtains the name of the log file used to record the details related to the migration processing. Returns null if a file name could not be constructed.

Returns:
the migration log file name
Throws:
IOException