wt.step.processor
Class ExportToP21Processor

java.lang.Object
  extended bywt.step.processor.ExportToP21Processor

public class ExportToP21Processor
extends Object

Processes export requests generating a STEP file in Windchill Schema.


Nested Class Summary
private  class ExportToP21Processor.WTInstanceMap
          A Hashtable capable of comparing Windchill instances
 
Field Summary
private  Vector _associatedDocuments
          A collection of all associated documents reference by exported instances
private  Properties _entityScope
          A collection identifing all WT class types to be exported
private  ExportToP21Processor.WTInstanceMap _instanceScope
          A map containing all instances to be exported (the scope of the export)
private  boolean _limitExportEntityScope
           
(package private)  PrintWriter _p21FileWriter
           
private  int _p21InstanceCounter
           
private  ExpressSchema _theWtSchema
           
private  ExportToP21Processor.WTInstanceMap _wtInstanceToP21IdMap
          A map of windchill instances to their Part21 ids in the Step file
private static boolean DEBUG_ASSOCIATIONS
          Debug associations but providing extract output
private static boolean DEBUG_PART21
          If set (by property debug.part21) attribute names are written
private static Object[] NO_ARGS
           
private static Class[] NO_CLASS_ARGS
           
private static int UNDEFINED_ENTITY_ID
           
private  Hashtable undefined_methods
           
 
Constructor Summary
ExportToP21Processor(ExpressSchema wtSchema, Properties exportEntityScope, String outputFilename, FileOutputStream outputStream, WTObject[] objects, boolean downloadAssociatedFiles)
           
ExportToP21Processor(ExpressSchema wtSchema, Properties exportEntityScope, String outputFilename, PrintWriter outputWriter, WTObject[] objects, boolean downloadAssociatedFiles)
           
ExportToP21Processor(ExpressSchema wtSchema, Properties exportEntityScope, String outputFilename, WTObject[] objects, boolean downloadAssociatedFiles)
           
 
Method Summary
private  boolean appendEntityAttributesToStatement(StringBuffer statement, boolean isFirstAttribute, EntityDefinition entityType, Object windchillInstance, Hashtable writtenTypes)
           
private  void appendEntityAttributeToStatement(StringBuffer statement, EntityDefinition instanceType, Object windchillInstance, EntityDefinition.AttributeDefinition attribute)
           
private  void appendEntityAttributeValueToStatement(StringBuffer statement, Object windchillValue, String attributeTypeName)
           
private  StringBuffer createP21EntityStatement(EntityDefinition entityType, Object windchillInstance)
           
private  void downloadAssociatedDocuments(String stepFilename)
          Downloads document contents into subdirectories of the step files directory, one for each document with content.
private  Object getAssociatedWindchillObjects(Object windchillInstance, EntityDefinition instanceType, TypeDefinition attributeType, EntityDefinition.AttributeDefinition attribute)
          Returns associated objects by traversing Windchill ObjectToObject links for an attribute which represents a role of an association.
private  QueryResult getEntityLinksFrom(Object windchillInstance, Class linkType)
           
private  Throwable getLowestException(Throwable ex)
           
private  int getP21IdForWindchillInstance(String attributeType, Object windchillInstance)
          Gets a Part21 step file Id for an instance.
private  Object getRelatedWindchillObject(Object windchillInstance, EntityDefinition instanceType, EntityDefinition.AttributeDefinition attribute)
           
private  Object getWindchillAttributeValue(Object windchillInstance, EntityDefinition instanceType, EntityDefinition.AttributeDefinition attribute)
          Gets the 'raw' value for a particular Windchill object instance.
private  void initialiseInstanceScope(WTObject[] scope)
           
private  boolean isAlreadyTranslated(Object instance)
          Has this instance already been translated ?
private  boolean isWithinEntityScope(Object instance)
          Is this type of instance one of those explicitly asked to be exported
private  boolean isWithinInstanceScope(Persistable instance)
          Is this instance one of those explicitly asked to be exported
