com.ptc.windchill.esi.rnd
Class ResponseRendererImpl

java.lang.Object
  extended bycom.ptc.windchill.esi.rnd.ResponseRendererImpl
All Implemented Interfaces:
ResponseRenderer
Direct Known Subclasses:
BOMHeaderRendererImpl, BOMRendererImpl, ESIChangeHeaderRenderer, ESIChangeOrder2Renderer, ESIDocumentRenderer, ESIPartRenderer, ESIWTPartRenderer

public abstract class ResponseRendererImpl
extends Object
implements ResponseRenderer

Abstract base class containing generally useful behavior for all ESI XML response renderers.

Supported API: true

Extendable: false


Field Summary
private  VdbBuilder builder
           
private static String CLASSNAME
           
private static String CODEBASE
           
private static String DELIMITER
           
private static String EFFECTIVITY_DATE_FORMAT
           
private static String EFFECTIVITY_END_NAME
           
private static String EFFECTIVITY_START_NAME
           
private  ESIEffectivityHandler effectivityHandler
           
private  ESIMapper mapper
           
private static String NULL_STRING
           
private static String RESOURCE
           
private static int UFID_SIZE
           
static String XML_META_NAME
           
 
Constructor Summary
ResponseRendererImpl()
           
 
Method Summary
protected  void adjustEffectivities(Element element, Eff eff)
          Adds effectivity information to an Element based on the effectivity of the WTPart.
protected  void adjustObjectID(Element element, String objectID)
          If the Info*Engine element argument has an "objectID" attribute, change its value to the value of the objectID argument.
protected  void adjustTargets(Element element, Collection targets)
          For each entry in the targets argument, create a new Info*Engine Att object and add it to the element argument.
protected abstract  void buildGroups()
          Abstract method that forces subclasses to implement buildGroups.
protected  String buildUfidString(Collection objects, String completeUFIDString, Class objectType)
          This method will build the ufid string of Object ids for the I*E task.
protected  String getAttsFromMapFile(String grpName)
          Returns a list of attributes from the mapfile.
 VdbBuilder getBuilder()
          Gets the value of the attribute: builder.
 ESIEffectivityHandler getEffectivityHandler()
          Getter for the effectivityHandler attribute.
protected  ESIGroupInfo getGroupInfo(String groupName)
           
protected  ESIMap getMap(ESIMapInfo mapInfo)
           
protected  ESIMapInfo getMapInfo(String groupName)
           
protected  Collection getTargetsFromAssns(Collection targetAssns)
           
protected  IeCollection invokeQueryTask(String taskName, String className, String ufids, String auth, String wcAdapter)
          This method will call the I*E task specfied by the task name.
protected  void logException(Exception e)
          Provides consistent error logging for subclasses.
protected  Element mapElement(String groupName, Element element)
          Calls the ESI mapper to create an Info*Engine Element using a different I*E element as input.
protected  Element mapObject(String groupName, Object object)
          Calls the ESI mapper to create an Info*Engine Element using an object as input.
 void render(VdbBuilder builder)
          This is a template method for ESI Services renderers.
 void setBuilder(VdbBuilder a_Builder)
          Sets the value of the attribute: builder.
 void setEffectivityHandler(ESIEffectivityHandler handler)
          Set the effectivityHandler attribute.
protected abstract  void validate()
          Force all subclasses to implement the method.
 
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

builder

private VdbBuilder builder

effectivityHandler

private ESIEffectivityHandler effectivityHandler

XML_META_NAME

public static final String XML_META_NAME
See Also:
Constant Field Values

EFFECTIVITY_DATE_FORMAT

private static final String EFFECTIVITY_DATE_FORMAT

EFFECTIVITY_START_NAME

private static final String EFFECTIVITY_START_NAME

EFFECTIVITY_END_NAME

private static final String EFFECTIVITY_END_NAME

CODEBASE

private static final String CODEBASE
See Also:
Constant Field Values

DELIMITER

private static final String DELIMITER
See Also:
Constant Field Values

NULL_STRING

private static final String NULL_STRING
See Also:
Constant Field Values

UFID_SIZE

private static final int UFID_SIZE
See Also:
Constant Field Values

mapper

private ESIMapper mapper
Constructor Detail

ResponseRendererImpl

public ResponseRendererImpl()
Method Detail

getBuilder

public VdbBuilder getBuilder()
Gets the value of the attribute: builder.

Supported API: true

Returns:
VdbBuilder

setBuilder

public void setBuilder(VdbBuilder a_Builder)
Sets the value of the attribute: builder.

Supported API: true

Parameters:
a_Builder -

validate

protected abstract void validate()
                          throws ESIRendererException
Force all subclasses to implement the method. The concrete method is expected to examine the attributes of the object and throw an exception if they are not set properly.

Supported API: false

Throws:
ESIRendererException

buildGroups

protected abstract void buildGroups()
                             throws ESIRendererException
Abstract method that forces subclasses to implement buildGroups. The concrete method is expected to navigate the object of interest and to create I*E groups of Elements and Atts. When completed with the construction of the groups, the concrete class is expected to add the constructed groups into the IeCollection that this object created. ESI renderers use the services of a VdbBuilder to create and render the output.

