com.ptc.windchill.esi.utl
Class TaskHelper

java.lang.Object
  extended bycom.ptc.windchill.esi.utl.TaskHelper

public final class TaskHelper
extends Object

Common utility methods of general usefulness to ESI classes and ESI Info*Engine tasks.

Supported API: true

Extendable: false


Field Summary
private static String CLASSNAME
           
private static String CODEBASE
           
protected static String NULL_STRING
           
private static String RESOURCE
           
private static String SEARCH_TYPES
           
private static int WAIT_INTERVAL_DEFAULT
           
private static String WAIT_INTERVAL_PROPERTY
           
private static int WAIT_TRIES_DEFAULT
           
private static String WAIT_TRIES_PROPERTY
           
static String XML_META_NAME
           
 
Constructor Summary
TaskHelper()
           
 
Method Summary
 void addMultivaluePersistableParamGroup(String paramName, String groupName, Tasklet task)
          Get the task parameter values and add each one to an element in a group.
 void addMultivalueUfidParamGroup(String paramName, String groupName, Tasklet task)
          Get the task parameter values and add each one to an element in a group.
 void addSuccessMsgGroup(String groupName, Tasklet task)
          Adds a group to the task to ensure that receivers are notified of a successful invocation of a service that returns a java void.
 void checkParameter(Object obj, String name)
          Test a method parameter to make sure that it is not null.
 void checkParameter(String param, String name)
          Test a string to make sure that it is not null and not empty, and not all spaces.
private  boolean convertStringToDefaultBoolean(String booleanString, boolean defaultValue, String paramName)
           
private  boolean convertToBoolean(String booleanString)
           
 boolean getBooleanStringParameter(String paramName, boolean defaultValue, Tasklet task)
          Obtains a task parameter and returns it as a boolean value.
 boolean getBooleanStringParameter(String paramName, Tasklet task)
          Obtains a task parameter and returns it as a boolean value.
 WTChangeOrder2 getChangeOrderFromUfid(String ufid)
           
 WTDocument getDocumentFromUfid(String ufid)
           
 Collection getMultivalueParam(String name, Tasklet task)
          Return a collection of the values of the task parameter identified by the name argument.
 Persistable getObjectFromUfid(String ufid)
           
 String getObjectID(Persistable object)
          Returns the UFID for a Persistable.
static String getObjectTypesForSearch()
          Return a string which has the object types for searching the ESI Transaction Search page.
 String getParameterString(String paramName, Tasklet tasklet)
          Returns the value of a task parameter.
 WTPart getPartFromUfid(String ufid)
           
 Iterator getRpcGroupNames(String groupName, Tasklet task)
          Obtains the results of an apply-service webject for an ESI RPC, adds all of the groups in the RPC response to the task passed in the argument, and returns an iterator of a collection of group names in the resultant VDB.
private  boolean isUfid(Object arg)
           
 void logException(Exception e)
           
 void removeDuplicateCreators(String groupName, Tasklet task)
          Remove elements that have duplicate values of attribute creator of ESITransaction class.
private static String retrieveTypesForSearch()
           
static void testParameterString(String s, String param)
          Test a string to make sure that it is not null and not empty.
 void waitForMethodServer()
          Waits until the method server is ready.
 
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

XML_META_NAME

public static final String XML_META_NAME
See Also:
Constant Field Values

NULL_STRING

protected static final String NULL_STRING
See Also:
Constant Field Values

CODEBASE

private static final String CODEBASE
See Also:
Constant Field Values

WAIT_INTERVAL_PROPERTY

private static final String WAIT_INTERVAL_PROPERTY
See Also:
Constant Field Values

WAIT_TRIES_PROPERTY

private static final String WAIT_TRIES_PROPERTY
See Also:
Constant Field Values

WAIT_INTERVAL_DEFAULT

private static final int WAIT_INTERVAL_DEFAULT
See Also:
Constant Field Values

