IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Adding rule to a .mms file using java api

    Posted Tue July 18, 2017 12:41 PM

    Originally posted by: abhishek7969


    I have a input and a output card

    i want to add a rule to the .mms file such that input is equals to output.

    I can do it by dragging and dropping it in WTX Design studio

    But i want to achieve this using java api code

     

    Plz help

    urgent

     


    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 2.  Re: Adding rule to a .mms file using java api

    Posted Thu July 20, 2017 04:22 AM

    Originally posted by: S2EG_Ramasamy_R


    Yes , we can do that by using mapexport option.

    After that you can add rule and reimport

     

    Ramasamy R

    +91 9445578778


    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 3.  Re: Adding rule to a .mms file using java api

    Posted Thu July 20, 2017 06:34 AM

    Originally posted by: PaulBrettIBM


    You can use the WTX Design Studio Java API to accomplish this:

    https://www.ibm.com/developerworks/community/blogs/efdcc4d6-e52d-4591-baf2-3f280af4795d/entry/using_the_design_studio_apis_of_wtx_8_4_1_to_generate_maps_and_type_trees_automatically_part_1?lang=en

    It's a very big topic, and cannot be adequately covered in the context of a forum post.

    Thank you.

    Paul

    Follow me on Twitter


    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 4.  Re: Adding rule to a .mms file using java api

    Posted Fri July 21, 2017 05:05 AM

    Originally posted by: abhishek7969


    This is how it can be achieved.

     

    public void run(){
     
    MSMapSource mapSource = MSMapSource.createMap(DefaultTargetLocation);
     
    if(mapSource != null){
    MSMap map = mapSource.addMap("TestMap");
    MSCard inputCard = new MSCard();
    inputCard.setCardName("Card1");
    inputCard.setTreeLocationPath(getInputTreeLocation());
    inputCard.setTypeName("Doc XSD");
    inputCard.getAdapter().setDocumentVerification(DOC_VERIFICATION.WELLFORMED);
     
    map.addInputCard(inputCard);
     
    inputCard.getAdapter().setAdapterType(MSConstants.IO_TYPES.DATAFILE.customOrdinal());
    inputCard.getAdapter().setFileName("C:\\Users\\Downloads\\MapFromSpecs\\CreateMapFromSpecs\\files/res.xml");
     
    // set type
    MSCard outputCard = new MSCard();
    outputCard.setCardName("card2");
    outputCard.setTreeLocationPath(getOutputTreeLocation());
    outputCard.setTypeName("Doc XSD");
    outputCard.getAdapter().setAdapterType(MSConstants.IO_TYPES.DATAFILE.customOrdinal());
    outputCard.getAdapter().setFileName("Label.txt");
    outputCard.getAdapter().setDocumentVerification(DOC_VERIFICATION.WELLFORMED);
    map.addOutputCard(outputCard);
     
    // add rules
    MSCardType root = outputCard.getRoot();
    Iterator<MSCardType> typeIter = root.getChildComponents();
    while (typeIter.hasNext()) {
    MSCardType nextType = (MSCardType) typeIter.next();
    processType(nextType);
    }
    }
    mapSource.save();
    mapSource.close();
     
    }
     
    public void processType(MSCardType type) {
     
    String nodeName = type.getTypePath();
    if(nodeName.equals("XSD:Prolog:Decl")){
    type.addRule("Decl Prolog:Card1");
    }
    if(nodeName.equals("XSD:Global")){
    type.addRule("Global:Card1");
    }
     
     
    /*Iterator<MSCardType> typeIter = type.getChildComponents();
    while (typeIter.hasNext()) {
    MSCardType nextType = (MSCardType) typeIter.next();
    processType(nextType);
    }*/
     
    }

    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange