com.ptc.windchill.enterprise.nativeapp.server
Class WindchillAttributeUtility

java.lang.Object
  extended bycom.ptc.windchill.enterprise.nativeapp.server.WindchillAttributeUtility

public class WindchillAttributeUtility
extends Object

Utility class for static methods to help the application interface to get the Windchill attribute values from the objects and present them back to the client in a displayable way. Also helps to convert attribute data from one input/output format to another. Provides some utilities for handling of the soft type attributes.

Supported API: false

Extendable: false


Field Summary
(package private)  AttributeHelper attributeHelper
           
private static String CLASSNAME
           
private static String DEFAULT_LIFECYCLE
           
private static IdentifierFactory IDENTIFIER_FACTORY
           
private static String RESOURCE
           
private static boolean VERBOSE
           
 
Constructor Summary
WindchillAttributeUtility(WTObject object)
          Constructor that sets the class of the object for all of the rest of the attributes.
 
Method Summary
static Object convertStringToValue(String stringValue, String dataType, ClientConfiguration clientInfo, Locale locale)
          Convert a string input value to the correct value for the data type.
static String convertValueToString(Object value, ClientConfiguration clientInfo, Locale locale)
          Convert an object into the string value for return to the client.
private static WindchillAttributeInformation getAttributeInfo(NetFactor object, WindchillAttributeInformation attribInfo, String name, ClientConfiguration clientInfo, AttributeHelper attributeHelper, Locale locale)
           
 String getAttributeValue(WTObject object, String attributeName, ClientConfiguration clientInfo, Locale locale)
          Return the localized and displayable value for the attribute.
private static String getDateString(ClientConfiguration clientInfo, Timestamp time)
           
private static EnumeratedType[] getEnumeratedTypeList(PropertyDescriptor pd, Locale locale)
           
private static AttributeContainerSpec getFilter(TypeIdentifier type)
           
private static HashMap getHashMap(TypeInstance ti, HashMap hashMap, Locale locale)
           
private static WindchillAttributeInformation getLocalizedName(NetFactor object, String name, WindchillAttributeInformation attrib, Locale locale)
           
private static String getOid(WTObject object)
           
private static ContentItem getPrimaryContentItem(FormatContentHolder holder)
           
private static String getRepository(Persistable object, Locale locale)
           
static WindchillAttributeInformation getShortWindchillAttributeInformation(Persistable object, String name, int order, AttributeHelper attributeHelper, ClientConfiguration clientInfo, Locale locale)
          Populate the WindchillAttributeInformation instance with the information for this attribute.
static HashMap getSoftAttributes(TypeInstanceIdentifier tii, HashMap hashMap, Locale locale)
          Retrieve the soft attributes for the object.
static HashMap getSoftAttributes(WTObject object, HashMap hashMap, Locale locale)
          Retrieve the soft attributes for the object.
private static TypeInstance getTypeInstance(TypeInstanceIdentifier tii, Locale locale)
           
static HashMap getViewSoftAttributes(TypeInstanceIdentifier tii, HashMap hashMap, Locale locale)
          Retrieve the soft attributes for the object.
static HashMap getViewSoftAttributes(WTObject object, HashMap hashMap, Locale locale)
          Retrieve the soft attributes for the object.
static WindchillAttributeInformation getWindchillAttributeInformation(Persistable object, String name, int order, boolean editable, AttributeHelper attributeHelper, Locale locale)
          Populate the WindchillAttributeInformation instance with the information for this attribute.
private static Method obtainFromCovertProperty(PropertyDescriptor pd)
           
static HashMap propertiesToHashMap(Properties formData, HashMap hashMap, TimeZone timeZone, Locale locale)
          Converts the soft attribute form data from an HTML template to a HashMap which can be used in the other methods.
private static float roundToTwoDecimals(float number)
           
static WindchillAttributeInformation setOrgInAttribInfo(WindchillAttributeInformation attrib, WTOrganization org, Locale locale)
          This method is very specific to generating the most recently visited list of Organizations into a WindchillAttributeInformation.
private static String trimValue(String longString)
           
 
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

attributeHelper

AttributeHelper attributeHelper

VERBOSE

private static boolean VERBOSE

DEFAULT_LIFECYCLE

private static String DEFAULT_LIFECYCLE

IDENTIFIER_FACTORY

private static final IdentifierFactory IDENTIFIER_FACTORY
Constructor Detail

WindchillAttributeUtility

public WindchillAttributeUtility(WTObject object)
                          throws WTException
Constructor that sets the class of the object for all of the rest of the attributes.

Supported API: false

Parameters:
object -
Throws:
WTException
Method Detail

