com.ptc.windchill.enterprise.doc.server
Class DocumentUtility

java.lang.Object
  extended bycom.ptc.windchill.enterprise.doc.server.DocumentUtility

public class DocumentUtility
extends Object

Makes available functions to set attributes on the documents. Used in the template processing and creating documents.

Supported API: false

Extendable: false


Field Summary
private static String CLASSNAME
           
private static String DRESOURCE
           
private static String RESOURCE
           
static String TYPE_SELECT_BLANK
           
static String TYPE_SELECT_STRING
           
private static boolean VERBOSE
           
 
Constructor Summary
DocumentUtility()
           
 
Method Summary
static boolean checkNameLength(String name)
           
static boolean checkNumberLength(String number)
           
static boolean checkTitleLength(String title)
           
static int getInsertLocation(Vector vector, Object object, Locale locale)
           
static int getNameUpperLimit()
           
static String getNumber(String number)
          Used to get the number either through user input or through automatic number generation.
static int getNumberUpperLimit()
           
private static String getPreferenceValue(String node, String key)
           
static int getTitleUpperLimit()
           
static Vector getTypeDisplayInfo(String solution, TypeIdentifier[] types, Locale locale)
          Gets the display information for a list of types.
static WTDocument setDept(WTDocument document, String dept)
          Used to set the dept through user input.
static WTDocument setDescription(WTDocument document, String desc)
          Used to set the description through user input.
static WTDocument setDocType(WTDocument document, String docType)
          Used to set the docType through user input.
static WTDocument setEnabled(WTDocument document, boolean enabled)
          Used to set the enabled attribute on the Document's Template object.
static WTDocument setLifeCycleTemplate(WTDocument document, String lifeCycle)
          Used to set the lifecycle template either through user input or through automatic default.
static WTDocument setLocation(WTDocument document, String location)
          Used to set the location either through user input or through automatic default of the location.
static WTDocument setName(WTDocument document, String name)
          Used to set the name through user input.
static WTDocument setNumber(WTDocument document, String number)
          Used to set the number either through user input or through automatic number generation.
static WTDocument setOldAttributes(WTDocument document)
          Used to set attributes that aren't used on documents anymore.
static WTDocument setOrganization(WTDocument document, String docOrg)
           
static WTDocument setSoftAttributes(WTDocument document, HashMap nameValueData, Locale locale)
          Set the soft attributes from the hash map into the object.
static WTDocument setTeamTemplate(WTDocument document, String teamTemplate)
          Used to set the team template on the document.
static WTDocument setTemplate(WTDocument document, boolean templated)
          Used to set the template object on the Document.
static WTDocument setTitle(WTDocument document, String title)
          Used to set the title through user input.
private static String validateTypePreference(TypeIdentifier[] types, String localizedString, Locale locale)
           
 
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

VERBOSE

private static final boolean VERBOSE

TYPE_SELECT_STRING

public static final String TYPE_SELECT_STRING
See Also:
Constant Field Values

TYPE_SELECT_BLANK

public static final String TYPE_SELECT_BLANK
See Also:
Constant Field Values

DRESOURCE

private static final String DRESOURCE
See Also:
Constant Field Values
Constructor Detail

DocumentUtility

public DocumentUtility()
Method Detail

setNumber

public static WTDocument setNumber(WTDocument document,
                                   String number)
                            throws WTException
Used to set the number either through user input or through automatic number generation. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the number on.
number - Number can either be a value entered by the user from the UI or it can be null and then auto generated.
Returns:
WTDocument
Throws:
WTException

getNumber

public static String getNumber(String number)
Used to get the number either through user input or through automatic number generation.

Supported API: false

Parameters:
number - Number can either be a value entered by the user from the UI or it can be null and then auto generated.
Returns:
String

setOldAttributes

public static WTDocument setOldAttributes(WTDocument document)
                                   throws WTException
Used to set attributes that aren't used on documents anymore. These attributes must be set to a default in order for the document to be persisted.

Supported API: false

Parameters:
document - The unpersisted document to set the attributes on.
Returns:
WTDocument
Throws:
WTException

setLocation

public static WTDocument setLocation(WTDocument document,
                                     String location)
                              throws WTException
Used to set the location either through user input or through automatic default of the location. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the location on.
location - Location can either be a value entered by the user from the UI or it can be null and then auto generated.
Returns:
WTDocument
Throws:
WTException

setLifeCycleTemplate

public static WTDocument setLifeCycleTemplate(WTDocument document,
                                              String lifeCycle)
                                       throws WTException
Used to set the lifecycle template either through user input or through automatic default. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the life cycle on.
lifeCycle - LifeCycle can either be a value entered by the user from the UI or it can be null and then auto generated.
Returns:
WTDocument
Throws:
WTException

setTeamTemplate

public static WTDocument setTeamTemplate(WTDocument document,
                                         String teamTemplate)
                                  throws WTException
