com.ptc.windchill.enterprise.templates
Class TemplatesUtility

java.lang.Object
  extended bycom.ptc.windchill.enterprise.templates.TemplatesUtility
All Implemented Interfaces:
Externalizable, Serializable

public class TemplatesUtility
extends Object
implements Externalizable

Makes template functions available for UI processing used during Create Template and Create from Template.

Supported API: false

Extendable: false

See Also:
Serialized Form

Field Summary
private static AttributeHelper attributeHelper
           
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
private static boolean VERBOSE
           
 
Constructor Summary
TemplatesUtility()
           
 
Method Summary
protected static String changeFilename(String origFilename, String format, FormatContentHolder contentHolder)
          Performs the filename conversion during a Create from Template action.
static void disablePriorIterations(Templateable obj)
          A method that uses a Templateable object as the input and disables the previously enabled version/iteration if the current iteration is enabled.
protected static String getAttributeValue(FormatContentHolder contentHolder, String attrName)
          Returns the value for the requested attribute from the given object.
static String getEnabledVersionString(Templateable object)
          A method that uses a Templateable object as the input and returns the enabled version.iteration string of that object.
static String getFilenameFormat()
          Returns the value stored in the site preference com/ptc/windchill/enterprise/templates/doc/renameFileFormatOnCreateFromTemplate.
static Templateable getLatestVersionIteration(Templateable obj)
          A method that takes a Templateable object as the input and returns the latest iteration of the latest version of the object.
static Persistable[] getTemplates(Class objClass, String context)
          Return a vector to represent the template list.
static TypeIdentifier[] getTemplateTypes(Class objClass, String context)
          Return an array of the types of an object that a template can be created with.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(TemplatesUtility thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
static RevisionControlled saveObjFromTemplate(RevisionControlled object, Templateable template)
          A wrapper function that uses a Templateable object as the input.
static FormatContentHolder setFilename(FormatContentHolder formatContentHolder)
          When creating objects from a template (i.e.
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

attributeHelper

private static AttributeHelper attributeHelper

VERBOSE

private static final boolean VERBOSE
Constructor Detail

TemplatesUtility

public TemplatesUtility()
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(TemplatesUtility thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

getTemplates

public static Persistable[] getTemplates(Class objClass,
                                         String context)
                                  throws WTException
Return a vector to represent the template list.

Supported API: false

Parameters:
objClass - The class of the object that the template list is requested for.
context - The product/library or project that this is requested from.
Returns:
Persistable[]
Throws:
WTException

getTemplateTypes

public static TypeIdentifier[] getTemplateTypes(Class objClass,
                                                String context)
                                         throws WTException
Return an array of the types of an object that a template can be created with. For create template.

Supported API: false

Parameters:
objClass - The class of the object that the template list is requested for.
context - The product/library or project that this is requested from.
Returns:
TypeIdentifier[]
Throws:
WTException

saveObjFromTemplate

public static RevisionControlled saveObjFromTemplate(RevisionControlled object,
                                                     Templateable template)
                                              throws WTException
A wrapper function that uses a Templateable object as the input. Returns the saved RevisionControlled object.

Supported API: false

Parameters:
object - Object the template is create from.
template - Template used to create the object from.
Returns:
RevisionControlled
Throws:
WTException

setFilename

public static FormatContentHolder setFilename(FormatContentHolder formatContentHolder)
                                       throws WTException
When creating objects from a template (i.e. WTDocument), it is desirable to append the additional information to the actual filename of the template document (i.e. template1_doc1namedoc1_number.doc instead of template1.doc). This allows multiple objects to be created from the same template and the primary content of each of these documents can be downloaded to the same direcotry without the files being overwritten.

Supported API: false

Parameters:
formatContentHolder -
Returns:
FormatContentHolder
Throws:
WTException

changeFilename

protected static String changeFilename(String origFilename,
                                       String format,
                                       FormatContentHolder contentHolder)
                                throws WTException
Performs the filename conversion during a Create from Template action. It uses the provided format for changing the existing filename to the new filename. By default it limits the new filename to 40 characters however this can be overridden by setting the site preference com/ptc/windchill/enterprise/templates/doc/filenameTrunctionLength to an integer value greater than 0.

Supported API: false

Parameters:
origFilename -
format -
contentHolder -
Returns:
String
Throws:
WTException

getAttributeValue

protected static String getAttributeValue(FormatContentHolder contentHolder,
                                          String attrName)
                                   throws WTException
Returns the value for the requested attribute from the given object. It uses Introspection to verify the requested attribute is on the provided object.

Supported API: false

Parameters:
contentHolder -
attrName -
Returns:
String
Throws:
WTException

getFilenameFormat

public static String getFilenameFormat()
Returns the value stored in the site preference com/ptc/windchill/enterprise/templates/doc/renameFileFormatOnCreateFromTemplate. The value of this preference can be any permuation of the following tokens: . Any characters can be added in between the tokens (except for '<' and '>' as these are token separators).

Supported API: false

Returns:
String

getEnabledVersionString

public static String getEnabledVersionString(Templateable object)
                                      throws WTException
A method that uses a Templateable object as the input and returns the enabled version.iteration string of that object. Returns an empty string if none of the iterations are enabled.

Parameters:
object - Object that implements the Templateable interface
Returns:
String
Throws:
WTException

disablePriorIterations

public static void disablePriorIterations(Templateable obj)
                                   throws WTException
A method that uses a Templateable object as the input and disables the previously enabled version/iteration if the current iteration is enabled. The method works only if the Templateable object passed in is a template.

Returns:
void
Throws:
WTException

getLatestVersionIteration

public static Templateable getLatestVersionIteration(Templateable obj)
                                              throws WTException
A method that takes a Templateable object as the input and returns the latest iteration of the latest version of the object.

Parameters:
obj - Object that implements the Templateable interface
Returns:
Templateable
Throws:
WTException