private  void recordAssociatedDocument(DocumentVersion document)
           
private  int translateWindchillInstance(EntityDefinition entityDef, Object windchillInstance)
           
private  int translateWindchillInstance(Object windchillInstance)
          Translate a Windchill object into STEP format.
 boolean windchillObjectIsInstanceOfAttributeType(String attributeType, Object windchillValue)
           
private  void writeEntityLinksFrom(EntityDefinition entityType, Object windchillInstance)
           
private  void writeP21Contents(WTObject[] objects)
           
protected  void writeP21Entity(int id, String statement)
           
protected  void writeP21Header(String schemaName, String fullFilename)
           
protected  void writeP21Tail()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED_ENTITY_ID

private static final int UNDEFINED_ENTITY_ID
See Also:
Constant Field Values

NO_ARGS

private static final Object[] NO_ARGS

NO_CLASS_ARGS

private static final Class[] NO_CLASS_ARGS

_theWtSchema

private ExpressSchema _theWtSchema

_p21InstanceCounter

private int _p21InstanceCounter

_wtInstanceToP21IdMap

private ExportToP21Processor.WTInstanceMap _wtInstanceToP21IdMap
A map of windchill instances to their Part21 ids in the Step file


_instanceScope

private ExportToP21Processor.WTInstanceMap _instanceScope
A map containing all instances to be exported (the scope of the export)


_entityScope

private Properties _entityScope
A collection identifing all WT class types to be exported


_limitExportEntityScope

private boolean _limitExportEntityScope

_p21FileWriter

PrintWriter _p21FileWriter

undefined_methods

private Hashtable undefined_methods

_associatedDocuments

private Vector _associatedDocuments
A collection of all associated documents reference by exported instances


DEBUG_PART21

private static boolean DEBUG_PART21
If set (by property debug.part21) attribute names are written


DEBUG_ASSOCIATIONS

private static boolean DEBUG_ASSOCIATIONS
Debug associations but providing extract output

Constructor Detail

ExportToP21Processor

public ExportToP21Processor(ExpressSchema wtSchema,
                            Properties exportEntityScope,
                            String outputFilename,
                            WTObject[] objects,
                            boolean downloadAssociatedFiles)
                     throws TransferException,
                            WTException,
                            FileNotFoundException,
                            IOException

ExportToP21Processor

public ExportToP21Processor(ExpressSchema wtSchema,
                            Properties exportEntityScope,
                            String outputFilename,
                            FileOutputStream outputStream,
                            WTObject[] objects,
                            boolean downloadAssociatedFiles)
                     throws TransferException,
                            WTException,
                            FileNotFoundException,
                            IOException

ExportToP21Processor

public ExportToP21Processor(ExpressSchema wtSchema,
                            Properties exportEntityScope,
                            String outputFilename,
                            PrintWriter outputWriter,
                            WTObject[] objects,
                            boolean downloadAssociatedFiles)
                     throws TransferException,
                            WTException,
                            FileNotFoundException,
                            IOException
Method Detail

isWithinEntityScope

private boolean isWithinEntityScope(Object instance)
Is this type of instance one of those explicitly asked to be exported


initialiseInstanceScope

private void initialiseInstanceScope(WTObject[] scope)

isWithinInstanceScope

private boolean isWithinInstanceScope(Persistable instance)
Is this instance one of those explicitly asked to be exported


writeP21Contents

private void writeP21Contents(WTObject[] objects)
                       throws TransferException,
                              WTException
Throws:
TransferException
WTException

writeP21Tail

protected void writeP21Tail()

writeP21Entity

protected void writeP21Entity(int id,
                              String statement)

writeP21Header

protected void writeP21Header(String schemaName,
                              String fullFilename)

isAlreadyTranslated

private boolean isAlreadyTranslated(Object instance)
Has this instance already been translated ?


translateWindchillInstance

private int translateWindchillInstance(Object windchillInstance)
                                throws TransferException,
                                       WTException
Translate a Windchill object into STEP format.

Parameters:
windchillInstance - An object to translate
Throws:
TransferException
WTException

