WebSphere Enterprise Service Bus for z/OS, Version 6.2.0 Operating Systems: z/OS


Transforming data objects from one bidirectional language format to another

For data coming from an external Enterprise Information System (EIS), you can create APIs that transform Service Data Objects into the supported bidirectional language format and that transform data sent from WebSphere® ESB to an external EIS into the bidirectional format used by that specific EIS.

Before you begin

For more information about bidirectional language support, see Globalization. Use the table in Globalization to determine the correct value for either the input string or output string to use when transforming DataObject-type data from one format to another.

To create an API to transform the bidirectional language format of data objects, perform the following steps.

Procedure
  1. Include all bidirectional classes that contain the bidirectional engine implementation. For example:
    import com.ibm.bidiTools.bdlayout.*;
  2. Include all the classes you need to manipulate the DataObject-type object. For example:
    import commonj.sdo.DataObject;
    import commonj.sdo.Type;
    import commonj.sdo.Property;
  3. Define string variables to contain the different types of strings that a DataObject-type object contains. This filters the attributes of type String while recursively transversing the DataObject. For example:
    String STRING_STR_TYPE = "String"; 
    String NORM_STRING_STR_TYPE = "normalizedString";
    String TOKEN_STR_TYPE = "token"; 
    String LANG_STR_TYPE = "language"; 
    String NAME_STR_TYPE = "Name"; 
    String NMTOKEN_STR_TYPE = "NMTOKEN"; 
    String NCNANE_STR_TYPE = "NCName"; 
    String ID_STR_TYPE = "ID"; 
    String IDREF_STR_TYPE = "IDREF"; 
    String IDREFS_STR_TYPE = "IDREFS"; 
    String ENTITY_STR_TYPE = "ENTITY"; 
    String ENTITIES_STR_TYPE = "ENTITIES";
  4. Define the function that verifies if the type of a property is String. For example:
    private static boolean isStringFamilyType (Property property) { 
        boolean rc = false; 
        if ((property.getType().getName().equalsIgnoreCase(STRING_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(NORM_STRING_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(TOKEN_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(LANG_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(NAME_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(NMTOKEN_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(NCNANE_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(ID_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(IDREF_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(IDREFS_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(ENTITY_STR_TYPE)) ||
        (property.getType().getName().equalsIgnoreCase(ENTITIES_STR_TYPE))) 
           rc = true; 
         return rc; 
    }
  5. Define the recursive function that applies the bidirectional transformation on the entire DataObject.
    Note: The code logic includes the following assumptions:
    • Bidirectional transformation is applied on the properties of string-type only.
    • The properties of type string in the DataObject are stored in one bidirectional format.
    For example:
    DataObject BiDiDataObjTransformationBO(DataObject boIn, String formatIn, String formatOut){ 
    
       Type type; 
       Property property; 
    
       if (boIn == null) return null; 
    
       type = boIn.getType(); 
       List propertyList = type.getProperties(); 
       for (int propertyNumber = 0; propertyNumber < propertyList.size(); propertyNumber++){ 
             property = (Property) propertyList.get(propertyNumber); 
             String propertyName = property.getName();
    1. Skip all non-string properties. For example:
             if (!isStringFamilyType(property)) 
                   continue; 
      
             if (property.isContainment()) { 
                  if (property.isMany()) { 
                        List childsList = boIn.getList(property);
    2. Recursively call the transformation to handle child objects. For example:
       
                        for (int childNumber = 0; childNumber < childsList.size(); 
      		   childNumber++){                   BiDiDataObjTransformationBO(connectionContext, 
      		 ((DataObject)childsList.get(childNumber)),formatIn, formatOut); 
                    } 
                } else { 
    3. Recursively call the transformation to handle child objects of any contained business objects. For example:
                    BiDiDataObjTransformationBO(connectionContext, 
      	     ((DataObject)boIn.get(property)),formatIn, formatOut); 
               } 
           } else {
    4. Transform the simple string attributes. For example:
               String str = BiDiStringTransformation(
                   (boIn.getString(propertyName),formatIn, formatOut); 
               boIn.setString(propertyName, str); 
           } 
         } 
         return boIn; 
      }

task Task topic

Terms of use | Feedback


Timestamp icon Last updated: 21 June 2010


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.zseries.doc/doc/tref_example_bididataobject.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).