wt.step.processor.conversion
Class SchemaConverter

java.lang.Object
  extended bywt.step.processor.conversion.SchemaConverter
Direct Known Subclasses:
EPMSchemaConverter, NullSchemaConverter

public abstract class SchemaConverter
extends Object

A base class for specific subclasses that implement import and export conversions between two schemas. Supports the use of multiple schemas for import and export through a schemas directory structure.

See Also:
getExportSchemaNames(), getImportSchemaNames()

Nested Class Summary
(package private) static class SchemaConverter.ExtensionFilter
           
 
Field Summary
private static SchemaConverter _converterInstance
          The schema converter instance used for all STEP Schema conversions.
private static FileFilter _directoryFilter
           
private static SchemaConverter.ExtensionFilter _mappingFileFilter
           
private static SchemaConverter.ExtensionFilter _schemaFileFilter
           
private static String SCHEMA_CONVERTER_CLASS
          The class implementing the SchemaConverter interface which can be used to convert between Windchill and other schemas
private static String SCHEMA_CONVERTER_LOGFILE
           
protected static String SCHEMAS_DIR_PROP
          Translation schema and express/X file access
protected static String WINDCHILL_SCHEMA_NAME_PROP
           
 
Constructor Summary
SchemaConverter()
           
 
Method Summary
static void clearConversionLog()
          Clears the conversion log file.
abstract  void convertForExport(String srcFilename, String targetFilename, String exportSchemaName)
          Converts the source file from Windchill schema to that defined by the converters configuration.
abstract  void convertForImport(String srcFilename, String targetFilename, String importSchemaName)
          Converts the source file to Windchill schema from that defined by the converters configuration.
static String getConversionLog()
          Provides access to the contents of the Schema Conversion log file.
static SchemaConverter getConverterInstance()
           
protected  File getExportMappingFile(String schemaName)
          The export mapping is found in the directory {schemasDir}/{schemaName}/export/{mappingName}.xpx Note: The mapping name MUST match the filename with extension .xpx
static String[] getExportSchemaNames()
          Lists schemas which have 'export' mappings, that is mappings from Windchill Schema to their Schema for export.
protected  String getExpressNameFromFile(File file)
          Converts a File to its Express name which is the filename without path or extension.
protected  File getImportMappingFile(String schemaName)
          The import mapping is found in the directory {schemasDir}/{schemaName}/import/{mappingName}.xpx Note: The mapping name MUST match the filename with extension .xpx
static String[] getImportSchemaNames()
          Lists schemas which have 'import' mappings, that is mappings from their schema to the Windchill schema that can be imported.
protected static String getLogFilename()
          Gets the filename for the schema converters log.
protected static String getMandatoryProperty(String propertyName)
          Gets a property value.
protected static String getProperty(String propertyName)
           
protected static File getSchemaFile(String schemaName)
          Access the File that matches a schema name, that is: {wt.step.schemasDir}/{schema-name}/{something}.xpx
private static String[] getSchemaNamesFor(String schemaFunction)
          Searchs the schemas dir for sub-directories (schemas) which have the required subdirectory/function ("import" or "export").
protected static File getSingleTypedFile(File dir, SchemaConverter.ExtensionFilter filter)
          Get a single file matching a given filename filter in the given directory.
static String getWindchillSchemaFilename()
          Returns the name of the Windchill schema so that it may be used during schema conversions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMAS_DIR_PROP

protected static final String SCHEMAS_DIR_PROP
Translation schema and express/X file access

See Also:
Constant Field Values

WINDCHILL_SCHEMA_NAME_PROP

protected static final String WINDCHILL_SCHEMA_NAME_PROP
See Also:
Constant Field Values

SCHEMA_CONVERTER_CLASS

private static final String SCHEMA_CONVERTER_CLASS
The class implementing the SchemaConverter interface which can be used to convert between Windchill and other schemas

See Also:
Constant Field Values

SCHEMA_CONVERTER_LOGFILE

private static final String SCHEMA_CONVERTER_LOGFILE
See Also:
Constant Field Values

_converterInstance

private static SchemaConverter _converterInstance
The schema converter instance used for all STEP Schema conversions. Defined by the property 'wt.step.schemaConverter.class'


_schemaFileFilter

private static SchemaConverter.ExtensionFilter _schemaFileFilter

_mappingFileFilter

private static SchemaConverter.ExtensionFilter _mappingFileFilter

_directoryFilter

private static FileFilter _directoryFilter
Constructor Detail

SchemaConverter

public SchemaConverter()
Method Detail

getConverterInstance

public static SchemaConverter getConverterInstance()
                                            throws TransferException