translateWindchillInstance

private int translateWindchillInstance(EntityDefinition entityDef,
                                       Object windchillInstance)
                                throws TransferException,
                                       WTException
Throws:
TransferException
WTException

createP21EntityStatement

private StringBuffer createP21EntityStatement(EntityDefinition entityType,
                                              Object windchillInstance)
                                       throws TransferException,
                                              WTException
Throws:
TransferException
WTException

getEntityLinksFrom

private QueryResult getEntityLinksFrom(Object windchillInstance,
                                       Class linkType)
                                throws WTException
Throws:
WTException

getAssociatedWindchillObjects

private Object getAssociatedWindchillObjects(Object windchillInstance,
                                             EntityDefinition instanceType,
                                             TypeDefinition attributeType,
                                             EntityDefinition.AttributeDefinition attribute)
                                      throws TransferException,
                                             WTException
Returns associated objects by traversing Windchill ObjectToObject links for an attribute which represents a role of an association. e.g. Content_holder.the__content_item, Content_item.the__content_holder

Returns:
A vector of the associated windchill objects.
Throws:
TransferException
WTException

getRelatedWindchillObject

private Object getRelatedWindchillObject(Object windchillInstance,
                                         EntityDefinition instanceType,
                                         EntityDefinition.AttributeDefinition attribute)
                                  throws TransferException,
                                         WTException
Throws:
TransferException
WTException

writeEntityLinksFrom

private void writeEntityLinksFrom(EntityDefinition entityType,
                                  Object windchillInstance)
                           throws WTException,
                                  TransferException
Throws:
WTException
TransferException

appendEntityAttributesToStatement

private boolean appendEntityAttributesToStatement(StringBuffer statement,
                                                  boolean isFirstAttribute,
                                                  EntityDefinition entityType,
                                                  Object windchillInstance,
                                                  Hashtable writtenTypes)
                                           throws TransferException,
                                                  WTException
Throws:
TransferException
WTException

appendEntityAttributeToStatement

private void appendEntityAttributeToStatement(StringBuffer statement,
                                              EntityDefinition instanceType,
                                              Object windchillInstance,
                                              EntityDefinition.AttributeDefinition attribute)
                                       throws TransferException,
                                              WTException
Throws:
TransferException
WTException

appendEntityAttributeValueToStatement

private void appendEntityAttributeValueToStatement(StringBuffer statement,
                                                   Object windchillValue,
                                                   String attributeTypeName)
                                            throws TransferException,
                                                   WTException
Throws:
TransferException
WTException

getP21IdForWindchillInstance

private int getP21IdForWindchillInstance(String attributeType,
                                         Object windchillInstance)
                                  throws TransferException,
                                         WTException
Gets a Part21 step file Id for an instance. If the instance has already been exported then its Id is returned immediately, otherwise it is exported and a new Id is generated.

Returns:
The new id number or 0 if the instance was not exported.
Throws:
TransferException
WTException

getWindchillAttributeValue

private Object getWindchillAttributeValue(Object windchillInstance,
                                          EntityDefinition instanceType,
                                          EntityDefinition.AttributeDefinition attribute)
                                   throws TransferException,
                                          WTException
Gets the 'raw' value for a particular Windchill object instance. In most cases this is done by calling the 'get' method for the named attribute. i.e. {instance}.get{attribute-name}()
Associations are treated as a special case. They are a collection filled from ObjectToObjectLinks which start from this instance.

Throws:
TransferException
WTException

getLowestException

private Throwable getLowestException(Throwable ex)

windchillObjectIsInstanceOfAttributeType

public boolean windchillObjectIsInstanceOfAttributeType(String attributeType,
                                                        Object windchillValue)

recordAssociatedDocument

private void recordAssociatedDocument(DocumentVersion document)

downloadAssociatedDocuments

private void downloadAssociatedDocuments(String stepFilename)
                                  throws TransferException
Downloads document contents into subdirectories of the step files directory, one for each document with content.

Throws:
TransferException