getAttributeValue

public String getAttributeValue(WTObject object,
                                String attributeName,
                                ClientConfiguration clientInfo,
                                Locale locale)
                         throws WTException
Return the localized and displayable value for the attribute. This is for modeled attributes.

Supported API: false

Parameters:
object - The persistent object that hold the values or references to the values.
attributeName - Name of the attribute that can be used to retrieve the information from the object.
clientInfo - Information from the client application.
locale - Locale of the client machine so attribute values that require localization can be converted.
Returns:
String
Throws:
WTException

propertiesToHashMap

public static HashMap propertiesToHashMap(Properties formData,
                                          HashMap hashMap,
                                          TimeZone timeZone,
                                          Locale locale)
                                   throws WTException
Converts the soft attribute form data from an HTML template to a HashMap which can be used in the other methods. Only processes soft type attribute information from the properties passed in, all other information is ignored. Modeled attributes must be manually populated into the hash map.

Supported API: false

Parameters:
formData - Data that is input from the template processing.
hashMap - Either a started hash map for the data or null if one is to be created inside of this method.
timeZone - TimeZone of the client.
locale - The locale of the client, used to return some of the strings in the locale of the client.
Returns:
HashMap
Throws:
WTException

convertStringToValue

public static Object convertStringToValue(String stringValue,
                                          String dataType,
                                          ClientConfiguration clientInfo,
                                          Locale locale)
                                   throws WTException
Convert a string input value to the correct value for the data type.

Supported API: false

Parameters:
stringValue - Value to convert.
dataType - Type to convert it to.
clientInfo - Information from the client application.
locale - The locale of the client, used to return some of the strings in the locale of the client.
Returns:
Object
Throws:
WTException

convertValueToString

public static String convertValueToString(Object value,
                                          ClientConfiguration clientInfo,
                                          Locale locale)
                                   throws WTException
Convert an object into the string value for return to the client.

Supported API: false

Parameters:
value - Value to convert.
clientInfo - Information from the client application.
locale - The locale of the client, used to return some of the strings in the locale of the client.
Returns:
String
Throws:
WTException

getSoftAttributes

public static HashMap getSoftAttributes(TypeInstanceIdentifier tii,
                                        HashMap hashMap,
                                        Locale locale)
                                 throws WTException
Retrieve the soft attributes for the object. They are added to the hash map that is passed in. In the format of a shorter, less precise soft attribute name as the key and a WindchillAttributeInformation populated with all of the information available on the attribute as the value.

Supported API: false

Parameters:
tii - Identifies the object that the soft attributes are going to be retrieved for.
hashMap - HashMap that is returned can be prepopulated with some information or null. This method will just add entries to it.
locale - Locale of the client for localization processing of information returned to the client.
Returns:
HashMap
Throws:
WTException

getSoftAttributes

public static HashMap getSoftAttributes(WTObject object,
                                        HashMap hashMap,
                                        Locale locale)
                                 throws WTException
Retrieve the soft attributes for the object. They are added to the hash map that is passed in. In the format of a shorter, less precise soft attribute name as the key and a WindchillAttributeInformation populated with all of the information available on the attribute as the value.

Supported API: false

Parameters:
object - Identifies the object that the soft attributes are going to be retrieved for.
hashMap - HashMap that is returned can be prepopulated with some information or null. This method will just add entries to it.
locale - Locale of the client for localization processing of information returned to the client.
Returns:
HashMap
Throws:
WTException

getWindchillAttributeInformation

public static WindchillAttributeInformation getWindchillAttributeInformation(Persistable object,
                                                                             String name,
                                                                             int order,
                                                                             boolean editable,
                                                                             AttributeHelper attributeHelper,
                                                                             Locale locale)
                                                                      throws WTException
Populate the WindchillAttributeInformation instance with the information for this attribute.

Supported API: false

Parameters:
object - The object to get the value from.
name - Name of the attribute.
order - The order the attribute should be used in.
editable - If this attribute is considered editable in this usage of it.
attributeHelper - Instance of AttributeHelper.
locale - Locale of the client.
Returns:
WindchillAttributeInformation
Throws:
WTException

getShortWindchillAttributeInformation

public static WindchillAttributeInformation getShortWindchillAttributeInformation(Persistable object,
                                                                                  String name,
                                                                                  int order,
                                                                                  AttributeHelper attributeHelper,
                                                                                  ClientConfiguration clientInfo,
                                                                                  Locale locale)
                                                                           throws WTException
Populate the WindchillAttributeInformation instance with the information for this attribute. This is assumed for display only so it will support some of the "made up" attributes that are not editable. Used mainly for the display of the details page.

