wt.step.processor
Class WTImportService

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

public class WTImportService
extends Object

A utilities class providing high-level utility methods used during STEP import.


Field Summary
private static WTContainerRef _containerRef
           
private static boolean _hasListeners
           
private static Folder _importFolder
           
private static FolderingInfo _importFolderingInfo
           
private static Vector _listeners
           
private static Object[] _singleArg
           
private static String ENUMERATED_TYPE_VALUE_ATTRIBUTE
          The name of the standard attribute within any wt.fc.EnumeratedType (in STEP entity form) which can be used to access the enum instance.
private static String IMPORT_FOLDER_PROP
           
private static Class[] NO_ARGS
           
private static String STEP_CHECKIN_COMMENT
           
private static String STEP_CHECKOUT_COMMENT
           
private static String UNNAMED_MASTER_NAME
           
 
Constructor Summary
WTImportService()
           
 
Method Summary
static void addListener(WTImportEventListener listener)
           
protected static Object convertToEnumTypeValue(Object rawValue, String enumTypeName, ExpressSchema wtSchema, StepData dataForEntityRefs)
          Takes a parsed value for an enumeration type ( result of EnumeratedType.getStringValue() ) and converts it into a Windchill enumeration type value.
static RevisionControlled createNewIteration(Versioned version, String masterName, String masterNumber, String versionId, String iterationId)
          Create a new version of the given Master.
static ObjectToObjectLink createNewLink(Class linkClass, Persistable roleAInstance, Persistable roleBInstance)
          Create a new link object.
static RevisionControlled createNewMasterVersionAndIteration(Class iterationClass, String masterNumber, String masterName, String vId, String iId)
          Create a new iteration with a given Number and Name.
static RevisionControlled createNewVersionAndIteration(Mastered master, String masterName, String masterNumber, String importVersionId, String importIterationId)
          Create a new version of the given Master.
static RevisionControlled findIteration(Class masterClass, String masterNumber, String masterName, String versionId, String iterationId)
          Finds the iteration given the number and name of the Master and the iteration Id.
static RevisionControlled findIteration(Versioned version, String iterationId)
          Finds the iteration of the given version with the given iteration Id.
static RevisionControlled findLatestIteration(Versioned version)
          Finds the latest version of the given master.
static RevisionControlled findLatestVersion(Mastered master)
          Finds the latest version of the given master.
static Mastered findMaster(Class masterClass, String masterImportNumber, String masterImportName)
          Find a (Part/Document)Master given its class, name and number.
protected static Method findSetMethod(Object wtObject, String attrName, String type)
          Finds a set method for a given Windchill object.
static Versioned findVersion(Mastered master, String versionId)
          Finds the version of the given master with the given version Id.
private static void fireEvent(Persistable instance, Persistable parentInstance, int objectType, int eventType)
           
private static void fireEvent(Persistable instance, Persistable parentInstance, int objectType, int eventType, String id1)
           
private static void fireEvent(Persistable instance, Persistable parentInstance, int objectType, int eventType, String id1, String id2)
           
private static void firePersistenceEvent(Persistable nonPersistent, Persistable persistent)
           
private static void fireWarningEvent(Persistable instance, String warning)
           
static ObjectToObjectLink getExistingLink(Class linkClass, Object tmpLink, Persistable roleAInstance, Persistable roleBInstance)
           
static Folder getImportFolder()
           
static Mastered getMaster(RevisionControlled iteration)
           
private static Method getMethod(Class theClass, String name)
           
private static Method getMethod(Class theClass, String name, Class[] args)
           
private static String getShortClassName(Class theClass)
           
private static Object invokeMethod(Method theMethod)
           
private static Object invokeMethod(Method theMethod, Object instance)
           
private static Object invokeMethod(Method theMethod, Object instance, Object[] args)
           
static Persistable makePersistent(Persistable instance)
           
static void progressMessage(String message)
           
static void removeListener(WTImportEventListener listener)
           
static void setImportFolder(Foldered instance)
           
static void setImportFolder(String folderName)
          Set the folder that all instances will be created in.
static void setInstanceAttributes(Persistable wtObject, StepEntity stepObject, ExpressSchema wtSchema, StepData dataForEntityReferences)
          Given a parse StepEntity and its corresponding imported Windchill instance set all the attributes it has values for.
private static void setPropertyToDefault(Persistable wtObject, PropertyDescriptor propertyInfo)
          Set a Windchill objects property to its default value.
private static void validateNewIterationIds(RevisionControlled newIteration, String masterName, String masterNumber, String importVersionId, String importIterationId, boolean incrementCheckedout)
          Validate that the actual version/iteration ids match the imported version/iteration ids.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPORT_FOLDER_PROP

private static final String IMPORT_FOLDER_PROP
See Also:
Constant Field Values

STEP_CHECKOUT_COMMENT

private static final String STEP_CHECKOUT_COMMENT
See Also:
Constant Field Values

STEP_CHECKIN_COMMENT

private static final String STEP_CHECKIN_COMMENT
See Also:
Constant Field Values

UNNAMED_MASTER_NAME

private static final String UNNAMED_MASTER_NAME
See Also:
Constant Field Values

ENUMERATED_TYPE_VALUE_ATTRIBUTE

private static final String ENUMERATED_TYPE_VALUE_ATTRIBUTE
The name of the standard attribute within any wt.fc.EnumeratedType (in STEP entity form) which can be used to access the enum instance.

See Also:
Constant Field Values

_importFolderingInfo

private static FolderingInfo _importFolderingInfo

_importFolder

private static Folder _importFolder

_containerRef

private static WTContainerRef _containerRef

NO_ARGS

private static final Class[] NO_ARGS

_singleArg

private static final Object[] _singleArg

_listeners

private static Vector _listeners

_hasListeners

private static boolean _hasListeners
Constructor Detail

WTImportService

public WTImportService()
Method Detail

addListener

public static void addListener(WTImportEventListener listener)

removeListener

public static void removeListener(WTImportEventListener listener)

fireEvent

private static void fireEvent(Persistable instance,
                              Persistable parentInstance,
                              int objectType,
                              int eventType)

fireEvent

private static void fireEvent(Persistable instance,
                              Persistable parentInstance,
                              int objectType,
                              int eventType,
                              String id1)

fireEvent

private static void fireEvent(Persistable instance,
                              Persistable parentInstance,
                              int objectType,
                              int eventType,
                              String id1,
                              String id2)

fireWarningEvent

private static void fireWarningEvent(Persistable instance,
                                     String warning)

firePersistenceEvent

private static void firePersistenceEvent(Persistable nonPersistent,
                                         Persistable persistent)

progressMessage

public static void progressMessage(String message)

findMaster

public static Mastered findMaster(Class masterClass,
                                  String masterImportNumber,
                                  String masterImportName)
                           throws TransferException
Find a (Part/Document)Master given its class, name and number. The query matches the number and generates a warning message if the name doesn't match.

Returns:
The Master object. null if none is found.
Throws:
TransferException

findVersion

public static Versioned findVersion(Mastered master,
                                    String versionId)
                             throws TransferException
Finds the version of the given master with the given version Id.

Returns:
The matching version or null if none is found.
Throws:
TransferException

findLatestVersion

public static RevisionControlled findLatestVersion(Mastered master)
                                            throws TransferException
Finds the latest version of the given master.

Returns:
The latest version or null if none is found.
Throws:
TransferException

findIteration

public static RevisionControlled findIteration(Versioned version,
                                               String iterationId)
                                        throws TransferException
Finds the iteration of the given version with the given iteration Id.

Returns:
The matching iteration or null if none is found.
Throws:
TransferException

findIteration

public static RevisionControlled findIteration(Class masterClass,
                                               String masterNumber,
                                               String masterName,
                                               String versionId,
                                               String iterationId)
                                        throws TransferException
Finds the iteration given the number and name of the Master and the iteration Id.

Returns:
The matching iteration or null if none is found.
Throws:
TransferException

findLatestIteration

public static RevisionControlled findLatestIteration(Versioned version)
                                              throws TransferException
Finds the latest version of the given master.

Returns:
The latest version or null if none is found.
Throws:
TransferException

getMethod

private static Method getMethod(Class theClass,
                                String name)
                         throws TransferException
Throws:
TransferException

getMethod

private static Method getMethod(Class theClass,
                                String name,
                                Class[] args)
                         throws TransferException
Throws:
TransferException

invokeMethod

private static Object invokeMethod(Method theMethod)
                            throws TransferException
Throws:
TransferException

invokeMethod

private static Object invokeMethod(Method theMethod,
                                   Object instance)
                            throws TransferException
Throws:
TransferException

invokeMethod

private static Object invokeMethod(Method theMethod,
                                   Object instance,
                                   Object[] args)
                            throws TransferException
Throws:
TransferException

createNewMasterVersionAndIteration

public static RevisionControlled createNewMasterVersionAndIteration(Class iterationClass,
                                                                    String masterNumber,
                                                                    String masterName,
                                                                    String vId,
                                                                    String iId)
                                                             throws TransferException
Create a new iteration with a given Number and Name. All other required attributes are defaulted. As this is a new type an associated Master will be constructed automatically.

Throws:
TransferException

getMaster

public static Mastered getMaster(RevisionControlled iteration)
                          throws TransferException
Throws:
TransferException

createNewVersionAndIteration

public static RevisionControlled createNewVersionAndIteration(Mastered master,
                                                              String masterName,
                                                              String masterNumber,
                                                              String importVersionId,
                                                              String importIterationId)
                                                       throws TransferException
Create a new version of the given Master. As a Version is the latest iteration then conceptually a new Version and Iteration are constructed.

Throws:
TransferException

createNewIteration

public static RevisionControlled createNewIteration(Versioned version,
                                                    String masterName,
                                                    String masterNumber,
                                                    String versionId,
                                                    String iterationId)
                                             throws TransferException
Create a new version of the given Master. As a Version is the latest iteration then conceptually a new Version and Iteration are constructed.

Throws:
TransferException

validateNewIterationIds

private static void validateNewIterationIds(RevisionControlled newIteration,
                                            String masterName,
                                            String masterNumber,
                                            String importVersionId,
                                            String importIterationId,
                                            boolean incrementCheckedout)
                                     throws TransferException
Validate that the actual version/iteration ids match the imported version/iteration ids. If not a warning is logged.

Throws:
TransferException
See Also:
ImportLog

getShortClassName

private static String getShortClassName(Class theClass)

setPropertyToDefault

private static void setPropertyToDefault(Persistable wtObject,
                                         PropertyDescriptor propertyInfo)
                                  throws TransferException
Set a Windchill objects property to its default value. Default values are: Other types are not handled and will throw a TransferException.

Throws:
TransferException

setImportFolder

public static void setImportFolder(String folderName)
                            throws TransferException
Set the folder that all instances will be created in.

Throws:
TransferException

getImportFolder

public static Folder getImportFolder()
                              throws TransferException
Throws:
TransferException

setImportFolder

public static void setImportFolder(Foldered instance)
                            throws TransferException
Throws:
TransferException

makePersistent

public static Persistable makePersistent(Persistable instance)
                                  throws TransferException
Throws:
TransferException

getExistingLink

public static ObjectToObjectLink getExistingLink(Class linkClass,
                                                 Object tmpLink,
                                                 Persistable roleAInstance,
                                                 Persistable roleBInstance)
                                          throws TransferException
Throws:
TransferException

createNewLink

public static ObjectToObjectLink createNewLink(Class linkClass,
                                               Persistable roleAInstance,
                                               Persistable roleBInstance)
                                        throws TransferException
Create a new link object. It is assumed that the link following the Windchill standard in that it has a factory method called:
{LinkClass}.new{LinkClass}(roleAObj, roleBObj)

Throws:
TransferException

setInstanceAttributes

public static void setInstanceAttributes(Persistable wtObject,
                                         StepEntity stepObject,
                                         ExpressSchema wtSchema,
                                         StepData dataForEntityReferences)
                                  throws TransferException
Given a parse StepEntity and its corresponding imported Windchill instance set all the attributes it has values for.

Throws:
TransferException

convertToEnumTypeValue

protected static Object convertToEnumTypeValue(Object rawValue,
                                               String enumTypeName,
                                               ExpressSchema wtSchema,
                                               StepData dataForEntityRefs)
                                        throws TransferException
Takes a parsed value for an enumeration type ( result of EnumeratedType.getStringValue() ) and converts it into a Windchill enumeration type value.

Parameters:
rawValue - Original value as parsed (a String).
enumTypeName - Name of the enumeration this value is one of.
Throws:
TransferException

findSetMethod

protected static Method findSetMethod(Object wtObject,
                                      String attrName,
                                      String type)
Finds a set method for a given Windchill object. Hence for attribute 'size' the method 'setSize' which takes on parameter and has no return value is searched for.

Parameters:
wtObject - The instance
attrName - The name of the attribute.