Used to set the team template on the document. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the team template on.
teamTemplate - Team Template to set the new document to.
Returns:
WTDocument
Throws:
WTException

setSoftAttributes

public static WTDocument setSoftAttributes(WTDocument document,
                                           HashMap nameValueData,
                                           Locale locale)
                                    throws WTException
Set the soft attributes from the hash map into the object.

Supported API: false

Parameters:
document - The document (non-persisted if create operation, persisted if update) to set the soft type values on. This method does not persist the changes that it makes to the document, that must be done outside of this method.
nameValueData -
locale - The locale of the client, used to return some of the strings in the locale of the client.
Returns:
WTDocument
Throws:
WTException

setName

public static WTDocument setName(WTDocument document,
                                 String name)
                          throws WTException
Used to set the name through user input. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the name on.
name - Name is a value entered by the user from the UI
Returns:
WTDocument
Throws:
WTException

setTitle

public static WTDocument setTitle(WTDocument document,
                                  String title)
                           throws WTException
Used to set the title through user input. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the title on.
title - Title is a value entered by the user from the UI
Returns:
WTDocument
Throws:
WTException

setDescription

public static WTDocument setDescription(WTDocument document,
                                        String desc)
                                 throws WTException
Used to set the description through user input. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the description on.
desc - Description entered by the user from the UI
Returns:
WTDocument
Throws:
WTException

setTemplate

public static WTDocument setTemplate(WTDocument document,
                                     boolean templated)
                              throws WTException
Used to set the template object on the Document. If the templated attribute passed in is true the template object is set on the document and not otherwise.

Supported API: false

Parameters:
document - The unpersisted document to set the template object on.
templated - Indicates whether the document is a template or not.
Returns:
WTDocument
Throws:
WTException

setEnabled

public static WTDocument setEnabled(WTDocument document,
                                    boolean enabled)
                             throws WTException
Used to set the enabled attribute on the Document's Template object. The enabled attribute is set to true/false, if the document being created is a template .

Supported API: false

Parameters:
document - The unpersisted document which may be a template, to set the enabled flag on.
enabled - Indicates whether the document template is enabled or not.
Returns:
WTDocument
Throws:
WTException

setDept

public static WTDocument setDept(WTDocument document,
                                 String dept)
                          throws WTException
Used to set the dept through user input. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the dept on.
dept - dept is selected by the user from the UI. It is a number passed in as a string.
Returns:
WTDocument
Throws:
WTException

setDocType

public static WTDocument setDocType(WTDocument document,
                                    String docType)
                             throws WTException
Used to set the docType through user input. Document is assumed to not be persisted yet.

Supported API: false

Parameters:
document - The unpersisted document to set the docType on.
docType - docType is selected by the user from the UI. It is a number passed in as a string.
Returns:
WTDocument
Throws:
WTException

getTypeDisplayInfo

public static Vector getTypeDisplayInfo(String solution,
                                        TypeIdentifier[] types,
                                        Locale locale)
                                 throws WTException
Gets the display information for a list of types. Returns the types in the correct order and with the localized display string for the type. Uses the preferences to determine what the default value should be and if that default value should be a localized string or a soft type. The return is a vector with the object in the first position being a vector of the localized display strings in order (with any default display strings), the second position being the corresponding types in order, and the third position being a string specifying what the default value is. Some example code of using this is: Vector display_info = DocumentUtility.getTypeDisplayInfo(types,locale); Vector type_localized = (Vector) display_info.get(0); Vector type_string = (Vector) display_info.get(1); String default_value = (String) display_info.get(2); int size = type_localized.size(); for (int i = 0; i < size; i++) { String type_name = (String) type_string.get(i); ... handle ui display issues... String localized = (String) type_localized.get(i); ... handle ui display issues... if (type_name.equals(default_value)) ... handle ui display issues of default... else ... handle ui display issues of non-default... }

Supported API: false

Parameters:
solution - The solution for which the type display info is needed
types - An array of the type identifiers for the types that are valid for this display.
locale - The locale of the client.
Returns:
Vector
Throws:
WTException

getNameUpperLimit

public static int getNameUpperLimit()

checkNameLength

public static boolean checkNameLength(String name)

getNumberUpperLimit

public static int getNumberUpperLimit()

checkNumberLength

public static boolean checkNumberLength(String number)

getTitleUpperLimit

public static int getTitleUpperLimit()

checkTitleLength

public static boolean checkTitleLength(String title)

setOrganization

public static WTDocument setOrganization(WTDocument document,
                                         String docOrg)
                                  throws WTException
Throws:
WTException

getInsertLocation

public static int getInsertLocation(Vector vector,
                                    Object object,
                                    Locale locale)

validateTypePreference

private static String validateTypePreference(TypeIdentifier[] types,
                                             String localizedString,
                                             Locale locale)
                                      throws WTException
Throws:
WTException

getPreferenceValue

private static String getPreferenceValue(String node,
                                         String key)