Supported API: false

Parameters:
object - The object to get the value from.
name - Name of the attribute.
order - The order the attribute should be used in.
attributeHelper - Instance of AttributeHelper.
clientInfo - Information from the client application.
locale - Locale of the client.
Returns:
WindchillAttributeInformation
Throws:
WTException

getViewSoftAttributes

public static HashMap getViewSoftAttributes(TypeInstanceIdentifier tii,
                                            HashMap hashMap,
                                            Locale locale)
                                     throws WTException
Retrieve the soft attributes for the object. They are added to the hash map that is passed in. In the format of a shorter, less precise soft attribute name as the key and a WindchillAttributeInformation populated with all of the information available on the attribute as the value. This method is similar to getSoftAttributes but removed default values from the type instance. The intent is to provide only attributes that are assigned to the current object.

Supported API: false

Parameters:
tii -
hashMap -
locale -
Returns:
HashMap
Throws:
WTException

getViewSoftAttributes

public static HashMap getViewSoftAttributes(WTObject object,
                                            HashMap hashMap,
                                            Locale locale)
                                     throws WTException
Retrieve the soft attributes for the object. They are added to the hash map that is passed in. In the format of a shorter, less precise soft attribute name as the key and a WindchillAttributeInformation populated with all of the information available on the attribute as the value. This method is similar to getSoftAttributes but removed default values from the type instance. The intent is to provide only attributes that are assigned to the current object.

Supported API: false

Parameters:
object -
hashMap -
locale -
Returns:
HashMap
Throws:
WTException

getHashMap

private static HashMap getHashMap(TypeInstance ti,
                                  HashMap hashMap,
                                  Locale locale)
                           throws WTException
Parameters:
ti -
hashMap -
locale -
Returns:
HashMap
Throws:
WTException

setOrgInAttribInfo

public static WindchillAttributeInformation setOrgInAttribInfo(WindchillAttributeInformation attrib,
                                                               WTOrganization org,
                                                               Locale locale)
                                                        throws WTException,
                                                               WTPropertyVetoException
This method is very specific to generating the most recently visited list of Organizations into a WindchillAttributeInformation. This method sets a display list (setDisplayList) and a value list (setList) in the WindchillAttributeInformation in addition to using the input org to set the default value.

Supported API: false

Parameters:
attrib - The attribute object to set all of the display and values on and return.
org - The org to use as th default.
locale -
Returns:
WindchillAttributeInformation
Throws:
WTException
WTPropertyVetoException

getOid

private static String getOid(WTObject object)
                      throws WTException
Throws:
WTException

getPrimaryContentItem

private static ContentItem getPrimaryContentItem(FormatContentHolder holder)
                                          throws WTException
Throws:
WTException

roundToTwoDecimals

private static float roundToTwoDecimals(float number)

getRepository

private static String getRepository(Persistable object,
                                    Locale locale)

getEnumeratedTypeList

private static EnumeratedType[] getEnumeratedTypeList(PropertyDescriptor pd,
                                                      Locale locale)
                                               throws IllegalAccessException,
                                                      InvocationTargetException
Throws:
IllegalAccessException
InvocationTargetException

obtainFromCovertProperty

private static Method obtainFromCovertProperty(PropertyDescriptor pd)

getDateString

private static String getDateString(ClientConfiguration clientInfo,
                                    Timestamp time)

getLocalizedName

private static WindchillAttributeInformation getLocalizedName(NetFactor object,
                                                              String name,
                                                              WindchillAttributeInformation attrib,
                                                              Locale locale)
                                                       throws WTIntrospectionException,
                                                              WTPropertyVetoException
Throws:
WTIntrospectionException
WTPropertyVetoException

getTypeInstance

private static TypeInstance getTypeInstance(TypeInstanceIdentifier tii,
                                            Locale locale)
                                     throws WTException
Throws:
WTException

getFilter

private static AttributeContainerSpec getFilter(TypeIdentifier type)
                                         throws IllegalFormatException
Throws:
IllegalFormatException

getAttributeInfo

private static WindchillAttributeInformation getAttributeInfo(NetFactor object,
                                                              WindchillAttributeInformation attribInfo,
                                                              String name,
                                                              ClientConfiguration clientInfo,
                                                              AttributeHelper attributeHelper,
                                                              Locale locale)
                                                       throws WTPropertyVetoException,
                                                              WTIntrospectionException,
                                                              IllegalAccessException,
                                                              InvocationTargetException,
                                                              WTException
Throws:
WTPropertyVetoException
WTIntrospectionException
IllegalAccessException
InvocationTargetException
WTException

trimValue

private static String trimValue(String longString)