WAIT_TRIES_DEFAULT

private static final int WAIT_TRIES_DEFAULT
See Also:
Constant Field Values

SEARCH_TYPES

private static final String SEARCH_TYPES
Constructor Detail

TaskHelper

public TaskHelper()
Method Detail

getObjectID

public final String getObjectID(Persistable object)
Returns the UFID for a Persistable. If any exception is caught , null is returned.

Supported API: true

Parameters:
object - The persistable object whose UFID is desired.
Returns:
String

addMultivalueUfidParamGroup

public final void addMultivalueUfidParamGroup(String paramName,
                                              String groupName,
                                              Tasklet task)
                                       throws IEException
Get the task parameter values and add each one to an element in a group.


Supported API: false

Parameters:
paramName - The name of the task parameter whose values are to be obtained.
groupName - the name of the Group to add to the task's VDB.
task - The task whose parameters are to be obtained and whose VDB is to be updated.
Throws:
IEException

addMultivaluePersistableParamGroup

public final void addMultivaluePersistableParamGroup(String paramName,
                                                     String groupName,
                                                     Tasklet task)
                                              throws IEException
Get the task parameter values and add each one to an element in a group.


Supported API: true

Parameters:
paramName - The name of the task parameter whose values are to be obtained.
groupName - the name of the Group to add to the task's VDB.
task - The task whose parameters are to be obtained and whose VDB is to be updated.
Throws:
IEException

getBooleanStringParameter

public final boolean getBooleanStringParameter(String paramName,
                                               Tasklet task)
                                        throws IEException
Obtains a task parameter and returns it as a boolean value. If either argument is null, an exception is thrown. If the task has no such parameter, an exception is thrown. If the task parameter is neither "TRUE" nor "FALSE" (case-insensitive) an exception is thrown.

Supported API: true

Parameters:
paramName - The parameter to access.
task - The task whose parameter is to be examined.
Returns:
boolean
Throws:
IEException

getBooleanStringParameter

public final boolean getBooleanStringParameter(String paramName,
                                               boolean defaultValue,
                                               Tasklet task)
                                        throws IEException
Obtains a task parameter and returns it as a boolean value. If either argument is null, an exception is thrown. If the task has no such parameter, the default value is returned. If the task parameter is neither "TRUE" nor "FALSE" (case-insensitive) an exception is thrown.

Supported API: true

Parameters:
paramName - The parameter to access.
defaultValue - The value to return if the task has no parameter matching the value of the paramName argument.
task - The task whose parameter is to be examined.
Returns:
boolean
Throws:
IEException

getParameterString

public final String getParameterString(String paramName,
                                       Tasklet tasklet)
                                throws IEException
Returns the value of a task parameter. If either argument is null, or the task parameter is not specified, an exception is thrown.

Supported API: true

Parameters:
paramName - The name of the parameter to obtain.
tasklet - The Taskle whose parameter is to be queried.
Returns:
String
Throws:
IEException

waitForMethodServer

public final void waitForMethodServer()
Waits until the method server is ready. The method prevents ESI processes from activating until the Windchill Method Server is fully initialized. The method reads ESIProperties to determine the length of time to wait and the number of wait intervals. It locks its thread for the specified interval. If wt.method.WTAdapter.ADAPTER_INITIALIZED is true, the method exits. The method is accessed by the ESI SubscribeQueues task.

Supported API: true


addSuccessMsgGroup

public final void addSuccessMsgGroup(String groupName,
                                     Tasklet task)
                              throws IEException
Adds a group to the task to ensure that receivers are notified of a successful invocation of a service that returns a java void. If either argument is null, an exception is thrown.

Supported API: true

Parameters:
groupName - The name of the group to create.
task - The Tasklet whose VDB is to be updated.
Throws:
IEException

getRpcGroupNames

public final Iterator getRpcGroupNames(String groupName,
                                       Tasklet task)
                                throws IEException
