WebSphere Enterprise Service Bus, Version 6.2.0 Systèmes d'exploitation: AIX, HP-UX, i5/OS, Linux, Solaris, Windows


Transformation d'objets de données d'un format de langue bidirectionnelle dans un autre

Pour les données provenant d'un système d'information d'entreprise externe, vous pouvez créer des API qui transforment les objets SDO (Service Data Objects) au format de langue bidirectionnelle pris en charge et les données envoyées à partir de WebSphere ESB vers un système d'information d'entreprise externe au format bidirectionnel utilisé par ce système.

Avant de commencer

Pour plus d'informations sur la prise en charge des langues bidirectionnelles, reportez-vous à la section Localisation. Servez-vous du tableau de cette section pour déterminer la valeur correcte de la chaîne d'entrée ou de sortie à utiliser lors de la conversion de données de type DataObject d'un format dans un autre.

Pour créer une API permettant de transformer le format de langue bidirectionnelle des objets de données, procédez comme suit.

Procédure
  1. Il convient d'inclure toutes les classes bidirectionnelles contenant l'implémentation du moteur bidirectionnel. Exemple :
    import com.ibm.bidiTools.bdlayout.*;
  2. Incluez toutes les classes dont vous avez besoin pour manipuler l'objet de type DataObject. Exemple :
    import commonj.sdo.DataObject;
    import commonj.sdo.Type;
    import commonj.sdo.Property;
  3. Définissez des variables de chaîne contenant les différents types de chaîne qu'un objet de type DataObject peut contenir. Cette étape filtre les attributs de type String (chaîne) tout en transversalisant de manière récursive l'objet DataObject. Exemple :
    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. Définissez la fonction qui vérifie si le type d'une propriété est String (chaîne). Exemple :
    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. Définissez la fonction récursive qui applique la conversion bidirectionnelle à l'objet DataObject entier.
    Remarque : La logique du code comporte les hypothèses suivantes :
    • La conversion bidirectionnelle est appliquée aux propriétés de type chaîne (String) uniquement.
    • Les propriétés de type chaîne dans l'objet DataObject sont stockées dans le même format bidirectionnel.
    Exemple :
    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. Ignorez toutes les propriétés dont le type est différent de String (chaîne). Exemple :
             if (!isStringFamilyType(property)) 
                   continue; 
      
             if (property.isContainment()) { 
                  if (property.isMany()) { 
                        List childsList = boIn.getList(property);
    2. Appelez de manière récursive la conversion pour gérer les objets enfant. Exemple :
       
                        for (int childNumber = 0; childNumber < childsList.size(); 
      		   childNumber++){                   BiDiDataObjTransformationBO(connectionContext, 
      		 ((DataObject)childsList.get(childNumber)),formatIn, formatOut); 
                    } 
                } else { 
    3. Appelez de manière récursive la conversion pour gérer les objets enfant de tout objet métier contenu. Exemple :
                    BiDiDataObjTransformationBO(connectionContext, 
      	     ((DataObject)boIn.get(property)),formatIn, formatOut); 
               } 
           } else {
    4. Convertissez les attributs de chaîne simples. Exemple :
               String str = BiDiStringTransformation(
                   (boIn.getString(propertyName),formatIn, formatOut); 
               boIn.setString(propertyName, str); 
           } 
         } 
         return boIn; 
      }

task Rubrique relative à une tâche

Conditions d'utilisation | Commentaires en retour


Icône d'horodatage Dernière mise à jour: 07 juillet 2010


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.doc/doc/tref_example_bididataobject.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
Ce centre d'information est mis en service par la technologie Eclipse (http://www.eclipse.org).