高级自定义 > Windchill 适配器 > Custom Windchill Adapter Webjects > About the wt.adapter.delegates.properties File
  
About the wt.adapter.delegates.properties File
The wt.adapter.delegates.properties file contains properties for configuring Windchill adapter webject delegates. It includes sections for defining the following:
Available webject delegates
Delegates for attribute translation
Default attributes sets for certain Windchill types
Sets of attributes to exclude for certain Windchill types
* 
You must restart the method server before changes to wt.adapter.delegates.properties are recognized.
Defining Webject Delegates
Entries in this section specify the names of Windchill adapter webject delegates along with the type of object for which each webject delegate is valid. The form of a webject delegate definition is:
webjectName.TYPE|targetType=webjectDelegateClassname
webjectName is the name of the webject
targetType is the class or Windchill type specified in the TYPE parameter
webjectDelegateClassname is the class name of the webject delegate to invoke
For example, consider the following webject delegate definitions:
QUERYOBJECTS.WCTYPE|
java.lang.Object=com.ptc.core.adapter.server.impl.QueryObjectsWebjectDelegate

QUERYOBJECTS.WCTYPE|
wt.org.WTPrincipal=wt.adapter.org.QueryPrincipalsWebjectDelegate
Two webject delegates are defined with the name QUERYOBJECTS. The first delegate is for objects of type java.lang.Object. The second delegate is for objects of type wt.org.WTPrincipal.
When the Windchill adapter is asked to invoke a webject named QUERYOBJECTS it first looks at the TYPE parameter of the webject. If the TYPE parameter specifies wt.org.WTPrincipal or the name of a subclass of the wt.org.WTPrincipal class, then the second webject delegate is used.
The Windchill adapter then invokes the class wt.adapter.org.QueryPrincipalsWebjectDelegate to query for participants using the search criteria specified by the user.
Alternatively, if the TYPE parameter of the QUERYOBJECTS webject contains the name of any class or Windchill type that is not an instance of wt.org.WTPrincipal, the first webject delegate is used. The Windchill adapter invokes the class com.ptc.core.adapter.server.impl.QueryObjectsWebjectDelegate to query for objects using the search criteria specified by the user.
* 
The case of characters is ignored in webject names within tasks, and dashes are discarded when looking up webject delegates. Webject names specified in wt.adapter.delegates.properties must be specified entirely in uppercase and without dashes.
Defining Delegates for Attribute Translation
When a group is returned from Windchill adapter webjects, the FORMAT parameter determines whether or not the attribute values in the group type instances are formatted for the end user.
The attribute translation delegates defined in wt.adapter.delegates.properties determine how attribute values are translated when attribute formatting is requested by the user. Attribute translators are also used to translate values from external string form to the internal type needed by objects being created or updated.
The form of an attribute translation delegate is:
Attribute.attributeClass=attributeTranslatorClass
attributeClass is the fully qualified name of the class of the attribute value to translate
attributeTranslatorClass is the fully qualified name of the class that performs the translation
An attribute translation delegate entry is also valid for super classes of attributeClass. If no attribute translator is found for attributeClass, then a default translator is used.
The following example states that attribute values of the simple type boolean should be formatted for the end user by using the com.ptc.core.adapter.server.impl.BooleanTranslator class:
Attribute.boolean=com.ptc.core.adapter.server.impl.BooleanTranslator
This returns a string value of "true" or "false" for the boolean object content of the attribute.
Attribute values can also be translated from Windchill types. The following example indicates that attribute values of type com.ptc.core.meta.common.TypeInstanceIdentifier should be formatted for the end user by using the com.ptc.core.adapter.server.impl.ObjectReferenceTranslator class:
Attribute.com.ptc.core.meta.common.TypeInstanceIdentifier=
com.ptc.core.adapter.server.impl.ObjectReferenceTranslator
The ObjectReferenceTranslator class translates a TypeInstanceIdentifier by returning the persistence identifier of the TypeInstanceIdentifier.
Defining Default Attribute Sets
When the user does not specify an ATTRIBUTE parameter for a webject, the Windchill adapter returns the set of all attributes valid for the type instances in the output group.
You can configure the Windchill adapter to return a set of default attributes for certain types when no ATTRIBUTE parameter is specified for a webject. The form for specifying a default attribute set for a type is:
DefaultAttributes.type=attributeList
where type is the type of the type instances in the output group and attributeList is a comma-delimited list of logical attribute names valid for type.
In the following example, when WCTYPE|wt.part.WTPartUsageLink type instances are returned in an output group for a webject for which no ATTRIBUTE parameter is specified, the attributes quantity.amount and quantity.unit are included:
DefaultAttributes.WCTYPE|
wt.part.WTPartUsageLink=quantity.amount,quantity.unit
Defining Attribute Sets to Exclude
Sites might want to exclude attributes from certain type instances. You can configure the Windchill adapter to not return these attributes in output groups.
The format for specifying a set of attributes to exclude from a type is:
ExcludeAttributes.type=attributeList
where type is the type of the type instance from which to exclude attributes and attributeList is a comma-delimited list of logical attribute names valid for type.
In the following example, type instances in output groups of type WCTYPE|wt.annotation.StructuredAnnotationSet will not include the creator attribute.
ExcludeAttributes.WCTYPE|
wt.annotation.StructuredAnnotationSet=creator