Supported API: true

Throws:
ESIRendererException

logException

protected void logException(Exception e)
Provides consistent error logging for subclasses.

Supported API: false

Parameters:
e -

getAttsFromMapFile

protected String getAttsFromMapFile(String grpName)
                             throws ESIRendererException
Returns a list of attributes from the mapfile. The strings are "~" delimited.

Supported API: false

Parameters:
grpName - The name of the group
Returns:
String
Throws:
ESIRendererException

render

public void render(VdbBuilder builder)
            throws ESIRendererException
This is a template method for ESI Services renderers. It saves the argument and then calls validate() and buildGroups().

Supported API: true

Specified by:
render in interface ResponseRenderer
Parameters:
builder - The VDB builder to use when rendering output.
Throws:
ESIRendererException

buildUfidString

protected String buildUfidString(Collection objects,
                                 String completeUFIDString,
                                 Class objectType)
                          throws WTException
This method will build the ufid string of Object ids for the I*E task. The ufids will be returned delimited by "~" character.

Supported API: true

Parameters:
objects - Collection of persistable objects.
completeUFIDString - String of UFIDs from a previous call
objectType - The class of the persistable object. Used to return only objects of that type.
Returns:
String
Throws:
WTException

invokeQueryTask

protected IeCollection invokeQueryTask(String taskName,
                                       String className,
                                       String ufids,
                                       String auth,
                                       String wcAdapter)
                                throws WTException
This method will call the I*E task specfied by the task name. The I*E collection from the task is returned.

Supported API: true

Parameters:
taskName - The URL location and name of the task to be executed.
className - The Windchill class to run the I*E task on. This is the "Type" parameter in the Webject call.
ufids - This is a list of object ids to run the task with.
auth - This is the I*E authorization to run the task.
wcAdapter - Windchill adapter instance where the task will be executed.
Returns:
IeCollection
Throws:
WTException

getEffectivityHandler

public ESIEffectivityHandler getEffectivityHandler()
                                            throws ESIRendererException
Getter for the effectivityHandler attribute. Does lazy initialization. Throws an ESIRendererException if the lazy intialization fails.

Supported API: false

Returns:
ESIEffectivityHandler
Throws:
ESIRendererException

setEffectivityHandler

public void setEffectivityHandler(ESIEffectivityHandler handler)
Set the effectivityHandler attribute. If the argument is null or the attribute is not null, the method does nothing.

Supported API: false

Parameters:
handler -

mapElement

protected Element mapElement(String groupName,
                             Element element)
                      throws ESIRendererException
Calls the ESI mapper to create an Info*Engine Element using a different I*E element as input. Obtains the map information using the logical group name in the groupName argument.

Supported API: true

Parameters:
groupName - The logical VDB group name.
element - The Info*Engine Element to map.
Returns:
Element
Throws:
ESIRendererException

mapObject

protected Element mapObject(String groupName,
                            Object object)
                     throws ESIRendererException
Calls the ESI mapper to create an Info*Engine Element using an object as input. Obtains the map information using the logical group name in the groupName argument.

Supported API: true

Parameters:
groupName - The logical group name. Used to obtain the appropriate map information.
object - The object that is to be rendered as an Info*Engine element.
Returns:
Element
Throws:
ESIRendererException

adjustObjectID

protected void adjustObjectID(Element element,
                              String objectID)
                       throws ESIRendererException
If the Info*Engine element argument has an "objectID" attribute, change its value to the value of the objectID argument.

Supported API: true

Parameters:
element - The element to be updated.
objectID - The value to assign to the objectID attribute of the element argument.
Throws:
ESIRendererException

adjustTargets

protected void adjustTargets(Element element,
                             Collection targets)
                      throws ESIRendererException
For each entry in the targets argument, create a new Info*Engine Att object and add it to the element argument.

Supported API: true

Parameters:
element - The Info*Engine element that is to be updated.
targets - A collection of ESITarget objects.
Throws:
ESIRendererException

adjustEffectivities

protected void adjustEffectivities(Element element,
                                   Eff eff)
                            throws ESIRendererException
Adds effectivity information to an Element based on the effectivity of the WTPart. Does the following:
  1. Reads ESI properties to find the name for the effectivity end date Att of the argument Element and the name of the effectivity start date Att of the argument Element. If either of those Atts are missing, or contain a value they are ignored.
  2. Gets an ESIEffectivityHandler from the ESIEffectivityHandlerFactory.
  3. Gets a DateEff from the effectivity handler. If the result is not null:
    • Obtains the appropriate format from ESI properties
    • Formats and adds the start date to the appropriate Att
    • If the end date is present in the DateEff, formats it and adds it to the appropriate Att


Supported API: true

Parameters:
element - The element to be updated.
eff - The effectivity object to add to the element.
Throws:
ESIRendererException

getTargetsFromAssns

protected Collection getTargetsFromAssns(Collection targetAssns)

getMapInfo

protected ESIMapInfo getMapInfo(String groupName)

getGroupInfo

protected ESIGroupInfo getGroupInfo(String groupName)

getMap

protected ESIMap getMap(ESIMapInfo mapInfo)
                 throws ESIRendererException
Throws:
ESIRendererException