Example: Adding an Attribute to <Part>
With reference to the response meta information file provided out-of-the-box, the Map element having the value ESIPart for its id attribute is the one that controls the output for the <Part> element. The relevant Map element is reproduced below:
<esi:Map id="ESIPart">
<esi:attributeMapping sourceAttribute="obid">ObjectID</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx" defaultValue="com.ptc.windchill.esi.Part">Class</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="modifier">LastChangedBy</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="number">Number</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartSerialNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndSerialNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartLotNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndLotNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">SerialNumberEffectivityCxtPartNumber</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">LotNumberEffectivityCxtPartNumber</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="defaultUnit">DefaultUnit</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="name">Name</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="partType">PartType</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="source">Source</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="state.state">State</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="view" plantSpecificAttribute="true">View</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="storageLocation" plantSpecificAttribute="true">StorageLocation</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="phantom">IsPhantom</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="versionInfo.identifier.versionId">Version</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="iterationInfo.identifier.iterationId">Iteration</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="PreviousVersion">PreviousVersion</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="genericType">IsConfigurable</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="collapsible">IsCollapsible</esi:attributeMapping>
</esi:Map>
|
The Map element shown above is for illustration purpose only, and may or may not be identical to the one in the file ESIResponseMetaInfo.xml that comes with the ESI Services CD.
|
When using the above Map element, the ESI mapper generates an XML element with this structure:
If the Map element in the response meta information file were modified to have an additional entry that caters to the attribute traceCode of the part, it would then take the form shown below:
<esi:Map id="ESINewPart">
<esi:attributeMapping sourceAttribute="obid">ObjectID</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx" defaultValue="com.ptc.windchill.esi.Part">Class</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="modifier">LastChangedBy</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="number">Number</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartSerialNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndSerialNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">StartLotNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">EndLotNumberEffectivity</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">SerialNumberEffectivityCxtPartNumber</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="xxxx">LotNumberEffectivityCxtPartNumber</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="defaultUnit">DefaultUnit</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="name">Name</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="partType">PartType</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="source">Source</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="state.state">State</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="view" plantSpecificAttribute="true">View</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="storageLocation" plantSpecificAttribute="true">StorageLocation</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="phantom">IsPhantom</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="versionInfo.identifier.versionId">Version</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="iterationInfo.identifier.iterationId">Iteration</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="PreviousVersion">PreviousVersion</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="genericType">IsConfigurable</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="collapsible">IsCollapsible</esi:attributeMapping>
<esi:attributeMapping sourceAttribute="traceCode">TraceCode</esi:attributeMapping>
</esi:Map>
Note that the above illustrated Map element is different from the default version in that (i) its id attribute has a different value and (ii) it has an additional attributeMapping element for the traceCode attribute.
As for (i), it is imperative that the id attribute of a given Map element has a unique value for a given ESI installation. If on the other hand, the same value is shared between two or more versions of the response meta information file (where the Map elements that share the id are different), only one of the Map element versions will be used for response generation which is clearly not what is expected. Also, when changing the value of the id attribute for a given Map element, it should be accompanied by a change to the corresponding MapInformation element. The modified version of the MapInformation element for the above Map element is provided below:
<esi:MapInformation id="ESIPartInfo">
<esi:typedef>wt.part.WTPart</esi:typedef>
<esi:elementMetaName>Part</esi:elementMetaName>
<esi:keyAttribute>Number</esi:keyAttribute>
<esi:keyAttribute>Version</esi:keyAttribute>
<esi:keyAttribute>PreviousVersion</esi:keyAttribute>
<esi:keyAttribute>View</esi:keyAttribute>
<esi:keyAttribute>StorageLocation</esi:keyAttribute>
<esi:mapRef>ESINewPart</esi:mapRef>
</esi:MapInformation>
Note that the mapRef element has a value that matches the value of the id attribute of the Map element.
The response meta information file carrying the above changes is located in
<Windchill>/codebase/com/ptc/windchill/esi/examples/ESIResponseMetaInfoExample1.xml.
Using the Manage Distribution UI, bring up the Edit Distribution Target dialogue for an existing target and change the value of the field ESI Response Meta Information File Path to point to the file ESIResponseMetaInfoExample1.xml. After saving the target by clicking OK, associate a WTPart to the edited target and release it.
| Alternatively, the New Distribution Target dialogue may be brought up from the Manage Distribution UI, and the value of the said field may be set to point to the file ESIResponseMetaInfoExample1.xml. A WTPart may then be associated to this newly created target and released. |
| Changing the contents of the response meta information file can change the structure of the ESI response. |
The Windchill ESI mapper generates the following output if the file ESIResponseMetaInfoExample1.xml were used:
The XML schema definition for the Windchill ESI response that is generated when the customized response meta information file is used is located in
<Windchill>/codebase/com/ptc/windchill/esi/examples/Example1.xsd.
The Windchill ESI response that is generated when the customized response meta information file is used is located in <Windchill>/codebase/com/ptc/windchill/esi/examples/Example1.xml.
| You will find that the Part element in the response file above does not have the child elements View and StorageLocation, although they figure in the response meta information and schema files. This is only expected when the preference "Publish Plant Specific Attributes" is set to the default value (of "No"). Set this preference to "Yes" in order that the said child elements are sent with the ESI response. More information on this topic appears in a later section of this document. |
| A user may want to release a part after associating multiple distribution targets (that typically represent multiple destinations) to it. In such a case, a response message will be generated for each such target. The structure of the message that is generated for a given target will be determined by the contents of the response meta information file that is used for that target. Thus, a target can choose to receive the response message the way it wants, by having its responseMetaInfoPath attribute set to point to an appropriately customized version of the response meta information file. |