Throws:
TransferException

clearConversionLog

public static void clearConversionLog()
Clears the conversion log file. This should be called before any conversions to avoid confusion arising from viewing a previous conversions log.


getConversionLog

public static String getConversionLog()
Provides access to the contents of the Schema Conversion log file. This will contain only details of the last conversion operation performed.


getExportSchemaNames

public static String[] getExportSchemaNames()
                                     throws TransferException
Lists schemas which have 'export' mappings, that is mappings from Windchill Schema to their Schema for export. These are identified by looking in the 'schemas' directory (defined by the property 'wt.step.schemaDir') for subdirectories which contain a directory called 'export'. The schema names are these subdirectories names. It is expected that each subdirectory will contain an Express schema definition (.exp) and each 'export' directory will contain a mapping file (.xpx) from Windchill Schema to that Schema.

Throws:
TransferException
See Also:
getExpressNameFromFile(java.io.File)

getImportSchemaNames

public static String[] getImportSchemaNames()
                                     throws TransferException
Lists schemas which have 'import' mappings, that is mappings from their schema to the Windchill schema that can be imported. These are identified by looking in the 'schemas' directory (defined by the property 'wt.step.schemaDir') for subdirectories which contain a directory called 'import'. The schema names are these subdirectories names. It is expected that each subdirectory will contain an Express schema definition (.exp) and each 'import' directory will contain a mapping file (.xpx) from that Schema to the Windchill Schema.

Throws:
TransferException
See Also:
getExpressNameFromFile(java.io.File)

getSchemaNamesFor

private static String[] getSchemaNamesFor(String schemaFunction)
                                   throws TransferException
Searchs the schemas dir for sub-directories (schemas) which have the required subdirectory/function ("import" or "export").

Throws:
TransferException

getWindchillSchemaFilename

public static String getWindchillSchemaFilename()
                                         throws TransferException
Returns the name of the Windchill schema so that it may be used during schema conversions. Defined by the property wt.step.windchillSchemaName

Throws:
TransferException

getSchemaFile

protected static File getSchemaFile(String schemaName)
                             throws TransferException
Access the File that matches a schema name, that is: {wt.step.schemasDir}/{schema-name}/{something}.xpx

Throws:
TransferException

getSingleTypedFile

protected static File getSingleTypedFile(File dir,
                                         SchemaConverter.ExtensionFilter filter)
Get a single file matching a given filename filter in the given directory. If more than one file matches then the first is used and a warning is given. If none are found then null is returned.


getExpressNameFromFile

protected String getExpressNameFromFile(File file)
Converts a File to its Express name which is the filename without path or extension. e.g. '/a/b/c.d' becomes 'c'. This relies on the assumption that the name of the file (without extension) matches the name of its content (i.e. the file pdm_schema.exp must define the model for schema 'pdm_schema')


getExportMappingFile

protected File getExportMappingFile(String schemaName)
                             throws TransferException
The export mapping is found in the directory {schemasDir}/{schemaName}/export/{mappingName}.xpx Note: The mapping name MUST match the filename with extension .xpx

Throws:
TransferException

getImportMappingFile

protected File getImportMappingFile(String schemaName)
                             throws TransferException
The import mapping is found in the directory {schemasDir}/{schemaName}/import/{mappingName}.xpx Note: The mapping name MUST match the filename with extension .xpx

Throws:
TransferException

getMandatoryProperty

protected static String getMandatoryProperty(String propertyName)
                                      throws TransferException
Gets a property value. If it is property is undefined then a TransferException is thrown.

Throws:
TransferException

getProperty

protected static String getProperty(String propertyName)

getLogFilename

protected static String getLogFilename()
Gets the filename for the schema converters log. This is defined by the property 'wt.step.schemaConverter.logFile'.

Returns:
The log filename or null if the property is undefined.

convertForExport

public abstract void convertForExport(String srcFilename,
                                      String targetFilename,
                                      String exportSchemaName)
                               throws ConversionException,
                                      TransferException
Converts the source file from Windchill schema to that defined by the converters configuration. The result is the completed export file. Implementations can assume that the source and target files will have a different file location/name.

Parameters:
exportSchemaName - The name of the schema to export to. This should
Throws:
ConversionException
TransferException

convertForImport

public abstract void convertForImport(String srcFilename,
                                      String targetFilename,
                                      String importSchemaName)
                               throws ConversionException,
                                      TransferException
Converts the source file to Windchill schema from that defined by the converters configuration. The result is a STEP file ready for import into Windchill. Implementations can assume that the source and target files will have a different file location/name.

Throws:
ConversionException
TransferException