Obtains the results of an apply-service webject for an ESI RPC, adds all of the groups in the RPC response to the task passed in the argument, and returns an iterator of a collection of group names in the resultant VDB. Does the following:
  1. Validates arguments to make sure they are not null and that the groupName argument is not a null string.
  2. Extracts the Group whose name is equal to the first argument from the second argument. If no Group is found, throws an exception.
  3. Gets the first element from the group. If the group is empty, throws an exception.
  4. Gets the value of the "result" Att from the element just obtained. If Att is not found or null, throws an exception.
  5. Typecasts the Att value to an IeCollection.
  6. Creates a Collection to hold the names of the groups in the IeCollection
  7. For each group in the IeCollection:
    • Gets the group from the IeCollection
    • Adds the group to the second argument
    • Adds the name of the group to the collection of group names.
  8. Generates an Iterator for the collection of names and returns the Iterator instance.


Supported API: true

Parameters:
groupName - The name of the group to extract from the task argument. It is presumed to be the name of an Group containing one element with a single Att whose name is "result".
task -
Returns:
Iterator
Throws:
IEException

getMultivalueParam

public Collection getMultivalueParam(String name,
                                     Tasklet task)
                              throws IEException
Return a collection of the values of the task parameter identified by the name argument. Obtains the parameters from the task identied by the Info*Engine SAK tasklet object that is identified by the task argument.

Supported API: true

Parameters:
name - The name of the parameter whose values are to be obtained.
task - The tasklet whose parameter is to be obtained.
Returns:
Collection
Throws:
IEException

checkParameter

public final void checkParameter(String param,
                                 String name)
                          throws MissingParameterException
Test a string to make sure that it is not null and not empty, and not all spaces.

Supported API: true

Parameters:
param -
name -
Throws:
MissingParameterException

checkParameter

public final void checkParameter(Object obj,
                                 String name)
                          throws MissingParameterException
Test a method parameter to make sure that it is not null.

Supported API: true

Parameters:
obj -
name -
Throws:
MissingParameterException

getObjectFromUfid

public Persistable getObjectFromUfid(String ufid)
                              throws WTException
Throws:
WTException

getPartFromUfid

public WTPart getPartFromUfid(String ufid)
                       throws WTException
Throws:
WTException

getDocumentFromUfid

public WTDocument getDocumentFromUfid(String ufid)
                               throws WTException
Throws:
WTException

getChangeOrderFromUfid

public WTChangeOrder2 getChangeOrderFromUfid(String ufid)
                                      throws WTException
Throws:
WTException

logException

public void logException(Exception e)

testParameterString

public static void testParameterString(String s,
                                       String param)
                                throws IEException
Test a string to make sure that it is not null and not empty.

Parameters:
s - The string to be tested.
param - The name of the parameter that is being tested. Used only for descriptive text in the event of error.
Throws:
IEException - Thrown if the incoming string is null or empty or all spaces.

convertToBoolean

private boolean convertToBoolean(String booleanString)
                          throws IEException
Throws:
IEException

convertStringToDefaultBoolean

private boolean convertStringToDefaultBoolean(String booleanString,
                                              boolean defaultValue,
                                              String paramName)
                                       throws IEException
Throws:
IEException

isUfid

private boolean isUfid(Object arg)

removeDuplicateCreators

public final void removeDuplicateCreators(String groupName,
                                          Tasklet task)
                                   throws IEException
Remove elements that have duplicate values of attribute creator of ESITransaction class. This method is intended to be used with ESI DCA.

Parameters:
groupName - The name of the group to extract from the task argument.
task - task
Throws:
IEException.
IEException

retrieveTypesForSearch

private static String retrieveTypesForSearch()

getObjectTypesForSearch

public static final String getObjectTypesForSearch()
Return a string which has the object types for searching the ESI Transaction Search page. This method is intended to be used with ESI DCA.