Дополнительная настройка > Business Logic Customization > Data Exchange using Standards in Windchill > STEP Data Exchange using EXPRESS > STEP Foundation > Configuring Metadata Mapping > Logging > Customizing Mapping Behavior
  
Customizing Mapping Behavior
Class Diagram
Customization
* 
Please refer to the class diagram and data structure table in the previous section for reference.
OOTB, only two mapping processor implementations are provided.
wt.ixb.publicforapps.extendedmapping.processor.SingleTagMappingProcessor would handle single tag mapping including support for regex.
wt.ixb.publicforapps.extendedmapping.processor.MultiTagMappingProcessor would handle mappings with more than one tag (including condition tags). This processor would also support regex in both condition and non condition tags.
The above two OOTB mapping processors work on the concept of simple String matching. For most of the cases, those two classes should be sufficient to provide desired mapping behavior.
If any business logic is required to be added to those string values under consideration from mapping data and object data to be imported, customer would need to write their customized mapping processor/Mapper based on this guideline below.
To customize the behavior of the above two mapping processors, extend SingleTagMappingProcessor or MultiTagMappingProcessor as per the use case and override postprocessMappedValue method. The details of the method parameters are as follows.
/** Customization point to process Mapped value as per business logic.
* OOTB implementation returns the mapped value as-is
 * @param tag The Tag to be evaluated for Mapping
* @param parentTags Parent Tags separated by <code>TAG_SEPARATOR</code>.
* This would be null if tagValue represents the full Tag as defined in
* IXMappingConfiguration.xml
    * @param value The source value for the Tag
    * @param mappedValue The mapped value of the source value for the Tag
    * @param srcElement The IXBElement representation of the object
* data to be imported
    * @return The Mapped value
    * @throws WTException
    */

   protected String postprocessMappedValue(String tag, String parentTags,
String value, String mappedValue,
IxbElement srcElement) throws WTException



For Mapping definition with multiple Tags with conditions and regular expressions in IXMappingConfiguration.xml, matching mapping can be more than one. In those cases, OOTB implementation uses the logic to return the match with maximum conditions met (there can be some mappings in multiple matches without all conditions provided in the mapping). Also in case of multiple regular expressions defined in the Mapping matches the source object values, the natural sort order as implemented by java.util.TreeMap is used and the first match is used for mapping value.
The above behavior to pick the matching key can be customized.
Extend wt.ixb.publicforapps.extendedmapping.mapper.MultiTagComplexMapper class and override getBestMatchKey method as per the below details.
/** Get the best matching key to be used to get the mapped values
    * OOTB implementation returns the first matching key.
    * This api can be overridden to return any other matching key from
    * @param matchingKeys
    *   All matching keys satisfying the Mapping conditions
    * @return The first key out of all matching keys
    */

   protected List<String> getBestMatchKey(List<List<String>> matchingKeys)
Then extend SingleTagMappingProcessor or MultiTagMappingProcessor as per the use case and override protected Mapper getMapper() method to return the above mapper as per the use case.
In both the customization cases mentioned above, the extended Mapping processor needs to be added to the appropriate Mapping element attribute “mappingProcessor” in <Windchill Home>/codebase/registry/ixb/mapping/IXMappingConfiguration.xml. For example, if the extended class from MultiTagMappingProcessor is mycustomizationpackage.MyMultiTagMappingProcessor, the mappingProcessor attribute should assigned mycustomizationpackage.MyMultiTagMappingProcessor. All values in the example are for example only and needs to be as per the customer defined Mapping
<Mapping preferenceDefinition="ExtendedLifecycleMapping" separator=";"
mappingProcessor="mycustomizationpackage.MyMultiTagMappingProcessor">
<Tag value="externalTypeId" condition="true" regex="true"/>
<Tag value="lifecycleInfo/lifecycleTemplateName"/>
<Tag value="lifecycleInfo/lifecycleState"/>
</Mapping>